Merge branch 'master' of git.gromacs.org:gromacs
authorSzilard Pall <pszilard@cbr.su.se>
Tue, 5 Oct 2010 09:40:08 +0000 (11:40 +0200)
committerSzilard Pall <pszilard@cbr.su.se>
Tue, 5 Oct 2010 09:40:08 +0000 (11:40 +0200)
158 files changed:
CMakeLists.txt
Makefile.am
README
cmake/FindFFTW2.cmake
cmake/FindFFTW2F.cmake
cmake/FindFFTW3.cmake
cmake/FindFFTW3F.cmake
cmake/FindOpenMM.cmake
configure.ac
include/copyrite.h
include/genborn.h
include/gstat.h
include/index.h
include/mdrun.h
include/membed.h [moved from include/gmx_membed.h with 100% similarity]
include/thread_mpi.h
include/thread_mpi/atomic.h
include/thread_mpi/atomic/gcc_ppc.h
include/thread_mpi/atomic/gcc_spinlock.h
include/thread_mpi/atomic/xlc_ppc.h
include/thread_mpi/lock.h
include/tmpi.h
include/types/enums.h
include/types/genborn.h
include/types/state.h
share/html/online/mdp_opt.html
share/top/charmm27.ff/aminoacids.rtp
share/top/charmm27.ff/dna.rtp
share/top/charmm27.ff/ffnonbonded.itp
share/top/charmm27.ff/forcefield.doc
share/top/charmm27.ff/lipids.rtp
share/top/charmm27.ff/rna.rtp
share/top/gurgle.dat
share/top/ions.itp
share/tutor/gmxdemo/demo
src/contrib/Makefile.am
src/contrib/do_multiprot.c [new file with mode: 0644]
src/gmxlib/bondfree.c
src/gmxlib/chargegroup.c
src/gmxlib/checkpoint.c
src/gmxlib/futil.c
src/gmxlib/genversion.sh
src/gmxlib/gmxfio.c
src/gmxlib/gmxfio_int.h
src/gmxlib/ifunc.c
src/gmxlib/index.c
src/gmxlib/main.c
src/gmxlib/matio.c
src/gmxlib/names.c
src/gmxlib/nonbonded/nb_kernel_power6/Makefile.am
src/gmxlib/nonbonded/nb_kernel_power6/nb_kernel_pwr6sync.c [moved from src/gmxlib/nonbonded/nb_kernel_power6/nb_kernel_f77sync.c with 98% similarity]
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel010.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel020.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel030.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel100.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel101.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel102.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel103.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel104.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel110.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel111.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel112.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel113.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel114.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel120.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel121.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel122.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel123.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel124.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel130.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel131.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel132.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel133.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel134.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel200.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel201.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel202.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel203.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel204.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel210.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel211.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel212.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel213.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel214.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel220.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel221.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel222.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel223.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel224.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel230.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel231.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel232.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel233.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel234.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel300.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel301.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel302.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel303.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel304.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel310.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel311.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel312.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel313.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel314.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel320.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel321.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel322.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel323.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel324.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel330.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel331.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel332.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel333.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel334.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel400.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel410.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel420.F
src/gmxlib/nonbonded/nb_kernel_power6/pwr6kernel430.F
src/gmxlib/pdbio.c
src/gmxlib/selection/parsetree.c
src/gmxlib/thread_mpi/impl.h
src/gmxlib/thread_mpi/lock.c
src/gmxlib/topsort.c
src/gmxlib/tpxio.c
src/gmxlib/vmdio.c
src/kernel/CMakeLists.txt
src/kernel/Makefile.am
src/kernel/gmx_gpu_utils/CMakeLists.txt
src/kernel/grompp.c
src/kernel/md.c
src/kernel/md_openmm.c
src/kernel/membed.c [moved from src/kernel/gmx_membed.c with 99% similarity]
src/kernel/readir.c
src/kernel/runner.c
src/kernel/topio.c
src/kernel/toppush.c
src/kernel/tpbcmp.c
src/mdlib/force.c
src/mdlib/genborn.c
src/mdlib/mdebin.c
src/mdlib/mdebin_bar.c
src/mdlib/minimize.c
src/mdlib/tpi.c
src/mdlib/update.c
src/tools/CMakeLists.txt
src/tools/Makefile.am
src/tools/autocorr.c
src/tools/dlist.c
src/tools/gmx_analyze.c
src/tools/gmx_bar.c
src/tools/gmx_chi.c
src/tools/gmx_density.c
src/tools/gmx_dipoles.c
src/tools/gmx_eneconv.c
src/tools/gmx_membed.c
src/tools/gmx_pme_error.c
src/tools/gmx_traj.c
src/tools/gmx_tune_pme.c

index efde6dba111c0e4c4da6da36de5a04d6962bddfd..52f1138f018acace1ad04ed6a5aad173f1099a5d 100644 (file)
@@ -548,6 +548,11 @@ else(${GMX_ACCELERATION} STREQUAL "NONE")
 endif(${GMX_ACCELERATION} STREQUAL "NONE")
 
 
+if(GMX_FORTRAN)
+    if (GMX_THREADS)
+        message(WARNING "FORTRAN is incompatible with threads. Disable threads or FORTRAN kernels")
+    endif()
+endif()
 
 
 
index 323f83159b007a069bbe460c9cc950a02271116b..febdec51c310a36a9ef8eb66a387886ab4a2489e 100644 (file)
@@ -38,10 +38,15 @@ EXTRA_DIST = config/depcomp \
                         src/CMakeLists.txt \
                         src/tools/CMakeLists.txt \
                         COPYING-GPU \
-                        INSTALL-GPU
+                        INSTALL-GPU \
+                        INSTALL.cmake \
+                        INSTALL.automake
 
 
 install-exec-hook:
+if NO_LA_FILES
+       cd $(DESTDIR)$(libdir) && rm -f libmd@LIBSUFFIX@.la libgmx@LIBSUFFIX@.la libgmxpreprocess@LIBSUFFIX@.la libgmxana@LIBSUFFIX@.la
+endif
        @echo ""
        @echo "GROMACS is installed under $(prefix)."
        @echo "Make sure to update your PATH and MANPATH to find the"
@@ -65,6 +70,9 @@ install-mdrun:
        (cd $(top_builddir)/src/mdlib && $(MAKE) install ; exit 0)
        (cd $(top_builddir)/src/kernel && $(MAKE) install-libLTLIBRARIES ; exit 0)
        (cd $(top_builddir)/src/kernel && $(MAKE) install-mdrun ; exit 0)
+if NO_LA_FILES
+       cd $(DESTDIR)$(libdir) && rm -f libmd@LIBSUFFIX@.la libgmx@LIBSUFFIX@.la libgmxpreprocess@LIBSUFFIX@.la libgmxana@LIBSUFFIX@.la
+endif
 
 fahcore:
        (cd $(top_builddir)/src/gmxlib && $(MAKE) ; exit 0)
diff --git a/README b/README
index d24640e3c902f648c0ef821d59b405fa543d81b1..398c9fca27ec27446c4c5b32b695e0c5bc7d9769 100644 (file)
--- a/README
+++ b/README
@@ -2,8 +2,10 @@
                Welcome to the official version of GROMACS!
 
 If you are familiar with unix, it should be fairly trivial to compile and
-install GROMACS. Installation instructions are available in the INSTALL file,
-and a more extended step-by-step guide can be found on http://www.gromacs.org .
+install GROMACS. Installation instructions are available in the INSTALL.* 
+files (there is one for automake users, INSTALL.automake and one for cmake
+users, INSTALL.cmake). A more extended step-by-step guide can be found 
+on our website http://www.gromacs.org .
 
 Of course we will do our utmost to help you with any problems, but PLEASE 
 READ THE INSTALLATION INSTRUCTIONS BEFORE CONTACTING US!
index b41a5818aaa41aae4ef75d4e82a0e14547a5b5ef..34b6aa8d63291a447d8bcb95321b51f2ff2e6f87 100644 (file)
@@ -4,6 +4,8 @@
 #  FFTW2_INCLUDE_DIR - where to find [d]fftw.h
 #  FFTW2_LIBRARIES   - List of libraries when using FFTW.
 #  FFTW2_FOUND       - True if FFTW found.
+#
+# The FFTW2 root installation directory can be provided in the FFTW2_ROOT_DIR
 
 if (FFTW2_INCLUDE_DIR)
   # Already in cache, be silent
@@ -12,14 +14,22 @@ endif (FFTW2_INCLUDE_DIR)
 
 set(FFTW2_FOUND 0)
 
+file(TO_CMAKE_PATH "$ENV{FFTW2_ROOT_DIR}" _env_FFTW2_ROOT_DIR)
 
 foreach(fftw2_name dfftw fftw)
     string(TOUPPER ${fftw2_name} fftw2_uname)
     string(REPLACE "fftw" "rfftw" rfftw2_name ${fftw2_name})
     if(NOT FFTW2_FOUND)
-        find_path (FFTW2_INCLUDE_DIR ${fftw2_name}.h)
-       find_library (CFFTW2_LIBRARIES  ${fftw2_name})          
-        find_library (RFFTW2_LIBRARIES ${rfftw2_name})
+        find_path (FFTW2_INCLUDE_DIR 
+                    PATHS "${_env_FFTW2_ROOT_DIR}/include"
+                    ${fftw2_name}.h)
+                    CACHE STRING "Path to double precision FFTW2 headers")
+       find_library (CFFTW2_LIBRARIES  ${fftw2_name}
+                        PATHS "${_env_FFTW2_ROOT_DIR}/lib"
+                       CACHE STRING "Double precision CFFTW2 libraries")
+        find_library (RFFTW2_LIBRARIES ${rfftw2_name}
+                        PATHS "${_env_FFTW2_ROOT_DIR}/lib"
+                       CACHE STRING "Double precision RFFTW2 libraries")
        TRY_COMPILE(FFTW2_FOUND "${CMAKE_BINARY_DIR}"
                     "${CMAKE_SOURCE_DIR}/cmake/TestFFTW2.c"
                    COMPILE_DEFINITIONS "-I${FFTW2_INCLUDE_DIR} -DDOUBLE -D${fftw2_uname}" )
@@ -36,7 +46,8 @@ endif(FFTW2_FOUND)
 # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
 # all listed variables are TRUE
 include (FindPackageHandleStandardArgs)
-find_package_handle_standard_args (FFTW2 DEFAULT_MSG FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)
+set(__MSG "Could not find FFTW2. Provide the fftw2 install directory in the FFTW2_ROOT_DIR environment variable.")
+find_package_handle_standard_args (FFTW2 ${__MSG} FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)
 
 mark_as_advanced (RFFTW2_LIBRARIES CFFTW2_LIBRARIES FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)
 
index f04413cd70ecb7310ce1fa2ee7288f40e63233a0..23b389f6c7a1ac58c48d2f95d31f63b6e78308c8 100644 (file)
@@ -4,6 +4,9 @@
 #  FFTW2_INCLUDE_DIR    - where to find [d]fftw.h
 #  FFTW2_LIBRARIES   - List of libraries when using FFTW.
 #  FFTW2_FOUND       - True if FFTW found.
+#
+# The FFTW2F root installation directory can be provided in the FFTW2F_ROOT_DIR
+
 
 if (FFTW2_INCLUDE_DIR)
   # Already in cache, be silent
@@ -12,14 +15,22 @@ endif (FFTW2_INCLUDE_DIR)
 
 set(FFTW2_FOUND 0)
 
+file(TO_CMAKE_PATH "$ENV{FFTW2F_ROOT_DIR}" _env_FFTW2F_ROOT_DIR)
 
 foreach(fftw2_name sfftw fftw)
     string(TOUPPER ${fftw2_name} fftw2_uname)
     string(REPLACE "fftw" "rfftw" rfftw2_name ${fftw2_name})
     if(NOT FFTW2_FOUND)
-        find_path (FFTW2_INCLUDE_DIR ${fftw2_name}.h)
-       find_library (CFFTW2_LIBRARIES  ${fftw2_name})          
-        find_library (RFFTW2_LIBRARIES ${rfftw2_name})
+        find_path (FFTW2_INCLUDE_DIR
+                    PATHS "${_env_FFTW2F_ROOT_DIR}/include"
+                    ${fftw2_name}.h
+                    CACHE STRING "Path single precision FFTW2 headers") 
+       find_library (CFFTW2_LIBRARIES  ${fftw2_name}
+                        PATHS "${_env_FFTW2F_ROOT_DIR}/lib"
+                       CACHE STRING "Single precision CFFTW2 libraries")
+        find_library (RFFTW2_LIBRARIES ${rfftw2_name}
+                        PATHS "${_env_FFTW2F_ROOT_DIR}/lib"
+                       CACHE STRING "Single precision RFFTW2 libraries")
        TRY_COMPILE(FFTW2_FOUND "${CMAKE_BINARY_DIR}"
                     "${CMAKE_SOURCE_DIR}/cmake/TestFFTW2.c"
                    COMPILE_DEFINITIONS "-I${FFTW2_INCLUDE_DIR} -D${fftw2_uname}" )
@@ -36,7 +47,8 @@ endif(FFTW2_FOUND)
 # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
 # all listed variables are TRUE
 include (FindPackageHandleStandardArgs)
-find_package_handle_standard_args (FFTW2 DEFAULT_MSG FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)
+set(__MSG "Could not find FFTW2F. Provide the fftw2 install directory in the FFTW2F_ROOT_DIR environment variable.")
+find_package_handle_standard_args (FFTW2 ${__MSG} FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)
 
 mark_as_advanced (RFFTW2_LIBRARIES CFFTW2_LIBRARIES FFTW2_LIBRARIES FFTW2_INCLUDE_DIR)
 
index 616bbbf854fb4c03c2c32ce68ebd07827b88102a..e9a25dc7cd0caff606ff629ca0973f63245ad2d3 100644 (file)
@@ -4,26 +4,31 @@
 #  FFTW3_INCLUDE_DIR    - where to find fftw3.h
 #  FFTW3_LIBRARIES   - List of libraries when using FFTW.
 #  FFTW3_FOUND       - True if FFTW found.
+#
+# The FFTW3 root installation directory can be provided in the FFTW3_ROOT_DIR
 
 if (FFTW3_INCLUDE_DIR AND FFTW3_LIBRARIES)
   # Already in cache, be silent
   set (FFTW3_FIND_QUIETLY TRUE)
 endif (FFTW3_INCLUDE_DIR AND FFTW3_LIBRARIES)
 
-find_path (FFTW3_INCLUDE_DIR fftw3.h
-               CACHE STRING "Path to headers for double precision FFTW3")
+file(TO_CMAKE_PATH "$ENV{FFTW3_ROOT_DIR}" _env_FFTW3_ROOT_DIR)
 
+find_path (FFTW3_INCLUDE_DIR fftw3.h
+                PATHS "${_env_FFTW3_ROOT_DIR}/include"
+               CACHE STRING "Path to double precision FFTW3 headers")
 
 find_library (FFTW3_LIBRARIES 
                NAMES fftw3
-               PATHS "${FFTW3_INCLUDE_DIR}/../lib"
+                PATHS "${_env_FFTW3_ROOT_DIR}/lib"
+                      "${FFTW3_INCLUDE_DIR}/../lib" 
                CACHE STRING "Double precision FFTW3 libraries")
 
-
 # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
 # all listed variables are TRUE
 include (FindPackageHandleStandardArgs)
-find_package_handle_standard_args (FFTW3 DEFAULT_MSG FFTW3_LIBRARIES FFTW3_INCLUDE_DIR)
+set(__MSG "Could not find FFTW3. Provide the fftw3 install directory in the FFTW3_ROOT_DIR environment variable.")
+find_package_handle_standard_args (FFTW3 ${__MSG} FFTW3_LIBRARIES FFTW3_INCLUDE_DIR)
 
 mark_as_advanced (FFTW3_LIBRARIES FFTW3_INCLUDE_DIR)
 
index 23050153ad1d39f04a70c013b62b79601ab21c00..44824dade2a35d921e3991dbd3f2293708212b3b 100644 (file)
@@ -4,23 +4,30 @@
 #  FFTW3F_INCLUDE_DIR    - where to find fftw3.h
 #  FFTW3F_LIBRARIES   - List of libraries when using FFTW.
 #  FFTW3F_FOUND       - True if FFTW found.
+#
+# The FFTW3F root installation directory can be provided in the FFTW3F_ROOT_DIR
 
 if (FFTW3F_INCLUDE_DIR AND FFTW3F_LIBRARIES)
   # Already in cache, be silent
   set (FFTW3F_FIND_QUIETLY TRUE)
 endif (FFTW3F_INCLUDE_DIR AND FFTW3F_LIBRARIES)
 
+file(TO_CMAKE_PATH "$ENV{FFTW3F_ROOT_DIR}" _env_FFTW3F_ROOT_DIR)
+
 find_path (FFTW3F_INCLUDE_DIR fftw3.h 
-       CACHE STRING "Path to headers for single precision FFTW3")
+            PATHS "${_env_FFTW3F_ROOT_DIR}/include"
+           CACHE STRING "Path to single precision FFTW3 headers")
 
 find_library (FFTW3F_LIBRARIES 
                NAMES fftw3f
-               PATHS "${FFTW3F_INCLUDE_DIR}/../lib"
+                PATHS "${_env_FFTW3F_ROOT_DIR}/lib"
+                      "${FFTW3F_INCLUDE_DIR}/../lib" 
                CACHE STRING "Single precision FFTW3 libraries")
 
 # handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
 # all listed variables are TRUE
 include (FindPackageHandleStandardArgs)
-find_package_handle_standard_args (FFTW3F DEFAULT_MSG FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIR)
+set(__MSG "Could not find FFTW3F. Provide the fftw3 install directory in the FFTW3F_ROOT_DIR environment variable.")
+find_package_handle_standard_args (FFTW3F ${__MSG} FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIR)
 
 mark_as_advanced (FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIR)
index 5094d1bd942e86ad6f346b19caaccc89ff5e5383..541b2a453d3197f0143a941c275f697fb1219940 100644 (file)
@@ -66,8 +66,8 @@ if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
 endif()
 
 if(NOT IS_DIRECTORY ${OpenMM_ROOT_DIR})
-    message(FATAL_ERROR "Can't find OpenMM! Either set the OPENMM_ROOT_DIR environment " 
-    "variable to the path where your OpenMM installation is located or install it to the default location (/usr/local/openmm)!")
+    message(FATAL_ERROR "Could not find OpenMM! Set the OPENMM_ROOT_DIR environment "
+    "variable to contain the path of the OpenMM installation.")
 endif()
 
 if(NOT IS_DIRECTORY ${OpenMM_LIBRARY_DIR})
@@ -82,7 +82,7 @@ if(IS_DIRECTORY "${OpenMM_LIBRARY_DIR}/plugins")
     set(OpenMM_PLUGIN_DIR ${OpenMM_PLUGIN_DIR} CACHE PATH "OpenMM plugins directory")
 else()
     message(WARNING "Could not detect the OpenMM plugin directory at the default location (${OpenMM_LIBRARY_DIR}/plugins)."
-            "Check you OpenMM installation or manually set the OPENMM_PLUGIN_DIR environment variable!")
+            "Check your OpenMM installation or set the OPENMM_PLUGIN_DIR environment variable!")
 endif()
 
 if(NOT OpenMM_INCLUDE_DIR)
index 94a9d64093e39b237d8a5161a02b4583dac571bb..c7784141452340a876e3df7a9142bb732ec9927d 100644 (file)
@@ -51,10 +51,15 @@ AC_ARG_ENABLE(fortran,
   sparc*-solaris* | alpha*-* | rs6000*-aix* | powerpc*-aix* | mips*-irix*) enable_fortran=yes ;;
   *) enable_fortran=no ;;
  esac])
-# Generic fortran kernels will be turned off below if you enable power6-specific optimization!
 # always use CC for linking:
 AC_SUBST(F77LINK,"\$(LINK)")
 
+#On some systems GNU libtool's la files are more confusing for libtool than helpful due to the 
+#hard coded paths/libs in the files. And for better linking we have pkg-config files (.pc).
+AC_ARG_ENABLE(la-files,
+       [AS_HELP_STRING([--disable-la-files],[Do NOT install GNU libtool's la files])],,
+       [enable_la_files=yes])
+AM_CONDITIONAL(NO_LA_FILES,[test "$enable_la_files" = no])
 
 
 
@@ -149,9 +154,7 @@ esac
 AC_ARG_ENABLE(power6,
              [AC_HELP_STRING([--enable-power6],
                              [Use IBM Pwr6/PPC440/PPC450-specific F77 kernels])],,enable_power6=no)
-# Turn off generic fortran loops if we are using power6-specific optimization
 if test "$enable_power6" = "yes"; then
-  enable_fortran=no;
   AC_DEFINE(GMX_POWER6,,[Enable IBM Pwr6/PPC440/PPC450-specific F77 kernels])
 fi
 
@@ -325,11 +328,11 @@ AM_CONDITIONAL([USE_VERSION_H],[test "$generate_version" = "yes"])
 case "${host_cpu}-${host_os}" in
   alpha*-linux*)
     cc_names="ccc cc gcc"
-    f77_names="fort f77 g77"
+    f77_names="fort f77 gfortran g77"
     ;;
   *) 
     cc_names="cc icc xlc gcc"
-    f77_names="f77 ifort xlf xlf77 cf77 fl32 g77 fort77 f90 xlf90 pgf77 cf77 fort fort77 pgf90"
+    f77_names="f77 ifort xlf xlf77 cf77 fl32 gfortran g77 fort77 f90 xlf90 pgf77 cf77 fort fort77 pgf90"
     ;;
 esac
 # the (non-mpi) c compiler, which is also used for programs executed during build stage
@@ -464,6 +467,9 @@ if test "$enable_threads" = "yes"; then
   if test "$with_fft" = "fftw2"; then
     AC_MSG_ERROR([fftw2 can't be used with threads. Use fftw3 or mkl.])
   fi 
+  if test "$enable_fortran" = "yes"; then
+    AC_MSG_ERROR([FORTRAN is incompatible with threads. Use --disable-threads.])
+  fi
   AC_CHECK_HEADERS(unistd.h)
   AC_CHECK_HEADERS(sys/time.h)
   AC_CHECK_HEADERS(sched.h)
@@ -1207,7 +1213,7 @@ AC_ARG_VAR(
    variable you can overwrite it
   ]
 )
-if test -z ${LIBSUFFIX} ; then
+if test -z "${LIBSUFFIX}" ; then
   if test "$enable_mpi" = "yes"; then
     LIBSUFFIX="_mpi"
   fi
index 08dd3d355949d6680fdf959219d77a527928da01..cafabf2c893c4804ebedcb5438749b658ba3bc40 100644 (file)
@@ -55,7 +55,7 @@ static const char *
 CopyrightText[] = {
   "Written by Emile Apol, Rossen Apostolov, Herman J.C. Berendsen,",
   "Aldert van Buuren, Pär Bjelkmar, Rudi van Drunen, Anton Feenstra, ",
-  "Gerrit Groenhof, Peter Kasson, Per Larsson, Peiter Meulenhoff, ",
+  "Gerrit Groenhof, Peter Kasson, Per Larsson, Pieter Meulenhoff, ",
   "Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schultz, ",
   "Michael Shirts, Alfons Sijbers, Peter Tieleman,\n",
   "Berk Hess, David van der Spoel, and Erik Lindahl.\n",
index bea7163118d8f7fe7eaf8b1899f06de567286efe..a76fab76530d3138aec83a2a95a1cee4e8d3957d 100644 (file)
@@ -88,7 +88,7 @@ convert_gb_params(gmx_ffparams_t *ffparams, t_functype ftype, t_params *gb_plist
 /* Functions for calculating adjustments due to ie chain rule terms */
 void
 calc_gb_forces(t_commrec *cr, t_mdatoms *md, gmx_genborn_t *born, gmx_localtop_t *top, const t_atomtypes *atype,
-                          rvec x[], rvec f[], t_forcerec *fr,t_idef *idef,int gb_algorithm, t_nrnb *nrnb, gmx_bool bRad,
+                          rvec x[], rvec f[], t_forcerec *fr,t_idef *idef,int gb_algorithm, int sa_algorithm, t_nrnb *nrnb, gmx_bool bRad,
                           const t_pbc *pbc, const t_graph *graph, gmx_enerdata_t *enerd);
 
 
index f2d2b3761ebc850a8e4b1e04f8df213f1480de06..a9ac497c6873248df9b21d4458ce8d9d769fdbfc 100644 (file)
@@ -392,7 +392,7 @@ gmx_bool has_dihedral(int Dih,t_dlist *dl);
 t_dlist *mk_dlist(FILE *log, 
                         t_atoms *atoms, int *nlist,
                         gmx_bool bPhi, gmx_bool bPsi, gmx_bool bChi, gmx_bool bHChi,
-                        int maxchi,int r0,int naa,char **aa);
+                        int maxchi, int r0, gmx_residuetype_t rt);
                         
 void pr_dlist(FILE *fp,int nl,t_dlist dl[],real dt,  int printtype,
                     gmx_bool bPhi, gmx_bool bPsi,gmx_bool bChi,gmx_bool bOmega, int maxchi);
index b327bd34d974302e96b45cdda3f4537bf5a5bc19..ad91baa98d7eaeaea1992e5a7e877da7e008f668 100644 (file)
@@ -123,6 +123,15 @@ gmx_residuetype_is_dna(gmx_residuetype_t rt, const char *resnm);
 gmx_bool 
 gmx_residuetype_is_rna(gmx_residuetype_t rt, const char *resnm);
 
+int
+gmx_residuetype_get_size(gmx_residuetype_t rt);
+
+int
+gmx_residuetype_get_index(gmx_residuetype_t rt, const char *resnm);
+
+const char *
+gmx_residuetype_get_name(gmx_residuetype_t rt, int index);
+
 
 
 
index b288e4a18a9c9680d066739162a2d4cc9df186b2..db0f7d7c05922c8a8d25b0e88896230bd3fae2a4 100644 (file)
@@ -50,7 +50,7 @@
 #include "vsite.h"
 #include "pull.h"
 #include "update.h"
-#include "gmx_membed.h"
+#include "membed.h"
 
 #ifdef __cplusplus
 extern "C" {
similarity index 100%
rename from include/gmx_membed.h
rename to include/membed.h
index f951df001dd99546f2c597c87a1e1e7275385650..ab38d4fccbae3cccd5098e2f57d5945f3fe784fa 100644 (file)
@@ -98,6 +98,7 @@ files.
 #include "thread_mpi/threads.h"
 #include "thread_mpi/barrier.h"
 #include "thread_mpi/event.h"
+#include "thread_mpi/lock.h"
 #include "thread_mpi/tmpi.h"
 #include "thread_mpi/collective.h"
 #include "thread_mpi/hwinfo.h"
index e893f52b529c97b31ed0055846ea15f519bc1b13..fe8b0a47e397f54831cdbf617d64cf5f6dfc9338 100644 (file)
@@ -91,7 +91,8 @@ extern "C"
 #endif
 
 
-/* first check for gcc/icc platforms. icc on linux+mac will take this path, 
+/* first check for gcc/icc platforms. 
+   Some compatible compilers, like icc on linux+mac will take this path, 
    too */
 #if ( (defined(__GNUC__) || defined(__PATHSCALE__) || defined(__PGI)) && (!defined(__xlc__)) )
 
@@ -105,13 +106,9 @@ extern "C"
 /* then ia64: */
 #include "atomic/gcc_ia64.h"
 
-#elif (defined(__powerpc__) || (defined(__ppc__)) )
-/* and powerpc: */
-/*#include "atomic/gcc_ppc.h"*/
-
 /* for now we use gcc intrinsics on gcc: */
-#include "atomic/gcc.h"
-
+/*#elif (defined(__powerpc__) || (defined(__ppc__)) )*/
+/*#include "atomic/gcc_ppc.h"*/
 
 #else
 /* otherwise, there's a generic gcc intrinsics version: */
@@ -127,22 +124,16 @@ extern "C"
 
 #elif ( (defined(__IBM_GCC_ASM) || defined(__IBM_STDCPP_ASM))  && \
         (defined(__powerpc__) || defined(__ppc__)))
-/* PowerPC using xlC inline assembly. 
- * Recent versions of xlC (>=7.0) _partially_ support GCC inline assembly
- * if you use the option -qasm=gcc but we have had to hack things a bit, in 
- * particular when it comes to clobbered variables. Since this implementation
- * _could_ be buggy, we have separated it from the known-to-be-working gcc
- * one above.
- */
+
+/* PowerPC using xlC intrinsics.  */
+
 #include "atomic/xlc_ppc.h"
 
-#elif defined(__xlC__) && defined (_AIX)
-/* IBM xlC compiler on AIX */
+#elif defined(__xlC__)  || defined(__xlc__)
+/* IBM xlC compiler */
 #include "atomic/xlc_ppc.h"
 
-#elif (defined(__hpux) || defined(__HP_cc)) && defined(__ia64)
-/* HP compiler on ia64 */
-#include "atomic/hpux.h"
+
 
 
 
index bfaa43281b5ba56f695959105a6923748a805e6f..37ded4f9bf404fdc92a099012439468de708db20 100644 (file)
@@ -264,7 +264,7 @@ static inline int tMPI_Spinlock_trylock(tMPI_Spinlock_t *x)
                          : "r" (mask), "r" (p), "m" (*p)
                          : "cc", "memory");
     
-    return ((old & mask) != 0);    
+    return (old & mask);    
 }
 
 
index 7b2b93c5de6ad9f9602cc2e00e376e86eeba23ff..1336406db2df1ac96849919af49e92678cc99563 100644 (file)
@@ -78,7 +78,7 @@ static inline void tMPI_Spinlock_lock(tMPI_Spinlock_t *x)
 
 static inline int tMPI_Spinlock_trylock(tMPI_Spinlock_t *x)
 {
-    return (__sync_lock_test_and_set(&(x->lock), 1) == 1);
+    return __sync_lock_test_and_set(&(x->lock), 1) ;
 }
 
 
index f3df95937fbcbaa7ef27b4da1243383773fd80d4..710462e804712a786cd039d4afa49bbbf4ddda4d 100644 (file)
@@ -252,7 +252,7 @@ static inline int tMPI_Spinlock_trylock(tMPI_Spinlock_t *x)
     int ret;
     /* Return 0 if we got the lock */
     __fence();
-    ret=__check_lock_mp((int*)&(x->lock), 0, 1) != 0;
+    ret=__check_lock_mp((int*)&(x->lock), 0, 1);
     tMPI_Atomic_memory_barrier_acq();
     return ret;
 }
@@ -270,7 +270,7 @@ static inline int tMPI_Spinlock_islocked(const tMPI_Spinlock_t *x)
     int ret;
     __fence();
     ret=((x->lock) != 0);
-    tMPI_Atomic_memory_acq();
+    tMPI_Atomic_memory_barrier_acq();
     return ret;
 }
 
index d2567cb713b24eefa5536295ffbf6c5adfd0a0e6..21dc37ea95b7422e0707492f8db1c86a4a637939 100644 (file)
@@ -39,6 +39,7 @@ files.
 #define _TMPI_FASTLOCK_H_
 
 #include "wait.h"
+#include "atomic.h"
 
 /** Fast (possibly busy-wait-based) lock type
  *
index 31c13c3df64dda34df3f6ad179991f9e0a0d1164..1a660bc2218e711ab36f84c0fe6d701ccc3e2eee 100644 (file)
@@ -121,6 +121,7 @@ files.
 #include "thread_mpi/threads.h"
 #include "thread_mpi/barrier.h"
 #include "thread_mpi/event.h"
+#include "thread_mpi/lock.h"
 #include "thread_mpi/tmpi.h"
 #include "thread_mpi/collective.h"
 #include "thread_mpi/hwinfo.h"
index 4df68277ebb4ebb06ccda7fb9be06db428f499cc..a12c3074446a701ca5f5a4842da98bf8efb0361e 100644 (file)
@@ -205,7 +205,7 @@ enum {
 };
 
 enum {
-  esaNO, esaAPPROX, esaSTILL, esaNR
+  esaAPPROX, esaNO, esaSTILL, esaNR
 };
 
 /* Wall types */
index b8aac19d5f249ecb97753d0eabd6742741d4ee98..8461574979661367bda1830d1eb15c7a2fb836e3 100644 (file)
@@ -97,6 +97,8 @@ typedef struct
        real gb_doffset;          /* Dielectric offset for Still/HCT/OBC */
        real gb_epsilon_solvent;  /*   */
        real epsilon_r;           /* Used for inner dielectric */
+  
+  real sa_surface_tension;  /* Surface tension for non-polar solvation */
        
        real *work;               /* Used for parallel summation and in the chain rule, length natoms         */
        real *buf;                /* Used for parallel summation and in the chain rule, length natoms         */
index 4501d1849f9cf3c49a06d4d94cda551e0f02b62b..4e753e7efe863855fba335cd782cea4d15ff5b86 100644 (file)
@@ -108,6 +108,9 @@ typedef struct
 
     double start_time;     /* the start time of these energy diff blocks */
     double start_lambda;   /* lambda at start time */
+
+    gmx_bool start_lambda_set; /* whether the lambda value is set. Here
+                                  For backward-compatibility. */
 } delta_h_history_t; 
 
 typedef struct
index f08e750dcdfc06c062203313f32795bfc374d52f..9cbf19db3326bebe106e5f6a3061a540794a31cc 100644 (file)
@@ -829,18 +829,18 @@ to the energy and log file.</dd>
 <dt><b>nsttcouple: (-1)</b></dt>
 <dd>The frequency for coupling the temperature.
 The default value of -1 sets <b>nsttcouple</b> equal to <b>nstlist</b>,
-unless <b>nstlist</b> &le;0, then a value of 10 is used.
+unless <b>nstlist</b>&le;0, then a value of 10 is used.
 For velocity Verlet integrators <b>nsttcouple</b> is set to 1.</dd>
 </dd>
 <dt><b>nh-chain-length (10)</b></dt>
-<dd>the number of chained Nose-Hoover thermostats for velocity Verlet integrators, the leap-frog <b>md</b> integrator only supports 1.  Data for the NH chain variables is not printed to the .edr, but can be using the GMX_NOSEHOOVER_CHAINS environment variable</dd>
+<dd>the number of chained Nose-Hoover thermostats for velocity Verlet integrators, the leap-frog <b>md</b> integrator only supports 1.  Data for the NH chain variables is not printed to the .edr, but can be using the <tt>GMX_NOSEHOOVER_CHAINS</tt> environment variable</dd>
 <dt><b>tc_grps:</b></dt>
 <dd>groups to couple separately to temperature bath</dd>
 <dt><b>tau_t: [ps]</b></dt>
-<dd>time constant for coupling (one for each group in tc_grps),
+<dd>time constant for coupling (one for each group in <b>tc_grps</b>),
 -1 means no temperature coupling</dd>
 <dt><b>ref_t: [K]</b></dt>
-<dd>reference temperature for coupling (one for each group in tc_grps)</dd>
+<dd>reference temperature for coupling (one for each group in <b>tc_grps</b>)</dd>
 </dl>
 
 <A NAME="pc"><br>
@@ -965,10 +965,10 @@ Simulated annealing is controlled separately for each temperature group in GROMA
 each temperature group. Use 0 for groups that are not annealed. The number of entries should equal the number of temperature groups.</dd>
 
 <dt><b>annealing_time:</b></dt>
-<dd>List of times at the annealing reference/control points for each group. If you are using periodic annealing, the times will be used modulo the last value, i.e. if the values are 0, 5, 10, and 15, the coupling will restart at the 0ps value after 15ps, 30ps, 45ps, etc. The number of entries should equal the sum of the numbers given in annealing_npoints.</dd>
+<dd>List of times at the annealing reference/control points for each group. If you are using periodic annealing, the times will be used modulo the last value, i.e. if the values are 0, 5, 10, and 15, the coupling will restart at the 0ps value after 15ps, 30ps, 45ps, etc. The number of entries should equal the sum of the numbers given in <tt>annealing_npoints</tt>.</dd>
 
 <dt><b>annealing_temp:</b></dt>
-<dd>List of temperatures at the annealing reference/control points for each group. The number of entries should equal the sum of the numbers given in annealing_npoints.</dd>
+<dd>List of temperatures at the annealing reference/control points for each group. The number of entries should equal the sum of the numbers given in <tt>annealing_npoints</tt>.</dd>
 <br>
 Confused? OK, let's use an example. Assume you have two temperature groups, set the group selections to <tt>annealing = single periodic</tt>, the number of points of each group to <tt>annealing_npoints = 3 4</tt>, the times to <tt>annealing_time = 0 3 6 0 2 4 6</tt> and finally temperatures to <tt>annealing_temp = 298 280 270 298 320 320 298</tt>.
 The first group will be coupled to 298K at 0ps, but the reference temperature will drop linearly to reach 280K at 3ps, and then linearly between 280K and 270K from 3ps to 6ps. After this is stays constant, at 270K. The second group is coupled to 298K at 0ps, it increases linearly to 320K at 2ps, where it stays constant until 4ps. Between 4ps and 6ps it decreases to 298K, and then it starts over with the same pattern again, i.e. rising linearly from 298K to 320K between 6ps and 8ps. Check the summary printed by grompp if you are unsure!
@@ -1297,7 +1297,7 @@ restraint information in topology file)</dd>
 <dt><b>simple</b></dt>
 <dd>simple (per-molecule) distance restraints,
 ensemble averaging can be performed with <tt>mdrun -multi</tt>
-where the environment variable GMX_DISRE_ENSEMBLE_SIZE sets the number
+where the environment variable <tt>GMX_DISRE_ENSEMBLE_SIZE</tt> sets the number
 of systems within each ensemble (usually equal to the mdrun -multi value)</dd>
 <dt><b>ensemble</b></dt>
 <dd>distance restraints over an ensemble of molecules in one simulation box,
@@ -1503,7 +1503,7 @@ or a liquid.</dd>
 <dl>
 <dt><b>E_x ; E_y ; E_z:</b></dt>
 <dd>If you want to use an electric field in a direction, enter 3 numbers
-after the appropriate E_*, the first number: the number of cosines,
+after the appropriate <b>E_*</b>, the first number: the number of cosines,
 only 1 is implemented (with frequency 0) so enter 1,
 the second number: the strength of the electric field in
 <b>V nm<sup>-1</sup></b>,
@@ -1607,7 +1607,8 @@ method.</dd>
 <dt><b>GBSA</b></dt>
 <dd>Do a simulation with implicit solvent using the Generalized Born formalism. 
 Three different methods for calculating the Born radii are available, Still, HCT and
-OBC. These are specified with the <b>gb_algorithm</b> field.</dd>
+OBC. These are specified with the <b>gb_algorithm</b> field. The non-polar solvation
+is specified with the <b>sa_algorithm</b> field.</dd>
 </dl>
 
 <dt></dt><b>gb_algorithm:</b>
@@ -1645,15 +1646,22 @@ for the corresponding atom</dd>
 
 <dt></dt><b>sa_algorithm</b>
 <dd><dl compact="compact">
-<dt><b>no</b></dt>
-<dd>Which algorithm is used the the SA part. Note that currently no specific
-SA algorithm is implemented. With implicit_solvent=GBSA, a very crude ACE-style
-algorithm is used by default</dd>
+<dt><b>Ace-approx</b></dt>
+<dd>Use an Ace-type approximation (default)</dd>
+<dt><b>None</b></dt>
+<dd>No non-polar solvation calculation done. For GBSA only the polar part gets 
+calculated</dd>
 </dl>
 
-<dt></dt><b>sa_surface_tension: (2.092) [kj/mol/nm2]</b>
-<dd>Default values for surface tension with SA algorithms. The value, 2.092, 
-correponds to 0.005 kcal/mol/Angstrom2</dd>
+<dt></dt><b>sa_surface_tension: [kj/mol/nm2]</b>
+<dd>Default value for surface tension with SA algorithms. The default value is -1, 
+<br>Note that if this default value is not changed
+it will be over-ridden by grompp using values that are specific for the choice
+of radii algorithm (0.0049 kcal/mol/Angstrom2 for Still, 0.0054 kcal/mol/Angstrom2 
+for HCT/OBC)
+<br>Setting it to 0 will while using an sa_algorithm other than None means 
+no non-polar calculations are done.
+</dd>
 </dl>   
 
 <A NAME="user"><br>
index 086226e212e7eef54a26ce651e85b89d47f7c0d6..904612cdc8c69d8846048b063fdcebb2d5412385 100644 (file)
 [ ALA ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT3     -0.27   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       HB3     HA      0.09    1
-       C       C       0.51    2
-       O       O       -0.51   2
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT3     -0.27   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       HB3     HA      0.09    7
+       C       C       0.51    8
+       O       O       -0.51   9
  [ bonds ]
        CB      CA
        N       HN
 [ ARG ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CT2     -0.18   2
-       HG1     HA      0.09    2
-       HG2     HA      0.09    2
-       CD      CT2     0.20    3
-       HD1     HA      0.09    3
-       HD2     HA      0.09    3
-       NE      NC2     -0.70   3
-       HE      HC      0.44    3
-       CZ      C       0.64    3
-       NH1     NC2     -0.80   3
-       HH11    HC      0.46    3
-       HH12    HC      0.46    3
-       NH2     NC2     -0.80   3
-       HH21    HC      0.46    3
-       HH22    HC      0.46    3
-       C       C       0.51    4
-       O       O       -0.51   4
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CT2     -0.18   7
+       HG1     HA      0.09    8
+       HG2     HA      0.09    9
+       CD      CT2     0.20    10
+       HD1     HA      0.09    11
+       HD2     HA      0.09    12
+       NE      NC2     -0.70   13
+       HE      HC      0.44    14
+       CZ      C       0.64    15
+       NH1     NC2     -0.80   16
+       HH11    HC      0.46    17
+       HH12    HC      0.46    18
+       NH2     NC2     -0.80   19
+       HH21    HC      0.46    20
+       HH22    HC      0.46    21
+       C       C       0.51    22
+       O       O       -0.51   23
  [ bonds ]
        CB      CA
        CG      CB
 [ ASN ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CC      0.55    2
-       OD1     O       -0.55   2
-       ND2     NH2     -0.62   3
-       HD21    H       0.32    3
-       HD22    H       0.30    3
-       C       C       0.51    4
-       O       O       -0.51   4
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CC      0.55    7
+       OD1     O       -0.55   8
+       ND2     NH2     -0.62   9
+       HD21    H       0.32    10
+       HD22    H       0.30    11
+       C       C       0.51    12
+       O       O       -0.51   13
  [ bonds ]
        CB      CA
        CG      CB
 [ ASP ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.28   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CC      0.62    1
-       OD1     OC      -0.76   1
-       OD2     OC      -0.76   1
-       C       C       0.51    2
-       O       O       -0.51   2
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.28   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CC      0.62    7
+       OD1     OC      -0.76   8
+       OD2     OC      -0.76   9
+       C       C       0.51    10
+       O       O       -0.51   11
  [ bonds ]
        CB      CA
        CG      CB
 [ CYS ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.11   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       SG      S       -0.23   1
-       HG1     HS      0.16    1
-       C       C       0.51    2
-       O       O       -0.51   2
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.11   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       SG      S       -0.23   7
+       HG1     HS      0.16    8
+       C       C       0.51    9
+       O       O       -0.51   10
  [ bonds ]
        CB      CA
        SG      CB
 [ GLN ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CT2     -0.18   2
-       HG1     HA      0.09    2
-       HG2     HA      0.09    2
-       CD      CC      0.55    3
-       OE1     O       -0.55   3
-       NE2     NH2     -0.62   4
-       HE21    H       0.32    4
-       HE22    H       0.30    4
-       C       C       0.51    5
-       O       O       -0.51   5
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CT2     -0.18   7
+       HG1     HA      0.09    8
+       HG2     HA      0.09    9
+       CD      CC      0.55    10
+       OE1     O       -0.55   11
+       NE2     NH2     -0.62   12
+       HE21    H       0.32    13
+       HE22    H       0.30    14
+       C       C       0.51    15
+       O       O       -0.51   16
  [ bonds ]
        CB      CA
        CG      CB
 [ GLU ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CT2     -0.28   2
-       HG1     HA      0.09    2
-       HG2     HA      0.09    2
-       CD      CC      0.62    2
-       OE1     OC      -0.76   2
-       OE2     OC      -0.76   2
-       C       C       0.51    3
-       O       O       -0.51   3
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CT2     -0.28   7
+       HG1     HA      0.09    8
+       HG2     HA      0.09    9
+       CD      CC      0.62    10
+       OE1     OC      -0.76   11
+       OE2     OC      -0.76   12
+       C       C       0.51    13
+       O       O       -0.51   14
  [ bonds ]
        CB      CA
        CG      CB
 [ GLY ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT2     -0.02   0
-       HA1     HB      0.09    0
-       HA2     HB      0.09    0
-       C       C       0.51    1
-       O       O       -0.51   1
+       HN      H       0.31    1
+       CA      CT2     -0.02   2
+       HA1     HB      0.09    3
+       HA2     HB      0.09    4
+       C       C       0.51    5
+       O       O       -0.51   6
  [ bonds ]
        N       HN
        N       CA
 [ HSD ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.09   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       ND1     NR1     -0.36   1
-       HD1     H       0.32    1
-       CG      CPH1    -0.05   1
-       CE1     CPH2    0.25    2
-       HE1     HR1     0.13    2
-       NE2     NR2     -0.70   2
-       CD2     CPH1    0.22    2
-       HD2     HR3     0.10    2
-       C       C       0.51    3
-       O       O       -0.51   3
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.09   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       ND1     NR1     -0.36   7
+       HD1     H       0.32    8
+       CG      CPH1    -0.05   9
+       CE1     CPH2    0.25    10
+       HE1     HR1     0.13    11
+       NE2     NR2     -0.70   12
+       CD2     CPH1    0.22    13
+       HD2     HR3     0.10    14
+       C       C       0.51    15
+       O       O       -0.51   16
  [ bonds ]
        CB      CA
        CG      CB
 [ HSE ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.08   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       ND1     NR2     -0.70   1
-       CG      CPH1    0.22    1
-       CE1     CPH2    0.25    1
-       HE1     HR1     0.13    1
-       NE2     NR1     -0.36   2
-       HE2     H       0.32    2
-       CD2     CPH1    -0.05   2
-       HD2     HR3     0.09    2
-       C       C       0.51    3
-       O       O       -0.51   3
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.08   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       ND1     NR2     -0.70   7
+       CG      CPH1    0.22    8
+       CE1     CPH2    0.25    9
+       HE1     HR1     0.13    10
+       NE2     NR1     -0.36   11
+       HE2     H       0.32    12
+       CD2     CPH1    -0.05   13
+       HD2     HR3     0.09    14
+       C       C       0.51    15
+       O       O       -0.51   16
  [ bonds ]
        CB      CA
        CG      CB
 [ HSP ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.05   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CD2     CPH1    0.19    1
-       HD2     HR1     0.13    1
-       CG      CPH1    0.19    1
-       NE2     NR3     -0.51   2
-       HE2     H       0.44    2
-       ND1     NR3     -0.51   2
-       HD1     H       0.44    2
-       CE1     CPH2    0.32    2
-       HE1     HR2     0.18    2
-       C       C       0.51    3
-       O       O       -0.51   3
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.05   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CD2     CPH1    0.19    7
+       HD2     HR1     0.13    8
+       CG      CPH1    0.19    9
+       NE2     NR3     -0.51   10
+       HE2     H       0.44    11
+       ND1     NR3     -0.51   12
+       HD1     H       0.44    13
+       CE1     CPH2    0.32    14
+       HE1     HR2     0.18    15
+       C       C       0.51    16
+       O       O       -0.51   17
  [ bonds ]
        CB      CA
        CG      CB
 [ ILE ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT1     -0.09   1
-       HB      HA      0.09    1
-       CG2     CT3     -0.27   2
-       HG21    HA      0.09    2
-       HG22    HA      0.09    2
-       HG23    HA      0.09    2
-       CG1     CT2     -0.18   3
-       HG11    HA      0.09    3
-       HG12    HA      0.09    3
-       CD      CT3     -0.27   4
-       HD1     HA      0.09    4
-       HD2     HA      0.09    4
-       HD3     HA      0.09    4
-       C       C       0.51    5
-       O       O       -0.51   5
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT1     -0.09   4
+       HB      HA      0.09    5
+       CG2     CT3     -0.27   6
+       HG21    HA      0.09    7
+       HG22    HA      0.09    8
+       HG23    HA      0.09    9
+       CG1     CT2     -0.18   10
+       HG11    HA      0.09    11
+       HG12    HA      0.09    12
+       CD      CT3     -0.27   13
+       HD1     HA      0.09    14
+       HD2     HA      0.09    15
+       HD3     HA      0.09    16
+       C       C       0.51    17
+       O       O       -0.51   18
  [ bonds ]
        CB      CA
        CG1     CB
 [ LEU ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CT1     -0.09   2
-       HG      HA      0.09    2
-       CD1     CT3     -0.27   3
-       HD11    HA      0.09    3
-       HD12    HA      0.09    3
-       HD13    HA      0.09    3
-       CD2     CT3     -0.27   4
-       HD21    HA      0.09    4
-       HD22    HA      0.09    4
-       HD23    HA      0.09    4
-       C       C       0.51    5
-       O       O       -0.51   5
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CT1     -0.09   7
+       HG      HA      0.09    8
+       CD1     CT3     -0.27   9
+       HD11    HA      0.09    10
+       HD12    HA      0.09    11
+       HD13    HA      0.09    12
+       CD2     CT3     -0.27   13
+       HD21    HA      0.09    14
+       HD22    HA      0.09    15
+       HD23    HA      0.09    16
+       C       C       0.51    17
+       O       O       -0.51   18
  [ bonds ]
        CB      CA
        CG      CB
 [ LYS ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CT2     -0.18   2
-       HG1     HA      0.09    2
-       HG2     HA      0.09    2
-       CD      CT2     -0.18   3
-       HD1     HA      0.09    3
-       HD2     HA      0.09    3
-       CE      CT2     0.21    4
-       HE1     HA      0.05    4
-       HE2     HA      0.05    4
-       NZ      NH3     -0.30   4
-       HZ1     HC      0.33    4
-       HZ2     HC      0.33    4
-       HZ3     HC      0.33    4
-       C       C       0.51    5
-       O       O       -0.51   5
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CT2     -0.18   7
+       HG1     HA      0.09    8
+       HG2     HA      0.09    9
+       CD      CT2     -0.18   10
+       HD1     HA      0.09    11
+       HD2     HA      0.09    12
+       CE      CT2     0.21    13
+       HE1     HA      0.05    14
+       HE2     HA      0.05    15
+       NZ      NH3     -0.30   16
+       HZ1     HC      0.33    17
+       HZ2     HC      0.33    18
+       HZ3     HC      0.33    19
+       C       C       0.51    20
+       O       O       -0.51   21
  [ bonds ]
        CB      CA
        CG      CB
 [ MET ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CT2     -0.14   2
-       HG1     HA      0.09    2
-       HG2     HA      0.09    2
-       SD      S       -0.09   2
-       CE      CT3     -0.22   2
-       HE1     HA      0.09    2
-       HE2     HA      0.09    2
-       HE3     HA      0.09    2
-       C       C       0.51    3
-       O       O       -0.51   3
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CT2     -0.14   7
+       HG1     HA      0.09    8
+       HG2     HA      0.09    9
+       SD      S       -0.09   10
+       CE      CT3     -0.22   11
+       HE1     HA      0.09    12
+       HE2     HA      0.09    13
+       HE3     HA      0.09    14
+       C       C       0.51    15
+       O       O       -0.51   16
  [ bonds ]
        CB      CA
        CG      CB
 [ PHE ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CA      0.00    2
-       CD1     CA      -0.115  3
-       HD1     HP      0.115   3
-       CE1     CA      -0.115  4
-       HE1     HP      0.115   4
-       CZ      CA      -0.115  5
-       HZ      HP      0.115   5
-       CD2     CA      -0.115  6
-       HD2     HP      0.115   6
-       CE2     CA      -0.115  7
-       HE2     HP      0.115   7
-       C       C       0.51    8
-       O       O       -0.51   8
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CA      0.00    7
+       CD1     CA      -0.115  8
+       HD1     HP      0.115   9
+       CE1     CA      -0.115  10
+       HE1     HP      0.115   11
+       CZ      CA      -0.115  12
+       HZ      HP      0.115   13
+       CD2     CA      -0.115  14
+       HD2     HP      0.115   15
+       CE2     CA      -0.115  16
+       HE2     HP      0.115   17
+       C       C       0.51    18
+       O       O       -0.51   19
  [ bonds ]
        CB      CA
        CG      CB
 [ PRO ]
  [ atoms ]
        N       N       -0.29   0
-       CD      CP3     0.00    0
-       HD1     HA      0.09    0
-       HD2     HA      0.09    0
-       CA      CP1     0.02    0
-       HA      HB      0.09    0
-       CB      CP2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CP2     -0.18   2
-       HG1     HA      0.09    2
-       HG2     HA      0.09    2
-       C       C       0.51    3
-       O       O       -0.51   3
+       CD      CP3     0.00    1
+       HD1     HA      0.09    2
+       HD2     HA      0.09    3
+       CA      CP1     0.02    4
+       HA      HB      0.09    5
+       CB      CP2     -0.18   6
+       HB1     HA      0.09    7
+       HB2     HA      0.09    8
+       CG      CP2     -0.18   9
+       HG1     HA      0.09    10
+       HG2     HA      0.09    11
+       C       C       0.51    12
+       O       O       -0.51   13
  [ bonds ]
        C       CA
        C       +N
 [ SER ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     0.05    1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       OG      OH1     -0.66   1
-       HG1     H       0.43    1
-       C       C       0.51    2
-       O       O       -0.51   2
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     0.05    4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       OG      OH1     -0.66   7
+       HG1     H       0.43    8
+       C       C       0.51    9
+       O       O       -0.51   10
  [ bonds ]
        CB      CA
        OG      CB
 [ THR ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT1     0.14    1
-       HB      HA      0.09    1
-       OG1     OH1     -0.66   1
-       HG1     H       0.43    1
-       CG2     CT3     -0.27   2
-       HG21    HA      0.09    2
-       HG22    HA      0.09    2
-       HG23    HA      0.09    2
-       C       C       0.51    3
-       O       O       -0.51   3
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT1     0.14    4
+       HB      HA      0.09    5
+       OG1     OH1     -0.66   6
+       HG1     H       0.43    7
+       CG2     CT3     -0.27   8
+       HG21    HA      0.09    9
+       HG22    HA      0.09    10
+       HG23    HA      0.09    11
+       C       C       0.51    12
+       O       O       -0.51   13
  [ bonds ]
        CB      CA
        OG1     CB
 [ TRP ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CY      -0.03   2
-       CD1     CA      0.035   2
-       HD1     HP      0.115   2
-       NE1     NY      -0.61   2
-       HE1     H       0.38    2
-       CE2     CPT     0.13    2
-       CD2     CPT     -0.02   2
-       CE3     CA      -0.115  3
-       HE3     HP      0.115   3
-       CZ3     CA      -0.115  4
-       HZ3     HP      0.115   4
-       CZ2     CA      -0.115  5
-       HZ2     HP      0.115   5
-       CH2     CA      -0.115  6
-       HH2     HP      0.115   6
-       C       C       0.51    7
-       O       O       -0.51   7
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CY      -0.03   7
+       CD1     CA      0.035   8
+       HD1     HP      0.115   9
+       NE1     NY      -0.61   10
+       HE1     H       0.38    11
+       CE2     CPT     0.13    12
+       CD2     CPT     -0.02   13
+       CE3     CA      -0.115  14
+       HE3     HP      0.115   15
+       CZ3     CA      -0.115  16
+       HZ3     HP      0.115   17
+       CZ2     CA      -0.115  18
+       HZ2     HP      0.115   19
+       CH2     CA      -0.115  20
+       HH2     HP      0.115   21
+       C       C       0.51    22
+       O       O       -0.51   23
  [ bonds ]
        CB      CA
        CG      CB
 [ TYR ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT2     -0.18   1
-       HB1     HA      0.09    1
-       HB2     HA      0.09    1
-       CG      CA      0.00    2
-       CD1     CA      -0.115  3
-       HD1     HP      0.115   3
-       CE1     CA      -0.115  4
-       HE1     HP      0.115   4
-       CZ      CA      0.11    5
-       OH      OH1     -0.54   5
-       HH      H       0.43    5
-       CD2     CA      -0.115  6
-       HD2     HP      0.115   6
-       CE2     CA      -0.115  7
-       HE2     HP      0.115   7
-       C       C       0.51    8
-       O       O       -0.51   8
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT2     -0.18   4
+       HB1     HA      0.09    5
+       HB2     HA      0.09    6
+       CG      CA      0.00    7
+       CD1     CA      -0.115  8
+       HD1     HP      0.115   9
+       CE1     CA      -0.115  10
+       HE1     HP      0.115   11
+       CZ      CA      0.11    12
+       OH      OH1     -0.54   13
+       HH      H       0.43    14
+       CD2     CA      -0.115  15
+       HD2     HP      0.115   16
+       CE2     CA      -0.115  17
+       HE2     HP      0.115   18
+       C       C       0.51    19
+       O       O       -0.51   20
  [ bonds ]
        CB      CA
        CG      CB
 [ VAL ]
  [ atoms ]
        N       NH1     -0.47   0
-       HN      H       0.31    0
-       CA      CT1     0.07    0
-       HA      HB      0.09    0
-       CB      CT1     -0.09   1
-       HB      HA      0.09    1
-       CG1     CT3     -0.27   2
-       HG11    HA      0.09    2
-       HG12    HA      0.09    2
-       HG13    HA      0.09    2
-       CG2     CT3     -0.27   3
-       HG21    HA      0.09    3
-       HG22    HA      0.09    3
-       HG23    HA      0.09    3
-       C       C       0.51    4
-       O       O       -0.51   4
+       HN      H       0.31    1
+       CA      CT1     0.07    2
+       HA      HB      0.09    3
+       CB      CT1     -0.09   4
+       HB      HA      0.09    5
+       CG1     CT3     -0.27   6
+       HG11    HA      0.09    7
+       HG12    HA      0.09    8
+       HG13    HA      0.09    9
+       CG2     CT3     -0.27   10
+       HG21    HA      0.09    11
+       HG22    HA      0.09    12
+       HG23    HA      0.09    13
+       C       C       0.51    14
+       O       O       -0.51   15
  [ bonds ]
        CB      CA
        CG1     CB
 [ ALAD ] ; Alanine dipeptide
  [ atoms ]
        CL      CT3     -0.27   0
-       HL1     HA      0.09    0
-       HL2     HA      0.09    0
-       HL3     HA      0.09    0
-       CLP     C       0.51    1
-       OL      O       -0.51   1
-       NL      NH1     -0.47   2
-       HL      H       0.31    2
-       CA      CT1     0.07    2
-       HA      HB      0.09    2
-       CB      CT3     -0.27   3
-       HB1     HA      0.09    3
-       HB2     HA      0.09    3
-       HB3     HA      0.09    3
-       CRP     C       0.51    4
-       OR      O       -0.51   4
-       NR      NH1     -0.47   5
-       HR      H       0.31    5
-       CR      CT3     -0.11   5
-       HR1     HA      0.09    5
-       HR2     HA      0.09    5
-       HR3     HA      0.09    5
+       HL1     HA      0.09    1
+       HL2     HA      0.09    2
+       HL3     HA      0.09    3
+       CLP     C       0.51    4
+       OL      O       -0.51   5
+       NL      NH1     -0.47   6
+       HL      H       0.31    7
+       CA      CT1     0.07    8
+       HA      HB      0.09    9
+       CB      CT3     -0.27   10
+       HB1     HA      0.09    11
+       HB2     HA      0.09    12
+       HB3     HA      0.09    13
+       CRP     C       0.51    14
+       OR      O       -0.51   15
+       NR      NH1     -0.47   16
+       HR      H       0.31    17
+       CR      CT3     -0.11   18
+       HR1     HA      0.09    19
+       HR2     HA      0.09    20
+       HR3     HA      0.09    21
  [ bonds ]
        CL      CLP
        CLP     NL
 [ TIP3 ]
  [ atoms ]
        OH2     OT      -0.834  0
-       H1      HT      0.417   0
-       H2      HT      0.417   0
+       H1      HT      0.417   1
+       H2      HT      0.417   2
  [ bonds ]
        OH2     H1
        OH2     H2
 [ TP3M ]
  [ atoms ]
        OH2     OT      -0.834  0
-       H1      HT      0.417   0
-       H2      HT      0.417   0
+       H1      HT      0.417   1
+       H2      HT      0.417   2
  [ bonds ]
        OH2     H1
        OH2     H2
index b45e646cdc2b96e98efdc0578b92ceb61c0e4a21..983b381a57babeba0eb106098ff099139fa9aad4 100644 (file)
 ;
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2     -0.05   2
-C5     CN5      0.28   2
-N7     NN4     -0.71   2
-C8     CN4      0.34   2
-H8     HN3      0.12   2
-N1     NN3A    -0.74   2
-C2     CN4      0.50   2
-H2     HN3      0.13   2
-N3     NN3A    -0.75   2
-C4     CN5      0.43   2
-C6     CN2      0.46   2
-N6     NN1     -0.77   2
-H61    HN1      0.38   2
-H62    HN1      0.38   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6     -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N9     NN2     -0.05   12
+C5     CN5      0.28   13
+N7     NN4     -0.71   14
+C8     CN4      0.34   15
+H8     HN3      0.12   16
+N1     NN3A    -0.74   17
+C2     CN4      0.50   18
+H2     HN3      0.13   19
+N3     NN3A    -0.75   20
+C4     CN5      0.43   21
+C6     CN2      0.46   22
+N6     NN1     -0.77   23
+H61    HN1      0.38   24
+H62    HN1      0.38   25
+C2'    CN8     -0.18   26
+H2'1   HN8      0.09   27
+H2'2   HN8      0.09   28
+C3'    CN7      0.01   29
+H3'    HN7      0.09   30
+O3'    ON2     -0.57   31
 [ bonds ]
 -O3'     P
 P      O1P
@@ -139,35 +139,35 @@ C6        N1      C5      N6
 ;
 [ atoms ]
 H5T     HN5      0.43   0
-O5'    ON5     -0.66   0
-C5'    CN8B     0.05   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2     -0.05   2
-C5     CN5      0.28   2
-N7     NN4     -0.71   2
-C8     CN4      0.34   2
-H8     HN3      0.12   2
-N1     NN3A    -0.74   2
-C2     CN4      0.50   2
-H2     HN3      0.13   2
-N3     NN3A    -0.75   2
-C4     CN5      0.43   2
-C6     CN2      0.46   2
-N6     NN1     -0.77   2
-H61    HN1      0.38   2
-H62    HN1      0.38   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O5'    ON5     -0.66   1
+C5'    CN8B     0.05   2
+H5'1   HN8      0.09   3
+H5'2   HN8      0.09   4
+C4'    CN7      0.16   5
+H4'    HN7      0.09   6
+O4'    ON6     -0.50   7
+C1'    CN7B     0.16   8
+H1'    HN7      0.09   9
+N9     NN2     -0.05   10
+C5     CN5      0.28   11
+N7     NN4     -0.71   12
+C8     CN4      0.34   13
+H8     HN3      0.12   14
+N1     NN3A    -0.74   15
+C2     CN4      0.50   16
+H2     HN3      0.13   17
+N3     NN3A    -0.75   18
+C4     CN5      0.43   19
+C6     CN2      0.46   20
+N6     NN1     -0.77   21
+H61    HN1      0.38   22
+H62    HN1      0.38   23
+C2'    CN8     -0.18   24
+H2'1   HN8      0.09   25
+H2'2   HN8      0.09   26
+C3'    CN7      0.01   27
+H3'    HN7      0.09   28
+O3'    ON2     -0.57   29
 [ bonds ]
 H5T    O5'
 O5'    C5'
@@ -233,38 +233,38 @@ C6        N1      C5      N6
 
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2     -0.05   2
-C5     CN5      0.28   2
-N7     NN4     -0.71   2
-C8     CN4      0.34   2
-H8     HN3      0.12   2
-N1     NN3A    -0.74   2
-C2     CN4      0.50   2
-H2     HN3      0.13   2
-N3     NN3A    -0.75   2
-C4     CN5      0.43   2
-C6     CN2      0.46   2
-N6     NN1     -0.77   2
-H61    HN1      0.38   2
-H62    HN1      0.38   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.14   4
-H3'    HN7      0.09   4
-O3'    ON5     -0.66   4
-H3T     HN5      0.43   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6     -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N9     NN2     -0.05   12
+C5     CN5      0.28   13
+N7     NN4     -0.71   14
+C8     CN4      0.34   15
+H8     HN3      0.12   16
+N1     NN3A    -0.74   17
+C2     CN4      0.50   18
+H2     HN3      0.13   19
+N3     NN3A    -0.75   20
+C4     CN5      0.43   21
+C6     CN2      0.46   22
+N6     NN1     -0.77   23
+H61    HN1      0.38   24
+H62    HN1      0.38   25
+C2'    CN8     -0.18   26
+H2'1   HN8      0.09   27
+H2'2   HN8      0.09   28
+C3'    CN7      0.14   29
+H3'    HN7      0.09   30
+O3'    ON5     -0.66   31
+H3T     HN5      0.43   32
 [ bonds ]
 -O3'     P
 P      O1P
@@ -334,35 +334,35 @@ C6        N1      C5      N6
 ;                     
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2     -0.13   2
-C6     CN3      0.05   2
-H6     HN3      0.17   2
-C5     CN3     -0.13   2
-H5     HN3      0.07   2
-C2     CN1      0.52   2
-O2     ON1C    -0.49   2
-N3     NN3     -0.66   2
-C4     CN2      0.65   2
-N4     NN1     -0.75   2
-H41    HN1      0.37   2
-H42    HN1      0.33   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6     -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N1     NN2     -0.13   12
+C6     CN3      0.05   13
+H6     HN3      0.17   14
+C5     CN3     -0.13   15
+H5     HN3      0.07   16
+C2     CN1      0.52   17
+O2     ON1C    -0.49   18
+N3     NN3     -0.66   19
+C4     CN2      0.65   20
+N4     NN1     -0.75   21
+H41    HN1      0.37   22
+H42    HN1      0.33   23
+C2'    CN8     -0.18   24
+H2'1   HN8      0.09   25
+H2'2   HN8      0.09   26
+C3'    CN7      0.01   27
+H3'    HN7      0.09   28
+O3'    ON2     -0.57   29
 [ bonds ]
 -O3'     P
 P      O1P
@@ -428,33 +428,33 @@ N4        C4      H41     H42
 ;   
 [ atoms ]
 H5T     HN5      0.43   0
-O5'    ON5     -0.66   0
-C5'    CN8B     0.05   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2     -0.13   2
-C6     CN3      0.05   2
-H6     HN3      0.17   2
-C5     CN3     -0.13   2
-H5     HN3      0.07   2
-C2     CN1      0.52   2
-O2     ON1C    -0.49   2
-N3     NN3     -0.66   2
-C4     CN2      0.65   2
-N4     NN1     -0.75   2
-H41    HN1      0.37   2
-H42    HN1      0.33   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O5'    ON5     -0.66   1
+C5'    CN8B     0.05   2
+H5'1   HN8      0.09   3
+H5'2   HN8      0.09   4
+C4'    CN7      0.16   5
+H4'    HN7      0.09   6
+O4'    ON6     -0.50   7
+C1'    CN7B     0.16   8
+H1'    HN7      0.09   9
+N1     NN2     -0.13   10
+C6     CN3      0.05   11
+H6     HN3      0.17   12
+C5     CN3     -0.13   13
+H5     HN3      0.07   14
+C2     CN1      0.52   15
+O2     ON1C    -0.49   16
+N3     NN3     -0.66   17
+C4     CN2      0.65   18
+N4     NN1     -0.75   19
+H41    HN1      0.37   20
+H42    HN1      0.33   21
+C2'    CN8     -0.18   22
+H2'1   HN8      0.09   23
+H2'2   HN8      0.09   24
+C3'    CN7      0.01   25
+H3'    HN7      0.09   26
+O3'    ON2     -0.57   27
 [ bonds ]
 H5T    O5'
 O5'    C5'
@@ -517,36 +517,36 @@ N4        C4      H41     H42
 ;                  H3T
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2     -0.13   2
-C6     CN3      0.05   2
-H6     HN3      0.17   2
-C5     CN3     -0.13   2
-H5     HN3      0.07   2
-C2     CN1      0.52   2
-O2     ON1C    -0.49   2
-N3     NN3     -0.66   2
-C4     CN2      0.65   2
-N4     NN1     -0.75   2
-H41    HN1      0.37   2
-H42    HN1      0.33   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.14   4
-H3'    HN7      0.09   4
-O3'    ON5     -0.66   4
-H3T     HN5      0.43   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6     -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N1     NN2     -0.13   12
+C6     CN3      0.05   13
+H6     HN3      0.17   14
+C5     CN3     -0.13   15
+H5     HN3      0.07   16
+C2     CN1      0.52   17
+O2     ON1C    -0.49   18
+N3     NN3     -0.66   19
+C4     CN2      0.65   20
+N4     NN1     -0.75   21
+H41    HN1      0.37   22
+H42    HN1      0.33   23
+C2'    CN8     -0.18   24
+H2'1   HN8      0.09   25
+H2'2   HN8      0.09   26
+C3'    CN7      0.14   27
+H3'    HN7      0.09   28
+O3'    ON5     -0.66   29
+H3T     HN5      0.43   30
 [ bonds ]
 -O3'     P
 P      O1P
@@ -611,38 +611,38 @@ N4        C4      H41     H42
 ;                     
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2B    -0.02   2
-C4     CN5      0.26   2
-N2     NN1     -0.68   2
-H21    HN1      0.32   2
-H22    HN1      0.35   2
-N3     NN3G    -0.74   2
-C2     CN2      0.75   2
-N1     NN2G    -0.34   2
-H1     HN2      0.26   2
-C6     CN1      0.54   2
-O6     ON1     -0.51   2
-C5     CN5G     0.00   2
-N7     NN4     -0.60   2
-C8     CN4      0.25   2
-H8     HN3      0.16   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6     -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N9     NN2B    -0.02   12
+C4     CN5      0.26   13
+N2     NN1     -0.68   14
+H21    HN1      0.32   15
+H22    HN1      0.35   16
+N3     NN3G    -0.74   17
+C2     CN2      0.75   18
+N1     NN2G    -0.34   19
+H1     HN2      0.26   20
+C6     CN1      0.54   21
+O6     ON1     -0.51   22
+C5     CN5G     0.00   23
+N7     NN4     -0.60   24
+C8     CN4      0.25   25
+H8     HN3      0.16   26
+C2'    CN8     -0.18   27
+H2'1   HN8      0.09   28
+H2'2   HN8      0.09   29
+C3'    CN7      0.01   30
+H3'    HN7      0.09   31
+O3'    ON2     -0.57   32
 [ bonds ]
 -O3'     P
 P      O1P
@@ -709,36 +709,36 @@ N2        H21     C2      H22
 ;                     
 [ atoms ]
 H5T     HN5      0.43   0
-O5'    ON5     -0.66   0
-C5'    CN8B     0.05   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2B    -0.02   2
-C4     CN5      0.26   2
-N2     NN1     -0.68   2
-H21    HN1      0.32   2
-H22    HN1      0.35   2
-N3     NN3G    -0.74   2
-C2     CN2      0.75   2
-N1     NN2G    -0.34   2
-H1     HN2      0.26   2
-C6     CN1      0.54   2
-O6     ON1     -0.51   2
-C5     CN5G     0.00   2
-N7     NN4     -0.60   2
-C8     CN4      0.25   2
-H8     HN3      0.16   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O5'    ON5     -0.66   1
+C5'    CN8B     0.05   2
+H5'1   HN8      0.09   3
+H5'2   HN8      0.09   4
+C4'    CN7      0.16   5
+H4'    HN7      0.09   6
+O4'    ON6     -0.50   7
+C1'    CN7B     0.16   8
+H1'    HN7      0.09   9
+N9     NN2B    -0.02   10
+C4     CN5      0.26   11
+N2     NN1     -0.68   12
+H21    HN1      0.32   13
+H22    HN1      0.35   14
+N3     NN3G    -0.74   15
+C2     CN2      0.75   16
+N1     NN2G    -0.34   17
+H1     HN2      0.26   18
+C6     CN1      0.54   19
+O6     ON1     -0.51   20
+C5     CN5G     0.00   21
+N7     NN4     -0.60   22
+C8     CN4      0.25   23
+H8     HN3      0.16   24
+C2'    CN8     -0.18   25
+H2'1   HN8      0.09   26
+H2'2   HN8      0.09   27
+C3'    CN7      0.01   28
+H3'    HN7      0.09   29
+O3'    ON2     -0.57   30
 [ bonds ]
 H5T     O5'
 O5'    C5'
@@ -802,39 +802,39 @@ N2        H21     C2      H22
 ;                  H3T
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2B    -0.02   2
-C4     CN5      0.26   2
-N2     NN1     -0.68   2
-H21    HN1      0.32   2
-H22    HN1      0.35   2
-N3     NN3G    -0.74   2
-C2     CN2      0.75   2
-N1     NN2G    -0.34   2
-H1     HN2      0.26   2
-C6     CN1      0.54   2
-O6     ON1     -0.51   2
-C5     CN5G     0.00   2
-N7     NN4     -0.60   2
-C8     CN4      0.25   2
-H8     HN3      0.16   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.14   4
-H3'    HN7      0.09   4
-O3'    ON5     -0.66   4
-H3T     HN5      0.43   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6     -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N9     NN2B    -0.02   12
+C4     CN5      0.26   13
+N2     NN1     -0.68   14
+H21    HN1      0.32   15
+H22    HN1      0.35   16
+N3     NN3G    -0.74   17
+C2     CN2      0.75   18
+N1     NN2G    -0.34   19
+H1     HN2      0.26   20
+C6     CN1      0.54   21
+O6     ON1     -0.51   22
+C5     CN5G     0.00   23
+N7     NN4     -0.60   24
+C8     CN4      0.25   25
+H8     HN3      0.16   26
+C2'    CN8     -0.18   27
+H2'1   HN8      0.09   28
+H2'2   HN8      0.09   29
+C3'    CN7      0.14   30
+H3'    HN7      0.09   31
+O3'    ON5     -0.66   32
+H3T     HN5      0.43   33
 [ bonds ]
 -O3'     P
 P      O1P
@@ -904,37 +904,37 @@ N2        H21     C2      H22
 ;
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2B    -0.34   2
-C6     CN3      0.17   2
-H6     HN3      0.17   2
-C2     CN1T     0.51   2
-O2     ON1     -0.41   2
-N3     NN2U    -0.46   2
-H3     HN2      0.36   2
-C4     CN1      0.50   2
-O4     ON1     -0.45   2
-C5     CN3T    -0.15   2
-C5M    CN9     -0.11   2
-H51    HN9      0.07   2
-H52    HN9      0.07   2
-H53    HN9      0.07   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6     -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N1     NN2B    -0.34   12
+C6     CN3      0.17   13
+H6     HN3      0.17   14
+C2     CN1T     0.51   15
+O2     ON1     -0.41   16
+N3     NN2U    -0.46   17
+H3     HN2      0.36   18
+C4     CN1      0.50   19
+O4     ON1     -0.45   20
+C5     CN3T    -0.15   21
+C5M    CN9     -0.11   22
+H51    HN9      0.07   23
+H52    HN9      0.07   24
+H53    HN9      0.07   25
+C2'    CN8     -0.18   26
+H2'1   HN8      0.09   27
+H2'2   HN8      0.09   28
+C3'    CN7      0.01   29
+H3'    HN7      0.09   30
+O3'    ON2     -0.57   31
 [ bonds ]
 -O3'     P
 P      O1P
@@ -1000,35 +1000,35 @@ C5      C4      C6      C5M
 ;
 [ atoms ]
 H5T     HN5      0.43   0
-O5'    ON5     -0.66   0
-C5'    CN8B     0.05   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2B    -0.34   2
-C6     CN3      0.17   2
-H6     HN3      0.17   2
-C2     CN1T     0.51   2
-O2     ON1     -0.41   2
-N3     NN2U    -0.46   2
-H3     HN2      0.36   2
-C4     CN1      0.50   2
-O4     ON1     -0.45   2
-C5     CN3T    -0.15   2
-C5M    CN9     -0.11   2
-H51    HN9      0.07   2
-H52    HN9      0.07   2
-H53    HN9      0.07   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O5'    ON5     -0.66   1
+C5'    CN8B     0.05   2
+H5'1   HN8      0.09   3
+H5'2   HN8      0.09   4
+C4'    CN7      0.16   5
+H4'    HN7      0.09   6
+O4'    ON6     -0.50   7
+C1'    CN7B     0.16   8
+H1'    HN7      0.09   9
+N1     NN2B    -0.34   10
+C6     CN3      0.17   11
+H6     HN3      0.17   12
+C2     CN1T     0.51   13
+O2     ON1     -0.41   14
+N3     NN2U    -0.46   15
+H3     HN2      0.36   16
+C4     CN1      0.50   17
+O4     ON1     -0.45   18
+C5     CN3T    -0.15   19
+C5M    CN9     -0.11   20
+H51    HN9      0.07   21
+H52    HN9      0.07   22
+H53    HN9      0.07   23
+C2'    CN8     -0.18   24
+H2'1   HN8      0.09   25
+H2'2   HN8      0.09   26
+C3'    CN7      0.01   27
+H3'    HN7      0.09   28
+O3'    ON2     -0.57   29
 [ bonds ]
 H5T    O5'
 O5'    C5'
@@ -1091,38 +1091,38 @@ C5      C4      C6      C5M
 ;
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6     -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2B    -0.34   2
-C6     CN3      0.17   2
-H6     HN3      0.17   2
-C2     CN1T     0.51   2
-O2     ON1     -0.41   2
-N3     NN2U    -0.46   2
-H3     HN2      0.36   2
-C4     CN1      0.50   2
-O4     ON1     -0.45   2
-C5     CN3T    -0.15   2
-C5M    CN9     -0.11   2
-H51    HN9      0.07   2
-H52    HN9      0.07   2
-H53    HN9      0.07   2
-C2'    CN8     -0.18   3
-H2'1   HN8      0.09   3
-H2'2   HN8      0.09   3
-C3'    CN7      0.14   4
-H3'    HN7      0.09   4
-O3'    ON5     -0.66   4
-H3T     HN5      0.43   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6     -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N1     NN2B    -0.34   12
+C6     CN3      0.17   13
+H6     HN3      0.17   14
+C2     CN1T     0.51   15
+O2     ON1     -0.41   16
+N3     NN2U    -0.46   17
+H3     HN2      0.36   18
+C4     CN1      0.50   19
+O4     ON1     -0.45   20
+C5     CN3T    -0.15   21
+C5M    CN9     -0.11   22
+H51    HN9      0.07   23
+H52    HN9      0.07   24
+H53    HN9      0.07   25
+C2'    CN8     -0.18   26
+H2'1   HN8      0.09   27
+H2'2   HN8      0.09   28
+C3'    CN7      0.14   29
+H3'    HN7      0.09   30
+O3'    ON5     -0.66   31
+H3T     HN5      0.43   32
 [ bonds ]
 -O3'     P
 P      O1P
index f1a6ccf91fc4c5b2122121bb649edc135b1c48f6..41a6f2058c38c8d9d1c02c9e5cdb2b386aace2bf 100644 (file)
@@ -133,8 +133,8 @@ OWT3        8       9.951400        -0.834  A       3.15058e-01     6.36386e-01     ; TIP3p O
 HWT3   1       4.032000        0.417   A       0.0     0.0     ; TIP3p H
 OWT4   8       9.951400        0.0     A       3.15365e-01     6.48520e-01     ; TIP4p O
 HWT4   1       4.032000        0.52    A       0.0     0.0     ; TIP4p H
-MWT4   0       0.000000        -1.04   A       0.0     0.0     ; TIP 4p vsite
-OWT5   8       9.951400        0.0     A       3.12000e-01     6.69440e-01     ; TIP5p O
+MWT4   0       0.000000        -1.04   A       0.0     0.0     ; TIP4p vsite
+OWT5   8       9.951400        0.0     A       3.12000e-01     6.69440e-01     ; TIP5p O
 HWT5   1       4.032000        0.241   A       0.0     0.0     ; TIP5p H
 MWT5   0       0.000000        -0.241  A       0.0     0.0     ; TIP5p vsite
 OW     8       9.951400        -0.82   A       3.16557e-01     6.50194e-01     ; SPC 0
@@ -154,9 +154,7 @@ HW  1       1.008000        0.41    A       0.0     0.0     ; SPC H
 ; special dummy-type particles
 MNH3   0       0.000000        0.00    A       0.0     0.0
 MNH2   0       0.000000        0.00    A       0.0     0.0
-; CH3 bound to carbons
 MCH3   0       0.000000        0.00    A       0.0     0.0
-; CH3 bound to sulfur, type S only
 MCH3S  0       0.000000        0.00    A       0.0     0.0
 ; Ions and noble gases (useful for tutorials)
 Cu2+   29      63.54600        2.00    A       2.08470e-01     4.76976e+00
index a8c03d5d8f850533436bbb4e98d5430ce238970f..eac68cb7cd33d1d1b27af503feaa3da70c5d0c1d 100644 (file)
@@ -10,17 +10,11 @@ CHARMM27 all-atom force field (with CMAP) - version 2.0beta
 
 
 Parameters derived from c32b1 version of CHARMM
+NOTE: Atom-based charge groups
 
 References:
 
-Port
-
-Bjelkmar, P., Larsson, P., Cuendet, M. A, Bess, B., Lindahl, E.
-Implementation of the CHARMM force field in GROMACS: Analysis of protein
-stability effects from correction maps, virtual interaction sites, and
-water models., Journal of Chemical Theory and Computation, 6: 459-466, 2010.
-
-Protein parameterization
+Proteins
 
 MacKerell, Jr., A. D., Feig, M., Brooks, C.L., III, Extending the
 treatment of backbone energetics in protein force fields: limitations
@@ -34,13 +28,13 @@ MacKerell, Jr., A. D.,  et al. All-atom
 empirical potential for molecular modeling and dynamics Studies of
 proteins.  Journal of Physical Chemistry B, 1998, 102, 3586-3616.
 
-Lipid parameterization
+Lipids
 
 Feller, S. and MacKerell, Jr., A.D. An Improved Empirical Potential
 Energy Function for  Molecular Simulations of Phospholipids, Journal
 of Physical Chemistry B, 2000, 104: 7510-7515.
 
-Nucleic Acids parameterization
+Nucleic Acids
 
 Foloppe, N. and MacKerell, Jr., A.D. "All-Atom Empirical Force Field for
 Nucleic Acids: 2) Parameter Optimization Based on Small Molecule and
@@ -51,3 +45,11 @@ and
 MacKerell, Jr., A.D. and Banavali, N. "All-Atom Empirical Force Field for
 Nucleic Acids: 2) Application to Molecular Dynamics Simulations of DNA
 and RNA in Solution.  2000, 21: 105-120.
+
+
+
+If using there parameters for research please cite:
+Bjelkmar, P., Larsson, P., Cuendet, M. A, Bess, B., Lindahl, E.
+Implementation of the CHARMM force field in GROMACS: Analysis of protein
+stability effects from correction maps, virtual interaction sites, and
+water models., Journal of Chemical Theory and Computation, 6: 459-466, 2010.
index 20b9c6da7a74e336df714bdd080377bd7a96f514..351e4f652e21295dc0fbd66cf700813f4ea5a06a 100644 (file)
 [ LPPC ]
  [ atoms ]
        N       NTL     -0.60   0
-       C13     CTL5    -0.35   0
-       H13A    HL      0.25    0
-       H13B    HL      0.25    0
-       H13C    HL      0.25    0
-       C14     CTL5    -0.35   0
-       H14A    HL      0.25    0
-       H14B    HL      0.25    0
-       H14C    HL      0.25    0
-       C15     CTL5    -0.35   0
-       H15A    HL      0.25    0
-       H15B    HL      0.25    0
-       H15C    HL      0.25    0
-       C12     CTL2    -0.10   0
-       H12A    HL      0.25    0
-       H12B    HL      0.25    0
-       C11     CTL2    -0.08   1
-       H11A    HAL2    0.09    1
-       H11B    HAL2    0.09    1
-       P       PL      1.50    1
-       O13     O2L     -0.78   1
-       O14     O2L     -0.78   1
-       O11     OSL     -0.57   1
-       O12     OSL     -0.57   1
-       C1      CTL2    -0.08   1
-       HA      HAL2    0.09    1
-       HB      HAL2    0.09    1
-       C2      CTL2    -0.18   2
-       HS      HAL2    0.09    2
-       HR      HAL2    0.09    2
-       C3      CTL2    -0.05   3
-       HX      HAL2    0.09    3
-       HY      HAL2    0.09    3
-       O31     OSL     -0.34   3
-       C31     CL      0.63    3
-       O32     OBL     -0.52   3
-       C32     CTL2    -0.08   3
-       H2X     HAL2    0.09    3
-       H2Y     HAL2    0.09    3
-       C33     CTL2    -0.18   4
-       H3X     HAL2    0.09    4
-       H3Y     HAL2    0.09    4
-       C34     CTL2    -0.18   5
-       H4X     HAL2    0.09    5
-       H4Y     HAL2    0.09    5
-       C35     CTL2    -0.18   6
-       H5X     HAL2    0.09    6
-       H5Y     HAL2    0.09    6
-       C36     CTL2    -0.18   7
-       H6X     HAL2    0.09    7
-       H6Y     HAL2    0.09    7
-       C37     CTL2    -0.18   8
-       H7X     HAL2    0.09    8
-       H7Y     HAL2    0.09    8
-       C38     CTL2    -0.18   9
-       H8X     HAL2    0.09    9
-       H8Y     HAL2    0.09    9
-       C39     CTL2    -0.18   10
-       H9X     HAL2    0.09    10
-       H9Y     HAL2    0.09    10
-       C310    CTL2    -0.18   11
-       H10X    HAL2    0.09    11
-       H10Y    HAL2    0.09    11
-       C311    CTL2    -0.18   12
-       H11X    HAL2    0.09    12
-       H11Y    HAL2    0.09    12
-       C312    CTL3    -0.27   13
-       H12X    HAL3    0.09    13
-       H12Y    HAL3    0.09    13
-       H12Z    HAL3    0.09    13
+       C13     CTL5    -0.35   1
+       H13A    HL      0.25    2
+       H13B    HL      0.25    3
+       H13C    HL      0.25    4
+       C14     CTL5    -0.35   5
+       H14A    HL      0.25    6
+       H14B    HL      0.25    7
+       H14C    HL      0.25    8
+       C15     CTL5    -0.35   9
+       H15A    HL      0.25    10
+       H15B    HL      0.25    11
+       H15C    HL      0.25    12
+       C12     CTL2    -0.10   13
+       H12A    HL      0.25    14
+       H12B    HL      0.25    15
+       C11     CTL2    -0.08   16
+       H11A    HAL2    0.09    17
+       H11B    HAL2    0.09    18
+       P       PL      1.50    19
+       O13     O2L     -0.78   20
+       O14     O2L     -0.78   21
+       O11     OSL     -0.57   22
+       O12     OSL     -0.57   23
+       C1      CTL2    -0.08   24
+       HA      HAL2    0.09    25
+       HB      HAL2    0.09    26
+       C2      CTL2    -0.18   27
+       HS      HAL2    0.09    28
+       HR      HAL2    0.09    29
+       C3      CTL2    -0.05   30
+       HX      HAL2    0.09    31
+       HY      HAL2    0.09    32
+       O31     OSL     -0.34   33
+       C31     CL      0.63    34
+       O32     OBL     -0.52   35
+       C32     CTL2    -0.08   36
+       H2X     HAL2    0.09    37
+       H2Y     HAL2    0.09    38
+       C33     CTL2    -0.18   39
+       H3X     HAL2    0.09    40
+       H3Y     HAL2    0.09    41
+       C34     CTL2    -0.18   42
+       H4X     HAL2    0.09    43
+       H4Y     HAL2    0.09    44
+       C35     CTL2    -0.18   45
+       H5X     HAL2    0.09    46
+       H5Y     HAL2    0.09    47
+       C36     CTL2    -0.18   48
+       H6X     HAL2    0.09    49
+       H6Y     HAL2    0.09    50
+       C37     CTL2    -0.18   51
+       H7X     HAL2    0.09    52
+       H7Y     HAL2    0.09    53
+       C38     CTL2    -0.18   54
+       H8X     HAL2    0.09    55
+       H8Y     HAL2    0.09    56
+       C39     CTL2    -0.18   57
+       H9X     HAL2    0.09    58
+       H9Y     HAL2    0.09    59
+       C310    CTL2    -0.18   60
+       H10X    HAL2    0.09    61
+       H10Y    HAL2    0.09    62
+       C311    CTL2    -0.18   63
+       H11X    HAL2    0.09    64
+       H11Y    HAL2    0.09    65
+       C312    CTL3    -0.27   66
+       H12X    HAL3    0.09    67
+       H12Y    HAL3    0.09    68
+       H12Z    HAL3    0.09    69
  [ bonds ]
        N       C13
        N       C14
 [ GPE ]
  [ atoms ]
        N       NH3L    -0.30   0
-       HN1     HCL     0.33    0
-       HN2     HCL     0.33    0
-       HN3     HCL     0.33    0
-       C12     CTL2    0.13    0
-       H12A    HAL2    0.09    0
-       H12B    HAL2    0.09    0
-       C11     CTL2    -0.08   1
-       H11A    HAL2    0.09    1
-       H11B    HAL2    0.09    1
-       P       PL      1.50    1
-       O13     O2L     -0.78   1
-       O14     O2L     -0.78   1
-       O11     OSL     -0.57   1
-       O12     OSL     -0.57   1
-       C1      CTL2    -0.08   1
-       HA      HAL2    0.09    1
-       HB      HAL2    0.09    1
-       C2      CTL1    0.14    2
-       HS      HAL1    0.09    2
-       OH2     OHL     -0.66   2
-       HO2     HOL     0.43    2
-       C3      CTL2    0.05    3
-       HX      HAL2    0.09    3
-       HY      HAL2    0.09    3
-       OH3     OHL     -0.66   3
-       HO3     HOL     0.43    3
+       HN1     HCL     0.33    1
+       HN2     HCL     0.33    2
+       HN3     HCL     0.33    3
+       C12     CTL2    0.13    4
+       H12A    HAL2    0.09    5
+       H12B    HAL2    0.09    6
+       C11     CTL2    -0.08   7
+       H11A    HAL2    0.09    8
+       H11B    HAL2    0.09    9
+       P       PL      1.50    10
+       O13     O2L     -0.78   11
+       O14     O2L     -0.78   12
+       O11     OSL     -0.57   13
+       O12     OSL     -0.57   14
+       C1      CTL2    -0.08   15
+       HA      HAL2    0.09    16
+       HB      HAL2    0.09    17
+       C2      CTL1    0.14    18
+       HS      HAL1    0.09    19
+       OH2     OHL     -0.66   20
+       HO2     HOL     0.43    21
+       C3      CTL2    0.05    22
+       HX      HAL2    0.09    23
+       HY      HAL2    0.09    24
+       OH3     OHL     -0.66   25
+       HO3     HOL     0.43    26
  [ bonds ]
        N       HN1
        N       HN2
 [ DLPE ]
  [ atoms ]
        N       NH3L    -0.30   0
-       HN1     HCL     0.33    0
-       HN2     HCL     0.33    0
-       HN3     HCL     0.33    0
-       C12     CTL2    0.13    0
-       H12A    HAL2    0.09    0
-       H12B    HAL2    0.09    0
-       C11     CTL2    -0.08   1
-       H11A    HAL2    0.09    1
-       H11B    HAL2    0.09    1
-       P       PL      1.50    1
-       O13     O2L     -0.78   1
-       O14     O2L     -0.78   1
-       O11     OSL     -0.57   1
-       O12     OSL     -0.57   1
-       C1      CTL2    -0.08   1
-       HA      HAL2    0.09    1
-       HB      HAL2    0.09    1
-       C2      CTL1    0.04    2
-       HS      HAL1    0.09    2
-       O21     OSL     -0.34   2
-       C21     CL      0.63    2
-       O22     OBL     -0.52   2
-       C22     CTL2    -0.08   2
-       H2R     HAL2    0.09    2
-       H2S     HAL2    0.09    2
-       C3      CTL2    -0.05   3
-       HX      HAL2    0.09    3
-       HY      HAL2    0.09    3
-       O31     OSL     -0.34   3
-       C31     CL      0.63    3
-       O32     OBL     -0.52   3
-       C32     CTL2    -0.08   3
-       H2X     HAL2    0.09    3
-       H2Y     HAL2    0.09    3
-       C23     CTL2    -0.18   4
-       H3R     HAL2    0.09    4
-       H3S     HAL2    0.09    4
-       C24     CTL2    -0.18   5
-       H4R     HAL2    0.09    5
-       H4S     HAL2    0.09    5
-       C25     CTL2    -0.18   6
-       H5R     HAL2    0.09    6
-       H5S     HAL2    0.09    6
-       C26     CTL2    -0.18   7
-       H6R     HAL2    0.09    7
-       H6S     HAL2    0.09    7
-       C27     CTL2    -0.18   8
-       H7R     HAL2    0.09    8
-       H7S     HAL2    0.09    8
-       C28     CTL2    -0.18   9
-       H8R     HAL2    0.09    9
-       H8S     HAL2    0.09    9
-       C29     CTL2    -0.18   10
-       H9R     HAL2    0.09    10
-       H9S     HAL2    0.09    10
-       C210    CTL2    -0.18   11
-       H10R    HAL2    0.09    11
-       H10S    HAL2    0.09    11
-       C211    CTL2    -0.18   12
-       H11R    HAL2    0.09    12
-       H11S    HAL2    0.09    12
-       C212    CTL3    -0.27   13
-       H12R    HAL3    0.09    13
-       H12S    HAL3    0.09    13
-       H12T    HAL3    0.09    13
-       C33     CTL2    -0.18   14
-       H3X     HAL2    0.09    14
-       H3Y     HAL2    0.09    14
-       C34     CTL2    -0.18   15
-       H4X     HAL2    0.09    15
-       H4Y     HAL2    0.09    15
-       C35     CTL2    -0.18   16
-       H5X     HAL2    0.09    16
-       H5Y     HAL2    0.09    16
-       C36     CTL2    -0.18   17
-       H6X     HAL2    0.09    17
-       H6Y     HAL2    0.09    17
-       C37     CTL2    -0.18   18
-       H7X     HAL2    0.09    18
-       H7Y     HAL2    0.09    18
-       C38     CTL2    -0.18   19
-       H8X     HAL2    0.09    19
-       H8Y     HAL2    0.09    19
-       C39     CTL2    -0.18   20
-       H9X     HAL2    0.09    20
-       H9Y     HAL2    0.09    20
-       C310    CTL2    -0.18   21
-       H10X    HAL2    0.09    21
-       H10Y    HAL2    0.09    21
-       C311    CTL2    -0.18   22
-       H11X    HAL2    0.09    22
-       H11Y    HAL2    0.09    22
-       C312    CTL3    -0.27   23
-       H12X    HAL3    0.09    23
-       H12Y    HAL3    0.09    23
-       H12Z    HAL3    0.09    23
+       HN1     HCL     0.33    1
+       HN2     HCL     0.33    2
+       HN3     HCL     0.33    3
+       C12     CTL2    0.13    4
+       H12A    HAL2    0.09    5
+       H12B    HAL2    0.09    6
+       C11     CTL2    -0.08   7
+       H11A    HAL2    0.09    8
+       H11B    HAL2    0.09    9
+       P       PL      1.50    10
+       O13     O2L     -0.78   11
+       O14     O2L     -0.78   12
+       O11     OSL     -0.57   13
+       O12     OSL     -0.57   14
+       C1      CTL2    -0.08   15
+       HA      HAL2    0.09    16
+       HB      HAL2    0.09    17
+       C2      CTL1    0.04    18
+       HS      HAL1    0.09    19
+       O21     OSL     -0.34   20
+       C21     CL      0.63    21
+       O22     OBL     -0.52   22
+       C22     CTL2    -0.08   23
+       H2R     HAL2    0.09    24
+       H2S     HAL2    0.09    25
+       C3      CTL2    -0.05   26
+       HX      HAL2    0.09    27
+       HY      HAL2    0.09    28
+       O31     OSL     -0.34   29
+       C31     CL      0.63    30
+       O32     OBL     -0.52   31
+       C32     CTL2    -0.08   32
+       H2X     HAL2    0.09    33
+       H2Y     HAL2    0.09    34
+       C23     CTL2    -0.18   35
+       H3R     HAL2    0.09    36
+       H3S     HAL2    0.09    37
+       C24     CTL2    -0.18   38
+       H4R     HAL2    0.09    39
+       H4S     HAL2    0.09    40
+       C25     CTL2    -0.18   41
+       H5R     HAL2    0.09    42
+       H5S     HAL2    0.09    43
+       C26     CTL2    -0.18   44
+       H6R     HAL2    0.09    45
+       H6S     HAL2    0.09    46
+       C27     CTL2    -0.18   47
+       H7R     HAL2    0.09    48
+       H7S     HAL2    0.09    49
+       C28     CTL2    -0.18   50
+       H8R     HAL2    0.09    51
+       H8S     HAL2    0.09    52
+       C29     CTL2    -0.18   53
+       H9R     HAL2    0.09    54
+       H9S     HAL2    0.09    55
+       C210    CTL2    -0.18   56
+       H10R    HAL2    0.09    57
+       H10S    HAL2    0.09    58
+       C211    CTL2    -0.18   59
+       H11R    HAL2    0.09    60
+       H11S    HAL2    0.09    61
+       C212    CTL3    -0.27   62
+       H12R    HAL3    0.09    63
+       H12S    HAL3    0.09    64
+       H12T    HAL3    0.09    65
+       C33     CTL2    -0.18   66
+       H3X     HAL2    0.09    67
+       H3Y     HAL2    0.09    68
+       C34     CTL2    -0.18   69
+       H4X     HAL2    0.09    70
+       H4Y     HAL2    0.09    71
+       C35     CTL2    -0.18   72
+       H5X     HAL2    0.09    73
+       H5Y     HAL2    0.09    74
+       C36     CTL2    -0.18   75
+       H6X     HAL2    0.09    76
+       H6Y     HAL2    0.09    77
+       C37     CTL2    -0.18   78
+       H7X     HAL2    0.09    79
+       H7Y     HAL2    0.09    80
+       C38     CTL2    -0.18   81
+       H8X     HAL2    0.09    82
+       H8Y     HAL2    0.09    83
+       C39     CTL2    -0.18   84
+       H9X     HAL2    0.09    85
+       H9Y     HAL2    0.09    86
+       C310    CTL2    -0.18   87
+       H10X    HAL2    0.09    88
+       H10Y    HAL2    0.09    89
+       C311    CTL2    -0.18   90
+       H11X    HAL2    0.09    91
+       H11Y    HAL2    0.09    92
+       C312    CTL3    -0.27   93
+       H12X    HAL3    0.09    94
+       H12Y    HAL3    0.09    95
+       H12Z    HAL3    0.09    96
  [ bonds ]
        N       HN1
        N       HN2
 [ DMPC ]
  [ atoms ]
        N       NTL     -0.60   0
-       C13     CTL5    -0.35   0
-       H13A    HL      0.25    0
-       H13B    HL      0.25    0
-       H13C    HL      0.25    0
-       C14     CTL5    -0.35   0
-       H14A    HL      0.25    0
-       H14B    HL      0.25    0
-       H14C    HL      0.25    0
-       C15     CTL5    -0.35   0
-       H15A    HL      0.25    0
-       H15B    HL      0.25    0
-       H15C    HL      0.25    0
-       C12     CTL2    -0.10   0
-       H12A    HL      0.25    0
-       H12B    HL      0.25    0
-       C11     CTL2    -0.08   1
-       H11A    HAL2    0.09    1
-       H11B    HAL2    0.09    1
-       P       PL      1.50    1
-       O13     O2L     -0.78   1
-       O14     O2L     -0.78   1
-       O11     OSL     -0.57   1
-       O12     OSL     -0.57   1
-       C1      CTL2    -0.08   1
-       HA      HAL2    0.09    1
-       HB      HAL2    0.09    1
-       C2      CTL1    0.04    2
-       HS      HAL1    0.09    2
-       O21     OSL     -0.34   2
-       C21     CL      0.63    2
-       O22     OBL     -0.52   2
-       C22     CTL2    -0.08   2
-       H2R     HAL2    0.09    2
-       H2S     HAL2    0.09    2
-       C3      CTL2    -0.05   3
-       HX      HAL2    0.09    3
-       HY      HAL2    0.09    3
-       O31     OSL     -0.34   3
-       C31     CL      0.63    3
-       O32     OBL     -0.52   3
-       C32     CTL2    -0.08   3
-       H2X     HAL2    0.09    3
-       H2Y     HAL2    0.09    3
-       C23     CTL2    -0.18   4
-       H3R     HAL2    0.09    4
-       H3S     HAL2    0.09    4
-       C24     CTL2    -0.18   5
-       H4R     HAL2    0.09    5
-       H4S     HAL2    0.09    5
-       C25     CTL2    -0.18   6
-       H5R     HAL2    0.09    6
-       H5S     HAL2    0.09    6
-       C26     CTL2    -0.18   7
-       H6R     HAL2    0.09    7
-       H6S     HAL2    0.09    7
-       C27     CTL2    -0.18   8
-       H7R     HAL2    0.09    8
-       H7S     HAL2    0.09    8
-       C28     CTL2    -0.18   9
-       H8R     HAL2    0.09    9
-       H8S     HAL2    0.09    9
-       C29     CTL2    -0.18   10
-       H9R     HAL2    0.09    10
-       H9S     HAL2    0.09    10
-       C210    CTL2    -0.18   11
-       H10R    HAL2    0.09    11
-       H10S    HAL2    0.09    11
-       C211    CTL2    -0.18   12
-       H11R    HAL2    0.09    12
-       H11S    HAL2    0.09    12
-       C212    CTL2    -0.18   13
-       H12R    HAL2    0.09    13
-       H12S    HAL2    0.09    13
-       C213    CTL2    -0.18   14
-       H13R    HAL2    0.09    14
-       H13S    HAL2    0.09    14
-       C214    CTL3    -0.27   15
-       H14R    HAL3    0.09    15
-       H14S    HAL3    0.09    15
-       H14T    HAL3    0.09    15
-       C33     CTL2    -0.18   16
-       H3X     HAL2    0.09    16
-       H3Y     HAL2    0.09    16
-       C34     CTL2    -0.18   17
-       H4X     HAL2    0.09    17
-       H4Y     HAL2    0.09    17
-       C35     CTL2    -0.18   18
-       H5X     HAL2    0.09    18
-       H5Y     HAL2    0.09    18
-       C36     CTL2    -0.18   19
-       H6X     HAL2    0.09    19
-       H6Y     HAL2    0.09    19
-       C37     CTL2    -0.18   20
-       H7X     HAL2    0.09    20
-       H7Y     HAL2    0.09    20
-       C38     CTL2    -0.18   21
-       H8X     HAL2    0.09    21
-       H8Y     HAL2    0.09    21
-       C39     CTL2    -0.18   22
-       H9X     HAL2    0.09    22
-       H9Y     HAL2    0.09    22
-       C310    CTL2    -0.18   23
-       H10X    HAL2    0.09    23
-       H10Y    HAL2    0.09    23
-       C311    CTL2    -0.18   24
-       H11X    HAL2    0.09    24
-       H11Y    HAL2    0.09    24
-       C312    CTL2    -0.18   25
-       H12X    HAL2    0.09    25
-       H12Y    HAL2    0.09    25
-       C313    CTL2    -0.18   26
-       H13X    HAL2    0.09    26
-       H13Y    HAL2    0.09    26
-       C314    CTL3    -0.27   27
-       H14X    HAL3    0.09    27
-       H14Y    HAL3    0.09    27
-       H14Z    HAL3    0.09    27
+       C13     CTL5    -0.35   1
+       H13A    HL      0.25    2
+       H13B    HL      0.25    3
+       H13C    HL      0.25    4
+       C14     CTL5    -0.35   5
+       H14A    HL      0.25    6
+       H14B    HL      0.25    7
+       H14C    HL      0.25    8
+       C15     CTL5    -0.35   9
+       H15A    HL      0.25    10
+       H15B    HL      0.25    11
+       H15C    HL      0.25    12
+       C12     CTL2    -0.10   13
+       H12A    HL      0.25    14
+       H12B    HL      0.25    15
+       C11     CTL2    -0.08   16
+       H11A    HAL2    0.09    17
+       H11B    HAL2    0.09    18
+       P       PL      1.50    19
+       O13     O2L     -0.78   20
+       O14     O2L     -0.78   21
+       O11     OSL     -0.57   22
+       O12     OSL     -0.57   23
+       C1      CTL2    -0.08   24
+       HA      HAL2    0.09    25
+       HB      HAL2    0.09    26
+       C2      CTL1    0.04    27
+       HS      HAL1    0.09    28
+       O21     OSL     -0.34   29
+       C21     CL      0.63    30
+       O22     OBL     -0.52   31
+       C22     CTL2    -0.08   32
+       H2R     HAL2    0.09    33
+       H2S     HAL2    0.09    34
+       C3      CTL2    -0.05   35
+       HX      HAL2    0.09    36
+       HY      HAL2    0.09    37
+       O31     OSL     -0.34   38
+       C31     CL      0.63    39
+       O32     OBL     -0.52   40
+       C32     CTL2    -0.08   41
+       H2X     HAL2    0.09    42
+       H2Y     HAL2    0.09    43
+       C23     CTL2    -0.18   44
+       H3R     HAL2    0.09    45
+       H3S     HAL2    0.09    46
+       C24     CTL2    -0.18   47
+       H4R     HAL2    0.09    48
+       H4S     HAL2    0.09    49
+       C25     CTL2    -0.18   50
+       H5R     HAL2    0.09    51
+       H5S     HAL2    0.09    52
+       C26     CTL2    -0.18   53
+       H6R     HAL2    0.09    54
+       H6S     HAL2    0.09    55
+       C27     CTL2    -0.18   56
+       H7R     HAL2    0.09    57
+       H7S     HAL2    0.09    58
+       C28     CTL2    -0.18   59
+       H8R     HAL2    0.09    60
+       H8S     HAL2    0.09    61
+       C29     CTL2    -0.18   62
+       H9R     HAL2    0.09    63
+       H9S     HAL2    0.09    64
+       C210    CTL2    -0.18   65
+       H10R    HAL2    0.09    66
+       H10S    HAL2    0.09    67
+       C211    CTL2    -0.18   68
+       H11R    HAL2    0.09    69
+       H11S    HAL2    0.09    70
+       C212    CTL2    -0.18   71
+       H12R    HAL2    0.09    72
+       H12S    HAL2    0.09    73
+       C213    CTL2    -0.18   74
+       H13R    HAL2    0.09    75
+       H13S    HAL2    0.09    76
+       C214    CTL3    -0.27   77
+       H14R    HAL3    0.09    78
+       H14S    HAL3    0.09    79
+       H14T    HAL3    0.09    80
+       C33     CTL2    -0.18   81
+       H3X     HAL2    0.09    82
+       H3Y     HAL2    0.09    83
+       C34     CTL2    -0.18   84
+       H4X     HAL2    0.09    85
+       H4Y     HAL2    0.09    86
+       C35     CTL2    -0.18   87
+       H5X     HAL2    0.09    88
+       H5Y     HAL2    0.09    89
+       C36     CTL2    -0.18   90
+       H6X     HAL2    0.09    91
+       H6Y     HAL2    0.09    92
+       C37     CTL2    -0.18   93
+       H7X     HAL2    0.09    94
+       H7Y     HAL2    0.09    95
+       C38     CTL2    -0.18   96
+       H8X     HAL2    0.09    97
+       H8Y     HAL2    0.09    98
+       C39     CTL2    -0.18   99
+       H9X     HAL2    0.09    100
+       H9Y     HAL2    0.09    101
+       C310    CTL2    -0.18   102
+       H10X    HAL2    0.09    103
+       H10Y    HAL2    0.09    104
+       C311    CTL2    -0.18   105
+       H11X    HAL2    0.09    106
+       H11Y    HAL2    0.09    107
+       C312    CTL2    -0.18   108
+       H12X    HAL2    0.09    109
+       H12Y    HAL2    0.09    110
+       C313    CTL2    -0.18   111
+       H13X    HAL2    0.09    112
+       H13Y    HAL2    0.09    113
+       C314    CTL3    -0.27   114
+       H14X    HAL3    0.09    115
+       H14Y    HAL3    0.09    116
+       H14Z    HAL3    0.09    117
  [ bonds ]
        N       C13
        N       C14
 [ SDS ]
  [ atoms ]
        S       SL      1.33    0
-       OS1     OSL     -0.28   0
-       OS2     O2L     -0.65   0
-       OS3     O2L     -0.65   0
-       OS4     O2L     -0.65   0
-       C1      CTL2    -0.28   0
-       H11     HAL2    0.09    0
-       H12     HAL2    0.09    0
-       C2      CTL2    -0.18   1
-       H21     HAL2    0.09    1
-       H22     HAL2    0.09    1
-       C3      CTL2    -0.18   2
-       H31     HAL2    0.09    2
-       H32     HAL2    0.09    2
-       C4      CTL2    -0.18   3
-       H41     HAL2    0.09    3
-       H42     HAL2    0.09    3
-       C5      CTL2    -0.18   4
-       H51     HAL2    0.09    4
-       H52     HAL2    0.09    4
-       C6      CTL2    -0.18   5
-       H61     HAL2    0.09    5
-       H62     HAL2    0.09    5
-       C7      CTL2    -0.18   6
-       H71     HAL2    0.09    6
-       H72     HAL2    0.09    6
-       C8      CTL2    -0.18   7
-       H81     HAL2    0.09    7
-       H82     HAL2    0.09    7
-       C9      CTL2    -0.18   8
-       H91     HAL2    0.09    8
-       H92     HAL2    0.09    8
-       C10     CTL2    -0.18   9
-       H101    HAL2    0.09    9
-       H102    HAL2    0.09    9
-       C11     CTL2    -0.18   10
-       H111    HAL2    0.09    10
-       H112    HAL2    0.09    10
-       C12     CTL3    -0.27   11
-       H121    HAL3    0.09    11
-       H122    HAL3    0.09    11
-       H123    HAL3    0.09    11
+       OS1     OSL     -0.28   1
+       OS2     O2L     -0.65   2
+       OS3     O2L     -0.65   3
+       OS4     O2L     -0.65   4
+       C1      CTL2    -0.28   5
+       H11     HAL2    0.09    6
+       H12     HAL2    0.09    7
+       C2      CTL2    -0.18   8
+       H21     HAL2    0.09    9
+       H22     HAL2    0.09    10
+       C3      CTL2    -0.18   11
+       H31     HAL2    0.09    12
+       H32     HAL2    0.09    13
+       C4      CTL2    -0.18   14
+       H41     HAL2    0.09    15
+       H42     HAL2    0.09    16
+       C5      CTL2    -0.18   17
+       H51     HAL2    0.09    18
+       H52     HAL2    0.09    19
+       C6      CTL2    -0.18   20
+       H61     HAL2    0.09    21
+       H62     HAL2    0.09    22
+       C7      CTL2    -0.18   23
+       H71     HAL2    0.09    24
+       H72     HAL2    0.09    25
+       C8      CTL2    -0.18   26
+       H81     HAL2    0.09    27
+       H82     HAL2    0.09    28
+       C9      CTL2    -0.18   29
+       H91     HAL2    0.09    30
+       H92     HAL2    0.09    31
+       C10     CTL2    -0.18   32
+       H101    HAL2    0.09    33
+       H102    HAL2    0.09    34
+       C11     CTL2    -0.18   35
+       H111    HAL2    0.09    36
+       H112    HAL2    0.09    37
+       C12     CTL3    -0.27   38
+       H121    HAL3    0.09    39
+       H122    HAL3    0.09    40
+       H123    HAL3    0.09    41
  [ bonds ]
        S       OS1
        S       OS2
 [ POPC ]
  [ atoms ]
        N       NTL     -0.60   0
-       C11     CTL2    -0.10   0
-       C12     CTL5    -0.35   0
-       C13     CTL5    -0.35   0
-       C14     CTL5    -0.35   0
-       H11     HL      0.25    0
-       H12     HL      0.25    0
-       H21     HL      0.25    0
-       H22     HL      0.25    0
-       H23     HL      0.25    0
-       H31     HL      0.25    0
-       H32     HL      0.25    0
-       H33     HL      0.25    0
-       H41     HL      0.25    0
-       H42     HL      0.25    0
-       H43     HL      0.25    0
-       C15     CTL2    -0.08   1
-       H51     HAL2    0.09    1
-       H52     HAL2    0.09    1
-       P1      PL      1.50    2
-       O3      O2L     -0.78   2
-       O4      O2L     -0.78   2
-       O1      OSL     -0.57   2
-       O2      OSL     -0.57   2
-       C1      CTL2    -0.08   3
-       HA      HAL2    0.09    3
-       HB      HAL2    0.09    3
-       C2      CTL1    0.04    4
-       HS      HAL1    0.09    4
-       O21     OSL     -0.34   4
-       C21     CL      0.63    4
-       O22     OBL     -0.52   4
-       C22     CTL2    -0.08   4
-       H2R     HAL2    0.09    4
-       H2S     HAL2    0.09    4
-       C3      CTL2    -0.05   5
-       HX      HAL2    0.09    5
-       HY      HAL2    0.09    5
-       O31     OSL     -0.34   5
-       C31     CL      0.63    5
-       O32     OBL     -0.52   5
-       C32     CTL2    -0.08   5
-       H2X     HAL2    0.09    5
-       H2Y     HAL2    0.09    5
-       C23     CTL2    -0.18   6
-       H3R     HAL2    0.09    6
-       H3S     HAL2    0.09    6
-       C24     CTL2    -0.18   7
-       H4R     HAL2    0.09    7
-       H4S     HAL2    0.09    7
-       C25     CTL2    -0.18   8
-       H5R     HAL2    0.09    8
-       H5S     HAL2    0.09    8
-       C26     CTL2    -0.18   9
-       H6R     HAL2    0.09    9
-       H6S     HAL2    0.09    9
-       C27     CTL2    -0.18   10
-       H7R     HAL2    0.09    10
-       H7S     HAL2    0.09    10
-       C28     CTL2    -0.18   11
-       H8R     HAL2    0.09    11
-       H8S     HAL2    0.09    11
-       C29     CEL1    -0.15   12
-       H91     HEL1    0.15    12
-       C210    CEL1    -0.15   13
-       H101    HEL1    0.15    13
-       C211    CTL2    -0.18   14
-       H11R    HAL2    0.09    14
-       H11S    HAL2    0.09    14
-       C212    CTL2    -0.18   15
-       H12R    HAL2    0.09    15
-       H12S    HAL2    0.09    15
-       C213    CTL2    -0.18   16
-       H13R    HAL2    0.09    16
-       H13S    HAL2    0.09    16
-       C214    CTL2    -0.18   17
-       H14R    HAL2    0.09    17
-       H14S    HAL2    0.09    17
-       C215    CTL2    -0.18   18
-       H15R    HAL2    0.09    18
-       H15S    HAL2    0.09    18
-       C216    CTL2    -0.18   19
-       H16R    HAL2    0.09    19
-       H16S    HAL2    0.09    19
-       C217    CTL2    -0.18   20
-       H17R    HAL2    0.09    20
-       H17S    HAL2    0.09    20
-       C218    CTL3    -0.27   21
-       H18R    HAL3    0.09    21
-       H18S    HAL3    0.09    21
-       H18T    HAL3    0.09    21
-       C33     CTL2    -0.18   22
-       H3X     HAL2    0.09    22
-       H3Y     HAL2    0.09    22
-       C34     CTL2    -0.18   23
-       H4X     HAL2    0.09    23
-       H4Y     HAL2    0.09    23
-       C35     CTL2    -0.18   24
-       H5X     HAL2    0.09    24
-       H5Y     HAL2    0.09    24
-       C36     CTL2    -0.18   25
-       H6X     HAL2    0.09    25
-       H6Y     HAL2    0.09    25
-       C37     CTL2    -0.18   26
-       H7X     HAL2    0.09    26
-       H7Y     HAL2    0.09    26
-       C38     CTL2    -0.18   27
-       H8X     HAL2    0.09    27
-       H8Y     HAL2    0.09    27
-       C39     CTL2    -0.18   28
-       H9X     HAL2    0.09    28
-       H9Y     HAL2    0.09    28
-       C310    CTL2    -0.18   29
-       H10X    HAL2    0.09    29
-       H10Y    HAL2    0.09    29
-       C311    CTL2    -0.18   30
-       H11X    HAL2    0.09    30
-       H11Y    HAL2    0.09    30
-       C312    CTL2    -0.18   31
-       H12X    HAL2    0.09    31
-       H12Y    HAL2    0.09    31
-       C313    CTL2    -0.18   32
-       H13X    HAL2    0.09    32
-       H13Y    HAL2    0.09    32
-       C314    CTL2    -0.18   33
-       H14X    HAL2    0.09    33
-       H14Y    HAL2    0.09    33
-       C315    CTL2    -0.18   34
-       H15X    HAL2    0.09    34
-       H15Y    HAL2    0.09    34
-       C316    CTL3    -0.27   35
-       H16X    HAL3    0.09    35
-       H16Y    HAL3    0.09    35
-       H16Z    HAL3    0.09    35
+       C11     CTL2    -0.10   1
+       C12     CTL5    -0.35   2
+       C13     CTL5    -0.35   3
+       C14     CTL5    -0.35   4
+       H11     HL      0.25    5
+       H12     HL      0.25    6
+       H21     HL      0.25    7
+       H22     HL      0.25    8
+       H23     HL      0.25    9
+       H31     HL      0.25    10
+       H32     HL      0.25    11
+       H33     HL      0.25    12
+       H41     HL      0.25    13
+       H42     HL      0.25    14
+       H43     HL      0.25    15
+       C15     CTL2    -0.08   16
+       H51     HAL2    0.09    17
+       H52     HAL2    0.09    18
+       P1      PL      1.50    19
+       O3      O2L     -0.78   20
+       O4      O2L     -0.78   21
+       O1      OSL     -0.57   22
+       O2      OSL     -0.57   23
+       C1      CTL2    -0.08   24
+       HA      HAL2    0.09    25
+       HB      HAL2    0.09    26
+       C2      CTL1    0.04    27
+       HS      HAL1    0.09    28
+       O21     OSL     -0.34   29
+       C21     CL      0.63    30
+       O22     OBL     -0.52   31
+       C22     CTL2    -0.08   32
+       H2R     HAL2    0.09    33
+       H2S     HAL2    0.09    34
+       C3      CTL2    -0.05   35
+       HX      HAL2    0.09    36
+       HY      HAL2    0.09    37
+       O31     OSL     -0.34   38
+       C31     CL      0.63    39
+       O32     OBL     -0.52   40
+       C32     CTL2    -0.08   41
+       H2X     HAL2    0.09    42
+       H2Y     HAL2    0.09    43
+       C23     CTL2    -0.18   44
+       H3R     HAL2    0.09    45
+       H3S     HAL2    0.09    46
+       C24     CTL2    -0.18   47
+       H4R     HAL2    0.09    48
+       H4S     HAL2    0.09    49
+       C25     CTL2    -0.18   50
+       H5R     HAL2    0.09    51
+       H5S     HAL2    0.09    52
+       C26     CTL2    -0.18   53
+       H6R     HAL2    0.09    54
+       H6S     HAL2    0.09    55
+       C27     CTL2    -0.18   56
+       H7R     HAL2    0.09    57
+       H7S     HAL2    0.09    58
+       C28     CTL2    -0.18   59
+       H8R     HAL2    0.09    60
+       H8S     HAL2    0.09    61
+       C29     CEL1    -0.15   62
+       H91     HEL1    0.15    63
+       C210    CEL1    -0.15   64
+       H101    HEL1    0.15    65
+       C211    CTL2    -0.18   66
+       H11R    HAL2    0.09    67
+       H11S    HAL2    0.09    68
+       C212    CTL2    -0.18   69
+       H12R    HAL2    0.09    70
+       H12S    HAL2    0.09    71
+       C213    CTL2    -0.18   72
+       H13R    HAL2    0.09    73
+       H13S    HAL2    0.09    74
+       C214    CTL2    -0.18   75
+       H14R    HAL2    0.09    76
+       H14S    HAL2    0.09    77
+       C215    CTL2    -0.18   78
+       H15R    HAL2    0.09    79
+       H15S    HAL2    0.09    80
+       C216    CTL2    -0.18   81
+       H16R    HAL2    0.09    82
+       H16S    HAL2    0.09    83
+       C217    CTL2    -0.18   84
+       H17R    HAL2    0.09    85
+       H17S    HAL2    0.09    86
+       C218    CTL3    -0.27   87
+       H18R    HAL3    0.09    88
+       H18S    HAL3    0.09    89
+       H18T    HAL3    0.09    90
+       C33     CTL2    -0.18   91
+       H3X     HAL2    0.09    92
+       H3Y     HAL2    0.09    93
+       C34     CTL2    -0.18   94
+       H4X     HAL2    0.09    95
+       H4Y     HAL2    0.09    96
+       C35     CTL2    -0.18   97
+       H5X     HAL2    0.09    98
+       H5Y     HAL2    0.09    99
+       C36     CTL2    -0.18   100
+       H6X     HAL2    0.09    101
+       H6Y     HAL2    0.09    102
+       C37     CTL2    -0.18   103
+       H7X     HAL2    0.09    104
+       H7Y     HAL2    0.09    105
+       C38     CTL2    -0.18   106
+       H8X     HAL2    0.09    107
+       H8Y     HAL2    0.09    108
+       C39     CTL2    -0.18   109
+       H9X     HAL2    0.09    110
+       H9Y     HAL2    0.09    111
+       C310    CTL2    -0.18   112
+       H10X    HAL2    0.09    113
+       H10Y    HAL2    0.09    114
+       C311    CTL2    -0.18   115
+       H11X    HAL2    0.09    116
+       H11Y    HAL2    0.09    117
+       C312    CTL2    -0.18   118
+       H12X    HAL2    0.09    119
+       H12Y    HAL2    0.09    120
+       C313    CTL2    -0.18   121
+       H13X    HAL2    0.09    122
+       H13Y    HAL2    0.09    123
+       C314    CTL2    -0.18   124
+       H14X    HAL2    0.09    125
+       H14Y    HAL2    0.09    126
+       C315    CTL2    -0.18   127
+       H15X    HAL2    0.09    128
+       H15Y    HAL2    0.09    129
+       C316    CTL3    -0.27   130
+       H16X    HAL3    0.09    131
+       H16Y    HAL3    0.09    132
+       H16Z    HAL3    0.09    133
  [ bonds ]
        N       C11
        N       C12
 [ POPE ]
  [ atoms ]
        N       NH3L    -0.30   0
-       HN1     HCL     0.33    0
-       HN2     HCL     0.33    0
-       HN3     HCL     0.33    0
-       C12     CTL2    0.13    0
-       H12A    HAL2    0.09    0
-       H12B    HAL2    0.09    0
-       C11     CTL2    -0.08   1
-       H11A    HAL2    0.09    1
-       H11B    HAL2    0.09    1
-       P       PL      1.50    1
-       O13     O2L     -0.78   1
-       O14     O2L     -0.78   1
-       O11     OSL     -0.57   1
-       O12     OSL     -0.57   1
-       C1      CTL2    -0.08   1
-       HA      HAL2    0.09    1
-       HB      HAL2    0.09    1
-       C2      CTL1    0.04    2
-       HS      HAL1    0.09    2
-       O21     OSL     -0.34   2
-       C21     CL      0.63    2
-       O22     OBL     -0.52   2
-       C22     CTL2    -0.08   2
-       H2R     HAL2    0.09    2
-       H2S     HAL2    0.09    2
-       C3      CTL2    -0.05   3
-       HX      HAL2    0.09    3
-       HY      HAL2    0.09    3
-       O31     OSL     -0.34   3
-       C31     CL      0.63    3
-       O32     OBL     -0.52   3
-       C32     CTL2    -0.08   3
-       H2X     HAL2    0.09    3
-       H2Y     HAL2    0.09    3
-       C23     CTL2    -0.18   4
-       H3R     HAL2    0.09    4
-       H3S     HAL2    0.09    4
-       C24     CTL2    -0.18   5
-       H4R     HAL2    0.09    5
-       H4S     HAL2    0.09    5
-       C25     CTL2    -0.18   6
-       H5R     HAL2    0.09    6
-       H5S     HAL2    0.09    6
-       C26     CTL2    -0.18   7
-       H6R     HAL2    0.09    7
-       H6S     HAL2    0.09    7
-       C27     CTL2    -0.18   8
-       H7R     HAL2    0.09    8
-       H7S     HAL2    0.09    8
-       C28     CTL2    -0.18   9
-       H8R     HAL2    0.09    9
-       H8S     HAL2    0.09    9
-       C29     CEL1    -0.15   10
-       H91     HEL1    0.15    10
-       C210    CEL1    -0.15   11
-       H101    HEL1    0.15    11
-       C211    CTL2    -0.18   12
-       H11R    HAL2    0.09    12
-       H11S    HAL2    0.09    12
-       C212    CTL2    -0.18   13
-       H12R    HAL2    0.09    13
-       H12S    HAL2    0.09    13
-       C213    CTL2    -0.18   14
-       H13R    HAL2    0.09    14
-       H13S    HAL2    0.09    14
-       C214    CTL2    -0.18   15
-       H14R    HAL2    0.09    15
-       H14S    HAL2    0.09    15
-       C215    CTL2    -0.18   16
-       H15R    HAL2    0.09    16
-       H15S    HAL2    0.09    16
-       C216    CTL2    -0.18   17
-       H16R    HAL2    0.09    17
-       H16S    HAL2    0.09    17
-       C217    CTL2    -0.18   18
-       H17R    HAL2    0.09    18
-       H17S    HAL2    0.09    18
-       C218    CTL3    -0.27   19
-       H18R    HAL3    0.09    19
-       H18S    HAL3    0.09    19
-       H18T    HAL3    0.09    19
-       C33     CTL2    -0.18   20
-       H3X     HAL2    0.09    20
-       H3Y     HAL2    0.09    20
-       C34     CTL2    -0.18   21
-       H4X     HAL2    0.09    21
-       H4Y     HAL2    0.09    21
-       C35     CTL2    -0.18   22
-       H5X     HAL2    0.09    22
-       H5Y     HAL2    0.09    22
-       C36     CTL2    -0.18   23
-       H6X     HAL2    0.09    23
-       H6Y     HAL2    0.09    23
-       C37     CTL2    -0.18   24
-       H7X     HAL2    0.09    24
-       H7Y     HAL2    0.09    24
-       C38     CTL2    -0.18   25
-       H8X     HAL2    0.09    25
-       H8Y     HAL2    0.09    25
-       C39     CTL2    -0.18   26
-       H9X     HAL2    0.09    26
-       H9Y     HAL2    0.09    26
-       C310    CTL2    -0.18   27
-       H10X    HAL2    0.09    27
-       H10Y    HAL2    0.09    27
-       C311    CTL2    -0.18   28
-       H11X    HAL2    0.09    28
-       H11Y    HAL2    0.09    28
-       C312    CTL2    -0.18   29
-       H12X    HAL2    0.09    29
-       H12Y    HAL2    0.09    29
-       C313    CTL2    -0.18   30
-       H13X    HAL2    0.09    30
-       H13Y    HAL2    0.09    30
-       C314    CTL2    -0.18   31
-       H14X    HAL2    0.09    31
-       H14Y    HAL2    0.09    31
-       C315    CTL2    -0.18   32
-       H15X    HAL2    0.09    32
-       H15Y    HAL2    0.09    32
-       C316    CTL3    -0.27   33
-       H16X    HAL3    0.09    33
-       H16Y    HAL3    0.09    33
-       H16Z    HAL3    0.09    33
+       HN1     HCL     0.33    1
+       HN2     HCL     0.33    2
+       HN3     HCL     0.33    3
+       C12     CTL2    0.13    4
+       H12A    HAL2    0.09    5
+       H12B    HAL2    0.09    6
+       C11     CTL2    -0.08   7
+       H11A    HAL2    0.09    8
+       H11B    HAL2    0.09    9
+       P       PL      1.50    10
+       O13     O2L     -0.78   11
+       O14     O2L     -0.78   12
+       O11     OSL     -0.57   13
+       O12     OSL     -0.57   14
+       C1      CTL2    -0.08   15
+       HA      HAL2    0.09    16
+       HB      HAL2    0.09    17
+       C2      CTL1    0.04    18
+       HS      HAL1    0.09    19
+       O21     OSL     -0.34   20
+       C21     CL      0.63    21
+       O22     OBL     -0.52   22
+       C22     CTL2    -0.08   23
+       H2R     HAL2    0.09    24
+       H2S     HAL2    0.09    25
+       C3      CTL2    -0.05   26
+       HX      HAL2    0.09    27
+       HY      HAL2    0.09    28
+       O31     OSL     -0.34   29
+       C31     CL      0.63    30
+       O32     OBL     -0.52   31
+       C32     CTL2    -0.08   32
+       H2X     HAL2    0.09    33
+       H2Y     HAL2    0.09    34
+       C23     CTL2    -0.18   35
+       H3R     HAL2    0.09    36
+       H3S     HAL2    0.09    37
+       C24     CTL2    -0.18   38
+       H4R     HAL2    0.09    39
+       H4S     HAL2    0.09    40
+       C25     CTL2    -0.18   41
+       H5R     HAL2    0.09    42
+       H5S     HAL2    0.09    43
+       C26     CTL2    -0.18   44
+       H6R     HAL2    0.09    45
+       H6S     HAL2    0.09    46
+       C27     CTL2    -0.18   47
+       H7R     HAL2    0.09    48
+       H7S     HAL2    0.09    49
+       C28     CTL2    -0.18   50
+       H8R     HAL2    0.09    51
+       H8S     HAL2    0.09    52
+       C29     CEL1    -0.15   53
+       H91     HEL1    0.15    54
+       C210    CEL1    -0.15   55
+       H101    HEL1    0.15    56
+       C211    CTL2    -0.18   57
+       H11R    HAL2    0.09    58
+       H11S    HAL2    0.09    59
+       C212    CTL2    -0.18   60
+       H12R    HAL2    0.09    61
+       H12S    HAL2    0.09    62
+       C213    CTL2    -0.18   63
+       H13R    HAL2    0.09    64
+       H13S    HAL2    0.09    65
+       C214    CTL2    -0.18   66
+       H14R    HAL2    0.09    67
+       H14S    HAL2    0.09    68
+       C215    CTL2    -0.18   69
+       H15R    HAL2    0.09    70
+       H15S    HAL2    0.09    71
+       C216    CTL2    -0.18   72
+       H16R    HAL2    0.09    73
+       H16S    HAL2    0.09    74
+       C217    CTL2    -0.18   75
+       H17R    HAL2    0.09    76
+       H17S    HAL2    0.09    77
+       C218    CTL3    -0.27   78
+       H18R    HAL3    0.09    79
+       H18S    HAL3    0.09    80
+       H18T    HAL3    0.09    81
+       C33     CTL2    -0.18   82
+       H3X     HAL2    0.09    83
+       H3Y     HAL2    0.09    84
+       C34     CTL2    -0.18   85
+       H4X     HAL2    0.09    86
+       H4Y     HAL2    0.09    87
+       C35     CTL2    -0.18   88
+       H5X     HAL2    0.09    89
+       H5Y     HAL2    0.09    90
+       C36     CTL2    -0.18   91
+       H6X     HAL2    0.09    92
+       H6Y     HAL2    0.09    93
+       C37     CTL2    -0.18   94
+       H7X     HAL2    0.09    95
+       H7Y     HAL2    0.09    96
+       C38     CTL2    -0.18   97
+       H8X     HAL2    0.09    98
+       H8Y     HAL2    0.09    99
+       C39     CTL2    -0.18   100
+       H9X     HAL2    0.09    101
+       H9Y     HAL2    0.09    102
+       C310    CTL2    -0.18   103
+       H10X    HAL2    0.09    104
+       H10Y    HAL2    0.09    105
+       C311    CTL2    -0.18   106
+       H11X    HAL2    0.09    107
+       H11Y    HAL2    0.09    108
+       C312    CTL2    -0.18   109
+       H12X    HAL2    0.09    110
+       H12Y    HAL2    0.09    111
+       C313    CTL2    -0.18   112
+       H13X    HAL2    0.09    113
+       H13Y    HAL2    0.09    114
+       C314    CTL2    -0.18   115
+       H14X    HAL2    0.09    116
+       H14Y    HAL2    0.09    117
+       C315    CTL2    -0.18   118
+       H15X    HAL2    0.09    119
+       H15Y    HAL2    0.09    120
+       C316    CTL3    -0.27   121
+       H16X    HAL3    0.09    122
+       H16Y    HAL3    0.09    123
+       H16Z    HAL3    0.09    124
  [ bonds ]
        N       HN1
        N       HN2
 [ PALM ]
  [ atoms ]
        C1      CL      0.62    0
-       O1      OCL     -0.76   0
-       O2      OCL     -0.76   0
-       C2      CTL2    -0.28   0
-       H2A     HAL2    0.09    0
-       H2B     HAL2    0.09    0
-       C3      CTL2    -0.18   1
-       H3A     HAL2    0.09    1
-       H3B     HAL2    0.09    1
-       C4      CTL2    -0.18   2
-       H4A     HAL2    0.09    2
-       H4B     HAL2    0.09    2
-       C5      CTL2    -0.18   3
-       H5A     HAL2    0.09    3
-       H5B     HAL2    0.09    3
-       C6      CTL2    -0.18   4
-       H6A     HAL2    0.09    4
-       H6B     HAL2    0.09    4
-       C7      CTL2    -0.18   5
-       H7A     HAL2    0.09    5
-       H7B     HAL2    0.09    5
-       C8      CTL2    -0.18   6
-       H8A     HAL2    0.09    6
-       H8B     HAL2    0.09    6
-       C9      CTL2    -0.18   7
-       H9A     HAL2    0.09    7
-       H9B     HAL2    0.09    7
-       C10     CTL2    -0.18   8
-       H10A    HAL2    0.09    8
-       H10B    HAL2    0.09    8
-       C11     CTL2    -0.18   9
-       H11A    HAL2    0.09    9
-       H11B    HAL2    0.09    9
-       C12     CTL2    -0.18   10
-       H12A    HAL2    0.09    10
-       H12B    HAL2    0.09    10
-       C13     CTL2    -0.18   11
-       H13A    HAL2    0.09    11
-       H13B    HAL2    0.09    11
-       C14     CTL2    -0.18   12
-       H14A    HAL2    0.09    12
-       H14B    HAL2    0.09    12
-       C15     CTL2    -0.18   13
-       H15A    HAL2    0.09    13
-       H15B    HAL2    0.09    13
-       C16     CTL3    -0.27   14
-       H16A    HAL3    0.09    14
-       H16B    HAL3    0.09    14
-       H16C    HAL3    0.09    14
+       O1      OCL     -0.76   1
+       O2      OCL     -0.76   2
+       C2      CTL2    -0.28   3
+       H2A     HAL2    0.09    4
+       H2B     HAL2    0.09    5
+       C3      CTL2    -0.18   6
+       H3A     HAL2    0.09    7
+       H3B     HAL2    0.09    8
+       C4      CTL2    -0.18   9
+       H4A     HAL2    0.09    10
+       H4B     HAL2    0.09    11
+       C5      CTL2    -0.18   12
+       H5A     HAL2    0.09    13
+       H5B     HAL2    0.09    14
+       C6      CTL2    -0.18   15
+       H6A     HAL2    0.09    16
+       H6B     HAL2    0.09    17
+       C7      CTL2    -0.18   18
+       H7A     HAL2    0.09    19
+       H7B     HAL2    0.09    20
+       C8      CTL2    -0.18   21
+       H8A     HAL2    0.09    22
+       H8B     HAL2    0.09    23
+       C9      CTL2    -0.18   24
+       H9A     HAL2    0.09    25
+       H9B     HAL2    0.09    26
+       C10     CTL2    -0.18   27
+       H10A    HAL2    0.09    28
+       H10B    HAL2    0.09    29
+       C11     CTL2    -0.18   30
+       H11A    HAL2    0.09    31
+       H11B    HAL2    0.09    32
+       C12     CTL2    -0.18   33
+       H12A    HAL2    0.09    34
+       H12B    HAL2    0.09    35
+       C13     CTL2    -0.18   36
+       H13A    HAL2    0.09    37
+       H13B    HAL2    0.09    38
+       C14     CTL2    -0.18   39
+       H14A    HAL2    0.09    40
+       H14B    HAL2    0.09    41
+       C15     CTL2    -0.18   42
+       H15A    HAL2    0.09    43
+       H15B    HAL2    0.09    44
+       C16     CTL3    -0.27   45
+       H16A    HAL3    0.09    46
+       H16B    HAL3    0.09    47
+       H16C    HAL3    0.09    48
  [ bonds ]
        C1      O1
        C1      O2
 [ OLEO ]
  [ atoms ]
        C1      CL      0.62    0
-       O1      OCL     -0.76   0
-       O2      OCL     -0.76   0
-       C2      CTL2    -0.28   0
-       H2A     HAL2    0.09    0
-       H2B     HAL2    0.09    0
-       C3      CTL2    -0.18   1
-       H3A     HAL2    0.09    1
-       H3B     HAL2    0.09    1
-       C4      CTL2    -0.18   2
-       H4A     HAL2    0.09    2
-       H4B     HAL2    0.09    2
-       C5      CTL2    -0.18   3
-       H5A     HAL2    0.09    3
-       H5B     HAL2    0.09    3
-       C6      CTL2    -0.18   4
-       H6A     HAL2    0.09    4
-       H6B     HAL2    0.09    4
-       C7      CTL2    -0.18   5
-       H7A     HAL2    0.09    5
-       H7B     HAL2    0.09    5
-       C8      CTL2    -0.18   6
-       H8A     HAL2    0.09    6
-       H8B     HAL2    0.09    6
-       C9      CEL1    -0.15   7
-       H9A     HEL1    0.15    7
-       C10     CEL1    -0.15   8
-       H10A    HEL1    0.15    8
-       C11     CTL2    -0.18   9
-       H11A    HAL2    0.09    9
-       H11B    HAL2    0.09    9
-       C12     CTL2    -0.18   10
-       H12A    HAL2    0.09    10
-       H12B    HAL2    0.09    10
-       C13     CTL2    -0.18   11
-       H13A    HAL2    0.09    11
-       H13B    HAL2    0.09    11
-       C14     CTL2    -0.18   12
-       H14A    HAL2    0.09    12
-       H14B    HAL2    0.09    12
-       C15     CTL2    -0.18   13
-       H15A    HAL2    0.09    13
-       H15B    HAL2    0.09    13
-       C16     CTL2    -0.18   14
-       H16A    HAL2    0.09    14
-       H16B    HAL2    0.09    14
-       C17     CTL2    -0.18   15
-       H17A    HAL2    0.09    15
-       H17B    HAL2    0.09    15
-       C18     CTL3    -0.27   16
-       H18A    HAL3    0.09    16
-       H18B    HAL3    0.09    16
-       H18C    HAL3    0.09    16
+       O1      OCL     -0.76   1
+       O2      OCL     -0.76   2
+       C2      CTL2    -0.28   3
+       H2A     HAL2    0.09    4
+       H2B     HAL2    0.09    5
+       C3      CTL2    -0.18   6
+       H3A     HAL2    0.09    7
+       H3B     HAL2    0.09    8
+       C4      CTL2    -0.18   9
+       H4A     HAL2    0.09    10
+       H4B     HAL2    0.09    11
+       C5      CTL2    -0.18   12
+       H5A     HAL2    0.09    13
+       H5B     HAL2    0.09    14
+       C6      CTL2    -0.18   15
+       H6A     HAL2    0.09    16
+       H6B     HAL2    0.09    17
+       C7      CTL2    -0.18   18
+       H7A     HAL2    0.09    19
+       H7B     HAL2    0.09    20
+       C8      CTL2    -0.18   21
+       H8A     HAL2    0.09    22
+       H8B     HAL2    0.09    23
+       C9      CEL1    -0.15   24
+       H9A     HEL1    0.15    25
+       C10     CEL1    -0.15   26
+       H10A    HEL1    0.15    27
+       C11     CTL2    -0.18   28
+       H11A    HAL2    0.09    29
+       H11B    HAL2    0.09    30
+       C12     CTL2    -0.18   31
+       H12A    HAL2    0.09    32
+       H12B    HAL2    0.09    33
+       C13     CTL2    -0.18   34
+       H13A    HAL2    0.09    35
+       H13B    HAL2    0.09    36
+       C14     CTL2    -0.18   37
+       H14A    HAL2    0.09    38
+       H14B    HAL2    0.09    39
+       C15     CTL2    -0.18   40
+       H15A    HAL2    0.09    41
+       H15B    HAL2    0.09    42
+       C16     CTL2    -0.18   43
+       H16A    HAL2    0.09    44
+       H16B    HAL2    0.09    45
+       C17     CTL2    -0.18   46
+       H17A    HAL2    0.09    47
+       H17B    HAL2    0.09    48
+       C18     CTL3    -0.27   49
+       H18A    HAL3    0.09    50
+       H18B    HAL3    0.09    51
+       H18C    HAL3    0.09    52
  [ bonds ]
        C1      O1
        C1      C2
 [ DHA ]
  [ atoms ]
        C1      CL      0.62    0
-       O1      OCL     -0.76   0
-       O2      OCL     -0.76   0
-       C2      CTL2    -0.28   0
-       H2A     HAL2    0.09    0
-       H2B     HAL2    0.09    0
-       C3      CTL2    -0.18   1
-       H3A     HAL2    0.09    1
-       H3B     HAL2    0.09    1
-       C4      CEL1    -0.15   2
-       H4      HEL1    0.15    2
-       C5      CEL1    -0.15   3
-       H5      HEL1    0.15    3
-       C6      CTL2    -0.18   4
-       H6A     HAL2    0.09    4
-       H6B     HAL2    0.09    4
-       C7      CEL1    -0.15   5
-       H7      HEL1    0.15    5
-       C8      CEL1    -0.15   6
-       H8      HEL1    0.15    6
-       C9      CTL2    -0.18   7
-       H9A     HAL2    0.09    7
-       H9B     HAL2    0.09    7
-       C10     CEL1    -0.15   8
-       H10     HEL1    0.15    8
-       C11     CEL1    -0.15   9
-       H11     HEL1    0.15    9
-       C12     CTL2    -0.18   10
-       H12A    HAL2    0.09    10
-       H12B    HAL2    0.09    10
-       C13     CEL1    -0.15   11
-       H13     HEL1    0.15    11
-       C14     CEL1    -0.15   12
-       H14     HEL1    0.15    12
-       C15     CTL2    -0.18   13
-       H15A    HAL2    0.09    13
-       H15B    HAL2    0.09    13
-       C16     CEL1    -0.15   14
-       H16     HEL1    0.15    14
-       C17     CEL1    -0.15   15
-       H17     HEL1    0.15    15
-       C18     CTL2    -0.18   16
-       H18A    HAL2    0.09    16
-       H18B    HAL2    0.09    16
-       C19     CEL1    -0.15   17
-       H19     HEL1    0.15    17
-       C20     CEL1    -0.15   18
-       H20     HEL1    0.15    18
-       C21     CTL2    -0.18   19
-       H21A    HAL2    0.09    19
-       H21B    HAL2    0.09    19
-       C22     CTL3    -0.27   20
-       H22A    HAL3    0.09    20
-       H22B    HAL3    0.09    20
-       H22C    HAL3    0.09    20
+       O1      OCL     -0.76   1
+       O2      OCL     -0.76   2
+       C2      CTL2    -0.28   3
+       H2A     HAL2    0.09    4
+       H2B     HAL2    0.09    5
+       C3      CTL2    -0.18   6
+       H3A     HAL2    0.09    7
+       H3B     HAL2    0.09    8
+       C4      CEL1    -0.15   9
+       H4      HEL1    0.15    10
+       C5      CEL1    -0.15   11
+       H5      HEL1    0.15    12
+       C6      CTL2    -0.18   13
+       H6A     HAL2    0.09    14
+       H6B     HAL2    0.09    15
+       C7      CEL1    -0.15   16
+       H7      HEL1    0.15    17
+       C8      CEL1    -0.15   18
+       H8      HEL1    0.15    19
+       C9      CTL2    -0.18   20
+       H9A     HAL2    0.09    21
+       H9B     HAL2    0.09    22
+       C10     CEL1    -0.15   23
+       H10     HEL1    0.15    24
+       C11     CEL1    -0.15   25
+       H11     HEL1    0.15    26
+       C12     CTL2    -0.18   27
+       H12A    HAL2    0.09    28
+       H12B    HAL2    0.09    29
+       C13     CEL1    -0.15   30
+       H13     HEL1    0.15    31
+       C14     CEL1    -0.15   32
+       H14     HEL1    0.15    33
+       C15     CTL2    -0.18   34
+       H15A    HAL2    0.09    35
+       H15B    HAL2    0.09    36
+       C16     CEL1    -0.15   37
+       H16     HEL1    0.15    38
+       C17     CEL1    -0.15   39
+       H17     HEL1    0.15    40
+       C18     CTL2    -0.18   41
+       H18A    HAL2    0.09    42
+       H18B    HAL2    0.09    43
+       C19     CEL1    -0.15   44
+       H19     HEL1    0.15    45
+       C20     CEL1    -0.15   46
+       H20     HEL1    0.15    47
+       C21     CTL2    -0.18   48
+       H21A    HAL2    0.09    49
+       H21B    HAL2    0.09    50
+       C22     CTL3    -0.27   51
+       H22A    HAL3    0.09    52
+       H22B    HAL3    0.09    53
+       H22C    HAL3    0.09    54
  [ bonds ]
        C1      O1
        C1      C2
 [ STEA ]
  [ atoms ]
        C1      CL      0.62    0
-       O1      OCL     -0.76   0
-       O2      OCL     -0.76   0
-       C2      CTL2    -0.28   0
-       H2A     HAL2    0.09    0
-       H2B     HAL2    0.09    0
-       C3      CTL2    -0.18   1
-       H3A     HAL2    0.09    1
-       H3B     HAL2    0.09    1
-       C4      CTL2    -0.18   2
-       H4A     HAL2    0.09    2
-       H4B     HAL2    0.09    2
-       C5      CTL2    -0.18   3
-       H5A     HAL2    0.09    3
-       H5B     HAL2    0.09    3
-       C6      CTL2    -0.18   4
-       H6A     HAL2    0.09    4
-       H6B     HAL2    0.09    4
-       C7      CTL2    -0.18   5
-       H7A     HAL2    0.09    5
-       H7B     HAL2    0.09    5
-       C8      CTL2    -0.18   6
-       H8A     HAL2    0.09    6
-       H8B     HAL2    0.09    6
-       C9      CTL2    -0.18   7
-       H9A     HAL2    0.09    7
-       H9B     HAL2    0.09    7
-       C10     CTL2    -0.18   8
-       H10A    HAL2    0.09    8
-       H10B    HAL2    0.09    8
-       C11     CTL2    -0.18   9
-       H11A    HAL2    0.09    9
-       H11B    HAL2    0.09    9
-       C12     CTL2    -0.18   10
-       H12A    HAL2    0.09    10
-       H12B    HAL2    0.09    10
-       C13     CTL2    -0.18   11
-       H13A    HAL2    0.09    11
-       H13B    HAL2    0.09    11
-       C14     CTL2    -0.18   12
-       H14A    HAL2    0.09    12
-       H14B    HAL2    0.09    12
-       C15     CTL2    -0.18   13
-       H15A    HAL2    0.09    13
-       H15B    HAL2    0.09    13
-       C16     CTL2    -0.18   14
-       H16A    HAL2    0.09    14
-       H16B    HAL2    0.09    14
-       C17     CTL2    -0.18   15
-       H17A    HAL2    0.09    15
-       H17B    HAL2    0.09    15
-       C18     CTL3    -0.27   16
-       H18A    HAL3    0.09    16
-       H18B    HAL3    0.09    16
-       H18C    HAL3    0.09    16
+       O1      OCL     -0.76   1
+       O2      OCL     -0.76   2
+       C2      CTL2    -0.28   3
+       H2A     HAL2    0.09    4
+       H2B     HAL2    0.09    5
+       C3      CTL2    -0.18   6
+       H3A     HAL2    0.09    7
+       H3B     HAL2    0.09    8
+       C4      CTL2    -0.18   9
+       H4A     HAL2    0.09    10
+       H4B     HAL2    0.09    11
+       C5      CTL2    -0.18   12
+       H5A     HAL2    0.09    13
+       H5B     HAL2    0.09    14
+       C6      CTL2    -0.18   15
+       H6A     HAL2    0.09    16
+       H6B     HAL2    0.09    17
+       C7      CTL2    -0.18   18
+       H7A     HAL2    0.09    19
+       H7B     HAL2    0.09    20
+       C8      CTL2    -0.18   21
+       H8A     HAL2    0.09    22
+       H8B     HAL2    0.09    23
+       C9      CTL2    -0.18   24
+       H9A     HAL2    0.09    25
+       H9B     HAL2    0.09    26
+       C10     CTL2    -0.18   27
+       H10A    HAL2    0.09    28
+       H10B    HAL2    0.09    29
+       C11     CTL2    -0.18   30
+       H11A    HAL2    0.09    31
+       H11B    HAL2    0.09    32
+       C12     CTL2    -0.18   33
+       H12A    HAL2    0.09    34
+       H12B    HAL2    0.09    35
+       C13     CTL2    -0.18   36
+       H13A    HAL2    0.09    37
+       H13B    HAL2    0.09    38
+       C14     CTL2    -0.18   39
+       H14A    HAL2    0.09    40
+       H14B    HAL2    0.09    41
+       C15     CTL2    -0.18   42
+       H15A    HAL2    0.09    43
+       H15B    HAL2    0.09    44
+       C16     CTL2    -0.18   45
+       H16A    HAL2    0.09    46
+       H16B    HAL2    0.09    47
+       C17     CTL2    -0.18   48
+       H17A    HAL2    0.09    49
+       H17B    HAL2    0.09    50
+       C18     CTL3    -0.27   51
+       H18A    HAL3    0.09    52
+       H18B    HAL3    0.09    53
+       H18C    HAL3    0.09    54
  [ bonds ]
        C1      O1
        C1      C2
 [ PCGL ]
  [ atoms ]
        N       NTL     -0.60   0
-       C5      CTL2    -0.10   0
-       C6      CTL5    -0.35   0
-       C7      CTL5    -0.35   0
-       C8      CTL5    -0.35   0
-       H5A     HL      0.25    0
-       H5B     HL      0.25    0
-       H6A     HL      0.25    0
-       H6B     HL      0.25    0
-       H6C     HL      0.25    0
-       H7A     HL      0.25    0
-       H7B     HL      0.25    0
-       H7C     HL      0.25    0
-       H8A     HL      0.25    0
-       H8B     HL      0.25    0
-       H8C     HL      0.25    0
-       C4      CTL2    -0.08   1
-       H4A     HAL2    0.09    1
-       H4B     HAL2    0.09    1
-       P       PL      1.50    1
-       OP3     O2L     -0.78   1
-       OP4     O2L     -0.78   1
-       OP1     OSL     -0.57   1
-       OP2     OSL     -0.57   1
-       C3      CTL2    -0.08   1
-       H3A     HAL2    0.09    1
-       H3B     HAL2    0.09    1
-       C2      CTL1    0.14    2
-       H2A     HAL1    0.09    2
-       O2      OHL     -0.66   2
-       H2      HOL     0.43    2
-       C1      CTL2    0.05    3
-       H1A     HAL2    0.09    3
-       H1B     HAL2    0.09    3
-       O1      OHL     -0.66   3
-       H1      HOL     0.43    3
+       C5      CTL2    -0.10   1
+       C6      CTL5    -0.35   2
+       C7      CTL5    -0.35   3
+       C8      CTL5    -0.35   4
+       H5A     HL      0.25    5
+       H5B     HL      0.25    6
+       H6A     HL      0.25    7
+       H6B     HL      0.25    8
+       H6C     HL      0.25    9
+       H7A     HL      0.25    10
+       H7B     HL      0.25    11
+       H7C     HL      0.25    12
+       H8A     HL      0.25    13
+       H8B     HL      0.25    14
+       H8C     HL      0.25    15
+       C4      CTL2    -0.08   16
+       H4A     HAL2    0.09    17
+       H4B     HAL2    0.09    18
+       P       PL      1.50    19
+       OP3     O2L     -0.78   20
+       OP4     O2L     -0.78   21
+       OP1     OSL     -0.57   22
+       OP2     OSL     -0.57   23
+       C3      CTL2    -0.08   24
+       H3A     HAL2    0.09    25
+       H3B     HAL2    0.09    26
+       C2      CTL1    0.14    27
+       H2A     HAL1    0.09    28
+       O2      OHL     -0.66   29
+       H2      HOL     0.43    30
+       C1      CTL2    0.05    31
+       H1A     HAL2    0.09    32
+       H1B     HAL2    0.09    33
+       O1      OHL     -0.66   34
+       H1      HOL     0.43    35
  [ bonds ]
        N       C5
        N       C6
index d0c6576bc246722d4daa1a6866adbd00748a5d52..dd53e919c1364601f6aca61abb510cbc437b94d4 100644 (file)
  ;
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2     -0.05   2
-C5     CN5      0.28   2
-N7     NN4     -0.71   2
-C8     CN4      0.34   2
-H8     HN3      0.12   2
-N1     NN3A    -0.74   2
-C2     CN4      0.50   2
-H2     HN3      0.13   2
-N3     NN3A    -0.75   2
-C4     CN5      0.43   2
-C6     CN2      0.46   2
-N6     NN1     -0.77   2
-H61    HN1      0.38   2
-H62    HN1      0.38   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6B    -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N9     NN2     -0.05   12
+C5     CN5      0.28   13
+N7     NN4     -0.71   14
+C8     CN4      0.34   15
+H8     HN3      0.12   16
+N1     NN3A    -0.74   17
+C2     CN4      0.50   18
+H2     HN3      0.13   19
+N3     NN3A    -0.75   20
+C4     CN5      0.43   21
+C6     CN2      0.46   22
+N6     NN1     -0.77   23
+H61    HN1      0.38   24
+H62    HN1      0.38   25
+C2'    CN7B     0.14   26
+H2'2   HN7      0.09   27
+O2'    ON5     -0.66   28
+H2'1   HN5      0.43   29
+C3'    CN7      0.01   30
+H3'    HN7      0.09   31
+O3'    ON2     -0.57   32
 [ bonds ]
 -O3'     P
 P      O1P
@@ -141,36 +141,36 @@ C6        N1      C5      N6
  ;
 [ atoms ]
 H5T     HN5      0.43   0
-O5'    ON5     -0.66   0
-C5'    CN8B     0.05   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2     -0.05   2
-C5     CN5      0.28   2
-N7     NN4     -0.71   2
-C8     CN4      0.34   2
-H8     HN3      0.12   2
-N1     NN3A    -0.74   2
-C2     CN4      0.50   2
-H2     HN3      0.13   2
-N3     NN3A    -0.75   2
-C4     CN5      0.43   2
-C6     CN2      0.46   2
-N6     NN1     -0.77   2
-H61    HN1      0.38   2
-H62    HN1      0.38   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O5'    ON5     -0.66   1
+C5'    CN8B     0.05   2
+H5'1   HN8      0.09   3
+H5'2   HN8      0.09   4
+C4'    CN7      0.16   5
+H4'    HN7      0.09   6
+O4'    ON6B    -0.50   7
+C1'    CN7B     0.16   8
+H1'    HN7      0.09   9
+N9     NN2     -0.05   10
+C5     CN5      0.28   11
+N7     NN4     -0.71   12
+C8     CN4      0.34   13
+H8     HN3      0.12   14
+N1     NN3A    -0.74   15
+C2     CN4      0.50   16
+H2     HN3      0.13   17
+N3     NN3A    -0.75   18
+C4     CN5      0.43   19
+C6     CN2      0.46   20
+N6     NN1     -0.77   21
+H61    HN1      0.38   22
+H62    HN1      0.38   23
+C2'    CN7B     0.14   24
+H2'2   HN7      0.09   25
+O2'    ON5     -0.66   26
+H2'1   HN5      0.43   27
+C3'    CN7      0.01   28
+H3'    HN7      0.09   29
+O3'    ON2     -0.57   30
 [ bonds ]
 H5T    O5'
 O5'    C5'
@@ -237,39 +237,39 @@ C6        N1      C5      N6
  ;
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2     -0.05   2
-C5     CN5      0.28   2
-N7     NN4     -0.71   2
-C8     CN4      0.34   2
-H8     HN3      0.12   2
-N1     NN3A    -0.74   2
-C2     CN4      0.50   2
-H2     HN3      0.13   2
-N3     NN3A    -0.75   2
-C4     CN5      0.43   2
-C6     CN2      0.46   2
-N6     NN1     -0.77   2
-H61    HN1      0.38   2
-H62    HN1      0.38   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.14   4
-H3'    HN7      0.09   4
-O3'    ON5     -0.66   4
-H3T     HN5      0.43   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6B    -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N9     NN2     -0.05   12
+C5     CN5      0.28   13
+N7     NN4     -0.71   14
+C8     CN4      0.34   15
+H8     HN3      0.12   16
+N1     NN3A    -0.74   17
+C2     CN4      0.50   18
+H2     HN3      0.13   19
+N3     NN3A    -0.75   20
+C4     CN5      0.43   21
+C6     CN2      0.46   22
+N6     NN1     -0.77   23
+H61    HN1      0.38   24
+H62    HN1      0.38   25
+C2'    CN7B     0.14   26
+H2'2   HN7      0.09   27
+O2'    ON5     -0.66   28
+H2'1   HN5      0.43   29
+C3'    CN7      0.14   30
+H3'    HN7      0.09   31
+O3'    ON5     -0.66   32
+H3T     HN5      0.43   33
 [ bonds ]
 -O3'     P
 P      O1P
@@ -340,36 +340,36 @@ C6        N1      C5      N6
 ;                          H2'1
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2     -0.13   2
-C6     CN3      0.05   2
-H6     HN3      0.17   2
-C5     CN3     -0.13   2
-H5     HN3      0.07   2
-C2     CN1      0.52   2
-O2     ON1C    -0.49   2
-N3     NN3     -0.66   2
-C4     CN2      0.65   2
-N4     NN1     -0.75   2
-H41    HN1      0.37   2
-H42    HN1      0.33   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6B    -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N1     NN2     -0.13   12
+C6     CN3      0.05   13
+H6     HN3      0.17   14
+C5     CN3     -0.13   15
+H5     HN3      0.07   16
+C2     CN1      0.52   17
+O2     ON1C    -0.49   18
+N3     NN3     -0.66   19
+C4     CN2      0.65   20
+N4     NN1     -0.75   21
+H41    HN1      0.37   22
+H42    HN1      0.33   23
+C2'    CN7B     0.14   24
+H2'2   HN7      0.09   25
+O2'    ON5     -0.66   26
+H2'1   HN5      0.43   27
+C3'    CN7      0.01   28
+H3'    HN7      0.09   29
+O3'    ON2     -0.57   30
 [ bonds ]
 -O3'     P
 P      O1P
@@ -436,34 +436,34 @@ N4        C4      H41     H42
 ;                          H2'1
 [ atoms ]
 H5T     HN5      0.43   0
-O5'    ON5     -0.66   0
-C5'    CN8B     0.05   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2     -0.13   2
-C6     CN3      0.05   2
-H6     HN3      0.17   2
-C5     CN3     -0.13   2
-H5     HN3      0.07   2
-C2     CN1      0.52   2
-O2     ON1C    -0.49   2
-N3     NN3     -0.66   2
-C4     CN2      0.65   2
-N4     NN1     -0.75   2
-H41    HN1      0.37   2
-H42    HN1      0.33   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O5'    ON5     -0.66   1
+C5'    CN8B     0.05   2
+H5'1   HN8      0.09   3
+H5'2   HN8      0.09   4
+C4'    CN7      0.16   5
+H4'    HN7      0.09   6
+O4'    ON6B    -0.50   7
+C1'    CN7B     0.16   8
+H1'    HN7      0.09   9
+N1     NN2     -0.13   10
+C6     CN3      0.05   11
+H6     HN3      0.17   12
+C5     CN3     -0.13   13
+H5     HN3      0.07   14
+C2     CN1      0.52   15
+O2     ON1C    -0.49   16
+N3     NN3     -0.66   17
+C4     CN2      0.65   18
+N4     NN1     -0.75   19
+H41    HN1      0.37   20
+H42    HN1      0.33   21
+C2'    CN7B     0.14   22
+H2'2   HN7      0.09   23
+O2'    ON5     -0.66   24
+H2'1   HN5      0.43   25
+C3'    CN7      0.01   26
+H3'    HN7      0.09   27
+O3'    ON2     -0.57   28
 [ bonds ]
 H5T    O5'
 O5'    C5'
@@ -527,37 +527,37 @@ N4        C4      H41     H42
 ;                  H3T     H2'1
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2     -0.13   2
-C6     CN3      0.05   2
-H6     HN3      0.17   2
-C5     CN3     -0.13   2
-H5     HN3      0.07   2
-C2     CN1      0.52   2
-O2     ON1C    -0.49   2
-N3     NN3     -0.66   2
-C4     CN2      0.65   2
-N4     NN1     -0.75   2
-H41    HN1      0.37   2
-H42    HN1      0.33   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.14   4
-H3'    HN7      0.09   4
-O3'    ON5     -0.66   4
-H3T     HN5      0.43   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6B    -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N1     NN2     -0.13   12
+C6     CN3      0.05   13
+H6     HN3      0.17   14
+C5     CN3     -0.13   15
+H5     HN3      0.07   16
+C2     CN1      0.52   17
+O2     ON1C    -0.49   18
+N3     NN3     -0.66   19
+C4     CN2      0.65   20
+N4     NN1     -0.75   21
+H41    HN1      0.37   22
+H42    HN1      0.33   23
+C2'    CN7B     0.14   24
+H2'2   HN7      0.09   25
+O2'    ON5     -0.66   26
+H2'1   HN5      0.43   27
+C3'    CN7      0.14   28
+H3'    HN7      0.09   29
+O3'    ON5     -0.66   30
+H3T     HN5      0.43   31
 [ bonds ]
 -O3'     P
 P      O1P
@@ -623,39 +623,39 @@ N4        C4      H41     H42
 ;                             H2'1
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2B    -0.02   2
-C4     CN5      0.26   2
-N2     NN1     -0.68   2
-H21    HN1      0.32   2
-H22    HN1      0.35   2
-N3     NN3G    -0.74   2
-C2     CN2      0.75   2
-N1     NN2G    -0.34   2
-H1     HN2      0.26   2
-C6     CN1      0.54   2
-O6     ON1     -0.51   2
-C5     CN5G     0.00   2
-N7     NN4     -0.60   2
-C8     CN4      0.25   2
-H8     HN3      0.16   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6B    -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N9     NN2B    -0.02   12
+C4     CN5      0.26   13
+N2     NN1     -0.68   14
+H21    HN1      0.32   15
+H22    HN1      0.35   16
+N3     NN3G    -0.74   17
+C2     CN2      0.75   18
+N1     NN2G    -0.34   19
+H1     HN2      0.26   20
+C6     CN1      0.54   21
+O6     ON1     -0.51   22
+C5     CN5G     0.00   23
+N7     NN4     -0.60   24
+C8     CN4      0.25   25
+H8     HN3      0.16   26
+C2'    CN7B     0.14   27
+H2'2   HN7      0.09   28
+O2'    ON5     -0.66   29
+H2'1   HN5      0.43   30
+C3'    CN7      0.01   31
+H3'    HN7      0.09   32
+O3'    ON2     -0.57   33
 [ bonds ]
 -O3'     P
 P      O1P
@@ -723,37 +723,37 @@ N2        H21     C2      H22
 ;                            H2'1
 [ atoms ]
 H5T     HN5      0.43   0
-O5'    ON5     -0.66   0
-C5'    CN8B     0.05   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2B    -0.02   2
-C4     CN5      0.26   2
-N2     NN1     -0.68   2
-H21    HN1      0.32   2
-H22    HN1      0.35   2
-N3     NN3G    -0.74   2
-C2     CN2      0.75   2
-N1     NN2G    -0.34   2
-H1     HN2      0.26   2
-C6     CN1      0.54   2
-O6     ON1     -0.51   2
-C5     CN5G     0.00   2
-N7     NN4     -0.60   2
-C8     CN4      0.25   2
-H8     HN3      0.16   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O5'    ON5     -0.66   1
+C5'    CN8B     0.05   2
+H5'1   HN8      0.09   3
+H5'2   HN8      0.09   4
+C4'    CN7      0.16   5
+H4'    HN7      0.09   6
+O4'    ON6B    -0.50   7
+C1'    CN7B     0.16   8
+H1'    HN7      0.09   9
+N9     NN2B    -0.02   10
+C4     CN5      0.26   11
+N2     NN1     -0.68   12
+H21    HN1      0.32   13
+H22    HN1      0.35   14
+N3     NN3G    -0.74   15
+C2     CN2      0.75   16
+N1     NN2G    -0.34   17
+H1     HN2      0.26   18
+C6     CN1      0.54   19
+O6     ON1     -0.51   20
+C5     CN5G     0.00   21
+N7     NN4     -0.60   22
+C8     CN4      0.25   23
+H8     HN3      0.16   24
+C2'    CN7B     0.14   25
+H2'2   HN7      0.09   26
+O2'    ON5     -0.66   27
+H2'1   HN5      0.43   28
+C3'    CN7      0.01   29
+H3'    HN7      0.09   30
+O3'    ON2     -0.57   31
 [ bonds ]
 H5T     O5'
 O5'    C5'
@@ -818,40 +818,40 @@ N2        H21     C2      H22
 ;                    H3T     H2'1
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N9     NN2B    -0.02   2
-C4     CN5      0.26   2
-N2     NN1     -0.68   2
-H21    HN1      0.32   2
-H22    HN1      0.35   2
-N3     NN3G    -0.74   2
-C2     CN2      0.75   2
-N1     NN2G    -0.34   2
-H1     HN2      0.26   2
-C6     CN1      0.54   2
-O6     ON1     -0.51   2
-C5     CN5G     0.00   2
-N7     NN4     -0.60   2
-C8     CN4      0.25   2
-H8     HN3      0.16   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.14   4
-H3'    HN7      0.09   4
-O3'    ON5     -0.66   4
-H3T     HN5      0.43   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6B    -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N9     NN2B    -0.02   12
+C4     CN5      0.26   13
+N2     NN1     -0.68   14
+H21    HN1      0.32   15
+H22    HN1      0.35   16
+N3     NN3G    -0.74   17
+C2     CN2      0.75   18
+N1     NN2G    -0.34   19
+H1     HN2      0.26   20
+C6     CN1      0.54   21
+O6     ON1     -0.51   22
+C5     CN5G     0.00   23
+N7     NN4     -0.60   24
+C8     CN4      0.25   25
+H8     HN3      0.16   26
+C2'    CN7B     0.14   27
+H2'2   HN7      0.09   28
+O2'    ON5     -0.66   29
+H2'1   HN5      0.43   30
+C3'    CN7      0.14   31
+H3'    HN7      0.09   32
+O3'    ON5     -0.66   33
+H3T     HN5      0.43   34
 [ bonds ]
 -O3'     P
 P      O1P
@@ -922,35 +922,35 @@ N2        H21     C2      H22
  ;
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2B    -0.34   2
-C6     CN3      0.20   2
-H6     HN3      0.14   2
-C2     CN1T     0.55   2
-O2     ON1     -0.45   2
-N3     NN2U    -0.46   2
-H3     HN2      0.36   2
-C4     CN1      0.53   2
-O4     ON1     -0.48   2
-C5     CN3     -0.15   2
-H5     HN3      0.10   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6B    -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N1     NN2B    -0.34   12
+C6     CN3      0.20   13
+H6     HN3      0.14   14
+C2     CN1T     0.55   15
+O2     ON1     -0.45   16
+N3     NN2U    -0.46   17
+H3     HN2      0.36   18
+C4     CN1      0.53   19
+O4     ON1     -0.48   20
+C5     CN3     -0.15   21
+H5     HN3      0.10   22
+C2'    CN7B     0.14   23
+H2'2   HN7      0.09   24
+O2'    ON5     -0.66   25
+H2'1   HN5      0.43   26
+C3'    CN7      0.01   27
+H3'    HN7      0.09   28
+O3'    ON2     -0.57   29
 [ bonds ]
 -O3'     P
 P      O1P
@@ -1013,33 +1013,33 @@ C4      N3      C5      O4
  ;
 [ atoms ]
 H5T     HN5      0.43   0
-O5'    ON5     -0.66   0
-C5'    CN8B     0.05   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2B    -0.34   2
-C6     CN3      0.20   2
-H6     HN3      0.14   2
-C2     CN1T     0.55   2
-O2     ON1     -0.45   2
-N3     NN2U    -0.46   2
-H3     HN2      0.36   2
-C4     CN1      0.53   2
-O4     ON1     -0.48   2
-C5     CN3     -0.15   2
-H5     HN3      0.10   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.01   4
-H3'    HN7      0.09   4
-O3'    ON2     -0.57   4
+O5'    ON5     -0.66   1
+C5'    CN8B     0.05   2
+H5'1   HN8      0.09   3
+H5'2   HN8      0.09   4
+C4'    CN7      0.16   5
+H4'    HN7      0.09   6
+O4'    ON6B    -0.50   7
+C1'    CN7B     0.16   8
+H1'    HN7      0.09   9
+N1     NN2B    -0.34   10
+C6     CN3      0.20   11
+H6     HN3      0.14   12
+C2     CN1T     0.55   13
+O2     ON1     -0.45   14
+N3     NN2U    -0.46   15
+H3     HN2      0.36   16
+C4     CN1      0.53   17
+O4     ON1     -0.48   18
+C5     CN3     -0.15   19
+H5     HN3      0.10   20
+C2'    CN7B     0.14   21
+H2'2   HN7      0.09   22
+O2'    ON5     -0.66   23
+H2'1   HN5      0.43   24
+C3'    CN7      0.01   25
+H3'    HN7      0.09   26
+O3'    ON2     -0.57   27
 [ bonds ]
 H5T    O5'
 O5'    C5'
@@ -1099,36 +1099,36 @@ C4      N3      C5      O4
  ;
 [ atoms ]
 P      P        1.50   0
-O1P    ON3     -0.78   0
-O2P    ON3     -0.78   0
-O5'    ON2     -0.57   0
-C5'    CN8B    -0.08   0
-H5'1   HN8      0.09   0
-H5'2   HN8      0.09   0
-C4'    CN7      0.16   1
-H4'    HN7      0.09   1
-O4'    ON6B    -0.50   1
-C1'    CN7B     0.16   1
-H1'    HN7      0.09   1
-N1     NN2B    -0.34   2
-C6     CN3      0.20   2
-H6     HN3      0.14   2
-C2     CN1T     0.55   2
-O2     ON1     -0.45   2
-N3     NN2U    -0.46   2
-H3     HN2      0.36   2
-C4     CN1      0.53   2
-O4     ON1     -0.48   2
-C5     CN3     -0.15   2
-H5     HN3      0.10   2
-C2'    CN7B     0.14   3
-H2'2   HN7      0.09   3
-O2'    ON5     -0.66   3
-H2'1   HN5      0.43   3
-C3'    CN7      0.14   4
-H3'    HN7      0.09   4
-O3'    ON5     -0.66   4
-H3T     HN5      0.43   4
+O1P    ON3     -0.78   1
+O2P    ON3     -0.78   2
+O5'    ON2     -0.57   3
+C5'    CN8B    -0.08   4
+H5'1   HN8      0.09   5
+H5'2   HN8      0.09   6
+C4'    CN7      0.16   7
+H4'    HN7      0.09   8
+O4'    ON6B    -0.50   9
+C1'    CN7B     0.16   10
+H1'    HN7      0.09   11
+N1     NN2B    -0.34   12
+C6     CN3      0.20   13
+H6     HN3      0.14   14
+C2     CN1T     0.55   15
+O2     ON1     -0.45   16
+N3     NN2U    -0.46   17
+H3     HN2      0.36   18
+C4     CN1      0.53   19
+O4     ON1     -0.48   20
+C5     CN3     -0.15   21
+H5     HN3      0.10   22
+C2'    CN7B     0.14   23
+H2'2   HN7      0.09   24
+O2'    ON5     -0.66   25
+H2'1   HN5      0.43   26
+C3'    CN7      0.14   27
+H3'    HN7      0.09   28
+O3'    ON5     -0.66   29
+H3T     HN5      0.43   30
 [ bonds ]
 -O3'     P
 P      O1P
index 0173391edf16fd78813d494ebf8196b30ba88aaa..b59676bc5bd5c4712fca7bd9604204529d09d52c 100644 (file)
@@ -1,4 +1,4 @@
-364
+365
 ��ߦ��ߨ���߬��������߻���ߦ��߷���ߋ�߻�߶�ߦ��������׷���������߶��
 �߳���ߋ��߳���߫���ߨ���߫���߻���׫������
 �����߽����߲�߷������ײ��������
 �ߓ���ߋ�߈����ߋ���߶ߙ���ߓ���߶ߛ�ߌ���������׼���߼�������
 ���߶ߗ���ߚ���������ߓ�����ߋ���ߚ���������ߚ����׻���߯������
 �����ߐ�ߜ�����������ߞ��ߋ��ߌ������߲�ߌ������ߖ�߈�������ߑ�����ߜ��������ײ�������
+��،ߊ����ߜ���ߋ���ߐ���߆��ߞ��߶ߔ����״���߽����
index a0939261188ae5483b4017c814f8c322a3069197..48c3d7af658f24e22601e3def9fd2116c57b62ca 100644 (file)
@@ -84,7 +84,7 @@ CU2+          1
 
 [ atoms ]
 ; id   at type res nr  residu name     at name  cg nr  charge   mass
-1      CU2+    1       CU2+            CU       1      2        63.54600
+1      Cu2+    1       CU2+            CU       1      2        63.54600
 
 [ moleculetype ]
 ; molname      nrexcl
@@ -92,7 +92,7 @@ ZN2+          1
 
 [ atoms ]
 ; id   at type res nr  residu name     at name  cg nr  charge   mass
-1      ZN2+    1       ZN2+            ZN       1      2        65.37000
+1      Zn2+    1       ZN2+            ZN       1      2        65.37000
 
 [ moleculetype ]
 ; molname      nrexcl
index a0566886994e2d44718cfe1963dc3f5ee6797ca0..f91d3ef70e1920a3c5a02ffc369bf325ed4e7844 100755 (executable)
@@ -82,7 +82,11 @@ echo "Starting pdb2gmx"
 if ( $?DISPLAY ) then 
        xterm -title pdb2gmx -sb -e tail +0f output.pdb2gmx &
 endif
-echo 0 | pdb2gmx -f ${MOL}.pdb -o ${MOL}.gro -p ${MOL}.top >& ! output.pdb2gmx
+pdb2gmx -f ${MOL}.pdb -o ${MOL}.gro -p ${MOL}.top >& ! output.pdb2gmx << KOKO
+1
+1
+KOKO
+
 echo "pdb2gmx finished"
 echo -n "Press <enter>"
 set  ans = $<
index 4fadc144721127bfc1f291cbdccc0b348245cb17..a6afabe62c858dd316ed70a55bc640934eab7341 100644 (file)
@@ -16,7 +16,8 @@ EXTRA_DIST              = README
 EXTRA_PROGRAMS         =       copyrgt         \
                        options         hrefify         \
                        addquote        compnl  \
-                       gen_table       ehole   g_sdf
+                       gen_table       ehole   g_sdf\
+                       do_multiprot
 
 compnl_SOURCES = compnl.c
 compnl_LDADD   = ../mdlib/libmd@LIBSUFFIX@.la ../gmxlib/libgmx@LIBSUFFIX@.la
diff --git a/src/contrib/do_multiprot.c b/src/contrib/do_multiprot.c
new file mode 100644 (file)
index 0000000..72ef05c
--- /dev/null
@@ -0,0 +1,462 @@
+/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
+ *
+ *                This source code is NOT REALLY part of
+ * 
+ *                 G   R   O   M   A   C   S
+ * 
+ *          GROningen MAchine for Chemical Simulations
+ * 
+ *                        VERSION 4.2.5
+ * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team,
+ * check out http://www.gromacs.org for more information.
+
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * If you want to redistribute modifications, please consider that
+ * scientific software is very special. Version control is crucial -
+ * bugs must be traceable. We will be happy to consider code for
+ * inclusion in the official distribution, but derived work must not
+ * be called official GROMACS. Details are found in the README & COPYING
+ * files - if they are missing, get the official version at www.gromacs.org.
+ * 
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the papers on the package - you can find them in the top README file.
+ * 
+ * For more info, check our website at http://www.gromacs.org
+ *
+ * Author: do_multiprot was written by Ran Friedman <r.friedman@bioc.uzh.ch>
+ * 
+ * And Hey:
+ * Green Red Orange Magenta Azure Cyan Skyblue
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "sysstuff.h"
+#include "typedefs.h"
+#include "string2.h"
+#include "strdb.h"
+#include "macros.h"
+#include "smalloc.h"
+#include "mshift.h"
+#include "statutil.h"
+#include "copyrite.h"
+#include "pdbio.h"
+#include "gmx_fatal.h"
+#include "xvgr.h"
+#include "matio.h"
+#include "index.h"
+#include "gstat.h"
+#include "tpxio.h"
+#include "viewit.h"
+#include "gbutil.h"
+#include "vec.h"
+#include "confio.h"
+#include "gmxfio.h"
+
+typedef struct {
+    int resnr; 
+    int count; 
+} t_countres;
+
+static void process_multiprot_output(const char *fn, real *rmsd, int *nres, rvec rotangles, 
+                                    rvec translation, bool bCountres, t_countres *countres)
+{
+    FILE       *mpoutput;
+    char       line[256];
+    char       *string;
+    int        i=0,j=0,res;
+    
+    (*rmsd)=-1;
+    (*nres)=0;
+    mpoutput=ffopen (fn,"r");
+    
+    if (bCountres) {
+       do {
+           fgets(line, 256, mpoutput);
+       } while (strstr(line,"Match List") == NULL);
+       fgets(line, 256, mpoutput);
+       do {
+           string = strtok (line,".");
+           while (i<2 && string != NULL) {
+               string = strtok (NULL,". ");
+               i++;
+           }
+           i=0;
+           res=atoi(string);
+           if (res > 0) {
+               while (countres[j].resnr!=res)
+                   j++;
+               countres[j].count++;
+           }
+           fgets(line, 256, mpoutput);
+       } while (strstr(line,"End of Match List") == NULL);
+       rewind(mpoutput);
+    }
+    do {
+       fgets(line, 256, mpoutput);
+    } while (strstr(line,"Trans : ") == NULL);
+    
+    string = strtok (line," :");
+    string = strtok (NULL," ");
+    while (i<3 && string != NULL) {
+       string = strtok (NULL," ");
+       rotangles[i]=atof(string);
+       i++;
+    }
+    i=0;
+    while (i<3 && string != NULL) {
+       string = strtok (NULL," ");
+       translation[i]=atof(string)/10;
+       i++;
+    }
+    if (i!=3) {
+       gmx_warning("Not enough values for rotation and translation vectors in the output of multiprot");
+    }
+    
+    rotangles[YY]=rotangles[YY]*(-1); 
+    
+    while ((*rmsd) <0) {
+       fgets(line, 256, mpoutput);
+       if (strstr(line,"RMSD : ") != NULL) {
+           string = strtok (line,":");
+           string = strtok (NULL,":");
+           (*rmsd)=atof(string)/10;
+       }
+    }
+    while (!(*nres)) {
+       fgets(line,256, mpoutput);
+       if (strstr(line,"Match List") != NULL) {
+           string = strtok (line,":");
+           string = strtok (NULL,":");
+           (*nres) = atoi(string);
+       }
+    }
+    ffclose(mpoutput);
+}
+
+int main(int argc,char *argv[])
+{
+    const char *desc[] = {
+       "do_multiprot ", 
+       "reads a trajectory file and aligns it to a reference structure  ",
+       "each time frame",
+       "calling the multiprot program. This allows you to use a reference",
+       "structure whose sequence is different than that of the protein in the ",
+       "trajectory, since the alignment is based on the geometry, not sequence.",
+       "The output of do_multiprot includes the rmsd and the number of residues",
+       "on which it was calculated.",
+       "[PAR]",
+       "An aligned trajectory file is generated with the [TT] -ox [tt] option.[PAR]",
+       "With the [TT] -cr [tt] option, the number of hits in the alignment is given",
+       "per residue. This number can be between 0 and the number of frames, and",
+       "indicates the structural conservation of this residue.[PAR]",
+       "If you do not have the multiprot program, get it. do_multiprot assumes", 
+       "that the multiprot executable is /usr/local/bin/multiprot. If this is ",
+       "not the case, then you should set an environment variable [BB]MULTIPROT[bb]", 
+       "pointing to the multiprot executable, e.g.: [PAR]",
+       "[TT]setenv MULTIPROT /usr/MultiProtInstall/multiprot.Linux[tt][PAR]",
+       "Note that at the current implementation only binary alignment (your",
+       "molecule to a reference) is supported. In addition, note that the ",
+       "by default multiprot aligns the two proteins on their C-alpha carbons.",
+       "and that this depends on the multiprot parameters which are not dealt ",
+       "with here. Thus, the C-alpha carbons is expected to give the same "
+       "results as choosing the whole protein and will be slightly faster.[PAR]",
+       "For information about multiprot, see:",
+       "http://bioinfo3d.cs.tau.ac.il/MultiProt/.[PAR]"
+    };
+    static bool bVerbose;
+    t_pargs pa[] = {
+       { "-v",  FALSE, etBOOL, {&bVerbose},
+         "HIDDENGenerate miles of useless information" }
+    };
+  
+    const char *bugs[] = { 
+       "The program is very slow, since multiprot is run externally"
+    };
+  
+    t_trxstatus *status;
+    t_trxstatus *trxout=NULL;
+    FILE        *tapein,*fo,*frc,*tmpf,*out=NULL,*fres=NULL;
+    const char  *fnRef;
+    const char  *fn="2_sol.res";
+    t_topology  top;
+    int         ePBC;
+    t_atoms     *atoms,ratoms,useatoms;
+    t_trxframe  fr;
+    t_pdbinfo   p;
+    int         nres,nres2,nr0;
+    real        t;
+    int         i,j,natoms,nratoms,nframe=0,model_nr=-1;
+    int         cur_res,prev_res;
+    int         nout;
+    t_countres  *countres=NULL;
+    matrix      box,rbox;
+    int         gnx;
+    char        *grpnm,*ss_str; 
+    atom_id     *index;
+    rvec        *xp,*x,*xr;
+    char        pdbfile[32],refpdb[256],title[256],rtitle[256],filemode[5];
+    char        out_title[256];
+    char        multiprot[256],*mptr;
+    int         ftp;
+    int         outftp=-1;
+    real        rmsd;
+    bool        bTrjout,bCountres;
+    const char  *TrjoutFile=NULL;
+    output_env_t oenv;
+    static rvec translation={0,0,0},rotangles={0,0,0};
+    gmx_rmpbc_t gpbc=NULL;
+    
+    t_filenm   fnm[] = {
+       { efTRX, "-f",   NULL,      ffREAD },
+       { efTPS, NULL,   NULL,      ffREAD },
+       { efNDX, NULL,   NULL,      ffOPTRD },
+       { efSTX, "-r",   NULL     , ffREAD },
+       { efXVG, "-o",  "rmss",     ffWRITE },
+       { efXVG, "-rc", "rescount", ffWRITE},
+       { efXVG, "-cr", "countres", ffOPTWR},
+       { efTRX, "-ox", "aligned",  ffOPTWR }
+    };
+#define NFILE asize(fnm)
+    
+    CopyRight(stderr,argv[0]);
+    parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_CAN_VIEW | PCA_TIME_UNIT | PCA_BE_NICE ,
+                     NFILE,fnm, asize(pa),pa, asize(desc),desc,
+                     asize(bugs),bugs,&oenv
+       );
+    fnRef=opt2fn("-r",NFILE,fnm);
+    bTrjout = opt2bSet("-ox",NFILE,fnm);
+    bCountres=  opt2bSet("-cr",NFILE,fnm);
+    
+    if (bTrjout) {
+       TrjoutFile = opt2fn_null("-ox",NFILE,fnm);
+    }
+    
+    read_tps_conf(ftp2fn(efTPS,NFILE,fnm),title,&top,&ePBC,&xp,NULL,box,FALSE);
+    gpbc = gmx_rmpbc_init(&top.idef,ePBC,top.atoms.nr,box);
+    atoms=&(top.atoms);
+
+    ftp=fn2ftp(fnRef);
+    get_stx_coordnum(fnRef,&nratoms);
+    init_t_atoms(&ratoms,nratoms,TRUE);  
+    snew(xr,nratoms);
+    read_stx_conf(fnRef,rtitle,&ratoms,xr,NULL,&ePBC,rbox);
+    
+    if (bVerbose) {
+       fprintf(stderr,"Read %d atoms\n",atoms->nr); 
+       fprintf(stderr,"Read %d reference atoms\n",ratoms.nr); 
+    }
+    if (bCountres) {
+       snew(countres,ratoms.nres);
+       j=0;
+       cur_res=0;
+       for (i=0;i<ratoms.nr;i++) {
+           prev_res=cur_res;
+           cur_res=ratoms.atom[i].resind;
+           if (cur_res != prev_res) {
+               countres[j].resnr=cur_res;
+               countres[j].count=0;
+               j++;
+           }
+       }
+    }
+    get_index(atoms,ftp2fn_null(efNDX,NFILE,fnm),1,&gnx,&index,&grpnm);
+    nres=0;
+    nr0=-1;
+    for(i=0; (i<gnx); i++) {
+       if (atoms->atom[index[i]].resind != nr0) {
+           nr0=atoms->atom[index[i]].resind;
+           nres++;
+       }
+    }
+    fprintf(stderr,"There are %d residues in your selected group\n",nres);
+    
+    strcpy(pdbfile,"ddXXXXXX");
+    gmx_tmpnam(pdbfile);
+    if ((tmpf = fopen(pdbfile,"w")) == NULL) {
+       sprintf(pdbfile,"%ctmp%cfilterXXXXXX",DIR_SEPARATOR,DIR_SEPARATOR);
+       gmx_tmpnam(pdbfile);
+       if ((tmpf = fopen(pdbfile,"w")) == NULL) {
+           gmx_fatal(FARGS,"Can not open tmp file %s",pdbfile);
+       }
+    }
+    else {
+       ffclose(tmpf);
+    }
+
+    if (ftp != efPDB) {
+       strcpy(refpdb,"ddXXXXXX");
+       gmx_tmpnam(refpdb);
+       strcat(refpdb,".pdb");
+       write_sto_conf(refpdb,rtitle,&ratoms,xr,NULL,ePBC,rbox);
+    }
+    else {
+       strcpy(refpdb,fnRef);
+    }
+
+    if ((mptr=getenv("MULTIPROT")) == NULL) {
+       mptr="/usr/local/bin/multiprot";
+    }
+    if (!gmx_fexist(mptr)) {
+       gmx_fatal(FARGS,"MULTIPROT executable (%s) does not exist (use setenv MULTIPROT)",
+                 mptr);
+    }
+    sprintf (multiprot,"%s %s %s > /dev/null %s",
+            mptr, refpdb, pdbfile, "2> /dev/null");
+    
+    if (bVerbose)
+       fprintf(stderr,"multiprot cmd='%s'\n",multiprot);
+    
+    if (!read_first_frame(oenv,&status,ftp2fn(efTRX,NFILE,fnm),&fr,TRX_READ_X)) 
+       gmx_fatal(FARGS,"Could not read a frame from %s",ftp2fn(efTRX,NFILE,fnm));
+    natoms = fr.natoms;
+
+    if (bTrjout) {
+       nout=natoms;
+       /* open file now */
+       outftp=fn2ftp(TrjoutFile);
+       if (bVerbose)
+           fprintf(stderr,"Will write %s: %s\n",ftp2ext(ftp),ftp2desc(outftp));
+       strcpy(filemode,"w");
+       switch (outftp) {
+           case efXTC:
+           case efG87:
+           case efTRR:
+           case efTRJ:
+               out=NULL;
+               trxout = open_trx(TrjoutFile,filemode);
+               break;
+           case efGRO:
+           case efG96:
+           case efPDB:
+               /* Make atoms struct for output in GRO or PDB files */
+               /* get memory for stuff to go in pdb file */
+               init_t_atoms(&useatoms,nout,FALSE);
+               sfree(useatoms.resinfo);
+               useatoms.resinfo=atoms->resinfo;
+               for(i=0;(i<nout);i++) {
+                   useatoms.atomname[i]=atoms->atomname[i];
+                   useatoms.atom[i]=atoms->atom[i];
+                   useatoms.nres=max(useatoms.nres,useatoms.atom[i].resind+1);
+               }
+               useatoms.nr=nout;
+               out=ffopen(TrjoutFile,filemode);
+               break;
+       }
+       if (outftp == efG87)
+           fprintf(gmx_fio_getfp(trx_get_fileio(trxout)),"Generated by %s. #atoms=%d, a BOX is"
+                   " stored in this file.\n",Program(),nout);   
+    }
+    
+    if (natoms > atoms->nr) {
+       gmx_fatal(FARGS,"\nTrajectory does not match topology!");
+    }
+    if (gnx > natoms) {
+       gmx_fatal(FARGS,"\nTrajectory does not match selected group!");
+    }
+
+    fo = xvgropen(opt2fn("-o",NFILE,fnm),"RMSD","Time (ps)","RMSD (nm)",oenv);
+    frc = xvgropen(opt2fn("-rc",NFILE,fnm),"Number of Residues in the alignment","Time (ps)","Residues",oenv);
+    
+    do {
+       t = output_env_conv_time(oenv,fr.time);
+       gmx_rmpbc(gpbc,natoms,fr.box,fr.x);
+       tapein=ffopen(pdbfile,"w");
+       write_pdbfile_indexed(tapein,NULL,atoms,fr.x,ePBC,fr.box,' ',-1,gnx,index,NULL,TRUE); 
+       ffclose(tapein);
+       system(multiprot);
+       remove(pdbfile);
+       process_multiprot_output(fn, &rmsd, &nres2,rotangles,translation,bCountres,countres);
+       fprintf(fo,"%12.7f",t);
+       fprintf(fo," %12.7f\n",rmsd);
+       fprintf(frc,"%12.7f",t);
+       fprintf(frc,"%12d\n",nres2);
+       if (bTrjout) {
+           rotate_conf(natoms,fr.x,NULL,rotangles[XX],rotangles[YY],rotangles[ZZ]);
+           for(i=0; i<natoms; i++) {
+               rvec_inc(fr.x[i],translation);
+           }
+           switch(outftp) {
+               case efTRJ:
+               case efTRR:
+               case efG87:
+               case efXTC:
+                   write_trxframe(trxout,&fr,NULL);
+                   break;
+               case efGRO:
+               case efG96:
+               case efPDB:
+                   sprintf(out_title,"Generated by do_multiprot : %s t= %g %s",
+                           title,output_env_conv_time(oenv,fr.time),output_env_get_time_unit(oenv));
+                   switch(outftp) {
+                       case efGRO: 
+                           write_hconf_p(out,out_title,&useatoms,prec2ndec(fr.prec),
+                                         fr.x,NULL,fr.box);
+                           break;
+                       case efPDB:
+                           fprintf(out,"REMARK    GENERATED BY DO_MULTIPROT\n");
+                           sprintf(out_title,"%s t= %g %s",title,output_env_conv_time(oenv,fr.time),output_env_get_time_unit(oenv));
+                           /* if reading from pdb, we want to keep the original 
+                              model numbering else we write the output frame
+                              number plus one, because model 0 is not allowed in pdb */
+                           if (ftp==efPDB && fr.step > model_nr) {
+                               model_nr = fr.step;
+                           }
+                           else {
+                               model_nr++;
+                           }
+                           write_pdbfile(out,out_title,&useatoms,fr.x,ePBC,fr.box,' ',model_nr,NULL,TRUE);
+                           break;
+                       case efG96:
+                           fr.title = out_title;
+                           fr.bTitle = (nframe == 0);
+                           fr.bAtoms = FALSE;
+                           fr.bStep = TRUE;
+                           fr.bTime = TRUE;
+                           write_g96_conf(out,&fr,-1,NULL);
+                   }
+                   break;
+           }
+       }
+       nframe++;
+    } while(read_next_frame(oenv,status,&fr));
+    if (bCountres) {
+       fres=  xvgropen(opt2fn("-cr",NFILE,fnm),"Number of frames in which the residues are aligned to","Residue","Number",oenv);
+       for (i=0;i<ratoms.nres;i++) {
+           fprintf(fres,"%10d  %12d\n",countres[i].resnr,countres[i].count);
+       }
+       ffclose(fres);
+    }
+    ffclose(fo);
+    ffclose(frc);
+    fprintf(stderr,"\n");
+    close_trj(status);
+    if (trxout != NULL) {
+       close_trx(trxout);
+    }
+    else if (out != NULL) {
+       ffclose(out);
+    }
+    view_all(oenv,NFILE, fnm);
+    sfree(xr);
+    if (bCountres) {
+       sfree(countres);
+    }
+    free_t_atoms(&ratoms,TRUE);
+    if (bTrjout) {
+       if (outftp==efPDB || outftp==efGRO || outftp==efG96) {
+           free_t_atoms(&useatoms,TRUE);
+       }
+    }
+    thanx(stderr);
+    return 0;
+}
index caacf3d53a78e6980a3d4e37d1eafa471d2553f7..f27df6d4790fb925c4366de6b3c8f1d67894a69f 100644 (file)
@@ -1245,96 +1245,115 @@ real idihs(int nbonds,
 
 
 real posres(int nbonds,
-           const t_iatom forceatoms[],const t_iparams forceparams[],
-           const rvec x[],rvec f[],rvec vir_diag,
-           t_pbc *pbc,
-           real lambda,real *dvdlambda,
-           int refcoord_scaling,int ePBC,rvec comA,rvec comB)
+            const t_iatom forceatoms[],const t_iparams forceparams[],
+            const rvec x[],rvec f[],rvec vir_diag,
+            t_pbc *pbc,
+            real lambda,real *dvdlambda,
+            int refcoord_scaling,int ePBC,rvec comA,rvec comB)
 {
-  int  i,ai,m,d,type,ki,npbcdim=0;
-  const t_iparams *pr;
-  real v,vtot,fm,*fc;
-  real posA,posB,ref=0;
-  rvec comA_sc,comB_sc,rdist,dpdl,pos,dx;
-
-  npbcdim = ePBC2npbcdim(ePBC);
-
-  if (refcoord_scaling == erscCOM) {
-    clear_rvec(comA_sc);
-    clear_rvec(comB_sc);
-    for(m=0; m<npbcdim; m++) {
-      for(d=m; d<npbcdim; d++) {
-       comA_sc[m] += comA[d]*pbc->box[d][m];
-       comB_sc[m] += comB[d]*pbc->box[d][m];
-      }
-    }
-  }
+    int  i,ai,m,d,type,ki,npbcdim=0;
+    const t_iparams *pr;
+    real L1;
+    real vtot,kk,fm;
+    real posA,posB,ref=0;
+    rvec comA_sc,comB_sc,rdist,dpdl,pos,dx;
 
-  vtot = 0.0;
-  for(i=0; (i<nbonds); ) {
-    type = forceatoms[i++];
-    ai   = forceatoms[i++];
-    pr   = &forceparams[type];
-    
-    for(m=0; m<DIM; m++) {
-      posA = forceparams[type].posres.pos0A[m];
-      posB = forceparams[type].posres.pos0B[m];
-      if (m < npbcdim) {
-       switch (refcoord_scaling) {
-       case erscNO:
-         ref      = 0;
-         rdist[m] = (1 - lambda)*posA + lambda*posB;
-         dpdl[m]  = posB - posA;
-         break;
-       case erscALL:
-         /* Box relative coordinates are stored for dimensions with pbc */
-         posA *= pbc->box[m][m];
-         posB *= pbc->box[m][m];
-         for(d=m+1; d<npbcdim; d++) {
-           posA += forceparams[type].posres.pos0A[d]*pbc->box[d][m];
-           posB += forceparams[type].posres.pos0B[d]*pbc->box[d][m];
-         }
-         ref      = (1 - lambda)*posA + lambda*posB;
-         rdist[m] = 0;
-         dpdl[m]  = posB - posA;
-         break;
-       case erscCOM:
-         ref      = (1 - lambda)*comA_sc[m] + lambda*comB_sc[m];
-         rdist[m] = (1 - lambda)*posA + lambda*posB;
-         dpdl[m]  = comB_sc[m] - comA_sc[m] + posB - posA;
-         break;
-       }
-      } else {
-       ref      = (1 - lambda)*posA + lambda*posB;
-       rdist[m] = 0;
-       dpdl[m]  = posB - posA;
-      }
+    npbcdim = ePBC2npbcdim(ePBC);
 
-      /* We do pbc_dx with ref+rdist,
-       * since with only ref we can be up to half a box vector wrong.
-       */
-      pos[m] = ref + rdist[m];
+    if (refcoord_scaling == erscCOM)
+    {
+        clear_rvec(comA_sc);
+        clear_rvec(comB_sc);
+        for(m=0; m<npbcdim; m++)
+        {
+            for(d=m; d<npbcdim; d++)
+            {
+                comA_sc[m] += comA[d]*pbc->box[d][m];
+                comB_sc[m] += comB[d]*pbc->box[d][m];
+            }
+        }
     }
 
-    if (pbc) {
-      pbc_dx(pbc,x[ai],pos,dx);
-    } else {
-      rvec_sub(x[ai],pos,dx);
-    }
+    L1 = 1.0 - lambda;
 
-    v=0;
-    for (m=0; (m<DIM); m++) {
-      *dvdlambda += harmonic(pr->posres.fcA[m],pr->posres.fcB[m],
-                            0,dpdl[m],dx[m],lambda,&v,&fm);
-      vtot += v;
-      f[ai][m] += fm;
+    vtot = 0.0;
+    for(i=0; (i<nbonds); )
+    {
+        type = forceatoms[i++];
+        ai   = forceatoms[i++];
+        pr   = &forceparams[type];
+        
+        for(m=0; m<DIM; m++)
+        {
+            posA = forceparams[type].posres.pos0A[m];
+            posB = forceparams[type].posres.pos0B[m];
+            if (m < npbcdim)
+            {
+                switch (refcoord_scaling)
+                {
+                case erscNO:
+                    ref      = 0;
+                    rdist[m] = L1*posA + lambda*posB;
+                    dpdl[m]  = posB - posA;
+                    break;
+                case erscALL:
+                    /* Box relative coordinates are stored for dimensions with pbc */
+                    posA *= pbc->box[m][m];
+                    posB *= pbc->box[m][m];
+                    for(d=m+1; d<npbcdim; d++)
+                    {
+                        posA += forceparams[type].posres.pos0A[d]*pbc->box[d][m];
+                        posB += forceparams[type].posres.pos0B[d]*pbc->box[d][m];
+                    }
+                    ref      = L1*posA + lambda*posB;
+                    rdist[m] = 0;
+                    dpdl[m]  = posB - posA;
+                    break;
+                case erscCOM:
+                    ref      = L1*comA_sc[m] + lambda*comB_sc[m];
+                    rdist[m] = L1*posA       + lambda*posB;
+                    dpdl[m]  = comB_sc[m] - comA_sc[m] + posB - posA;
+                    break;
+                }
+            }
+            else
+            {
+                ref      = L1*posA + lambda*posB;
+                rdist[m] = 0;
+                dpdl[m]  = posB - posA;
+            }
+
+            /* We do pbc_dx with ref+rdist,
+             * since with only ref we can be up to half a box vector wrong.
+             */
+            pos[m] = ref + rdist[m];
+        }
 
-      /* Here we correct for the pbc_dx which included rdist */
-      vir_diag[m] -= 0.5*(dx[m] + rdist[m])*fm;
+        if (pbc)
+        {
+            pbc_dx(pbc,x[ai],pos,dx);
+        }
+        else
+        {
+            rvec_sub(x[ai],pos,dx);
+        }
+
+        for (m=0; (m<DIM); m++)
+        {
+            kk          = L1*pr->posres.fcA[m] + lambda*pr->posres.fcB[m];
+            fm          = -kk*dx[m];
+            f[ai][m]   += fm;
+            vtot       += 0.5*kk*dx[m]*dx[m];
+            *dvdlambda +=
+                0.5*(pr->posres.fcB[m] - pr->posres.fcA[m])*dx[m]*dx[m]
+                -fm*dpdl[m];
+
+            /* Here we correct for the pbc_dx which included rdist */
+            vir_diag[m] -= 0.5*(dx[m] + rdist[m])*fm;
+        }
     }
-  }
 
-  return vtot;
+    return vtot;
 }
 
 static real low_angres(int nbonds,
index de875f327940851a31c26996ee1f8ea00208f22c..c2f8e3fbc030e7e77c70ad6044cd448100363af5 100644 (file)
@@ -52,8 +52,8 @@ void calc_chargegroup_radii(const gmx_mtop_t *mtop,rvec *x,
                             real *rcoul1,real *rcoul2)
 {
     real r2v1,r2v2,r2c1,r2c2,r2;
-    int  mb,m,cg,a_mol,a0,a1,a;
-    t_iparams *ip;
+    int  ntype,i,j,mb,m,cg,a_mol,a0,a1,a;
+    gmx_bool *bLJ;
     gmx_molblock_t *molb;
     gmx_moltype_t *molt;
     t_block *cgs;
@@ -65,7 +65,20 @@ void calc_chargegroup_radii(const gmx_mtop_t *mtop,rvec *x,
     r2c1 = 0;
     r2c2 = 0;
 
-    ip = mtop->ffparams.iparams;
+    ntype = mtop->ffparams.atnr;
+    snew(bLJ,ntype);
+    for(i=0; i<ntype; i++)
+    {
+        bLJ[i] = FALSE;
+        for(j=0; j<ntype; j++)
+        {
+            if (mtop->ffparams.iparams[i*ntype+j].lj.c6  != 0 ||
+                mtop->ffparams.iparams[i*ntype+j].lj.c12 != 0)
+            {
+                bLJ[i] = TRUE;
+            }
+        }
+    }
 
     a_mol = 0;
     for(mb=0; mb<mtop->nmolblock; mb++)
@@ -91,11 +104,8 @@ void calc_chargegroup_radii(const gmx_mtop_t *mtop,rvec *x,
                     for(a=a0; a<a1; a++)
                     {
                         r2 = distance2(cen,x[a_mol+a]);
-                        if (r2 > r2v2 &&
-                            (ip[atom[a].type ].lj.c6  != 0 ||
-                             ip[atom[a].type ].lj.c12 != 0 ||
-                             ip[atom[a].typeB].lj.c6  != 0 ||
-                             ip[atom[a].typeB].lj.c12 != 0))
+                        if (r2 > r2v2 && (bLJ[atom[a].type ] ||
+                                          bLJ[atom[a].typeB]))
                         {
                             if (r2 > r2v1)
                             {
@@ -127,6 +137,8 @@ void calc_chargegroup_radii(const gmx_mtop_t *mtop,rvec *x,
         }
     }
 
+    sfree(bLJ);
+
     *rvdw1  = sqrt(r2v1);
     *rvdw2  = sqrt(r2v2);
     *rcoul1 = sqrt(r2c1);
index 0b126131d0050f63df1ee44637a2cf1e210ff0cf..3185bec20f5d8aa66e6284a9453b76612b7529cc 100644 (file)
@@ -101,7 +101,8 @@ enum { eenhENERGY_N, eenhENERGY_AVER, eenhENERGY_SUM, eenhENERGY_NSUM,
        eenhENERGY_SUM_SIM, eenhENERGY_NSUM_SIM,
        eenhENERGY_NSTEPS, eenhENERGY_NSTEPS_SIM, 
        eenhENERGY_DELTA_H_NN,
-       eenhENERGY_DELTA_H_LIST, eenhENERGY_DELTA_H_STARTTIME, 
+       eenhENERGY_DELTA_H_LIST, 
+       eenhENERGY_DELTA_H_STARTTIME, 
        eenhENERGY_DELTA_H_STARTLAMBDA, 
        eenhNR };
 
@@ -111,7 +112,8 @@ const char *eenh_names[eenhNR]=
     "energy_sum_sim", "energy_nsum_sim",
     "energy_nsteps", "energy_nsteps_sim", 
     "energy_delta_h_nn",
-    "energy_delta_h_list", "energy_delta_h_start_time", 
+    "energy_delta_h_list", 
+    "energy_delta_h_start_time", 
     "energy_delta_h_start_lambda"
 };
 
@@ -957,6 +959,7 @@ static int do_cpt_enerhist(XDR *xd,gmx_bool bRead,
             snew(enerhist->dht,1);
             enerhist->dht->ndh = NULL;
             enerhist->dht->dh = NULL;
+            enerhist->dht->start_lambda_set=FALSE;
         }
     }
 
@@ -996,6 +999,7 @@ static int do_cpt_enerhist(XDR *xd,gmx_bool bRead,
                     ret=do_cpte_double(xd, 2, i, fflags, &(enerhist->dht->start_time), list); break;
                 case eenhENERGY_DELTA_H_STARTLAMBDA: 
                     ret=do_cpte_double(xd, 2, i, fflags, &(enerhist->dht->start_lambda), list); break;
+                    enerhist->dht->start_lambda_set=TRUE;
                 default:
                     gmx_fatal(FARGS,"Unknown energy history entry %d\n"
                               "You are probably reading a new checkpoint file with old code",i);
@@ -1226,7 +1230,8 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep,
         {
             flags_enh |= ( (1<< eenhENERGY_DELTA_H_NN) |
                            (1<< eenhENERGY_DELTA_H_LIST) | 
-                           (1<< eenhENERGY_DELTA_H_STARTTIME) );
+                           (1<< eenhENERGY_DELTA_H_STARTTIME) |
+                           (1<< eenhENERGY_DELTA_H_STARTLAMBDA) );
         }
     }
 
@@ -1595,9 +1600,16 @@ static void read_checkpoint(const char *fn,FILE **pfplog,
                                                  "You can try with the -noappend option, and get more info in the log file.\n");
                        }
                        
-            fprintf(stderr,
-                    "WARNING: The checkpoint state entries do not match the simulation,\n"
-                    "         see the log file for details\n\n");
+            if (getenv("GMX_ALLOW_CPT_MISMATCH") == NULL)
+            {
+                gmx_fatal(FARGS,"You seem to have switched ensemble, integrator, T and/or P-coupling algorithm between the cpt and tpr file. The recommended way of doing this is passing the cpt file to grompp (with option -t) instead of to mdrun. If you know what you are doing, you can override this error by setting the env.var. GMX_ALLOW_CPT_MISMATCH");
+            }
+            else
+            {
+                fprintf(stderr,
+                        "WARNING: The checkpoint state entries do not match the simulation,\n"
+                        "         see the log file for details\n\n");
+            }
         }
                
                if(fplog)
@@ -1733,16 +1745,19 @@ static void read_checkpoint(const char *fn,FILE **pfplog,
             if (outputfiles[i].chksum_size != -1)
             {
                 if (gmx_fio_get_file_md5(chksum_file,outputfiles[i].offset,
-                                     digest) != outputfiles[i].chksum_size)
+                                     digest) != outputfiles[i].chksum_size)  /*at the end of the call the file position is at the end of the file*/
                 {
                     gmx_fatal(FARGS,"Can't read %d bytes of '%s' to compute checksum. The file has been replaced or its contents has been modified.",
                               outputfiles[i].chksum_size, 
                               outputfiles[i].filename);
                 }
             } 
-            else if (i==0)  /*log file need to be seeked even when not reading md5*/
+            if (i==0)  /*log file needs to be seeked in case we need to truncate (other files are truncated below)*/
             {
-                gmx_fio_seek(chksum_file,outputfiles[i].offset);
+                if (gmx_fio_seek(chksum_file,outputfiles[i].offset))
+                {
+                       gmx_fatal(FARGS,"Seek error! Failed to truncate log-file: %s.", strerror(errno));
+                }
             }
 #endif
             
index da593c9d3a31264912ff8bf1be2f1dee77fd9934..f06e09892c0c043c648a333adfcd82d10cc11cd7 100644 (file)
@@ -890,14 +890,14 @@ char *low_gmxlibfn(const char *file, gmx_bool bAddCWD, gmx_bool bFatal)
             {
                 gmx_fatal(FARGS,
                           "Library file %s not found %sin your GMXLIB path.",
-                          bAddCWD ? "in current dir nor " : "",file);
+                          file, bAddCWD ? "in current dir nor " : "");
             }
             else
             {
                 gmx_fatal(FARGS,
                           "Library file %s not found %sin default directories.\n"
                         "(You can set the directories to search with the GMXLIB path variable)",
-                          bAddCWD ? "in current dir nor " : "",file);
+                          file, bAddCWD ? "in current dir nor " : "");
             }
         }
     }
index 93440bf3ba500c42e9ba824a286374a49fd9a4c7..ec412b686d2cf437b8b60f2a6369a8c736a8be61 100755 (executable)
@@ -14,7 +14,7 @@ if which git >/dev/null && test -d $GITDIR ; then
     # Git before 1.5.3 does not support any sensible date format,
     # so we need to massage the output.
     if git --git-dir=$GITDIR rev-list -n1 --pretty=format:%ci HEAD | grep '[0-9]\{4\}' >/dev/null 2>&1; then
-        date=`git --git-dir=$GITDIR rev-list -n1 --pretty=format:%ci HEAD | sed -ne '/commit/!{s/-\| .*$//g;p;}'`
+        date=`git --git-dir=$GITDIR rev-list -n1 --pretty=format:%ci HEAD | sed -ne '/commit/!{s/ .*$//;s/-//g;p;}'`
     else
         date=`git --git-dir=$GITDIR rev-list -n1 --pretty=format:%cD HEAD | \
               sed -ne '/commit/!{s/^.*, *\([ 0-9][0-9]\) \([a-zA-Z]*\) \([0-9]*\) .*$/\3\2\1/;y/ /0/;\
index 5ec8ff3151acbe5fe8c3734857705583d38b1859..832d6e0d2f4648e42b05adde472c07e21da787a7 100644 (file)
@@ -254,14 +254,14 @@ static void gmx_fio_set_iotype(t_fileio *fio)
 void gmx_fio_lock(t_fileio *fio)
 {
 #ifdef GMX_THREADS
-    tMPI_Spinlock_lock(&(fio->mtx));
+    tMPI_Lock_lock(&(fio->mtx));
 #endif
 }
 /* unlock the mutex associated with this fio.  */
 void gmx_fio_unlock(t_fileio *fio)
 {
 #ifdef GMX_THREADS
-    tMPI_Spinlock_unlock(&(fio->mtx));
+    tMPI_Lock_unlock(&(fio->mtx));
 #endif
 }
 
@@ -276,7 +276,7 @@ static void gmx_fio_make_dummy(void)
         open_files->next=open_files;
         open_files->prev=open_files;
 #ifdef GMX_THREADS
-        tMPI_Spinlock_init(&(open_files->mtx));
+        tMPI_Lock_init(&(open_files->mtx));
 #endif
     }
 }
@@ -491,7 +491,7 @@ t_fileio *gmx_fio_open(const char *fn, const char *mode)
 
     snew(fio, 1);
 #ifdef GMX_THREADS
-    tMPI_Spinlock_init(&(fio->mtx));
+    tMPI_Lock_init(&(fio->mtx));
 #endif
     bRead = (newmode[0]=='r' && newmode[1]!='+');
     bReadWrite = (newmode[1]=='+');
@@ -1087,7 +1087,7 @@ int gmx_fio_seek(t_fileio* fio, gmx_off_t fpos)
     gmx_fio_lock(fio);
     if (fio->fp)
     {
-        gmx_fseek(fio->fp, fpos, SEEK_SET);
+        rc = gmx_fseek(fio->fp, fpos, SEEK_SET);
     }
     else
     {
index 1ee685125e56143c21696e172f22950d10c669d7..d6bb34a9960593c1fb2cbc2d1bd58ff0c06928dc 100644 (file)
@@ -95,10 +95,10 @@ struct t_fileio
     t_fileio *next, *prev; /* next and previous file pointers in the
                               linked list */
 #ifdef GMX_THREADS
-    tMPI_Spinlock_t  mtx;  /* content locking mutex. This is a spinlock
-                              for performance reasons: in some cases every
-                              single byte that gets read/written requires
-                              a lock */
+    tMPI_Lock_t  mtx;  /* content locking mutex. This is a fast lock
+                          for performance reasons: in some cases every
+                          single byte that gets read/written requires
+                          a lock */
 #endif
 }; 
 
index 8808f4cf95a156b3eed6aa08bd8d5d2e2907f9f3..d0444c565be5bdf7e869df92cbfbad25af5bc675 100644 (file)
@@ -112,11 +112,11 @@ const t_interaction_function interaction_function[F_NRE]=
   def_bonded  ("PIDIHS",   "Improper Dih.",   4, 3, 3,  eNR_PROPER, pdihs         ),
   def_bondedt ("TABDIHS", "Tab. Dih.",        4, 2, 2,  eNR_TABDIHS, tab_dihs     ),
   def_bonded  ("CMAP",  "CMAP Dih.",          5, -1, -1,  eNR_CMAP,   unimplemented ),
-  def_bonded  ("GB12",     "GB 1-2 Pol.",     2, 2, 2,  eNR_GB,     unimplemented ),
-  def_bonded  ("GB13",     "GB 1-3 Pol.",     2, 2, 2,  eNR_GB,     unimplemented ),
-  def_bonded  ("GB14",     "GB 1-4 Pol.",     2, 2, 2,  eNR_GB,     unimplemented ),
+  def_bonded  ("GB12",     "GB 1-2 Pol.",     2, 4, 0,  eNR_GB,     unimplemented ),
+  def_bonded  ("GB13",     "GB 1-3 Pol.",     2, 4, 0,  eNR_GB,     unimplemented ),
+  def_bonded  ("GB14",     "GB 1-4 Pol.",     2, 4, 0,  eNR_GB,     unimplemented ),
   def_nofc    ("GBPOL",    "GB Polarization" ),
-  def_nofc    ("NPSOLVATION", "Nonpolar sol." ),
+  def_nofc    ("NPSOLVATION", "Nonpolar Sol." ),
   def_bondedz ("LJ14",     "LJ-14",           2, 2, 2,  eNR_NB14,   unimplemented ),
   def_nofc    ("COUL14",   "Coulomb-14"                                           ),
   def_bondedz ("LJC14_Q",  "LJC-14 q",        2, 5, 0,  eNR_NB14,   unimplemented ),
index 4156d70405edbf6f9d30b6dedb597edab3cc0df8..0cb96f65d215944c381281358b8eeaea56edd5c1 100644 (file)
@@ -662,6 +662,42 @@ gmx_residuetype_is_rna(gmx_residuetype_t rt, const char *resnm)
     return rc;
 }
 
+/* Return the size of the arrays */
+int
+gmx_residuetype_get_size(gmx_residuetype_t rt)
+{
+    return rt->n;
+}
+
+/* Search for a residuetype with name resnm within the
+ * gmx_residuetype database. Return the index if found,
+ * otherwise -1.
+ */
+int
+gmx_residuetype_get_index(gmx_residuetype_t rt, const char *resnm)
+{
+    int i,rc;
+
+    rc=-1;
+    for(i=0;i<rt->n && rc;i++)
+    {
+        rc=gmx_strcasecmp(rt->resname[i],resnm);
+    }
+
+    return (0 == rc) ? i-1 : -1;
+}
+
+/* Return the name of the residuetype with the given index, or
+ * NULL if not found. */
+const char *
+gmx_residuetype_get_name(gmx_residuetype_t rt, int index)
+{
+  if(index >= 0 && index < rt->n) {
+    return rt->resname[index];
+  } else {
+    return NULL;
+  }
+}
 
 
 
index 1e9ed0155c8469966758241ce18c56c4bc956f33..b50ded75b68478fffa99c586a93830d0a08e6ec9 100644 (file)
@@ -244,7 +244,11 @@ void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly,
         par_fn(tmpnm,efLOG,cr,FALSE,!bMasterOnly,buf,255);
         fp = gmx_fio_fopen(buf, bAppend ? "a+" : "w+" );
     }
+#ifdef GMX_FAHCORE
+    else if (!bAppend)
+#else
     else
+#endif
     {
         fp = gmx_fio_fopen(tmpnm, bAppend ? "a+" : "w+" );
     }
index 022f6f4619d36cb99093c90fed31b8ac0d530354..e77df3b11dfdceeeac24c7674cd12c90cc85ba6a 100644 (file)
@@ -217,7 +217,7 @@ void skipstr(char *line)
       line[c-i] = line[c];
       c++;
     }
-  line[i-c] = '\0';
+  line[c-i] = '\0';
 }
 
 char *line2string(char **line)
@@ -258,12 +258,12 @@ void parsestring(char *line,const char *label, char *string)
 void read_xpm_entry(FILE *in,t_matrix *mm)
 {
   t_mapping *map;
-  char *line=NULL,*str,buf[256];
+  char *line_buf=NULL,*line=NULL,*str,buf[256];
   int i,m,col_len,nch,n_axis_x,n_axis_y,llmax;
   int llalloc=0;
   unsigned int r,g,b;
   double u;
-  gmx_bool bGetOnWithIt;
+  gmx_bool bGetOnWithIt,bSetLine;
   t_xpmelmt c;
 
   mm->flags=0;
@@ -278,8 +278,9 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
 
   llmax = STRLEN;
 
-  while ((NULL != fgetline(&line,llmax,&llalloc,in)) && 
-         (strncmp(line,"static",6) != 0)) {
+  while ((NULL != fgetline(&line_buf,llmax,&llalloc,in)) && 
+         (strncmp(line_buf,"static",6) != 0)) {
+    line = line_buf;
     parsestring(line,"title",(mm->title));
     parsestring(line,"legend",(mm->legend));
     parsestring(line,"x-label",(mm->label_x));
@@ -297,7 +298,8 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
     gmx_input("Invalid XPixMap");
   /* Read sizes */
   bGetOnWithIt=FALSE;
-  while (!bGetOnWithIt && (NULL != fgetline(&line,llmax,&llalloc,in))) {
+  while (!bGetOnWithIt && (NULL != fgetline(&line_buf,llmax,&llalloc,in))) {
+    line = line_buf;
     while (( line[0] != '\"' ) && ( line[0] != '\0' ))
       line++;
 
@@ -317,8 +319,8 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
   /* Read color map */
   snew(map,mm->nmap);
   m=0;
-  while ((m < mm->nmap) && (NULL != fgetline(&line,llmax,&llalloc,in))) {
-    line=strchr(line,'\"');
+  while ((m < mm->nmap) && (NULL != fgetline(&line_buf,llmax,&llalloc,in))) {
+    line = strchr(line_buf,'\"');
     if  (line) {
       line++;
       /* Read xpm color map entry */
@@ -372,7 +374,11 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
   n_axis_x=0;
   n_axis_y=0;
   bGetOnWithIt=FALSE;
+  bSetLine=FALSE;
   do {
+    if (bSetLine)
+      line = line_buf;
+    bSetLine = TRUE;
     if (strstr(line,"x-axis")) {
       line=strstr(line,"x-axis");
       skipstr(line);
@@ -405,14 +411,18 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
        skipstr(line);
       }
     }
-  } while ((line[0] != '\"') && (NULL != fgetline(&line,llmax,&llalloc,in)));
+  } while ((line[0] != '\"') && (NULL != fgetline(&line_buf,llmax,&llalloc,in)));
 
   /* Read matrix */
   snew(mm->matrix,mm->nx);
   for(i=0; i<mm->nx; i++)
     snew(mm->matrix[i],mm->ny);
   m=mm->ny-1;
+  bSetLine = FALSE;
   do {
+    if (bSetLine)
+      line = line_buf;
+    bSetLine = TRUE;
     if(m%(1+mm->ny/100)==0) 
       fprintf(stderr,"%3d%%\b\b\b\b",(100*(mm->ny-m))/mm->ny);
     while ((line[0] != '\"') && (line[0] != '\0'))
@@ -431,7 +441,7 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
        }
       m--;
     }
-  } while ((m>=0) && (NULL != fgetline(&line,llmax,&llalloc,in)));
+  } while ((m>=0) && (NULL != fgetline(&line_buf,llmax,&llalloc,in)));
   if (m>=0)
     gmx_incons("Not enough rows in the matrix");
 
index a500b2ee692629e1b7a52f45b463b7b336e8fc8e..a876d4946bdb0852a4935f0b313e444b6d9d261a 100644 (file)
@@ -173,7 +173,7 @@ const char *egb_names[egbNR+1] = {
 };
 
 const char *esa_names[esaNR+1] = {
-  "No", "Ace-approximation", "Still", NULL
+  "Ace-approx", "None", "Still", NULL
 };
 
 const char *ewt_names[ewtNR+1] = {
index 89edd6daa1b45c10f4445318519e697bd82089d7..11e8068e4e6f7d30d8b862c60b21d290a22b3095 100644 (file)
@@ -38,7 +38,7 @@ libnb_kernel_power6_la_SOURCES = \
        nb_kernel323_power6.h nb_kernel324_power6.h nb_kernel330_power6.h nb_kernel331_power6.h \
        nb_kernel332_power6.h nb_kernel333_power6.h nb_kernel334_power6.h nb_kernel400_power6.h \
        nb_kernel410_power6.h nb_kernel420_power6.h nb_kernel430_power6.h                       \
-       nb_kernel_power6.c    nb_kernel_power6.h    nb_kernel_f77sync.c                         \
+       nb_kernel_power6.c    nb_kernel_power6.h    nb_kernel_pwr6sync.c                         \
        pwr6kernel010.F       pwr6kernel020.F       pwr6kernel030.F       pwr6kernel100.F       \
        pwr6kernel101.F       pwr6kernel102.F       pwr6kernel103.F       pwr6kernel104.F       \
        pwr6kernel110.F       pwr6kernel111.F       pwr6kernel112.F       pwr6kernel113.F       \
similarity index 98%
rename from src/gmxlib/nonbonded/nb_kernel_power6/nb_kernel_f77sync.c
rename to src/gmxlib/nonbonded/nb_kernel_power6/nb_kernel_pwr6sync.c
index d5b3b03763e78d0ccf21a6856f4eea9be65a56d4..b3b9354b7dde8bc9ba881acd7dbfe69d0854e4b6 100644 (file)
@@ -37,6 +37,7 @@
 #include <pthread.h>
 #endif
 
+#include <stdio.h>
 
 /*! \brief Lock innerloop mutex and read lists indices
  *
@@ -77,7 +78,7 @@
  *          Gromacs without any Fortran nonbonded kernels.
  */
 void 
-F77_FUNC(f77kernelsync,F77KERNELSYNC)
+F77_FUNC(pwr6kernelsync,PWR6KERNELSYNC)
      (int *       mtx,
       int *       count,
       int *       nri,
@@ -86,6 +87,8 @@ F77_FUNC(f77kernelsync,F77KERNELSYNC)
       int *       nn1)
 {
   int n0,n1;
+        
+    
 #ifdef HAVE_PTHREADS_H  
   pthread_mutex_lock((pthread_mutex_t *)mtx);
 #endif
@@ -96,7 +99,6 @@ F77_FUNC(f77kernelsync,F77KERNELSYNC)
 #ifdef HAVE_PTHREADS_H
   pthread_mutex_unlock((pthread_mutex_t *)mtx);
 #endif
-  n0              = *count;
   *nn0            = n0;
   *nn1            = n1;
 }
index 0c2176245b943ac6585e538228df27a8ea72558a..ab2048844bca0e2c74b13c4940722f90d921326d 100644 (file)
@@ -110,7 +110,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -301,7 +301,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index e4307c33be1cc4a5382dea808a63a07028f1ed31..84d0a4eed95a867b06a3272f16be6897ed61eaa3 100644 (file)
@@ -110,7 +110,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -316,7 +316,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index e5052e1a2dde39b5e97a6e1376a1d8e8a4f1dedf..514351c7e69c569e21631720353760eb35de4a9c 100644 (file)
@@ -113,7 +113,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -345,7 +345,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 91d04529619040f788dad40cf86e3a63664de808..0c6bcb2ba661a8b5b6d64c733873d158ff42e8f5 100644 (file)
@@ -106,7 +106,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -301,7 +301,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 7c304adccc346e77e3732321329aeb68a036db6e..4b5b606ebbd2de8adb5b92ba266c92e7d455c1b9 100644 (file)
@@ -117,7 +117,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -420,7 +420,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 5495ce98e6c82c9be1c8724b60bb6bea7c1d7eb5..db9b7b301125819994ba82ccbba5cb08acbea7ce 100644 (file)
@@ -127,7 +127,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -692,7 +692,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 5dac8be9d5916be404bda1efe95a168441df92da..bf47d6eff5863f09e857348445c859b59bce963f 100644 (file)
@@ -117,7 +117,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -420,7 +420,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 0d6e3f86a0f9d0ef3789274ca0eb1a1faa86abab..1682d876e47402f8af7981c8eb60b980fac50567 100644 (file)
@@ -127,7 +127,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -692,7 +692,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index b89c66e76200a22d426fd73e11ae443f0477de9b..246e40e39875266b8e90340dbf9c6959bc58dfb0 100644 (file)
@@ -112,7 +112,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -327,7 +327,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 37970caad8581f9f0984c89e3c6ecc696c05cf28..46d89adc07b2bde5da88c775c7ecaa6a7c224d25 100644 (file)
@@ -124,7 +124,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -447,7 +447,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 0f578d4227b8a0148501c274eec67730cb395414..9728d2a4f4f52ca2d0b26cb4224ffd84068c6e1c 100644 (file)
@@ -135,7 +135,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -718,7 +718,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 4e8438e8e8724e1f205da2b489122a5b00dda1ae..7dd4294b19a9eb625187369394532467b8246638 100644 (file)
@@ -126,7 +126,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -482,7 +482,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index b3004582d13561faec7c9cbe6e86e45ebb5be1f2..361023bba250e90cd93f915d0ee2f6f034ee8905 100644 (file)
@@ -138,7 +138,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -758,7 +758,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index efc4acbf85e9a4d4a645a552a183417dbfe0a5da..e2094101cf66f962886e431cc2aa6ebe3d39a59a 100644 (file)
@@ -112,7 +112,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -328,7 +328,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index c807ff0bd47626bfb4ebce0942000f47232bd9df..9a3b5460cdefeee73cfe610aeb15375998a0c9b3 100644 (file)
@@ -124,7 +124,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -448,7 +448,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index eb90b879f9f70b2c187a28a3f46d5b6eecee9da0..ee92763720197f552a714d692b869322761b4898 100644 (file)
@@ -136,7 +136,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -720,7 +720,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 8d1befb15826a779b2261ddebd878536e1ffe47c..936c5fd48c914cfcce1decc725107b088384b912 100644 (file)
@@ -126,7 +126,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -497,7 +497,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 55028560aff95275814579fed416878a0c6dfa94..9bdbebdc2f7338530cb2c5fe337c74a2fc862bcf 100644 (file)
@@ -139,7 +139,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -774,7 +774,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index e0cd39a0cd0b615f576eb891c00e20eee2c800ff..f29700f997bd2d4d59ebf7a745d5c0a173408cfa 100644 (file)
@@ -116,7 +116,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -360,7 +360,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 008067d2e7b6e8e4e4d6e81ab940a8bc3f8c433a..c0dbe2f80c3117fa6079107ddf3888c42c3404e0 100644 (file)
@@ -128,7 +128,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -480,7 +480,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 90dd4e86729d643cd04a3b1f101bbb5ffb443bfa..b291f90d966bf6ecf82ac87908e4f238144c80f0 100644 (file)
@@ -139,7 +139,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -751,7 +751,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index edec8c8854872ecb7075023b954247fb743ca297..f1f09aaeb821bad97de3bc8447f1e4dbf48bd739 100644 (file)
@@ -130,7 +130,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -527,7 +527,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 2b9c6fd8903b06a46432f28cf9e444c36a419260..28076ff75767790fdb33df7c4bae59d0de8f24a6 100644 (file)
@@ -142,7 +142,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -803,7 +803,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 242bbc38864aa3ea0f1e263d3b419e8b7fffe5ef..52d591afe6d2d38b94561e392952c7fe08db7107 100644 (file)
@@ -107,7 +107,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -304,7 +304,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index be7993cb69f0a3dfe191e0e15f01564fc36e8340..049cd0d5a301111c30af9d2139d01ad86263c7ee 100644 (file)
@@ -118,7 +118,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -425,7 +425,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 89823223432c97cc57a9f9e45c23824644701d14..d58d76afe57bd26c0ca52b85ee073a42c38eaaa4 100644 (file)
@@ -128,7 +128,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -703,7 +703,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index a47f9e584a678c74fd43647676c96aa43eda002f..4e71111fdecd3146eb6723c42f6b9d567e4cd9fa 100644 (file)
@@ -118,7 +118,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -425,7 +425,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 2bd2f4106ba79d7c17a8b4e987c0f8856157347b..5957385773ce38544261f6cdef609257cbf2a757 100644 (file)
@@ -128,7 +128,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -703,7 +703,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 5689bdbe8fd91fba3460f09379707b21c9d84ebf..0f829a120ad3ed80ba77b8c656b41a584bca544a 100644 (file)
@@ -113,7 +113,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -330,7 +330,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index b464d6b8789379eb0925ab62bbd71ae2df16d55c..d70de16c69f98fe6b6fcd0d6fd6ef6b83bfeaf32 100644 (file)
@@ -125,7 +125,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -452,7 +452,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index e3f550322d9a973cd11eef7dc1767d16f0bfe754..9b297cb7ae6670de364ec698a08d771369048ede 100644 (file)
@@ -136,7 +136,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -729,7 +729,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 3f3657e91a170e036c40c6adeefaf58aa55cb5dc..1c169fd3d74e4aa564af0e7ac69a37306daff9bc 100644 (file)
@@ -127,7 +127,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -487,7 +487,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index ab5152a66975ab9ff57f4b447c138f2b72ec5891..33229158cce315b8d8ce9f8d21c6fdf45d31715e 100644 (file)
@@ -139,7 +139,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -769,7 +769,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 19d71c4bbd3e3771a2788eb0d4f0326a42a452d6..b13ce6710ad23d40ff25d34b1eb8ca02694c38a8 100644 (file)
@@ -113,7 +113,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -332,7 +332,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 8c09ec4af72882f924293ad1a51fcfa0ba37e3aa..d97c26b1227f40daf95acb5c0cbd493a8fe7bbb3 100644 (file)
@@ -125,7 +125,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -454,7 +454,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 9db7b0dce5fa94ab292e25c7944f3e0a1a97fd95..edaa1b0c5aaf2a240834f4fcbf1e6fa4fd2c84b5 100644 (file)
@@ -137,7 +137,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -732,7 +732,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 7462107366c9619740c7f27cb1012d192e4c449d..83d88c71f70b41ed5c4cc62e960fd5d4df3b9641 100644 (file)
@@ -127,7 +127,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -502,7 +502,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 6ef862e67b915d1a3c5d0f44c25ad554a353f5df..88c7170bd61746e414f4958c0da95a8801cc8da5 100644 (file)
@@ -140,7 +140,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -785,7 +785,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 131242d39a68ba50e2e51296281d7422d706f887..004f622b9e03e0c654d0ba7b2207de322e722dc1 100644 (file)
@@ -117,7 +117,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -363,7 +363,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 2c952b69822be33649c1f4f444bf59a2eabdccf2..6b9034406685e9c95a57ef74546bf107cd73098f 100644 (file)
@@ -129,7 +129,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -485,7 +485,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index b6b01899d3d98cfaa27c4fd47f3c8c7db4179bf6..9f871429226b667e45ef3de31bfd2f9ab14d7892 100644 (file)
@@ -140,7 +140,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -762,7 +762,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 233f041a8fa9a8487a817f0c3dad82140992c945..12e1db12a8533c5e0430e43cc507f92280f03038 100644 (file)
@@ -131,7 +131,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -532,7 +532,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index d3340466f8870d75dbd6e9ea388fdb37c20d5dac..a2669f43c58ab44a6d044a635cf75415d7b01c31 100644 (file)
@@ -143,7 +143,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -814,7 +814,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index c6840f035ce5ec90c87779376152c983b3bb355c..ec1ef0896827caa3d81e1faed0870401dba918fe 100644 (file)
@@ -110,7 +110,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -325,7 +325,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index cb5f292792ef0151750981a07567775c0747ac63..163b205257f674bd8f070dca665fd5dfedcf7698 100644 (file)
@@ -121,7 +121,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -478,7 +478,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 418a00baffe26ee1149b3eff6f86a818b2c5f491..81724ac360efa8731877c344dc9c834b08b0beb6 100644 (file)
@@ -131,7 +131,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -852,7 +852,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 386b7ed33707abfd84cc90f078ffcd91b455cde5..c7d4466708b3711beafa41661e22914b6e4f9307 100644 (file)
@@ -121,7 +121,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -478,7 +478,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 302fd64d5dc09343f21a260750ea96af2600609f..ffef1c7a934f9b8912c50da9ea492cd006ddca2a 100644 (file)
@@ -131,7 +131,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -852,7 +852,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 4243d4f6f751d55d5b585919a7788055bf228af1..d3b00e41ddc546853dca9b604d79bb8fbca7abdc 100644 (file)
@@ -117,7 +117,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -353,7 +353,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index ff6e15a935fe20dd786d397f864fb1643dc817de..9d2c78b72ea6c2f68f45ac9218846cb70cda2aa3 100644 (file)
@@ -129,7 +129,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -507,7 +507,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index c346136ad2a0047872ec504e1b0167b9dd2ec2b9..60f4715ea2d5c1e15ebd3b12c87c49075cb85d11 100644 (file)
@@ -140,7 +140,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -880,7 +880,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 6a0c23ebf595bbae7faa5f2e07fa534a126a6e0f..e8364de65aabf972f795a59a434598be9d206211 100644 (file)
@@ -131,7 +131,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -541,7 +541,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 2c19abb093e89755e509aa7d7d91b2c30193a9df..90e66812f4d8101d655cb120498ea39dcd6e5d6e 100644 (file)
@@ -143,7 +143,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -919,7 +919,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 72ec41dc8ec6c895dcbe637514c1c8c3de42ded5..1fe105d343ba55fc022e816643c360ae90f0ec3c 100644 (file)
@@ -117,7 +117,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -355,7 +355,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index d17c8f70571eec053fa4bde9bd8e1dcbe2033ede..a75ae24969be7f54061a2022af5d85667b414e21 100644 (file)
@@ -129,7 +129,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -509,7 +509,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 1b9a211ac45b6a769f9f9c828f4931e988c8d424..2c62d0f51ce7f01646dbdf95273659800d04dd12 100644 (file)
@@ -141,7 +141,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -883,7 +883,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index ab19da760b3b35bc2261e1755a2852ec6fc54f92..979219dbcb35488a5f2a1bd83b19dba39206aff6 100644 (file)
@@ -131,7 +131,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -556,7 +556,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 2cd1d03647b3beb27438e9833e5facc38915adf1..e6f35c1d48c0a85807eff24ce7152e1a1a403593 100644 (file)
@@ -144,7 +144,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -935,7 +935,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index b8324de7d461cfb147fc284d2f7d23bbd44a895d..7a489e8d0c966acbc90eee4cec9ecf3c216686a8 100644 (file)
@@ -116,7 +116,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -367,7 +367,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index db9dc7830fd0922c494286e96b0a46d4d2ac060a..d99f08a69e814600660395a6f60cb281229f4777 100644 (file)
@@ -128,7 +128,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -521,7 +521,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index b892a3704bc8eb5ff0a67f381d3ef508c3d61c90..d7e14d6e130eb5da6bc4893835ab566d4a7a5e1f 100644 (file)
@@ -139,7 +139,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -894,7 +894,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index af24c785ab5f7322644ef137343db0620183fdf6..9cff142642db108b91306ae9ab4a6c9918beb727 100644 (file)
@@ -130,7 +130,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -579,7 +579,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 65450d8aafdc261ddf62a594d55e092e77b61edb..1fe06097d0fb8ae6bde173a2b3d3c64619039a7a 100644 (file)
@@ -142,7 +142,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -957,7 +957,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 1412fb4abe1aee801cdc4a399ad071f25f0ff047..144add863de5d7288f80acbc8bf10f29370ede60 100644 (file)
@@ -112,7 +112,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -339,7 +339,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 6162713dbcb28f45c5627ee1f56e9a25f612441a..c9e07b7bc776d76844b6e38e3ed15415c9d6dae9 100644 (file)
@@ -119,7 +119,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -367,7 +367,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index b872a9bc59076791644ea61e3c636e1d8a817094..33f751ca6952d071c213019a85b74cbcb0c7a0a4 100644 (file)
@@ -119,7 +119,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -369,7 +369,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 4bd20b597bdb214ae12dba53bce665fef99c83d3..ee2c5d9b8744f35f8ba015b565e716fd1c1afc5a 100644 (file)
@@ -118,7 +118,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
@@ -391,7 +391,7 @@ C    Reset outer and inner iteration counters
       ninner           = 0               
 
 C    Loop over thread workunits
-   10 call f77kernelsync(mtx,count,nri,nthreads,nn0,nn1)
+   10 call pwr6kernelsync(mtx,count,nri,nthreads,nn0,nn1)
         if(nn1.gt.nri) nn1=nri
 
 C      Start outer loop over neighborlists
index 40ce78420c3edd2085c52da62acb2553935fc932..33342dd1b5c1328dce2a30b56714d45b5f4f2777 100644 (file)
@@ -436,7 +436,7 @@ static void read_anisou(char line[],int natom,t_atoms *atoms)
 
 void get_pdb_atomnumber(t_atoms *atoms,gmx_atomprop_t aps)
 {
-  int  i,atomnumber;
+  int  i,atomnumber,len;
   size_t k;
   char anm[6],anm_copy[6];
   char nc='\0';
@@ -448,8 +448,9 @@ void get_pdb_atomnumber(t_atoms *atoms,gmx_atomprop_t aps)
   for(i=0; (i<atoms->nr); i++) {
     strcpy(anm,atoms->pdbinfo[i].atomnm);
     strcpy(anm_copy,atoms->pdbinfo[i].atomnm);
+    len = strlen(anm);
     atomnumber = NOTSET;
-    if (anm[0] != ' ') {
+    if ((anm[0] != ' ') && ((len <=2) || ((len > 2) && !isdigit(anm[2])))) {
       anm_copy[2] = nc;
       if (gmx_atomprop_query(aps,epropElement,"???",anm_copy,&eval))
        atomnumber = gmx_nint(eval);
index 921cad3cccd2116cc979dbf983cf98ae140c5fe6..2da5106bab0aa7ad1c12fb2204b89e47ede16da5 100644 (file)
@@ -862,10 +862,6 @@ _gmx_sel_init_modifier(gmx_ana_selmethod_t *method, t_selexpr_param *params,
     if (!_gmx_sel_parse_params(params, mod->u.expr.method->nparams,
                                mod->u.expr.method->param, mod, scanner))
     {
-        if (mod->child != sel)
-        {
-            _gmx_selelem_free(sel);
-        }
         _gmx_selelem_free(mod);
         return NULL;
     }
@@ -1304,7 +1300,15 @@ _gmx_sel_append_selection(t_selelem *sel, t_selelem *last, yyscan_t scanner)
                     child = child->child;
                     if (child->type == SEL_SUBEXPRREF)
                     {
-                        child = child->child->child;
+                        child = child->child;
+                        /* Because most subexpression elements are created
+                         * during compilation, we need to check for them
+                         * explicitly here.
+                         */
+                        if (child->type == SEL_SUBEXPR)
+                        {
+                            child = child->child;
+                        }
                     }
                 }
                 /* For variable references, we should skip the
index 867719704f46c574986d14fd9993af2cbe4b5015..4d3a03b2cef6733e78fad79da5ee14c8b6c5c3a3 100644 (file)
@@ -91,14 +91,11 @@ typedef int tmpi_bool;
 **************************************************************************/
 
 
-/* Buffer structure. Every thread structure has several of these ready to
-   be used when the data transmission is small enough for double copying to 
-   occur (i.e. the size of the transmission is less than N*MAX_COPY_BUFFER_SIZE,
-   where N is the number of receiving threads).
-
-   These buffers come in two sizes: one pre-allocated to MAX_COPY_BUFFER_SIZE
-   (for point-to-point transmissions, and one pre-allocated to 
-   Nthreads*MAX_COPY_BUFFE_SIZE). */
+/* Buffer structure for collective communications. Every thread structure 
+   has several of these ready to be used when the collective data 
+   transmission is small enough for double copying to occur (i.e. the size 
+   of the transmission is less than N*MAX_COPY_BUFFER_SIZE, where N is the 
+   number of receiving threads).  */
 struct copy_buffer
 {
     void *buf; /* the actual buffer */
index 275cbf7ad5eca048a29703209b83b660f5a7b35b..e1e027223b4003ab7dd5c304c2312ab07de64af0 100644 (file)
@@ -66,7 +66,7 @@ void tMPI_Lock_init(tMPI_Lock_t *lock)
 
 void tMPI_Lock_lock(tMPI_Lock_t *lock)
 {
-    while(!tMPI_Spinlock_trylock(&(lock->lock)))
+    while(tMPI_Spinlock_trylock(&(lock->lock)))
     {
         TMPI_YIELD_WAIT(lock);
     }
index fbf7aa4982e25c9b7fa7c0df7a8d7213b2e0ad35..128e57fb2d5b256364cf5a165c5e04c5e3123819 100644 (file)
@@ -61,6 +61,7 @@ static gmx_bool ip_pert(int ftype,const t_iparams *ip)
     case F_ANGLES:
     case F_G96ANGLES:
     case F_IDIHS:
+    case F_PIDIHS:
         bPert = (ip->harmonic.rA  != ip->harmonic.rB ||
                  ip->harmonic.krA != ip->harmonic.krB);
         break;
index 8e4f3766f029722ed8b7edb0042ccdd12390baf6..fd30a89e0dc0c2c3e6b9a63b5b6f15d35528b21a 100644 (file)
@@ -439,6 +439,20 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir,gmx_bool bRead,
                        ir->sa_algorithm = esaAPPROX;
                }
                gmx_fio_do_real(fio,ir->sa_surface_tension);
+
+    /* Override sa_surface_tension if it is not changed in the mpd-file */
+    if(ir->sa_surface_tension<0)
+    {
+      if(ir->gb_algorithm==egbSTILL)
+      {
+        ir->sa_surface_tension = 0.0049 * 100 * CAL2JOULE;
+      }
+      else if(ir->gb_algorithm==egbHCT || ir->gb_algorithm==egbOBC)
+      {
+        ir->sa_surface_tension = 0.0054 * 100 * CAL2JOULE;
+      }
+    }
+    
        }
        else
        {
index e0ed319d33f37838a846fb19c934a1c6f6544d56..15a868e9967c7a8b07d2ba4b5fb2630f4f6e83d3 100644 (file)
@@ -211,12 +211,19 @@ gmx_bool read_next_vmd_frame(int status,t_trxframe *fr)
 #endif
 
     fr->bX = 1;
-    vec[0] = .1*ts.A; vec[1] = .1*ts.B; vec[2] = .1*ts.B;
+    fr->bBox = 1;
+    vec[0] = .1*ts.A; vec[1] = .1*ts.B; vec[2] = .1*ts.C;
     angle[0] = ts.alpha; angle[1] = ts.beta; angle[2] = ts.gamma; 
     matrix_convert(fr->box,vec,angle);
-    fr->bTime = 1;
-    fr->time = ts.physical_time;
-
+    if (fr->vmdplugin.api->abiversion>10)
+    {
+        fr->bTime = TRUE;
+        fr->time = ts.physical_time;
+    }
+    else
+    {
+        fr->bTime = FALSE;
+    }
 
 
     return 1;
@@ -334,16 +341,22 @@ int read_first_vmd_frame(int *status,const char *fn,t_trxframe *fr,int flags)
         return 0;
     }
 
-    if (fr->natoms < 1) {
-        fprintf(stderr, "\nNo atoms found by VMD plugin in %s.\n"
-            "Or format does not record number of atoms.\n", fn );
+    if (fr->natoms == MOLFILE_NUMATOMS_UNKNOWN) {
+        fprintf(stderr, "\nFormat of file %s does not record number of atoms.\n", fn);
+        return 0;
+    } else if (fr->natoms == MOLFILE_NUMATOMS_NONE) {
+        fprintf(stderr, "\nNo atoms found by VMD plugin in file %s.\n", fn );
+        return 0;
+    } else if (fr->natoms < 1) { /*should not be reached*/
+        fprintf(stderr, "\nUnknown number of atoms %d for VMD plugin opening file %s.\n",
+                fr->natoms, fn );
         return 0;
     }
     
     snew(fr->x,fr->natoms);
 
     fr->vmdplugin.bV = 0;
-    if (fr->vmdplugin.api->read_timestep_metadata) 
+    if (fr->vmdplugin.api->abiversion > 10 && fr->vmdplugin.api->read_timestep_metadata)
     {
         fr->vmdplugin.api->read_timestep_metadata(fr->vmdplugin.handle, metadata);
         fr->vmdplugin.bV = metadata->has_velocities; 
index 52a36a86901109ae57d22e60bd0baf0b40e082b9..9d46825ce866b35017204abf6b78d704676e8093 100644 (file)
@@ -35,7 +35,7 @@ set(GMXPREPROCESS_SOURCES
 set(MDRUN_SOURCES 
     gctio.c    ionize.c runner.c
     do_gct.c     repl_ex.c  xutils.c
-    md.c         mdrun.c    genalg.c gmx_membed.c
+    md.c         mdrun.c    genalg.c membed.c
     md_openmm.c)
 
 add_library(gmxpreprocess ${GMXPREPROCESS_SOURCES})
@@ -57,8 +57,10 @@ if(GMX_OPENMM)
         add_definitions( -DOPENMM_PLUGIN_DIR="" )
     endif()
     add_library(openmm_api_wrapper openmm_wrapper.cpp)
+    target_link_libraries(openmm_api_wrapper gmx gmx_gpu_utils ${OpenMM_LIBRARIES})
 #    remove_definitions( -DOPENMM_PLUGIN_DIR="${OpenMM_PLUGIN_DIR}" )  # TODO where should this go?!
     set(GMX_OPENMM_LIBRARIES openmm_api_wrapper gmx_gpu_utils ${OpenMM_LIBRARIES})   
+       install(TARGETS openmm_api_wrapper DESTINATION ${LIB_INSTALL_DIR})   
 endif(GMX_OPENMM)
 
 if(GMX_FAHCORE)
index 7a95444d5c7cd8f0e0037d2954736dffe8f5a3f9..40a8bf01cad0a941ec564eba524fd6e7f23e896d 100644 (file)
@@ -58,7 +58,7 @@ bin_PROGRAMS = \
 g_x2top_SOURCES = g_x2top.c nm2type.c g_x2top.h
 
 mdrun_SOURCES = \
-       gctio.c         gmx_membed.c    gmx_membed.h    \
+       gctio.c         membed.c        membed.h    \
        ionize.c        ionize.h        xmdrun.h        \
        do_gct.c        repl_ex.c       repl_ex.h       \
        xutils.c        runner.c        md.c            mdrun.c         \
index d6b6527baf3b22f678f566fd62f8f6d94697c3c0..25f4aa12dbea6eed2420b726abc6d3593a41f232 100644 (file)
@@ -33,5 +33,6 @@ else()
 endif()
 CUDA_BUILD_CLEAN_TARGET()
 
+target_link_libraries(gmx_gpu_utils gmx)
 install(TARGETS gmx_gpu_utils DESTINATION ${LIB_INSTALL_DIR})   
 
index aed0c930cc39b08a33955c47290de5bdb9c445b1..1de43620c65eb568864885596b879f0ff81f2372 100644 (file)
@@ -183,6 +183,145 @@ static void check_cg_sizes(const char *topfn,t_block *cgs,warninp_t wi)
     }
 }
 
+static void check_bonds_timestep(gmx_mtop_t *mtop,double dt,warninp_t wi)
+{
+    /* This check is not intended to ensure accurate integration,
+     * rather it is to signal mistakes in the mdp settings.
+     * A common mistake is to forget to turn on constraints
+     * for MD after energy minimization with flexible bonds.
+     * This check can also detect too large time steps for flexible water
+     * models, but such errors will often be masked by the constraints
+     * mdp options, which turns flexible water into water with bond constraints,
+     * but without an angle constraint. Unfortunately such incorrect use
+     * of water models can not easily be detected without checking
+     * for specific model names.
+     *
+     * The stability limit of leap-frog or velocity verlet is 4.44 steps
+     * per oscillational period.
+     * But accurate bonds distributions are lost far before that limit.
+     * To allow relatively common schemes (although not common with Gromacs)
+     * of dt=1 fs without constraints and dt=2 fs with only H-bond constraints
+     * we set the note limit to 10.
+     */
+    int       min_steps_warn=5;
+    int       min_steps_note=10;
+    t_iparams *ip;
+    int       molt;
+    gmx_moltype_t *moltype,*w_moltype;
+    t_atom    *atom;
+    t_ilist   *ilist,*ilb,*ilc,*ils;
+    int       ftype;
+    int       i,a1,a2,w_a1,w_a2,j;
+    real      twopi2,limit2,fc,re,m1,m2,period2,w_period2;
+    gmx_bool  bFound,bWater,bWarn;
+    char      warn_buf[STRLEN];
+
+    ip = mtop->ffparams.iparams;
+
+    twopi2 = sqr(2*M_PI);
+
+    limit2 = sqr(min_steps_note*dt);
+
+    w_moltype = NULL;
+    for(molt=0; molt<mtop->nmoltype; molt++)
+    {
+        moltype = &mtop->moltype[molt];
+        atom  = moltype->atoms.atom;
+        ilist = moltype->ilist;
+        ilc = &ilist[F_CONSTR];
+        ils = &ilist[F_SETTLE];
+        for(ftype=0; ftype<F_NRE; ftype++)
+        {
+            if (!(ftype == F_BONDS || ftype == F_G96BONDS || ftype == F_HARMONIC))
+            {
+                continue;
+            }
+            
+            ilb = &ilist[ftype];
+            for(i=0; i<ilb->nr; i+=3)
+            {
+                fc = ip[ilb->iatoms[i]].harmonic.krA;
+                re = ip[ilb->iatoms[i]].harmonic.rA;
+                if (ftype == F_G96BONDS)
+                {
+                    /* Convert squared sqaure fc to harmonic fc */
+                    fc = 2*fc*re;
+                }
+                a1 = ilb->iatoms[i+1];
+                a2 = ilb->iatoms[i+2];
+                m1 = atom[a1].m;
+                m2 = atom[a2].m;
+                if (fc > 0 && m1 > 0 && m2 > 0)
+                {
+                    period2 = twopi2*m1*m2/((m1 + m2)*fc);
+                }
+                else
+                {
+                    period2 = GMX_FLOAT_MAX;
+                }
+                if (debug)
+                {
+                    fprintf(debug,"fc %g m1 %g m2 %g period %g\n",
+                            fc,m1,m2,sqrt(period2));
+                }
+                if (period2 < limit2)
+                {
+                    bFound = FALSE;
+                    for(j=0; j<ilc->nr; j+=3)
+                    {
+                        if ((ilc->iatoms[j+1] == a1 && ilc->iatoms[j+2] == a2) ||
+                            (ilc->iatoms[j+1] == a2 && ilc->iatoms[j+2] == a1))
+                            {
+                                bFound = TRUE;
+                            }
+                        }
+                    for(j=0; j<ils->nr; j+=2)
+                    {
+                        if ((a1 >= ils->iatoms[j+1] && a1 < ils->iatoms[j+1]+3) &&
+                            (a2 >= ils->iatoms[j+1] && a2 < ils->iatoms[j+1]+3))
+                        {
+                            bFound = TRUE;
+                        }
+                    }
+                    if (!bFound &&
+                        (w_moltype == NULL || period2 < w_period2))
+                    {
+                        w_moltype = moltype;
+                        w_a1      = a1;
+                        w_a2      = a2;
+                        w_period2 = period2;
+                    }
+                }
+            }
+        }
+    }
+    
+    if (w_moltype != NULL)
+    {
+        bWarn = (w_period2 < sqr(min_steps_warn*dt));
+        /* A check that would recognize most water models */
+        bWater = ((*w_moltype->atoms.atomname[0])[0] == 'O' &&
+                  w_moltype->atoms.nr <= 5);
+        sprintf(warn_buf,"The bond in molecule-type %s between atoms %d %s and %d %s has an estimated oscillational period of %.1e ps, which is less than %d times the time step of %.1e ps.\n"
+                "%s",
+                *w_moltype->name,
+                w_a1+1,*w_moltype->atoms.atomname[w_a1],
+                w_a2+1,*w_moltype->atoms.atomname[w_a2],
+                sqrt(w_period2),bWarn ? min_steps_warn : min_steps_note,dt,
+                bWater ?
+                "Maybe you asked for fexible water." :
+                "Maybe you forgot to change the constraints mdp option.");
+        if (bWarn)
+        {
+            warning(wi,warn_buf);
+        }
+        else
+        {
+            warning_note(wi,warn_buf);
+        }
+    }
+}
+
 static void check_vel(gmx_mtop_t *mtop,rvec v[])
 {
   gmx_mtop_atomloop_all_t aloop;
@@ -428,6 +567,45 @@ new_status(const char *topfile,const char *topppfile,const char *confin,
   *mi  = molinfo;
 }
 
+static void copy_state(const char *slog,t_trxframe *fr,
+                       gmx_bool bReadVel,t_state *state,
+                       double *use_time)
+{
+    int i;
+
+    if (fr->not_ok & FRAME_NOT_OK)
+    {
+        gmx_fatal(FARGS,"Can not start from an incomplete frame");
+    }
+    if (!fr->bX)
+    {
+        gmx_fatal(FARGS,"Did not find a frame with coordinates in file %s",
+                  slog);
+    }
+
+    for(i=0; i<state->natoms; i++)
+    {
+        copy_rvec(fr->x[i],state->x[i]);
+    }
+    if (bReadVel)
+    {
+        if (!fr->bV)
+        {
+            gmx_incons("Trajecory frame unexpectedly does not contain velocities");
+        }
+        for(i=0; i<state->natoms; i++)
+        {
+            copy_rvec(fr->v[i],state->v[i]);
+        }
+    }
+    if (fr->bBox)
+    {
+        copy_mat(fr->box,state->box);
+    }
+
+    *use_time = fr->time;
+}
+
 static void cont_status(const char *slog,const char *ener,
                        gmx_bool bNeedVel,gmx_bool bGenVel, real fr_time,
                        t_inputrec *ir,t_state *state,
@@ -435,55 +613,87 @@ static void cont_status(const char *slog,const char *ener,
                         const output_env_t oenv)
      /* If fr_time == -1 read the last frame available which is complete */
 {
-  t_trxframe  fr;
-  t_trxstatus *fp;
-
-  fprintf(stderr,
-         "Reading Coordinates%s and Box size from old trajectory\n",
-         (!bNeedVel || bGenVel) ? "" : ", Velocities");
-  if (fr_time == -1)
-    fprintf(stderr,"Will read whole trajectory\n");
-  else
-    fprintf(stderr,"Will read till time %g\n",fr_time);
-  if (!bNeedVel || bGenVel) {
-    if (bGenVel)
-      fprintf(stderr,"Velocities generated: "
-             "ignoring velocities in input trajectory\n");
-    read_first_frame(oenv,&fp,slog,&fr,TRX_NEED_X);
-  } else
-    read_first_frame(oenv,&fp,slog,&fr,TRX_NEED_X | TRX_NEED_V);
-  
-  state->natoms = fr.natoms;
+    gmx_bool bReadVel;
+    t_trxframe  fr;
+    t_trxstatus *fp;
+    int i;
+    double use_time;
 
-  if (sys->natoms != state->natoms)
-    gmx_fatal(FARGS,"Number of atoms in Topology "
-               "is not the same as in Trajectory");
+    bReadVel = (bNeedVel && !bGenVel);
 
-  /* Find the appropriate frame */
-  while ((fr_time == -1 || fr.time < fr_time) && read_next_frame(oenv,fp,&fr));
+    fprintf(stderr,
+            "Reading Coordinates%s and Box size from old trajectory\n",
+            bReadVel ? ", Velocities" : "");
+    if (fr_time == -1)
+    {
+        fprintf(stderr,"Will read whole trajectory\n");
+    }
+    else
+    {
+        fprintf(stderr,"Will read till time %g\n",fr_time);
+    }
+    if (!bReadVel)
+    {
+        if (bGenVel)
+        {
+            fprintf(stderr,"Velocities generated: "
+                    "ignoring velocities in input trajectory\n");
+        }
+        read_first_frame(oenv,&fp,slog,&fr,TRX_NEED_X);
+    }
+    else
+    {
+        read_first_frame(oenv,&fp,slog,&fr,TRX_NEED_X | TRX_NEED_V);
+        
+        if (!fr.bV)
+        {
+            fprintf(stderr,
+                    "\n"
+                    "WARNING: Did not find a frame with velocities in file %s,\n"
+                    "         all velocities will be set to zero!\n\n",slog);
+            for(i=0; i<sys->natoms; i++)
+            {
+                clear_rvec(state->v[i]);
+            }
+            close_trj(fp);
+            /* Search for a frame without velocities */
+            bReadVel = FALSE;
+            read_first_frame(oenv,&fp,slog,&fr,TRX_NEED_X);
+        }
+    }
+
+    state->natoms = fr.natoms;
+
+    if (sys->natoms != state->natoms)
+    {
+        gmx_fatal(FARGS,"Number of atoms in Topology "
+                  "is not the same as in Trajectory");
+    }
+    copy_state(slog,&fr,bReadVel,state,&use_time);
+
+    /* Find the appropriate frame */
+    while ((fr_time == -1 || fr.time < fr_time) &&
+           read_next_frame(oenv,fp,&fr))
+    {
+        copy_state(slog,&fr,bReadVel,state,&use_time);
+    }
   
-  close_trj(fp);
-
-  if (fr.not_ok & FRAME_NOT_OK)
-    gmx_fatal(FARGS,"Can not start from an incomplete frame");
-
-  state->x = fr.x;
-  if (bNeedVel && !bGenVel)
-    state->v = fr.v;
-  copy_mat(fr.box,state->box);
-  /* Set the relative box lengths for preserving the box shape.
-   * Note that this call can lead to differences in the last bit
-   * with respect to using tpbconv to create a tpx file.
-   */
-  set_box_rel(ir,state);
+    close_trj(fp);
 
-  fprintf(stderr,"Using frame at t = %g ps\n",fr.time);
-  fprintf(stderr,"Starting time for run is %g ps\n",ir->init_t); 
+    /* Set the relative box lengths for preserving the box shape.
+     * Note that this call can lead to differences in the last bit
+     * with respect to using tpbconv to create a tpx file.
+     */
+    set_box_rel(ir,state);
+
+    fprintf(stderr,"Using frame at t = %g ps\n",use_time);
+    fprintf(stderr,"Starting time for run is %g ps\n",ir->init_t); 
   
-  if ((ir->epc != epcNO  || ir->etc ==etcNOSEHOOVER) && ener) {
-    get_enx_state(ener,fr.time,&sys->groups,ir,state);
-    preserve_box_shape(ir,state->box_rel,state->boxv);
-  }
+    if ((ir->epc != epcNO  || ir->etc ==etcNOSEHOOVER) && ener)
+    {
+        get_enx_state(ener,use_time,&sys->groups,ir,state);
+        preserve_box_shape(ir,state->box_rel,state->boxv);
+    }
 }
 
 static void read_posres(gmx_mtop_t *mtop,t_molinfo *molinfo,gmx_bool bTopB,
@@ -1203,6 +1413,11 @@ int main (int argc, char *argv[])
       check_cg_sizes(ftp2fn(efTOP,NFILE,fnm),&sys->moltype[i].cgs,wi);
   }
 
+  if (EI_DYNAMICS(ir->eI) && ir->eI != eiBD)
+  {
+      check_bonds_timestep(sys,ir->delta_t,wi);
+  }
+
   check_warning_error(wi,FARGS);
        
   if (bVerbose) 
index 85463063468617205cd7b3e0dc379b9913a6b532..cdab2a7382e4e70fc56524df69ab87d35b74f17c 100644 (file)
@@ -89,7 +89,7 @@
 #include "checkpoint.h"
 #include "mtop_util.h"
 #include "sighandler.h"
-#include "gmx_membed.h"
+#include "membed.h"
 
 #ifdef GMX_LIB_MPI
 #include <mpi.h>
@@ -1860,7 +1860,7 @@ double do_md(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
          * or at the last step (but not when we do not want confout),
          * but never at the first step or with rerun.
          */
-        bCPT = (((gs.set[eglsCHKPT] && bNS) ||
+        bCPT = (((gs.set[eglsCHKPT] && (bNS || ir->nstlist == 0)) ||
                  (bLastStep && (Flags & MD_CONFOUT))) &&
                 step > ir->init_step && !bRerunMD);
         if (bCPT)
index 00f674b24ed2fd5eee4734ce6943a46972f3fb58..ce288475c8aefbddc50bc04fe4fb741818b5b774 100644 (file)
@@ -90,7 +90,7 @@
 #include "genborn.h"
 #include "string2.h"
 #include "copyrite.h"
-#include "gmx_membed.h"
+#include "membed.h"
 
 #ifdef GMX_THREADS
 #include "tmpi.h"
@@ -528,7 +528,7 @@ double do_md_openmm(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
 
             openmm_copy_state(openmmData, state, &t, f, enerd, bX, bV, bF, do_ene);
 
-            upd_mdebin(mdebin, FALSE,TRUE,
+            upd_mdebin(mdebin,FALSE,TRUE,
                        t,mdatoms->tmass,enerd,state,lastbox,
                        shake_vir,force_vir,total_vir,pres,
                        ekind,mu_tot,constr);
similarity index 99%
rename from src/kernel/gmx_membed.c
rename to src/kernel/membed.c
index debba53ab1aa52b984e2e4c22e95ff0fa823f881..039fabf76552074e17bb66a976f9cecf87737750 100644 (file)
@@ -55,7 +55,7 @@
 #include "mtop_util.h"
 #include "tpxio.h"
 #include "string2.h"
-#include "gmx_membed.h"
+#include "membed.h"
 #include "pbc.h"
 #include "readinp.h"
 
index 8c1cf816617d650212e7415bf94ecf5a32c10e44..46737516596eeab9947d25a79c9a4586f039f127 100644 (file)
@@ -637,12 +637,18 @@ void check_ir(const char *mdparin,t_inputrec *ir, t_gromppopts *opts,
            "setting implicit_solvent value to \"GBSA\" in input section.\n");
   }
 
+  if(ir->sa_algorithm==esaSTILL)
+  {
+    sprintf(err_buf,"Still SA algorithm not available yet, use %s or %s instead\n",esa_names[esaAPPROX],esa_names[esaNO]);
+    CHECK(ir->sa_algorithm == esaSTILL);
+  }
+  
   if(ir->implicit_solvent==eisGBSA)
   {
-      sprintf(err_buf,"With GBSA implicit solvent, rgbradii must be equal to rlist.");
-      CHECK(ir->rgbradii != ir->rlist);
+    sprintf(err_buf,"With GBSA implicit solvent, rgbradii must be equal to rlist.");
+    CHECK(ir->rgbradii != ir->rlist);
          
-         if(ir->coulombtype!=eelCUT)
+    if(ir->coulombtype!=eelCUT)
          {
                  sprintf(err_buf,"With GBSA, coulombtype must be equal to %s\n",eel_names[eelCUT]);
                  CHECK(ir->coulombtype!=eelCUT);
@@ -652,13 +658,37 @@ void check_ir(const char *mdparin,t_inputrec *ir, t_gromppopts *opts,
                  sprintf(err_buf,"With GBSA, vdw-type must be equal to %s\n",evdw_names[evdwCUT]);
                  CHECK(ir->vdwtype!=evdwCUT);
          }
-    
     if(ir->nstgbradii<1)
     {
       sprintf(warn_buf,"Using GBSA with nstgbradii<1, setting nstgbradii=1");
       warning_note(wi,warn_buf);
       ir->nstgbradii=1;
     }
+    if(ir->sa_algorithm==esaNO)
+    {
+      sprintf(warn_buf,"No SA (non-polar) calculation requested together with GB. Are you sure this is what you want?\n");
+      warning_note(wi,warn_buf);
+    }
+    if(ir->sa_surface_tension<0 && ir->sa_algorithm!=esaNO)
+    {
+      sprintf(warn_buf,"Value of sa_surface_tension is < 0. Changing it to 2.05016 or 2.25936 kJ/nm^2/mol for Still and HCT/OBC respectively\n");
+      warning_note(wi,warn_buf);
+      
+      if(ir->gb_algorithm==egbSTILL)
+      {
+        ir->sa_surface_tension = 0.0049 * CAL2JOULE * 100;
+      }
+      else
+      {
+        ir->sa_surface_tension = 0.0054 * CAL2JOULE * 100;
+      }
+    }
+    if(ir->sa_surface_tension==0 && ir->sa_algorithm!=esaNO)
+    {
+      sprintf(err_buf, "Surface tension set to 0 while SA-calculation requested\n");
+      CHECK(ir->sa_surface_tension==0 && ir->sa_algorithm!=esaNO);
+    }
+    
   }
 }
 
@@ -931,8 +961,8 @@ void get_ir(const char *mdparin,const char *mdparout,
   RTYPE ("gb_dielectric_offset", ir->gb_dielectric_offset, 0.009);
   EETYPE("sa_algorithm", ir->sa_algorithm, esa_names);
   CTYPE ("Surface tension (kJ/mol/nm^2) for the SA (nonpolar surface) part of GBSA");
-  CTYPE ("The default value (2.092) corresponds to 0.005 kcal/mol/Angstrom^2.");
-  RTYPE ("sa_surface_tension", ir->sa_surface_tension, 2.092);
+  CTYPE ("The value -1 will set default value for Still/HCT/OBC GB-models.");
+  RTYPE ("sa_surface_tension", ir->sa_surface_tension, -1);
                 
   /* Coupling stuff */
   CCTYPE ("OPTIONS FOR WEAK COUPLING ALGORITHMS");
@@ -1813,10 +1843,14 @@ void do_index(const char* mdparin, const char *ndx,
       for(i=0; (i<nr); i++)
       {
           ir->opts.tau_t[i] = strtod(ptr1[i],NULL);
-          if (ir->opts.tau_t[i] < 0)
+          if ((ir->eI == eiBD || ir->eI == eiSD2) && ir->opts.tau_t[i] <= 0)
+          {
+              sprintf(warn_buf,"With integrator %s tau_t should be larger than 0",ei_names[ir->eI]);
+              warning_error(wi,warn_buf);
+          }
+          if ((ir->etc == etcVRESCALE && ir->opts.tau_t[i] >= 0) || 
+              (ir->etc != etcVRESCALE && ir->opts.tau_t[i] >  0))
           {
-              gmx_fatal(FARGS,"tau_t for group %d negative",i);
-          } else if (ir->opts.tau_t[i] > 0) {
               tau_min = min(tau_min,ir->opts.tau_t[i]);
           }
       }
@@ -2269,7 +2303,7 @@ void triple_check(const char *mdparin,t_inputrec *ir,gmx_mtop_t *sys,
       warning(wi,err_buf);
     }
   } else {
-    if (ir->coulombtype == eelCUT && ir->rcoulomb > 0) {
+    if (ir->coulombtype == eelCUT && ir->rcoulomb > 0 && !ir->implicit_solvent) {
       sprintf(err_buf,
              "You are using a plain Coulomb cut-off, which might produce artifacts.\n"
              "You might want to consider using %s electrostatics.\n",
@@ -2484,11 +2518,10 @@ void check_chargegroup_radii(const gmx_mtop_t *mtop,const t_inputrec *ir,
              * not be zero at the cut-off.
              */
             if (EVDW_IS_ZERO_AT_CUTOFF(ir->vdwtype) &&
-                rvdw1 + rvdw2 > ir->rlistlong - ir->rvdw)
+                rvdw1 + rvdw2 > ir->rlist - ir->rvdw)
             {
-                sprintf(warn_buf,"The sum of the two largest charge group radii (%f) is larger than %s (%f) - rvdw (%f)\n",
+                sprintf(warn_buf,"The sum of the two largest charge group radii (%f) is larger than rlist (%f) - rvdw (%f)\n",
                         rvdw1+rvdw2,
-                        ir->rlistlong > ir->rlist ? "rlistlong" : "rlist",
                         ir->rlist,ir->rvdw);
                 if (ir_NVE(ir))
                 {
index d40bc968777486ae7117cd232aed94851e8fbebf..8bfc5cf17afa6db0f5736d79e63e12d418f11b99 100644 (file)
@@ -72,7 +72,7 @@
 #include "sighandler.h"
 #include "tpxio.h"
 #include "txtdump.h"
-#include "gmx_membed.h"
+#include "membed.h"
 
 #include "md_openmm.h"
 
@@ -256,13 +256,27 @@ static int get_nthreads(int nthreads_requested, t_inputrec *inputrec,
 {
     int nthreads,nthreads_new;
     int min_atoms_per_thread;
+    char *env;
 
     nthreads = nthreads_requested;
 
     /* determine # of hardware threads. */
     if (nthreads_requested < 1)
     {
-        nthreads = tMPI_Get_recommended_nthreads();
+        if ((env = getenv("GMX_MAX_THREADS")) != NULL)
+        {
+            nthreads = 0;
+            sscanf(env,"%d",&nthreads);
+            if (nthreads < 1)
+            {
+                gmx_fatal(FARGS,"GMX_MAX_THREADS (%d) should be larger than 0",
+                          nthreads);
+            }
+        }
+        else
+        {
+            nthreads = tMPI_Get_recommended_nthreads();
+        }
     }
 
     if (inputrec->eI == eiNM || EI_TPI(inputrec->eI))
index 24c982c726aba3249fefb642b1ed507bf4b6d094..4e291bd336ed132be27b8955f156110d22d38e55 100644 (file)
@@ -539,14 +539,20 @@ static char **read_topol(const char *infile,const char *outfile,
   char     *tmp_line=NULL;
   char       warn_buf[STRLEN];
 
-  /* open input and output file */
+  /* We need to open the output file before opening the input file,
+   * because cpp_open_file can change the current working directory.
+   */
+  if (outfile) {
+    out = gmx_fio_fopen(outfile,"w");
+  } else {
+    out = NULL;
+  }
+
+  /* open input file */
   status = cpp_open_file(infile,&handle,cpp_opts(define,include,infile,wi));
   if (status != 0) 
     gmx_fatal(FARGS,cpp_error(&handle,status));
-  if (outfile)
-    out = gmx_fio_fopen(outfile,"w");
-  else
-    out = NULL;
+
   /* some local variables */
   DS_Init(&DS);                        /* directive stack                       */
   nmol     = 0;                        /* no molecules yet...                   */
index d0cbd9c03351d62b340d129f7a329f974403405c..c5192aaee8a12b5c13019a3b9af2620bdc92aba0 100644 (file)
@@ -915,7 +915,7 @@ push_cmaptype(directive d, t_params bt[], int nral, gpp_atomtype_t at,
        int      i,j,ft,ftype,nn,nrfp,nrfpA,nrfpB;
        int      start;
        int      nxcmap,nycmap,ncmap,read_cmap,sl,nct;
-       char     s[20],alc[MAXATOMLIST+1][20];
+       char     s[20],alc[MAXATOMLIST+2][20];
        t_param  p;
        gmx_bool     bAllowRepeat;
        char     errbuf[256];
index 4e3054e0b87d9a9a12663a5f55f7a2cccca07359..0251d34232ef4a3a1202c149de27805e307c3004 100644 (file)
@@ -582,7 +582,7 @@ static void cmp_inputrec(FILE *fp,t_inputrec *ir1,t_inputrec *ir2,real ftol, rea
   cmp_real(fp,"inputrec->sc_sigma",-1,ir1->sc_sigma,ir2->sc_sigma,ftol,abstol);
   cmp_real(fp,"inputrec->sc_sigma_min",-1,ir1->sc_sigma_min,ir2->sc_sigma_min,ftol,abstol);
   cmp_int(fp,"inputrec->nstdhdl",-1,ir1->nstdhdl,ir2->nstdhdl);
-  cmp_int(fp,"inputrec->separate_dhdl_file",-1,ir1->separate_dhdl_file,ir2->nstdhdl);
+  cmp_int(fp,"inputrec->separate_dhdl_file",-1,ir1->separate_dhdl_file,ir2->separate_dhdl_file);
   cmp_int(fp,"inputrec->dhdl_derivatives",-1,ir1->dhdl_derivatives,ir2->dhdl_derivatives);
   cmp_int(fp,"inputrec->dh_hist_size",-1,ir1->dh_hist_size,ir2->dh_hist_size);
   cmp_double(fp,"inputrec->dh_hist_spacing",-1,ir1->dh_hist_spacing,ir2->dh_hist_spacing,ftol,abstol);
index 27888517e555e3e306146cc906c10ea015804eda..719938af7d6e4e669f849fad30ea235dfd6fd5d3 100644 (file)
@@ -265,7 +265,7 @@ void do_force_lowlevel(FILE       *fplog,   gmx_large_int_t step,
         * to the solvation forces */
        if (ir->implicit_solvent)  {
                calc_gb_forces(cr,md,born,top,atype,x,f,fr,idef,
-                       ir->gb_algorithm,nrnb,bBornRadii,&pbc,graph,enerd);
+                       ir->gb_algorithm,ir->sa_algorithm,nrnb,bBornRadii,&pbc,graph,enerd);
     }
 
 #ifdef GMX_MPI
index d4a860b1b9dc13ec7280ba92728d366ec077ba0d..325ab67156555c26a32fea5673271169e9bd526d 100644 (file)
@@ -502,7 +502,10 @@ int init_gb(gmx_genborn_t **p_born,
     born->epsilon_r = ir->epsilon_r;
     
     doffset = born->gb_doffset;
-    
+  
+    /* Set the surface tension */
+    born->sa_surface_tension = ir->sa_surface_tension;
+   
     /* If Still model, initialise the polarisation energies */
     if(gb_algorithm==egbSTILL)    
     {
@@ -1544,7 +1547,11 @@ real calc_gb_nonpolar(t_commrec *cr, t_forcerec *fr,int natoms,gmx_genborn_t *bo
         at1=natoms;
     }
     
-    /* The surface area factor is 0.0049 for Still model, 0.0054 for HCT/OBC */
+  /* factor is the surface tension */
+  factor = born->sa_surface_tension;
+  /*
+  
+    // The surface tension factor is 0.0049 for Still model, 0.0054 for HCT/OBC
     if(gb_algorithm==egbSTILL)
     {
         factor=0.0049*100*CAL2JOULE;
@@ -1553,7 +1560,7 @@ real calc_gb_nonpolar(t_commrec *cr, t_forcerec *fr,int natoms,gmx_genborn_t *bo
     {
         factor=0.0054*100*CAL2JOULE;    
     }
-    
+    */
     /* if(gb_algorithm==egbHCT || gb_algorithm==egbOBC) */
     
     es    = 0;
@@ -1704,7 +1711,7 @@ real calc_gb_chainrule(int natoms, t_nblist *nl, real *dadx, real *dvda, rvec x[
 
 void
 calc_gb_forces(t_commrec *cr, t_mdatoms *md, gmx_genborn_t *born, gmx_localtop_t *top, const t_atomtypes *atype, 
-               rvec x[], rvec f[], t_forcerec *fr, t_idef *idef, int gb_algorithm, t_nrnb *nrnb, gmx_bool bRad,
+               rvec x[], rvec f[], t_forcerec *fr, t_idef *idef, int gb_algorithm, int sa_algorithm, t_nrnb *nrnb, gmx_bool bRad,
                const t_pbc *pbc, const t_graph *graph, gmx_enerdata_t *enerd)
 {
     real v=0;
@@ -1718,11 +1725,14 @@ calc_gb_forces(t_commrec *cr, t_mdatoms *md, gmx_genborn_t *born, gmx_localtop_t
                pbc_null = pbc;
        else
                pbc_null = NULL;
-    
+  
+  if(sa_algorithm == esaAPPROX)
+  {
     /* Do a simple ACE type approximation for the non-polar solvation */
     enerd->term[F_NPSOLVATION] += calc_gb_nonpolar(cr, fr,born->nr, born, top, atype, fr->dvda, gb_algorithm,md);
-       
-    /* Calculate the bonded GB-interactions using either table or analytical formula */
+  }
+  
+  /* Calculate the bonded GB-interactions using either table or analytical formula */
     enerd->term[F_GBPOL]       += gb_bonds_tab(x,f,fr->fshift, md->chargeA,&(fr->gbtabscale),
                                      fr->invsqrta,fr->dvda,fr->gbtab.tab,idef,born->epsilon_r,born->gb_epsilon_solvent, fr->epsfac, pbc_null, graph);
     
index 8d8987a43d360a45951b65bd79622ee6cace09b4..70833bccf8ce19202fac3cb7d65ff122cd440ad4 100644 (file)
@@ -179,7 +179,9 @@ t_mdebin *init_mdebin(ener_file_t fp_ene,
         md->bEInd[i]=FALSE;
     }
 
-    for(i=0; i<F_NRE; i++) {
+#ifndef GMX_OPENMM
+    for(i=0; i<F_NRE; i++)
+    {
         md->bEner[i] = FALSE;
         if (i == F_LJ)
             md->bEner[i] = !bBHAM;
@@ -238,6 +240,13 @@ t_mdebin *init_mdebin(ener_file_t fp_ene,
         else
             md->bEner[i] = (gmx_mtop_ftype_count(mtop,i) > 0);
     }
+#else
+    /* OpenMM always produces only the following 4 energy terms */
+    md->bEner[F_EPOT] = TRUE;
+    md->bEner[F_EKIN] = TRUE;
+    md->bEner[F_ETOT] = TRUE;
+    md->bEner[F_TEMP] = TRUE;
+#endif
 
     md->f_nre=0;
     for(i=0; i<F_NRE; i++)
index a47aaecd7717a480fbba74edbacd0267105615b1..b34183f5512daeb17b7d99552ef1f7dcb93f27fd 100644 (file)
@@ -441,12 +441,6 @@ void mde_delta_h_coll_update_energyhistory(t_mde_delta_h_coll *dhc,
         snew(enerhist->dht->ndh, dhc->ndh);
         snew(enerhist->dht->dh, dhc->ndh);
         enerhist->dht->nndh=dhc->ndh;
-
-        /* these don't change during the simulation */
-        for(i=0;i<dhc->ndh;i++)
-        {
-            enerhist->dht->dh[i] = dhc->dh[i].dh;
-        }
     }
     else
     {
@@ -455,9 +449,11 @@ void mde_delta_h_coll_update_energyhistory(t_mde_delta_h_coll *dhc,
     }
     for(i=0;i<dhc->ndh;i++)
     {
+        enerhist->dht->dh[i] = dhc->dh[i].dh;
         enerhist->dht->ndh[i] = dhc->dh[i].ndh;
     }
     enerhist->dht->start_time=dhc->start_time;
+    enerhist->dht->start_lambda=dhc->start_lambda;
 }
 
 
@@ -483,7 +479,8 @@ void mde_delta_h_coll_restore_energyhistory(t_mde_delta_h_coll *dhc,
         }
     }
     dhc->start_time=enerhist->dht->start_time;
-    dhc->start_lambda=enerhist->dht->start_lambda;
+    if (enerhist->dht->start_lambda_set)
+        dhc->start_lambda=enerhist->dht->start_lambda;
     if (dhc->dh[0].ndh > 0)
         dhc->start_time_set=TRUE;
     else
index ebc766cbc8c9c34f9087e99637f90a0f03d70e6e..c11481d7577792c903af98bd9f91ae363505a688 100644 (file)
@@ -75,7 +75,7 @@
 #include "mtop_util.h"
 #include "gmxfio.h"
 #include "pme.h"
-#include "gmx_membed.h"
+#include "membed.h"
 
 typedef struct {
   t_state s;
index f4383f76900c563f96db59ca12426d5fe552de42..2a5ae3d18e828df7208bc2ab40c26de121538a0e 100644 (file)
@@ -162,11 +162,6 @@ double do_tpi(FILE *fplog,t_commrec *cr,
   gmx_bool bEnergyOutOfBounds;
   const char *tpid_leg[2]={"direct","reweighted"};
 
-  /* Since numerical problems can lead to extreme negative energies
-   * when atoms overlap, we need to set a lower limit for beta*U.
-   */
-  real bU_neg_limit = -50;
-
   /* Since there is no upper limit to the insertion energies,
    * we need to set an upper limit for the distribution output.
    */
@@ -401,7 +396,12 @@ double do_tpi(FILE *fplog,t_commrec *cr,
              mdatoms->nr,a_tp1-a_tp0);
 
   refvolshift = log(det(rerun_fr.box));
-  
+
+#if ( defined(GMX_IA32_SSE) || defined(GMX_X86_64_SSE) || defined(GMX_X86_64_SSE2) )
+    /* Make sure we don't detect SSE overflow generated before this point */
+    gmx_mm_check_and_reset_overflow();
+#endif
+
     while (bNotLastFrame)
     {
         lambda = rerun_fr.lambda;
@@ -599,10 +599,20 @@ double do_tpi(FILE *fplog,t_commrec *cr,
                 }
 #endif
                 /* If the compiler doesn't optimize this check away
-                 * we catch the NAN energies. With tables extreme negative
-                 * energies might occur close to r=0.
+                 * we catch the NAN energies.
+                 * The epot>GMX_REAL_MAX check catches inf values,
+                 * which should nicely result in embU=0 through the exp below,
+                 * but it does not hurt to check anyhow.
+                 */
+                /* Non-bonded Interaction usually diverge at r=0.
+                 * With tabulated interaction functions the first few entries
+                 * should be capped in a consistent fashion between
+                 * repulsion, dispersion and Coulomb to avoid accidental
+                 * negative values in the total energy.
+                 * The table generation code in tables.c does this.
+                 * With user tbales the user should take care of this.
                  */
-                if (epot != epot || epot*beta < bU_neg_limit)
+                if (epot != epot || epot > GMX_REAL_MAX)
                 {
                     bEnergyOutOfBounds = TRUE;
                 }
index dd8f475b81418c21f3865639280c1666b8da72ff..c410e244d09f8886bea00433e86979c2ba5df24f 100644 (file)
@@ -432,46 +432,64 @@ static gmx_stochd_t *init_stochd(FILE *fplog,t_inputrec *ir)
     int  ngtc,n;
     real y;
     
-  snew(sd,1);
+    snew(sd,1);
 
-  /* Initiate random number generator for langevin type dynamics,
-   * for BD, SD or velocity rescaling temperature coupling.
-   */
-  sd->gaussrand = gmx_rng_init(ir->ld_seed);
+    /* Initiate random number generator for langevin type dynamics,
+     * for BD, SD or velocity rescaling temperature coupling.
+     */
+    sd->gaussrand = gmx_rng_init(ir->ld_seed);
 
-  ngtc = ir->opts.ngtc;
+    ngtc = ir->opts.ngtc;
 
-  if (ir->eI == eiBD) {
-    snew(sd->bd_rf,ngtc);
-  } else if (EI_SD(ir->eI)) {
-    snew(sd->sdc,ngtc);
-    snew(sd->sdsig,ngtc);
+    if (ir->eI == eiBD)
+    {
+        snew(sd->bd_rf,ngtc);
+    }
+    else if (EI_SD(ir->eI))
+    {
+        snew(sd->sdc,ngtc);
+        snew(sd->sdsig,ngtc);
     
-    sdc = sd->sdc;
-    for(n=0; n<ngtc; n++) {
-      sdc[n].gdt = ir->delta_t/ir->opts.tau_t[n];
-      sdc[n].eph = exp(sdc[n].gdt/2);
-      sdc[n].emh = exp(-sdc[n].gdt/2);
-      sdc[n].em  = exp(-sdc[n].gdt);
-      if (sdc[n].gdt >= 0.05) {
-       sdc[n].b = sdc[n].gdt*(sdc[n].eph*sdc[n].eph - 1) 
-         - 4*(sdc[n].eph - 1)*(sdc[n].eph - 1);
-       sdc[n].c = sdc[n].gdt - 3 + 4*sdc[n].emh - sdc[n].em;
-       sdc[n].d = 2 - sdc[n].eph - sdc[n].emh;
-      } else {
-       y = sdc[n].gdt/2;
-       /* Seventh order expansions for small y */
-       sdc[n].b = y*y*y*y*(1/3.0+y*(1/3.0+y*(17/90.0+y*7/9.0)));
-       sdc[n].c = y*y*y*(2/3.0+y*(-1/2.0+y*(7/30.0+y*(-1/12.0+y*31/1260.0))));
-       sdc[n].d = y*y*(-1+y*y*(-1/12.0-y*y/360.0));
-      }
-      if(debug)
-       fprintf(debug,"SD const tc-grp %d: b %g  c %g  d %g\n",
-               n,sdc[n].b,sdc[n].c,sdc[n].d);
+        sdc = sd->sdc;
+        for(n=0; n<ngtc; n++)
+        {
+            if (ir->opts.tau_t[n] > 0)
+            {
+                sdc[n].gdt = ir->delta_t/ir->opts.tau_t[n];
+                sdc[n].eph = exp(sdc[n].gdt/2);
+                sdc[n].emh = exp(-sdc[n].gdt/2);
+                sdc[n].em  = exp(-sdc[n].gdt);
+            }
+            else
+            {
+                /* No friction and noise on this group */
+                sdc[n].gdt = 0;
+                sdc[n].eph = 1;
+                sdc[n].emh = 1;
+                sdc[n].em  = 1;
+            }
+            if (sdc[n].gdt >= 0.05)
+            {
+                sdc[n].b = sdc[n].gdt*(sdc[n].eph*sdc[n].eph - 1) 
+                    - 4*(sdc[n].eph - 1)*(sdc[n].eph - 1);
+                sdc[n].c = sdc[n].gdt - 3 + 4*sdc[n].emh - sdc[n].em;
+                sdc[n].d = 2 - sdc[n].eph - sdc[n].emh;
+            }
+            else
+            {
+                y = sdc[n].gdt/2;
+                /* Seventh order expansions for small y */
+                sdc[n].b = y*y*y*y*(1/3.0+y*(1/3.0+y*(17/90.0+y*7/9.0)));
+                sdc[n].c = y*y*y*(2/3.0+y*(-1/2.0+y*(7/30.0+y*(-1/12.0+y*31/1260.0))));
+                sdc[n].d = y*y*(-1+y*y*(-1/12.0-y*y/360.0));
+            }
+            if(debug)
+                fprintf(debug,"SD const tc-grp %d: b %g  c %g  d %g\n",
+                        n,sdc[n].b,sdc[n].c,sdc[n].d);
+        }
     }
-  }
 
-  return sd;
+    return sd;
 }
 
 void get_stochd_state(gmx_update_t upd,t_state *state)
index 0b05ab3670097d835c9bdba9826a62c5fd03cb22..18f8b7f6223a1bc5483e1d0f4afa843d8341f6d2 100644 (file)
@@ -29,7 +29,7 @@ add_library(gmxana
             gmx_editconf.c  gmx_genbox.c    gmx_genion.c    gmx_genconf.c   
             gmx_genpr.c     gmx_eneconv.c   gmx_vanhove.c   gmx_wheel.c     
             addconf.c       calcpot.c       edittop.c       gmx_bar.c
-            gmx_membed.c       gmx_pme_error.c )
+            gmx_pme_error.c    )
 
 
 target_link_libraries(gmxana md gmx)
@@ -51,7 +51,7 @@ set(GMX_TOOLS_PROGRAMS
     g_rmsf g_rotacf g_saltbr g_sas g_select g_sgangle g_sham g_sorient
     g_spol g_spatial g_tcaf g_traj g_tune_pme g_vanhove
     g_velacc g_clustsize g_mdmat g_wham g_sigeps g_bar
-    g_membed g_pme_error g_rmsdist g_rotmat)
+    g_pme_error g_rmsdist g_rotmat)
 
 
 
index aa5cc3445e0762411ddb06a80e8569c8c9c710a6..7ce8dbc44a866d36da77bf5689d0ee877096dfd1 100644 (file)
@@ -37,7 +37,7 @@ libgmxana@LIBSUFFIX@_la_SOURCES = \
        gmx_polystat.c  gmx_potential.c gmx_rama.c      \
        gmx_rdf.c       gmx_rms.c       gmx_rmsdist.c   gmx_rmsf.c      \
        gmx_rotacf.c    gmx_rotmat.c    gmx_saltbr.c    gmx_sas.c       \
-       gmx_select.c    gmx_pme_error.c \
+       gmx_select.c    gmx_pme_error.c gmx_membed.c    \
        gmx_sgangle.c   gmx_sorient.c   gmx_spol.c      gmx_tcaf.c      \
        gmx_traj.c      gmx_velacc.c    gmx_helixorient.c \
        gmx_clustsize.c gmx_mdmat.c     gmx_wham.c      eigio.h         \
@@ -64,7 +64,7 @@ bin_PROGRAMS = \
        g_enemat        g_energy        g_lie           g_filter        \
        g_gyrate        g_h2order       g_hbond         g_helix         \
        g_mindist       g_msd           g_morph         g_nmeig         \
-       g_nmens         g_order         \
+       g_nmens         g_order         g_membed        \
        g_polystat      g_potential     g_rama          \
        g_rdf           g_rms           g_rmsdist       g_rmsf          \
        g_rotacf        g_rotmat        g_saltbr        g_sas           \
index 5e3a4f2144267c73e6bca758f214fb41748b944f..70abce6e0388c2d057ba47c0e9a7641f2363d476 100644 (file)
@@ -509,7 +509,7 @@ real fit_acf(int ncorr,int fitfn,const output_env_t oenv,gmx_bool bVerbose,
             real tbeginfit,real tendfit,real dt,real c1[],real *fit)
 {
   real    fitparm[3];
-  real    tStart,tail_corr,sum,sumtot=0,ct_estimate,*sig;
+  real    tStart,tail_corr,sum,sumtot=0,c_start,ct_estimate,*sig;
   int     i,j,jmax,nf_int;
   gmx_bool    bPrint;
 
@@ -542,28 +542,54 @@ real fit_acf(int ncorr,int fitfn,const output_env_t oenv,gmx_bool bVerbose,
           "Fit from","Integral","Tail Value","Sum (ps)"," a1 (ps)",
           (nfp_ffn[fitfn]>=2) ? " a2 ()" : "",
           (nfp_ffn[fitfn]>=3) ? " a3 (ps)" : "");
-  if (tbeginfit > 0)
+
+  snew(sig,ncorr);
+
+  if (tbeginfit > 0) {
     jmax = 3;
-  else
-    jmax = 1;
-  if (fitfn == effnEXP3) {
-    fitparm[0] = 0.002*ncorr*dt;
-    fitparm[1] = 0.95;
-    fitparm[2] = 0.2*ncorr*dt;
   } else {
-    /* Good initial guess, this increases the probability of convergence */
-    fitparm[0] = ct_estimate;
-    fitparm[1] = 1.0;
-    fitparm[2] = 1.0;
+    jmax = 1;
   }
+  for(j=0; ((j<jmax) && (tStart < tendfit) && (tStart < ncorr*dt)); j++) {
+    /* Estimate the correlation time for better fitting */
+    c_start = -1;
+    ct_estimate = 0;
+    for(i=0; (i<ncorr) && (dt*i < tStart || c1[i]>0); i++) {
+      if (c_start < 0) {
+       if (dt*i >= tStart) {
+         c_start     = c1[i];
+         ct_estimate = 0.5*c1[i];
+       }
+      } else {
+       ct_estimate += c1[i];
+      }
+    }
+    if (c_start > 0) {
+      ct_estimate *= dt/c_start;
+    } else {
+      /* The data is strange, so we need to choose somehting */
+      ct_estimate = tendfit;
+    }
+    if (debug) {
+      fprintf(debug,"tStart %g ct_estimate: %g\n",tStart,ct_estimate);
+    }
+    
+    if (fitfn == effnEXP3) {
+      fitparm[0] = 0.002*ncorr*dt;
+      fitparm[1] = 0.95;
+      fitparm[2] = 0.2*ncorr*dt;
+    } else {
+      /* Good initial guess, this increases the probability of convergence */
+      fitparm[0] = ct_estimate;
+      fitparm[1] = 1.0;
+      fitparm[2] = 1.0;
+    }
 
-  /* Generate more or less appropriate sigma's */
-  snew(sig,ncorr);
-  for(i=0; i<ncorr; i++)
-    sig[i] = sqrt(ct_estimate+dt*i);
+    /* Generate more or less appropriate sigma's */
+    for(i=0; i<ncorr; i++) {
+      sig[i] = sqrt(ct_estimate+dt*i);
+    }
 
-  for(j=0; ((j<jmax) && (tStart < tendfit)); j++) {
-    /* Use the previous fitparm as starting values for the next fit */
     nf_int = min(ncorr,(int)((tStart+1e-4)/dt));
     sum    = print_and_integrate(debug,nf_int,dt,c1,NULL,1);
     tail_corr = do_lmfit(ncorr,c1,sig,dt,NULL,tStart,tendfit,oenv,
index ce9a61aea8f6ebb07c0ee2353d7b80e4674da759..7ff0660a54f44f0e1bd30a1375271ed9685f73d1 100644 (file)
 #include "smalloc.h"
 #include "gstat.h"
 #include "gmx_fatal.h"
+#include "index.h"
        
 t_dlist *mk_dlist(FILE *log, 
                  t_atoms *atoms, int *nlist,
                  gmx_bool bPhi, gmx_bool bPsi, gmx_bool bChi, gmx_bool bHChi,
-                 int maxchi,int r0,int naa,char **aa)
+                 int maxchi, int r0, gmx_residuetype_t rt)
 {
   int     ires,i,j,k,ii;
   t_dihatms atm,prev;
@@ -167,11 +168,7 @@ t_dlist *mk_dlist(FILE *log,
       }
       if ((atm.minC != -1) && (atm.minO != -1))
        nc[6]++;
-      for(k=0; (k<naa); k++) {
-       if (gmx_strcasecmp(aa[k],thisres) == 0)
-         break;
-      }
-      dl[nl].index=k;
+      dl[nl].index=gmx_residuetype_get_index(rt,thisres);
       
       sprintf(dl[nl].name,"%s%d",thisres,ires+r0);
       nl++;
index 4ebe8bfe130e4c13d5c9366483d2a6af62839626..4eaf3ea9a5d6c2ea9bf7bf7801a42996aec43866 100644 (file)
@@ -687,11 +687,12 @@ static void filter(real flen,int n,int nset,real **val,real dt,
   sfree(filt);
 }
 
-static void do_fit(FILE *out,int n,gmx_bool bYdy,int ny,real *x0,real **val,
-                  int npargs,t_pargs *ppa,const output_env_t oenv)
+static void do_fit(FILE *out,int n,gmx_bool bYdy,
+                   int ny,real *x0,real **val,
+                   int npargs,t_pargs *ppa,const output_env_t oenv)
 {
   real *c1=NULL,*sig=NULL,*fitparm;
-  real dt=0,tendfit,tbeginfit;
+  real tendfit,tbeginfit;
   int  i,efitfn,nparm;
   
   efitfn = get_acffitfn();
@@ -709,12 +710,12 @@ static void do_fit(FILE *out,int n,gmx_bool bYdy,int ny,real *x0,real **val,
   if (opt2parg_bSet("-beginfit",npargs,ppa)) {
     tbeginfit = opt2parg_real("-beginfit",npargs,ppa);
   } else {
-    tbeginfit = x0 ? x0[0]    : 0;
+    tbeginfit = x0[0];
   }
   if (opt2parg_bSet("-endfit",npargs,ppa)) {
     tendfit   = opt2parg_real("-endfit",npargs,ppa);
   } else {
-    tendfit   = x0 ? x0[ny-1] : (ny-1)*dt;
+    tendfit   = x0[ny-1];
   }
   
   snew(fitparm,nparm);
@@ -760,7 +761,7 @@ static void do_fit(FILE *out,int n,gmx_bool bYdy,int ny,real *x0,real **val,
   fprintf(out,"Starting parameters:\n");
   for(i=0; (i<nparm); i++) 
     fprintf(out,"a%-2d = %12.5e\n",i+1,fitparm[i]);
-  if (do_lmfit(ny,c1,sig,dt,x0,tbeginfit,tendfit,
+  if (do_lmfit(ny,c1,sig,0,x0,tbeginfit,tendfit,
               oenv,bDebugMode(),efitfn,fitparm,0)) {
     for(i=0; (i<nparm); i++) 
       fprintf(out,"a%-2d = %12.5e\n",i+1,fitparm[i]);
@@ -1086,50 +1087,75 @@ int gmx_analyze(int argc,char *argv[])
   eefile   = opt2fn_null("-ee",NFILE,fnm);
   balfile  = opt2fn_null("-bal",NFILE,fnm);
 /*   gemfile  = opt2fn_null("-gem",NFILE,fnm); */
-  if (opt2parg_bSet("-fitfn",npargs,ppa)) 
-    fitfile  = opt2fn("-g",NFILE,fnm);
-  else
-    fitfile  = opt2fn_null("-g",NFILE,fnm);
+    /* When doing autocorrelation we don't want a fitlog for fitting
+     * the function itself (not the acf) when the user did not ask for it.
+     */
+    if (opt2parg_bSet("-fitfn",npargs,ppa) && acfile == NULL)
+    {
+        fitfile  = opt2fn("-g",NFILE,fnm);
+    }
+    else
+    {
+        fitfile  = opt2fn_null("-g",NFILE,fnm);
+    }
     
-  val=read_xvg_time(opt2fn("-f",NFILE,fnm),bHaveT,
-                   opt2parg_bSet("-b",npargs,ppa),tb,
-                   opt2parg_bSet("-e",npargs,ppa),te,
-                   nsets_in,&nset,&n,&dt,&t);
-  printf("Read %d sets of %d points, dt = %g\n\n",nset,n,dt);
+    val = read_xvg_time(opt2fn("-f",NFILE,fnm),bHaveT,
+                        opt2parg_bSet("-b",npargs,ppa),tb,
+                        opt2parg_bSet("-e",npargs,ppa),te,
+                        nsets_in,&nset,&n,&dt,&t);
+    printf("Read %d sets of %d points, dt = %g\n\n",nset,n,dt);
   
-  if (bDer) {
-    printf("Calculating the derivative as (f[i+%d]-f[i])/(%d*dt)\n\n",
-           d,d);
-    n -= d;
-    for(s=0; s<nset; s++)
-      for(i=0; (i<n); i++)
-       val[s][i] = (val[s][i+d]-val[s][i])/(d*dt);
-  }
-  if (bIntegrate) {
-    real sum,stddev;
-    printf("Calculating the integral using the trapezium rule\n");
-    
-    if (bXYdy) {
-      sum = evaluate_integral(n,t,val[0],val[1],aver_start,&stddev);
-      printf("Integral %10.3f +/- %10.5f\n",sum,stddev);
+    if (bDer)
+    {
+        printf("Calculating the derivative as (f[i+%d]-f[i])/(%d*dt)\n\n",
+               d,d);
+        n -= d;
+        for(s=0; s<nset; s++)
+        {
+            for(i=0; (i<n); i++)
+            {
+                val[s][i] = (val[s][i+d]-val[s][i])/(d*dt);
+            }
+        }
     }
-    else {
-      for(s=0; s<nset; s++) {
-       sum = evaluate_integral(n,t,val[s],NULL,aver_start,&stddev);
-       printf("Integral %d  %10.5f  +/- %10.5f\n",s+1,sum,stddev);
-      }
+    
+    if (bIntegrate)
+    {
+        real sum,stddev;
+
+        printf("Calculating the integral using the trapezium rule\n");
+    
+        if (bXYdy)
+        {
+            sum = evaluate_integral(n,t,val[0],val[1],aver_start,&stddev);
+            printf("Integral %10.3f +/- %10.5f\n",sum,stddev);
+        }
+        else
+        {
+            for(s=0; s<nset; s++)
+            {
+                sum = evaluate_integral(n,t,val[s],NULL,aver_start,&stddev);
+                printf("Integral %d  %10.5f  +/- %10.5f\n",s+1,sum,stddev);
+            }
+        }
     }
-  }
-  if (fitfile) {
-    out_fit = ffopen(fitfile,"w");
-    if (bXYdy && nset>=2) {
-      do_fit(out_fit,0,TRUE,n,t,val,npargs,ppa,oenv);
-    } else {
-      for(s=0; s<nset; s++)
-       do_fit(out_fit,s,FALSE,n,t,val,npargs,ppa,oenv);
+
+    if (fitfile != NULL)
+    {
+        out_fit = ffopen(fitfile,"w");
+        if (bXYdy && nset >= 2)
+        {
+            do_fit(out_fit,0,TRUE,n,t,val,npargs,ppa,oenv);
+        }
+        else
+        {
+            for(s=0; s<nset; s++)
+            {
+                do_fit(out_fit,s,FALSE,n,t,val,npargs,ppa,oenv);
+            }
+        }
+        ffclose(out_fit);
     }
-    ffclose(out_fit);
-  }
 
   printf("                                      std. dev.    relative deviation of\n");
   printf("                       standard       ---------   cumulants from those of\n");
@@ -1207,14 +1233,23 @@ int gmx_analyze(int argc,char *argv[])
 /*                   nFitPoints, fit_start, fit_end, oenv); */
   if (bPower)
     power_fit(n,nset,val,t);
-  if (acfile) {
-    if (bSubAv) 
-      for(s=0; s<nset; s++)
-       for(i=0; i<n; i++)
-         val[s][i] -= av[s];
-    do_autocorr(acfile,oenv,"Autocorrelation",n,nset,val,dt,
-               eacNormal,bAverCorr);
-  }
+
+    if (acfile != NULL)
+    {
+        if (bSubAv)
+        {
+            for(s=0; s<nset; s++)
+            {
+                for(i=0; i<n; i++)
+                {
+                    val[s][i] -= av[s];
+                }
+            }
+        }
+        do_autocorr(acfile,oenv,"Autocorrelation",n,nset,val,dt,
+                    eacNormal,bAverCorr);
+    }
+
   if (bRegression)
       regression_analysis(n,bXYdy,t,nset,val);
 
index f4a5657cda277033be9a56477b42603b45a45117..6e8c00109802c5cbfcc8718bd544211c1175680a 100644 (file)
@@ -116,6 +116,7 @@ typedef struct samples_t
 
     /* allocation data: (not NULL for data 'owned' by this struct) */
     double *du_alloc, *t_alloc; /* allocated delta u arrays  */
+    size_t ndu_alloc, nt_alloc; /* pre-allocated sizes */
     hist_t *hist_alloc; /* allocated hist */
 
     gmx_large_int_t ntot; /* total number of samples */
@@ -240,6 +241,8 @@ static void samples_init(samples_t *s, double native_lambda,
     s->du_alloc=NULL;
     s->t_alloc=NULL;
     s->hist_alloc=NULL;
+    s->ndu_alloc=0;
+    s->nt_alloc=0;
 
     s->ntot=0;
     s->filename=filename;
@@ -2070,16 +2073,17 @@ static void read_bar_xvg(char *fn, real *temp, lambda_t *lambda_head)
     printf("\n\n");
 }
 
-static samples_t *read_edr_rawdh_block(int *nsamples, t_enxblock *blk, 
-                                       double start_time, double delta_time,
-                                       double native_lambda, double temp,
-                                       const char *filename)
+static void read_edr_rawdh_block(samples_t **smp, int *ndu, t_enxblock *blk, 
+                                 double start_time, double delta_time,
+                                 double native_lambda, double temp,
+                                 double *last_t, const char *filename)
 {
     int j;
     gmx_bool allocated;
     double foreign_lambda;
     int derivative;
-    samples_t *s;
+    samples_t *s; /* convenience pointer */
+    int startj;
 
     /* check the block types etc. */
     if ( (blk->nsub < 3) ||
@@ -2098,39 +2102,66 @@ static samples_t *read_edr_rawdh_block(int *nsamples, t_enxblock *blk,
     derivative = blk->sub[0].ival[0]; 
     foreign_lambda = blk->sub[1].dval[0];
 
-    /* initialize the samples structure */
-    snew(s, 1);
-    *nsamples=1;
-    samples_init(s, native_lambda, foreign_lambda, temp,
-                 derivative!=0, filename);
+    if (! *smp)
+    {
+        /* initialize the samples structure if it's empty. */
+        snew(*smp, 1);
+        samples_init(*smp, native_lambda, foreign_lambda, temp,
+                     derivative!=0, filename);
+        (*smp)->start_time=start_time;
+        (*smp)->delta_time=delta_time;
+    }
 
-    s->start_time=start_time;
-    s->delta_time=delta_time;
+    /* set convenience pointer */
+    s=*smp;
+
+    /* now double check */
+    if ( ! lambda_same(s->foreign_lambda, foreign_lambda) ||
+         (  (derivative!=0) != (s->derivative!=0) ) )
+    {
+        fprintf(stderr, "Got foreign lambda=%g, expected: %g\n", 
+                s->foreign_lambda, foreign_lambda);
+        fprintf(stderr, "Got derivative=%d, derivative: %d\n", 
+                derivative, s->derivative);
+        gmx_fatal(FARGS, "Inconsistent data in file %s around t=%g", filename,
+                  start_time);
+    }
 
     /* make room for the data */
-    snew(s->du, blk->sub[2].nr);
-    s->ndu = blk->sub[2].nr;
-    s->ntot = s->ndu;
+    if (s->ndu_alloc < (s->ndu + blk->sub[2].nr) )
+    {
+        s->ndu_alloc += (s->ndu_alloc < blk->sub[2].nr) ?  
+                            blk->sub[2].nr*2 : s->ndu_alloc;
+        srenew(s->du_alloc, s->ndu_alloc);
+        s->du=s->du_alloc;
+    }
+    startj = s->ndu;
+    s->ndu += blk->sub[2].nr;
+    s->ntot += blk->sub[2].nr;
+    *ndu = blk->sub[2].nr;
 
     /* and copy the data*/
     for(j=0;j<blk->sub[2].nr;j++)
     {
         if (blk->sub[2].type == xdr_datatype_float)
         {
-            s->du[j] = blk->sub[2].fval[j];
+            s->du[startj+j] = blk->sub[2].fval[j];
         }
         else
         {
-            s->du[j] = blk->sub[2].dval[j];
+            s->du[startj+j] = blk->sub[2].dval[j];
         }
     }
-    return s;
+    if (start_time + blk->sub[2].nr*delta_time > *last_t)
+    {
+        *last_t = start_time + blk->sub[2].nr*delta_time;
+    }
 }
 
 static samples_t *read_edr_hist_block(int *nsamples, t_enxblock *blk,
                                       double start_time, double delta_time,
                                       double native_lambda, double temp,
-                                      const char *filename)
+                                      double *last_t, const char *filename)
 {
     int i,j;
     samples_t *s;
@@ -2219,6 +2250,10 @@ static samples_t *read_edr_hist_block(int *nsamples, t_enxblock *blk,
         }
     }
 
+    if (start_time + s->hist->sum*delta_time > *last_t)
+    {
+        *last_t = start_time + s->hist->sum*delta_time;
+    }
     return s;
 }
 
@@ -2232,11 +2267,12 @@ static void read_barsim_edr(char *fn, real *temp, lambda_t *lambda_head)
     gmx_enxnm_t *enm=NULL;
     double first_t=-1;
     double last_t=-1;
-    int *nhists=NULL;
-    int *npts=NULL;
-    double *lambdas=NULL;
+    samples_t **samples_rawdh=NULL; /* contains samples for raw delta_h  */
+    int *nhists=NULL;       /* array to keep count & print at end */
+    int *npts=NULL;         /* array to keep count & print at end */
+    double *lambdas=NULL;   /* array to keep count & print at end */
     double native_lambda=-1;
-
+    double end_time;        /* the end time of the last batch of samples */
     int nsamples=0;
 
     fp = open_enx(fn,"r");
@@ -2280,14 +2316,13 @@ static void read_barsim_edr(char *fn, real *temp, lambda_t *lambda_head)
 
                 if (delta_lambda>0)
                 {
-                    gmx_fatal(FARGS, "Lambda values change in %s: can't apply BAR method", fn);
+                    gmx_fatal(FARGS, "Lambda values not constant in %s: can't apply BAR method", fn);
                 }
                 if ( ( *temp != rtemp) && (*temp > 0) )
                 {
                     gmx_fatal(FARGS,"Temperature in file %s different from earlier files or setting\n", fn);
                 }
                 *temp=rtemp;
-                native_lambda=start_lambda;
 
                 if (first_t < 0)
                     first_t=start_time;
@@ -2305,73 +2340,111 @@ static void read_barsim_edr(char *fn, real *temp, lambda_t *lambda_head)
 
         if (nsamples > 0)
         {
+            /* check the native lambda */
+            if (!lambda_same(start_lambda, native_lambda) )
+            {
+                gmx_fatal(FARGS, "Native lambda not constant in file %s: started at %g, and becomes %g at time %g", 
+                          fn, native_lambda, start_lambda, start_time);
+            }
             /* check the number of samples against the previous number */
             if ( ((nblocks_raw+nblocks_hist)!=nsamples) || (nlam!=1 ) )
             {
                 gmx_fatal(FARGS, "Unexpected block count in %s: was %d, now %d\n",
                           fn, nsamples+1, nblocks_raw+nblocks_hist+nlam);
             }
+            /* check whether last iterations's end time matches with 
+               the currrent start time */
+            if ( (fabs(last_t - start_time) > 2*delta_time)  && last_t>=0)
+            {
+                /* it didn't. We need to store our samples and reallocate */
+                for(i=0;i<nsamples;i++)
+                {
+                    if (samples_rawdh[i])
+                    {
+                        /* insert it into the existing list */
+                        lambda_list_insert_sample(lambda_head, 
+                                                  samples_rawdh[i]);
+                        /* and make sure we'll allocate a new one this time
+                           around */
+                        samples_rawdh[i]=NULL;
+                    }
+                }
+            }
         }
         else
         {
+            /* this is the first round; allocate the associated data 
+               structures */
+            native_lambda=start_lambda;
             nsamples=nblocks_raw+nblocks_hist;
             snew(nhists, nsamples);
             snew(npts, nsamples);
             snew(lambdas, nsamples);
+            snew(samples_rawdh, nsamples);
             for(i=0;i<nsamples;i++)
             {
                 nhists[i]=0;
                 npts[i]=0;
                 lambdas[i]=-1;
+                samples_rawdh[i]=NULL; /* init to NULL so we know which
+                                          ones contain values */
             }
         }
 
         /* and read them */
-        k=0;
+        k=0; /* counter for the lambdas, etc. arrays */
         for(i=0;i<fr->nblock;i++)
         {
-            int j;
-            int nb=0;
-            samples_t *s=NULL; /* this is where the data will go */
-
             if (fr->block[i].id == enxDH)
             {
-                s=read_edr_rawdh_block(&nb, &(fr->block[i]), 
-                                       start_time, delta_time, 
-                                       start_lambda, rtemp, fn);
-                npts[k] += s->ndu;
-                lambdas[k]=s->foreign_lambda;
+                int ndu;
+                read_edr_rawdh_block(&(samples_rawdh[k]),
+                                     &ndu,
+                                     &(fr->block[i]), 
+                                     start_time, delta_time, 
+                                     start_lambda, rtemp, 
+                                     &last_t, fn);
+                npts[k] += ndu;
+                if (samples_rawdh[k])
+                {
+                    lambdas[k]=samples_rawdh[k]->foreign_lambda;
+                }
                 k++;
             }
             else if (fr->block[i].id == enxDHHIST)
             {
+                int j;
+                int nb=0;
+                samples_t *s; /* this is where the data will go */
                 s=read_edr_hist_block(&nb, &(fr->block[i]), 
                                       start_time, delta_time, 
-                                      start_lambda, rtemp, fn);
+                                      start_lambda, rtemp, 
+                                      &last_t, fn);
                 nhists[k] += nb;
                 if (nb>0)
                 {
                     lambdas[k]= s->foreign_lambda;
                 }
                 k++;
-            }
-            for(j=0;j<nb;j++)
-            {
-                double endt;
-                lambda_list_insert_sample(lambda_head, s+j);
-                if (s[j].hist)
+                /* and insert the new sample immediately */
+                for(j=0;j<nb;j++)
                 {
-                    endt=s[j].hist->sum*delta_time + start_time;
+                    lambda_list_insert_sample(lambda_head, s+j);
                 }
-                else
-                {
-                    endt=s[j].ndu*delta_time + start_time;
-                }
-                if (endt > last_t)
-                    last_t = endt;
             }
         }
     }
+    /* Now store all our extant sample collections */
+    for(i=0;i<nsamples;i++)
+    {
+        if (samples_rawdh[i])
+        {
+            /* insert it into the existing list */
+            lambda_list_insert_sample(lambda_head, samples_rawdh[i]);
+        }
+    }
+
+
     fprintf(stderr, "\n");
     printf("%s: %.1f - %.1f; lambda = %.3f\n    foreign lambdas:", 
            fn, first_t, last_t, native_lambda);
index e97133fe0711374aaabe901cbc95eb6735216a32..bf18bdba3f31fba695b2ec3e0e06394c9042175f 100644 (file)
@@ -385,7 +385,7 @@ static int reset_em_all(int nlist,t_dlist dlist[],int nf,
   return j ; 
 }
 
-static void histogramming(FILE *log,int nbin, int naa,char **aa,
+static void histogramming(FILE *log,int nbin,gmx_residuetype_t rt,
                          int nf,int maxchi,real **dih,
                          int nlist,t_dlist dlist[],
                          atom_id index[],
@@ -426,7 +426,10 @@ static void histogramming(FILE *log,int nbin, int naa,char **aa,
   gmx_bool    bBfac,bOccup;
   char    hisfile[256],hhisfile[256],sshisfile[256],title[256],*ss_str=NULL;
   char **leg; 
-  
+  const char *residue_name;
+  int     rt_size;
+
+  rt_size = gmx_residuetype_get_size(rt);
   if (bSSHisto) {
     fp = ffopen(ssdump,"r");
     if(1 != fscanf(fp,"%d",&nres))
@@ -444,8 +447,8 @@ static void histogramming(FILE *log,int nbin, int naa,char **aa,
     /* Four dimensional array... Very cool */
     snew(his_aa_ss,3);
     for(i=0; (i<3); i++) {
-      snew(his_aa_ss[i],naa+1);
-      for(j=0; (j<=naa); j++) {
+      snew(his_aa_ss[i],rt_size+1);
+      for(j=0; (j<=rt_size); j++) {
        snew(his_aa_ss[i][j],edMax);
        for(Dih=0; (Dih<edMax); Dih++)
          snew(his_aa_ss[i][j][Dih],nbin+1);
@@ -454,8 +457,8 @@ static void histogramming(FILE *log,int nbin, int naa,char **aa,
   }
   snew(his_aa,edMax);
   for(Dih=0; (Dih<edMax); Dih++) {
-    snew(his_aa[Dih],naa+1);
-    for(i=0; (i<=naa); i++) {
+    snew(his_aa[Dih],rt_size+1);
+    for(i=0; (i<=rt_size); i++) {
       snew(his_aa[Dih][i],nbin+1);
     }
   }
@@ -611,7 +614,7 @@ static void histogramming(FILE *log,int nbin, int naa,char **aa,
   /* finished -jc stuff */ 
 
   snew(normhisto,nbin);
-  for(i=0; (i<naa); i++) {
+  for(i=0; (i<rt_size); i++) {
     for(Dih=0; (Dih<edMax); Dih++){
       /* First check whether something is in there */
       for(j=0; (j<nbin); j++)
@@ -625,23 +628,24 @@ static void histogramming(FILE *log,int nbin, int naa,char **aa,
        if (bNormalize)
          normalize_histo(nbin,his_aa[Dih][i],(360.0/nbin),normhisto);
        
+       residue_name = gmx_residuetype_get_name(rt,i);
        switch (Dih) {
        case edPhi:
-         sprintf(hisfile,"histo-phi%s",aa[i]);
-         sprintf(title,"\\xf\\f{} Distribution for %s",aa[i]);
+         sprintf(hisfile,"histo-phi%s",residue_name);
+         sprintf(title,"\\xf\\f{} Distribution for %s",residue_name);
          break;
        case edPsi:
-         sprintf(hisfile,"histo-psi%s",aa[i]);
-         sprintf(title,"\\xy\\f{} Distribution for %s",aa[i]);
+         sprintf(hisfile,"histo-psi%s",residue_name);
+         sprintf(title,"\\xy\\f{} Distribution for %s",residue_name);
          break;
        case edOmega:
-         sprintf(hisfile,"histo-omega%s",aa[i]);
-         sprintf(title,"\\xw\\f{} Distribution for %s",aa[i]);
+         sprintf(hisfile,"histo-omega%s",residue_name);
+         sprintf(title,"\\xw\\f{} Distribution for %s",residue_name);
          break;
        default:
-         sprintf(hisfile,"histo-chi%d%s",Dih-NONCHI+1,aa[i]);
+         sprintf(hisfile,"histo-chi%d%s",Dih-NONCHI+1,residue_name);
          sprintf(title,"\\xc\\f{}\\s%d\\N Distribution for %s",
-                 Dih-NONCHI+1,aa[i]);
+                 Dih-NONCHI+1,residue_name);
        }
        strcpy(hhisfile,hisfile);
        strcat(hhisfile,".xvg");
@@ -689,7 +693,7 @@ static void histogramming(FILE *log,int nbin, int naa,char **aa,
   if (bSSHisto) {
     /* Four dimensional array... Very cool */
     for(i=0; (i<3); i++) {
-      for(j=0; (j<=naa); j++) {
+      for(j=0; (j<=rt_size); j++) {
        for(Dih=0; (Dih<edMax); Dih++)
          sfree(his_aa_ss[i][j][Dih]);
        sfree(his_aa_ss[i][j]);
@@ -1113,18 +1117,18 @@ int gmx_chi(int argc,char *argv[])
   };
 
   FILE       *log;
-  int        natoms,nlist,naa,idum,nbin; 
+  int        natoms,nlist,idum,nbin;
   t_atoms    atoms;
   rvec       *x;
   int        ePBC;
   matrix     box;
   char       title[256],grpname[256]; 
   t_dlist    *dlist;
-  char       **aa;
   gmx_bool       bChi,bCorr,bSSHisto;
   gmx_bool       bDo_rt, bDo_oh, bDo_ot, bDo_jc ; 
   real       dt=0, traj_t_ns;
   output_env_t oenv;
+  gmx_residuetype_t rt;
   
   atom_id    isize,*index;
   int        ndih,nactdih,nf;
@@ -1203,8 +1207,8 @@ int gmx_chi(int argc,char *argv[])
   read_stx_conf(ftp2fn(efSTX,NFILE,fnm),title,&atoms,x,NULL,&ePBC,box);
   fprintf(log,"Title: %s\n",title);
   
-  naa=get_strings("aminoacids.dat",&aa);
-  dlist=mk_dlist(log,&atoms,&nlist,bPhi,bPsi,bChi,bHChi,maxchi,r0,naa,aa);
+  gmx_residuetype_init(&rt);
+  dlist=mk_dlist(log,&atoms,&nlist,bPhi,bPsi,bChi,bHChi,maxchi,r0,rt);
   fprintf(stderr,"%d residues with dihedrals found\n", nlist);
   
   if (nlist == 0) 
@@ -1239,7 +1243,7 @@ int gmx_chi(int argc,char *argv[])
     dump_em_all(nlist,dlist,nf,time,dih,maxchi,bPhi,bPsi,bChi,bOmega,bRAD,oenv);
   
   /* Histogramming & J coupling constants & calc of S2 order params */
-  histogramming(log,nbin,naa,aa,nf,maxchi,dih,nlist,dlist,index,
+  histogramming(log,nbin,rt,nf,maxchi,dih,nlist,dlist,index,
                bPhi,bPsi,bOmega,bChi,
                bNormHisto,bSSHisto,ftp2fn(efDAT,NFILE,fnm),bfac_max,&atoms,
                bDo_jc,opt2fn("-jc",NFILE,fnm),oenv);
@@ -1318,6 +1322,8 @@ int gmx_chi(int argc,char *argv[])
   if (bCorr)
     do_view(oenv,opt2fn("-corr",NFILE,fnm),"-nxy");
     
+  gmx_residuetype_destroy(rt);
+
   thanx(stderr);
     
   return 0;
index cd142c6834b17a5066a66af776b45eb6ba3dd940..0d0acae7f0d00e82e2740ebea95c739e741f8dd3 100644 (file)
@@ -149,10 +149,10 @@ void calc_electron_density(const char *fn, atom_id **index, int gnx[],
 {
   rvec *x0;              /* coordinates without pbc */
   matrix box;            /* box (3x3) */
+  double invvol;
   int natoms;            /* nr. atoms in trj */
   t_trxstatus *status;  
   int i,n,               /* loop indices */
-      ax1=0, ax2=0,
       nr_frames = 0,     /* number of frames */
       slice;             /* current slice */
   t_electron *found;     /* found by bsearch */
@@ -162,17 +162,7 @@ void calc_electron_density(const char *fn, atom_id **index, int gnx[],
   real t, 
         z;
 
-  switch(axis) {
-  case 0:
-    ax1 = 1; ax2 = 2;
-    break;
-  case 1:
-    ax1 = 0; ax2 = 2;
-    break;
-  case 2:
-    ax1 = 0; ax2 = 1;
-    break;
-  default:
+  if (axis < 0 || axis >= DIM) {
     gmx_fatal(FARGS,"Invalid axes. Terminating\n");
   }
 
@@ -196,6 +186,8 @@ void calc_electron_density(const char *fn, atom_id **index, int gnx[],
       center_coords(&top->atoms,box,x0,axis);
     
     *slWidth = box[axis][axis]/(*nslices);
+    invvol = *nslices/(box[XX][XX]*box[YY][YY]*box[ZZ][ZZ]);
+
     for (n = 0; n < nr_grps; n++) {      
       for (i = 0; i < gnx[n]; i++) {   /* loop over all atoms in index file */
          z = x0[index[n][i]][axis];
@@ -219,8 +211,8 @@ void calc_electron_density(const char *fn, atom_id **index, int gnx[],
            fprintf(stderr,"Couldn't find %s. Add it to the .dat file\n",
                    *(top->atoms.atomname[index[n][i]]));
          else  
-           (*slDensity)[n][slice] += found->nr_el - 
-                                     top->atoms.atom[index[n][i]].q;
+           (*slDensity)[n][slice] += (found->nr_el - 
+                                      top->atoms.atom[index[n][i]].q)*invvol;
          free(sought.atomname);
        }
     }
@@ -240,8 +232,7 @@ void calc_electron_density(const char *fn, atom_id **index, int gnx[],
 
   for (n =0; n < nr_grps; n++) {
     for (i = 0; i < *nslices; i++)
-      (*slDensity)[n][i] = (*slDensity)[n][i] * (*nslices) /
-       ( nr_frames * box[axis][axis] * box[ax1][ax1] * box[ax2][ax2]);
+      (*slDensity)[n][i] /= nr_frames;
   }
 
   sfree(x0);  /* free memory used by coordinate array */
@@ -254,6 +245,7 @@ void calc_density(const char *fn, atom_id **index, int gnx[],
 {
   rvec *x0;              /* coordinates without pbc */
   matrix box;            /* box (3x3) */
+  double invvol;
   int natoms;            /* nr. atoms in trj */
   t_trxstatus *status;  
   int  **slCount,         /* nr. of atoms in one slice for a group */
@@ -267,17 +259,7 @@ void calc_density(const char *fn, atom_id **index, int gnx[],
   char *buf;             /* for tmp. keeping atomname */
   gmx_rmpbc_t  gpbc=NULL;
 
-  switch(axis) {
-  case 0:
-    ax1 = 1; ax2 = 2;
-    break;
-  case 1:
-    ax1 = 0; ax2 = 2;
-    break;
-  case 2:
-    ax1 = 0; ax2 = 1;
-    break;
-  default:
+  if (axis < 0 || axis >= DIM) {
     gmx_fatal(FARGS,"Invalid axes. Terminating\n");
   }
 
@@ -302,6 +284,7 @@ void calc_density(const char *fn, atom_id **index, int gnx[],
       center_coords(&top->atoms,box,x0,axis);
     
     *slWidth = box[axis][axis]/(*nslices);
+    invvol = *nslices/(box[XX][XX]*box[YY][YY]*box[ZZ][ZZ]);
     teller++;
     
     for (n = 0; n < nr_grps; n++) {      
@@ -314,10 +297,9 @@ void calc_density(const char *fn, atom_id **index, int gnx[],
       
        /* determine which slice atom is in */
        slice = (int)(z / (*slWidth)); 
-       (*slDensity)[n][slice] += top->atoms.atom[index[n][i]].m;
+       (*slDensity)[n][slice] += top->atoms.atom[index[n][i]].m*invvol;
       }
     }
-
     nr_frames++;
   } while (read_next_x(oenv,status,&t,natoms,x0,box));
   gmx_rmpbc_done(gpbc);
@@ -334,8 +316,7 @@ void calc_density(const char *fn, atom_id **index, int gnx[],
 
   for (n =0; n < nr_grps; n++) {
     for (i = 0; i < *nslices; i++) {
-      (*slDensity)[n][i] = (*slDensity)[n][i] * (*nslices) /
-       (nr_frames * box[axis][axis] * box[ax1][ax1] * box[ax2][ax2]);
+      (*slDensity)[n][i] /= nr_frames;
     }
   }
 
index f1ffcc0fc82cc04f484be3b99b21edac9fd1eb28..f55d52e8c6a5751498f2dfaec690efe8782886c8 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
  * 
  *                This source code is part of
  * 
 #define CM2D  SPEED_OF_LIGHT*1.0e+24    /* Coulomb meter to Debye */
 
 typedef struct {
-  int  nelem;
-  real spacing,radius;
-  real *elem;
-  int  *count;
-  gmx_bool bPhi;
-  int  nx,ny;
-  real **cmap;
+    int  nelem;
+    real spacing,radius;
+    real *elem;
+    int  *count;
+    gmx_bool bPhi;
+    int  nx,ny;
+    real **cmap;
 } t_gkrbin;
 
 static t_gkrbin *mk_gkrbin(real radius,real rcmax,gmx_bool bPhi,int ndegrees)
 {
-  t_gkrbin *gb;
-  char *ptr;
-  int  i;
+    t_gkrbin *gb;
+    char *ptr;
+    int  i;
   
-  snew(gb,1);
+    snew(gb,1);
   
-  if ((ptr = getenv("GKRWIDTH")) != NULL) {
-    double bw;
-
-    sscanf(ptr,"%lf",&bw);
-    gb->spacing = bw; 
-  }
-  else
-    gb->spacing = 0.01; /* nm */
-  gb->nelem   = 1 + radius/gb->spacing;
-  if (rcmax == 0)
-    gb->nx = gb->nelem;
-  else
-    gb->nx = 1 + rcmax/gb->spacing;
-  gb->radius  = radius;
-  snew(gb->elem,gb->nelem);
-  snew(gb->count,gb->nelem);
+    if ((ptr = getenv("GKRWIDTH")) != NULL) {
+        double bw;
+
+        sscanf(ptr,"%lf",&bw);
+        gb->spacing = bw; 
+    }
+    else
+        gb->spacing = 0.01; /* nm */
+    gb->nelem   = 1 + radius/gb->spacing;
+    if (rcmax == 0)
+        gb->nx = gb->nelem;
+    else
+        gb->nx = 1 + rcmax/gb->spacing;
+    gb->radius  = radius;
+    snew(gb->elem,gb->nelem);
+    snew(gb->count,gb->nelem);
   
-  snew(gb->cmap,gb->nx);
-  gb->ny = max(2,ndegrees);
-  for(i=0; (i<gb->nx); i++)
-    snew(gb->cmap[i],gb->ny);
-  gb->bPhi = bPhi;
+    snew(gb->cmap,gb->nx);
+    gb->ny = max(2,ndegrees);
+    for(i=0; (i<gb->nx); i++)
+        snew(gb->cmap[i],gb->ny);
+    gb->bPhi = bPhi;
       
-  return gb;
+    return gb;
 }
 
 static void done_gkrbin(t_gkrbin **gb)
 {
-  sfree((*gb)->elem);
-  sfree((*gb)->count);
-  sfree((*gb));
-  *gb = NULL;
+    sfree((*gb)->elem);
+    sfree((*gb)->count);
+    sfree((*gb));
+    *gb = NULL;
 }
 
 static void add2gkr(t_gkrbin *gb,real r,real cosa,real phi)
 {
-  int  cy,index = gmx_nint(r/gb->spacing);
-  real alpha;
+    int  cy,index = gmx_nint(r/gb->spacing);
+    real alpha;
   
-  if (index < gb->nelem) {
-    gb->elem[index]  += cosa;
-    gb->count[index] ++;
-  }
-  if (index < gb->nx) {
-    alpha = acos(cosa);
-    if (gb->bPhi)
-      cy = (M_PI+phi)*gb->ny/(2*M_PI);
-    else
-      cy = (alpha*gb->ny)/M_PI;/*((1+cosa)*0.5*(gb->ny));*/
-    cy = min(gb->ny-1,max(0,cy));
-    if (debug)
-      fprintf(debug,"CY: %10f  %5d\n",alpha,cy);
-    gb->cmap[index][cy] += 1;
-  }
+    if (index < gb->nelem) {
+        gb->elem[index]  += cosa;
+        gb->count[index] ++;
+    }
+    if (index < gb->nx) {
+        alpha = acos(cosa);
+        if (gb->bPhi)
+            cy = (M_PI+phi)*gb->ny/(2*M_PI);
+        else
+            cy = (alpha*gb->ny)/M_PI;/*((1+cosa)*0.5*(gb->ny));*/
+        cy = min(gb->ny-1,max(0,cy));
+        if (debug)
+            fprintf(debug,"CY: %10f  %5d\n",alpha,cy);
+        gb->cmap[index][cy] += 1;
+    }
 }
 
 static void rvec2sprvec(rvec dipcart,rvec dipsp)
 {
-  clear_rvec(dipsp);
-  dipsp[0] = sqrt(dipcart[XX]*dipcart[XX]+dipcart[YY]*dipcart[YY]+dipcart[ZZ]*dipcart[ZZ]); /* R */ 
-  dipsp[1] = atan2(dipcart[YY],dipcart[XX]);  /* Theta */ 
-  dipsp[2] = atan2(sqrt(dipcart[XX]*dipcart[XX]+dipcart[YY]*dipcart[YY]),dipcart[ZZ]);       /* Phi */ 
+    clear_rvec(dipsp);
+    dipsp[0] = sqrt(dipcart[XX]*dipcart[XX]+dipcart[YY]*dipcart[YY]+dipcart[ZZ]*dipcart[ZZ]); /* R */ 
+    dipsp[1] = atan2(dipcart[YY],dipcart[XX]);  /* Theta */ 
+    dipsp[2] = atan2(sqrt(dipcart[XX]*dipcart[XX]+dipcart[YY]*dipcart[YY]),dipcart[ZZ]);       /* Phi */ 
 }
 
 
 
 void do_gkr(t_gkrbin *gb,int ncos,int *ngrp,int *molindex[],
-           int mindex[],rvec x[],rvec mu[],
-           int ePBC,matrix box,t_atom *atom,int *nAtom)
+            int mindex[],rvec x[],rvec mu[],
+            int ePBC,matrix box,t_atom *atom,int *nAtom)
 {
-  static rvec *xcm[2] = { NULL, NULL};
-  int    gi,gj,j0,j1,i,j,k,n,index,grp0,grp1;
-  real   qtot,q,r2,cosa,rr,phi;
-  rvec   dx;
-  t_pbc  pbc;
+    static rvec *xcm[2] = { NULL, NULL};
+    int    gi,gj,j0,j1,i,j,k,n,index,grp0,grp1;
+    real   qtot,q,r2,cosa,rr,phi;
+    rvec   dx;
+    t_pbc  pbc;
   
-  for(n=0; (n<ncos); n++) {
-    if (!xcm[n])
-      snew(xcm[n],ngrp[n]);
-    for(i=0; (i<ngrp[n]); i++) {
-      /* Calculate center of mass of molecule */
-      gi = molindex[n][i];
-      j0 = mindex[gi];
+    for(n=0; (n<ncos); n++) {
+        if (!xcm[n])
+            snew(xcm[n],ngrp[n]);
+        for(i=0; (i<ngrp[n]); i++) {
+            /* Calculate center of mass of molecule */
+            gi = molindex[n][i];
+            j0 = mindex[gi];
       
-      if (nAtom[n] > 0)
-       copy_rvec(x[j0+nAtom[n]-1],xcm[n][i]);
-      else {
-       j1 = mindex[gi+1];
-       clear_rvec(xcm[n][i]);
-       qtot = 0;
-       for(j=j0; j<j1; j++) {
-         q = fabs(atom[j].q);
-         qtot += q;
-         for(k=0; k<DIM; k++)
-           xcm[n][i][k] += q*x[j][k];
-       }
-       svmul(1/qtot,xcm[n][i],xcm[n][i]);
-      }
+            if (nAtom[n] > 0)
+                copy_rvec(x[j0+nAtom[n]-1],xcm[n][i]);
+            else {
+                j1 = mindex[gi+1];
+                clear_rvec(xcm[n][i]);
+                qtot = 0;
+                for(j=j0; j<j1; j++) {
+                    q = fabs(atom[j].q);
+                    qtot += q;
+                    for(k=0; k<DIM; k++)
+                        xcm[n][i][k] += q*x[j][k];
+                }
+                svmul(1/qtot,xcm[n][i],xcm[n][i]);
+            }
+        }
     }
-  }
-  set_pbc(&pbc,ePBC,box);
-  grp0 = 0;
-  grp1 = ncos-1;
-  for(i=0; i<ngrp[grp0]; i++) {
-    gi = molindex[grp0][i];
-    j0 = (ncos == 2) ? 0 : i+1;
-    for(j=j0; j<ngrp[grp1]; j++) {
-      gj   = molindex[grp1][j];
-      if ((iprod(mu[gi],mu[gi]) > 0) && (iprod(mu[gj],mu[gj]) > 0)) {
-       /* Compute distance between molecules including PBC */
-       pbc_dx(&pbc,xcm[grp0][i],xcm[grp1][j],dx);
-       rr = norm(dx);
+    set_pbc(&pbc,ePBC,box);
+    grp0 = 0;
+    grp1 = ncos-1;
+    for(i=0; i<ngrp[grp0]; i++) {
+        gi = molindex[grp0][i];
+        j0 = (ncos == 2) ? 0 : i+1;
+        for(j=j0; j<ngrp[grp1]; j++) {
+            gj   = molindex[grp1][j];
+            if ((iprod(mu[gi],mu[gi]) > 0) && (iprod(mu[gj],mu[gj]) > 0)) {
+                /* Compute distance between molecules including PBC */
+                pbc_dx(&pbc,xcm[grp0][i],xcm[grp1][j],dx);
+                rr = norm(dx);
        
-       if (gb->bPhi) {
-         rvec xi,xj,xk,xl;
-         rvec r_ij,r_kj,r_kl,mm,nn;
-         real sign;
-         int  t1,t2,t3;
+                if (gb->bPhi) {
+                    rvec xi,xj,xk,xl;
+                    rvec r_ij,r_kj,r_kl,mm,nn;
+                    real sign;
+                    int  t1,t2,t3;
          
-         copy_rvec(xcm[grp0][i],xj);
-         copy_rvec(xcm[grp1][j],xk);
-         rvec_add(xj,mu[gi],xi);
-         rvec_add(xk,mu[gj],xl);
-         phi = dih_angle(xi,xj,xk,xl,&pbc,
-                         r_ij,r_kj,r_kl,mm,nn, /* out */
-                         &sign,&t1,&t2,&t3);
-      cosa = cos(phi);
-       }
-       else {
-         cosa = cos_angle(mu[gi],mu[gj]);
-         phi = 0;
-       }
-       if (debug || (cosa != cosa))  {
-         fprintf(debug ? debug : stderr,
-                 "mu[%d] = %5.2f %5.2f %5.2f |mi| = %5.2f, mu[%d] = %5.2f %5.2f %5.2f |mj| = %5.2f rr = %5.2f cosa = %5.2f\n",
-                 gi,mu[gi][XX],mu[gi][YY],mu[gi][ZZ],norm(mu[gi]),
-                 gj,mu[gj][XX],mu[gj][YY],mu[gj][ZZ],norm(mu[gj]),
-                 rr,cosa);
-       }
+                    copy_rvec(xcm[grp0][i],xj);
+                    copy_rvec(xcm[grp1][j],xk);
+                    rvec_add(xj,mu[gi],xi);
+                    rvec_add(xk,mu[gj],xl);
+                    phi = dih_angle(xi,xj,xk,xl,&pbc,
+                                    r_ij,r_kj,r_kl,mm,nn, /* out */
+                                    &sign,&t1,&t2,&t3);
+                    cosa = cos(phi);
+                }
+                else {
+                    cosa = cos_angle(mu[gi],mu[gj]);
+                    phi = 0;
+                }
+                if (debug || (cosa != cosa))  {
+                    fprintf(debug ? debug : stderr,
+                            "mu[%d] = %5.2f %5.2f %5.2f |mi| = %5.2f, mu[%d] = %5.2f %5.2f %5.2f |mj| = %5.2f rr = %5.2f cosa = %5.2f\n",
+                            gi,mu[gi][XX],mu[gi][YY],mu[gi][ZZ],norm(mu[gi]),
+                            gj,mu[gj][XX],mu[gj][YY],mu[gj][ZZ],norm(mu[gj]),
+                            rr,cosa);
+                }
        
-       add2gkr(gb,rr,cosa,phi);
-      }
+                add2gkr(gb,rr,cosa,phi);
+            }
+        }
     }
-  }
 }
 
 static real normalize_cmap(t_gkrbin *gb)
 {
-  int    i,j;
-  double hi,vol;
+    int    i,j;
+    double hi,vol;
   
-  hi = 0;
-  for(i=0; (i<gb->nx); i++) {
-    vol = 4*M_PI*sqr(gb->spacing*i)*gb->spacing;
-    for(j=0; (j<gb->ny); j++) {
-      gb->cmap[i][j] /= vol;
-      hi = max(hi,gb->cmap[i][j]);
+    hi = 0;
+    for(i=0; (i<gb->nx); i++) {
+        vol = 4*M_PI*sqr(gb->spacing*i)*gb->spacing;
+        for(j=0; (j<gb->ny); j++) {
+            gb->cmap[i][j] /= vol;
+            hi = max(hi,gb->cmap[i][j]);
+        }
     }
-  }
-  if (hi <= 0)
-    gmx_fatal(FARGS,"No data in the cmap");
-  return hi;  
+    if (hi <= 0)
+        gmx_fatal(FARGS,"No data in the cmap");
+    return hi;  
 }
 
 static void print_cmap(const char *cmap,t_gkrbin *gb,int *nlevels)
 {
-  FILE   *out;
-  int    i,j;
-  real   hi;
+    FILE   *out;
+    int    i,j;
+    real   hi;
   
-  real   *xaxis,*yaxis;
-  t_rgb  rlo = { 1, 1, 1 };
-  t_rgb  rhi = { 0, 0, 0 };
+    real   *xaxis,*yaxis;
+    t_rgb  rlo = { 1, 1, 1 };
+    t_rgb  rhi = { 0, 0, 0 };
   
-  hi = normalize_cmap(gb);
-  snew(xaxis,gb->nx+1);
-  for(i=0; (i<gb->nx+1); i++)
-    xaxis[i] = i*gb->spacing;
-  snew(yaxis,gb->ny);
-  for(j=0; (j<gb->ny); j++) {
-    if (gb->bPhi)
-      yaxis[j] = (360.0*j)/(gb->ny-1.0)-180;
-    else
-      yaxis[j] = (180.0*j)/(gb->ny-1.0);
-    /*2.0*j/(gb->ny-1.0)-1.0;*/
-  }
-  out = ffopen(cmap,"w");
-  write_xpm(out,0,
-           "Dipole Orientation Distribution","Fraction","r (nm)",
-           gb->bPhi ? "Phi" : "Alpha",
-           gb->nx,gb->ny,xaxis,yaxis,
-           gb->cmap,0,hi,rlo,rhi,nlevels);
-  ffclose(out);
-  sfree(xaxis);
-  sfree(yaxis);
+    hi = normalize_cmap(gb);
+    snew(xaxis,gb->nx+1);
+    for(i=0; (i<gb->nx+1); i++)
+        xaxis[i] = i*gb->spacing;
+    snew(yaxis,gb->ny);
+    for(j=0; (j<gb->ny); j++) {
+        if (gb->bPhi)
+            yaxis[j] = (360.0*j)/(gb->ny-1.0)-180;
+        else
+            yaxis[j] = (180.0*j)/(gb->ny-1.0);
+        /*2.0*j/(gb->ny-1.0)-1.0;*/
+    }
+    out = ffopen(cmap,"w");
+    write_xpm(out,0,
+              "Dipole Orientation Distribution","Fraction","r (nm)",
+              gb->bPhi ? "Phi" : "Alpha",
+              gb->nx,gb->ny,xaxis,yaxis,
+              gb->cmap,0,hi,rlo,rhi,nlevels);
+    ffclose(out);
+    sfree(xaxis);
+    sfree(yaxis);
 }
 
 static void print_gkrbin(const char *fn,t_gkrbin *gb,
-                        int ngrp,int nframes,real volume,
+                         int ngrp,int nframes,real volume,
                          const output_env_t oenv)
 {
-  /* We compute Gk(r), gOO and hOO according to
-   * Nymand & Linse, JCP 112 (2000) pp 6386-6395.
-   * In this implementation the angle between dipoles is stored
-   * rather than their inner product. This allows to take polarizible
-   * models into account. The RDF is calculated as well, almost for free!
-   */
-  FILE   *fp;
-  const char *leg[] = { "G\\sk\\N(r)", "< cos >", "h\\sOO\\N", "g\\sOO\\N", "Energy" };
-  int    i,j,n,last;
-  real   x0,x1,ggg,Gkr,vol_s,rho,gOO,hOO,cosav,ener;
-  double fac;
+    /* We compute Gk(r), gOO and hOO according to
+     * Nymand & Linse, JCP 112 (2000) pp 6386-6395.
+     * In this implementation the angle between dipoles is stored
+     * rather than their inner product. This allows to take polarizible
+     * models into account. The RDF is calculated as well, almost for free!
+     */
+    FILE   *fp;
+    const char *leg[] = { "G\\sk\\N(r)", "< cos >", "h\\sOO\\N", "g\\sOO\\N", "Energy" };
+    int    i,j,n,last;
+    real   x0,x1,ggg,Gkr,vol_s,rho,gOO,hOO,cosav,ener;
+    double fac;
     
-  fp=xvgropen(fn,"Distance dependent Gk","r (nm)","G\\sk\\N(r)",oenv);
-  xvgr_legend(fp,asize(leg),leg,oenv);
+    fp=xvgropen(fn,"Distance dependent Gk","r (nm)","G\\sk\\N(r)",oenv);
+    xvgr_legend(fp,asize(leg),leg,oenv);
   
-  Gkr = 1;  /* Self-dipole inproduct = 1 */
-  rho = ngrp/volume;
+    Gkr = 1;  /* Self-dipole inproduct = 1 */
+    rho = ngrp/volume;
   
-  if (debug) {
-    fprintf(debug,"Number density is %g molecules / nm^3\n",rho);
-    fprintf(debug,"ngrp = %d, nframes = %d\n",ngrp,nframes);
-  }
+    if (debug) {
+        fprintf(debug,"Number density is %g molecules / nm^3\n",rho);
+        fprintf(debug,"ngrp = %d, nframes = %d\n",ngrp,nframes);
+    }
   
-  last = gb->nelem-1;
-  while(last>1 && gb->elem[last-1]==0)
-    last--;
-
-  /* Divide by dipole squared, by number of frames, by number of origins.
-   * Multiply by 2 because we only take half the matrix of interactions
-   * into account.
-   */
-  fac  = 2.0/((double) ngrp * (double) nframes);
-
-  x0 = 0;
-  for(i=0; i<last; i++) {
-    /* Centre of the coordinate in the spherical layer */
-    x1    = x0+gb->spacing;
+    last = gb->nelem-1;
+    while(last>1 && gb->elem[last-1]==0)
+        last--;
+
+    /* Divide by dipole squared, by number of frames, by number of origins.
+     * Multiply by 2 because we only take half the matrix of interactions
+     * into account.
+     */
+    fac  = 2.0/((double) ngrp * (double) nframes);
+
+    x0 = 0;
+    for(i=0; i<last; i++) {
+        /* Centre of the coordinate in the spherical layer */
+        x1    = x0+gb->spacing;
     
-    /* Volume of the layer */
-    vol_s = (4.0/3.0)*M_PI*(x1*x1*x1-x0*x0*x0);
+        /* Volume of the layer */
+        vol_s = (4.0/3.0)*M_PI*(x1*x1*x1-x0*x0*x0);
     
-    /* gOO */
-    gOO   = gb->count[i]*fac/(rho*vol_s);
+        /* gOO */
+        gOO   = gb->count[i]*fac/(rho*vol_s);
     
-    /* Dipole correlation hOO, normalized by the relative number density, like
-     * in a Radial distribution function.
-     */
-    ggg  = gb->elem[i]*fac;
-    hOO  = 3.0*ggg/(rho*vol_s);
-    Gkr += ggg;
-    if (gb->count[i])
-      cosav = gb->elem[i]/gb->count[i];
-    else
-      cosav = 0;
-    ener = -0.5*cosav*ONE_4PI_EPS0/(x1*x1*x1);
+        /* Dipole correlation hOO, normalized by the relative number density, like
+         * in a Radial distribution function.
+         */
+        ggg  = gb->elem[i]*fac;
+        hOO  = 3.0*ggg/(rho*vol_s);
+        Gkr += ggg;
+        if (gb->count[i])
+            cosav = gb->elem[i]/gb->count[i];
+        else
+            cosav = 0;
+        ener = -0.5*cosav*ONE_4PI_EPS0/(x1*x1*x1);
     
-    fprintf(fp,"%10.5e %12.5e %12.5e %12.5e %12.5e  %12.5e\n",
-           x1,Gkr,cosav,hOO,gOO,ener);
+        fprintf(fp,"%10.5e %12.5e %12.5e %12.5e %12.5e  %12.5e\n",
+                x1,Gkr,cosav,hOO,gOO,ener);
     
-    /* Swap x0 and x1 */
-    x0 = x1;
-  }
-  ffclose(fp);
+        /* Swap x0 and x1 */
+        x0 = x1;
+    }
+    ffclose(fp);
 }
 
 gmx_bool read_mu_from_enx(ener_file_t fmu,int Vol,ivec iMu,rvec mu,real *vol,
-                      real *t, int nre,t_enxframe *fr)
+                          real *t, int nre,t_enxframe *fr)
 {
-  int      i;
-  gmx_bool     bCont;
-  char     buf[22];
-
-  bCont = do_enx(fmu,fr);
-  if (fr->nre != nre) 
-    fprintf(stderr,"Something strange: expected %d entries in energy file at step %s\n(time %g) but found %d entries\n",
-           nre,gmx_step_str(fr->step,buf),fr->t,fr->nre);
+    int      i;
+    gmx_bool     bCont;
+    char     buf[22];
+
+    bCont = do_enx(fmu,fr);
+    if (fr->nre != nre) 
+        fprintf(stderr,"Something strange: expected %d entries in energy file at step %s\n(time %g) but found %d entries\n",
+                nre,gmx_step_str(fr->step,buf),fr->t,fr->nre);
   
-  if (bCont) {
-    if (Vol != -1)          /* we've got Volume in the energy file */
-      *vol = fr->ener[Vol].e;
-    for (i=0; i<DIM; i++)
-      mu[i] = fr->ener[iMu[i]].e;
-    *t = fr->t;
-  }
+    if (bCont) {
+        if (Vol != -1)          /* we've got Volume in the energy file */
+            *vol = fr->ener[Vol].e;
+        for (i=0; i<DIM; i++)
+            mu[i] = fr->ener[iMu[i]].e;
+        *t = fr->t;
+    }
   
-  return bCont;
+    return bCont;
 }
 
 static void neutralize_mols(int n,int *index,t_block *mols,t_atom *atom)
 {
-  double mtot,qtot;
-  int  ncharged,m,a0,a1,a;
-
-  ncharged = 0;
-  for(m=0; m<n; m++) {
-    a0 = mols->index[index[m]];
-    a1 = mols->index[index[m]+1];
-    mtot = 0;
-    qtot = 0;
-    for(a=a0; a<a1; a++) {
-      mtot += atom[a].m;
-      qtot += atom[a].q;
+    double mtot,qtot;
+    int  ncharged,m,a0,a1,a;
+
+    ncharged = 0;
+    for(m=0; m<n; m++) {
+        a0 = mols->index[index[m]];
+        a1 = mols->index[index[m]+1];
+        mtot = 0;
+        qtot = 0;
+        for(a=a0; a<a1; a++) {
+            mtot += atom[a].m;
+            qtot += atom[a].q;
+        }
+        /* This check is only for the count print */
+        if (fabs(qtot) > 0.01)
+            ncharged++;
+        if (mtot > 0) {
+            /* Remove the net charge at the center of mass */
+            for(a=a0; a<a1; a++)
+                atom[a].q -= qtot*atom[a].m/mtot;
+        }
     }
-    /* This check is only for the count print */
-    if (fabs(qtot) > 0.01)
-      ncharged++;
-    if (mtot > 0) {
-      /* Remove the net charge at the center of mass */
-      for(a=a0; a<a1; a++)
-       atom[a].q -= qtot*atom[a].m/mtot;
-    }
-  }
 
-  if (ncharged)
-    printf("There are %d charged molecules in the selection,\n"
-          "will subtract their charge at their center of mass\n",ncharged);
+    if (ncharged)
+        printf("There are %d charged molecules in the selection,\n"
+               "will subtract their charge at their center of mass\n",ncharged);
 }
 
 static void mol_dip(int k0,int k1,rvec x[],t_atom atom[],rvec mu)
 {
-  int  k,m;
-  real q;
+    int  k,m;
+    real q;
   
-  clear_rvec(mu);
-  for(k=k0; (k<k1); k++) {
-    q  = e2d(atom[k].q);
-    for(m=0; (m<DIM); m++) 
-      mu[m] += q*x[k][m];
-  }
+    clear_rvec(mu);
+    for(k=k0; (k<k1); k++) {
+        q  = e2d(atom[k].q);
+        for(m=0; (m<DIM); m++) 
+            mu[m] += q*x[k][m];
+    }
 }
 
 static void mol_quad(int k0,int k1,rvec x[],t_atom atom[],rvec quad)
 {
-  int    i,k,m,n,niter;
-  real   q,r2,mass,masstot;
-  rvec   com;          /* center of mass */
-  rvec   r;            /* distance of atoms to center of mass */
-  real   rcom_m,rcom_n;
-  double **inten;
-  double dd[DIM],**ev,tmp;
-
-  snew(inten,DIM);
-  snew(ev,DIM);
-  for(i=0; (i<DIM); i++) {
-    snew(inten[i],DIM);
-    snew(ev[i],DIM);
-    dd[i]=0.0;
-  }
-
-  /* Compute center of mass */
-  clear_rvec(com);
-  masstot = 0.0;
-  for(k=k0; (k<k1); k++) {
-    mass     = atom[k].m;
-    masstot += mass;
-    for(i=0; (i<DIM); i++)
-      com[i] += mass*x[k][i];
-  }
-  svmul((1.0/masstot),com,com);
-
-  /* We want traceless quadrupole moments, so let us calculate the complete
-   * quadrupole moment tensor and diagonalize this tensor to get
-   * the individual components on the diagonal.
-   */
+    int    i,k,m,n,niter;
+    real   q,r2,mass,masstot;
+    rvec   com;          /* center of mass */
+    rvec   r;            /* distance of atoms to center of mass */
+    real   rcom_m,rcom_n;
+    double **inten;
+    double dd[DIM],**ev,tmp;
+
+    snew(inten,DIM);
+    snew(ev,DIM);
+    for(i=0; (i<DIM); i++) {
+        snew(inten[i],DIM);
+        snew(ev[i],DIM);
+        dd[i]=0.0;
+    }
+
+    /* Compute center of mass */
+    clear_rvec(com);
+    masstot = 0.0;
+    for(k=k0; (k<k1); k++) {
+        mass     = atom[k].m;
+        masstot += mass;
+        for(i=0; (i<DIM); i++)
+            com[i] += mass*x[k][i];
+    }
+    svmul((1.0/masstot),com,com);
+
+    /* We want traceless quadrupole moments, so let us calculate the complete
+     * quadrupole moment tensor and diagonalize this tensor to get
+     * the individual components on the diagonal.
+     */
 
 #define delta(a,b) (( a == b ) ? 1.0 : 0.0)
 
-  for(m=0; (m<DIM); m++) 
-    for(n=0; (n<DIM); n++)
-      inten[m][n] = 0;
-  for(k=k0; (k<k1); k++) {       /* loop over atoms in a molecule */
-    q  = (atom[k].q)*100.0;
-    rvec_sub(x[k],com,r);
-    r2 = iprod(r,r);
-    for(m=0; (m<DIM); m++)
-      for(n=0; (n<DIM); n++)
-       inten[m][n] += 0.5*q*(3.0*r[m]*r[n] - r2*delta(m,n))*EANG2CM*CM2D;
-  }
-  if (debug)
-    for(i=0; (i<DIM); i++) 
-      fprintf(debug,"Q[%d] = %8.3f  %8.3f  %8.3f\n",
-             i,inten[i][XX],inten[i][YY],inten[i][ZZ]);
+    for(m=0; (m<DIM); m++) 
+        for(n=0; (n<DIM); n++)
+            inten[m][n] = 0;
+    for(k=k0; (k<k1); k++) {       /* loop over atoms in a molecule */
+        q  = (atom[k].q)*100.0;
+        rvec_sub(x[k],com,r);
+        r2 = iprod(r,r);
+        for(m=0; (m<DIM); m++)
+            for(n=0; (n<DIM); n++)
+                inten[m][n] += 0.5*q*(3.0*r[m]*r[n] - r2*delta(m,n))*EANG2CM*CM2D;
+    }
+    if (debug)
+        for(i=0; (i<DIM); i++) 
+            fprintf(debug,"Q[%d] = %8.3f  %8.3f  %8.3f\n",
+                    i,inten[i][XX],inten[i][YY],inten[i][ZZ]);
   
-  /* We've got the quadrupole tensor, now diagonalize the sucker */
-  jacobi(inten,3,dd,ev,&niter);
+    /* We've got the quadrupole tensor, now diagonalize the sucker */
+    jacobi(inten,3,dd,ev,&niter);
+
+    if (debug) {
+        for(i=0; (i<DIM); i++) 
+            fprintf(debug,"ev[%d] = %8.3f  %8.3f  %8.3f\n",
+                    i,ev[i][XX],ev[i][YY],ev[i][ZZ]);
+        for(i=0; (i<DIM); i++) 
+            fprintf(debug,"Q'[%d] = %8.3f  %8.3f  %8.3f\n",
+                    i,inten[i][XX],inten[i][YY],inten[i][ZZ]);
+    }
+    /* Sort the eigenvalues, for water we know that the order is as follows:
+     *
+     * Q_yy, Q_zz, Q_xx
+     *
+     * At the moment I have no idea how this will work out for other molecules...
+     */
 
-  if (debug) {
-    for(i=0; (i<DIM); i++) 
-      fprintf(debug,"ev[%d] = %8.3f  %8.3f  %8.3f\n",
-             i,ev[i][XX],ev[i][YY],ev[i][ZZ]);
-    for(i=0; (i<DIM); i++) 
-      fprintf(debug,"Q'[%d] = %8.3f  %8.3f  %8.3f\n",
-             i,inten[i][XX],inten[i][YY],inten[i][ZZ]);
-  }
-  /* Sort the eigenvalues, for water we know that the order is as follows:
-   *
-   * Q_yy, Q_zz, Q_xx
-   *
-   * At the moment I have no idea how this will work out for other molecules...
-   */
-
-#define SWAP(i)                        \
-  if (dd[i+1] > dd[i]) {               \
-    tmp=dd[i];                         \
-    dd[i]=dd[i+1];                     \
-    dd[i+1]=tmp;                       \
-  }
-  SWAP(0);
-  SWAP(1);
-  SWAP(0);
-
-  for(m=0; (m<DIM); m++) {
-    quad[0]=dd[2];  /* yy */
-    quad[1]=dd[0];  /* zz */
-    quad[2]=dd[1];  /* xx */
-  }
-
-  if (debug)
-    pr_rvec(debug,0,"Quadrupole",quad,DIM,TRUE);
-
-  /* clean-up */
-  for(i=0; (i<DIM); i++) {
-    sfree(inten[i]);
-    sfree(ev[i]);
-  }
-  sfree(inten);
-  sfree(ev);
+#define SWAP(i)                                 \
+    if (dd[i+1] > dd[i]) {                      \
+        tmp=dd[i];                              \
+        dd[i]=dd[i+1];                          \
+        dd[i+1]=tmp;                            \
+    }
+    SWAP(0);
+    SWAP(1);
+    SWAP(0);
+
+    for(m=0; (m<DIM); m++) {
+        quad[0]=dd[2];  /* yy */
+        quad[1]=dd[0];  /* zz */
+        quad[2]=dd[1];  /* xx */
+    }
+
+    if (debug)
+        pr_rvec(debug,0,"Quadrupole",quad,DIM,TRUE);
+
+    /* clean-up */
+    for(i=0; (i<DIM); i++) {
+        sfree(inten[i]);
+        sfree(ev[i]);
+    }
+    sfree(inten);
+    sfree(ev);
 }
 
 /*
@@ -519,882 +519,936 @@ static void mol_quad(int k0,int k1,rvec x[],t_atom atom[],rvec quad)
  */ 
 real calc_eps(double M_diff,double volume,double epsRF,double temp)
 {
-  double eps,A,teller,noemer;
-  double eps_0=8.854187817e-12;     /* epsilon_0 in C^2 J^-1 m^-1 */
-  double fac=1.112650021e-59;       /* converts Debye^2 to C^2 m^2 */
+    double eps,A,teller,noemer;
+    double eps_0=8.854187817e-12;     /* epsilon_0 in C^2 J^-1 m^-1 */
+    double fac=1.112650021e-59;       /* converts Debye^2 to C^2 m^2 */
 
-  A = M_diff*fac/(3*eps_0*volume*NANO*NANO*NANO*BOLTZMANN*temp);
+    A = M_diff*fac/(3*eps_0*volume*NANO*NANO*NANO*BOLTZMANN*temp);
  
-  if (epsRF == 0.0) {
-    teller = 1 + A;
-    noemer = 1; 
-  } else { 
-    teller = 1 + (A*2*epsRF/(2*epsRF+1));
-    noemer = 1 - (A/(2*epsRF+1));
-  }
-  eps = teller / noemer;
-
-  return eps;
+    if (epsRF == 0.0) {
+        teller = 1 + A;
+        noemer = 1; 
+    } else { 
+        teller = 1 + (A*2*epsRF/(2*epsRF+1));
+        noemer = 1 - (A/(2*epsRF+1));
+    }
+    eps = teller / noemer;
+
+    return eps;
 }
 
 static void update_slab_dipoles(int k0,int k1,rvec x[],rvec mu,
-                               int idim,int nslice,rvec slab_dipole[],
-                               matrix box)
+                                int idim,int nslice,rvec slab_dipole[],
+                                matrix box)
 {
-  int k;
-  real xdim=0;
+    int k;
+    real xdim=0;
   
-  for(k=k0; (k<k1); k++) 
-    xdim += x[k][idim];
-  xdim /= (k1-k0);
-  k = ((int)(xdim*nslice/box[idim][idim] + nslice)) % nslice;
-  rvec_inc(slab_dipole[k],mu);
+    for(k=k0; (k<k1); k++) 
+        xdim += x[k][idim];
+    xdim /= (k1-k0);
+    k = ((int)(xdim*nslice/box[idim][idim] + nslice)) % nslice;
+    rvec_inc(slab_dipole[k],mu);
 }
 
 static void dump_slab_dipoles(const char *fn,int idim,int nslice,
                               rvec slab_dipole[], matrix box,int nframes,
                               const output_env_t oenv)
 {
-  FILE *fp;
-  char buf[STRLEN];
-  int  i;
-  real mutot;
-  const char *leg_dim[4] = { 
-    "\\f{12}m\\f{4}\\sX\\N",
-    "\\f{12}m\\f{4}\\sY\\N",
-    "\\f{12}m\\f{4}\\sZ\\N",
-    "\\f{12}m\\f{4}\\stot\\N"
-  };
+    FILE *fp;
+    char buf[STRLEN];
+    int  i;
+    real mutot;
+    const char *leg_dim[4] = { 
+        "\\f{12}m\\f{4}\\sX\\N",
+        "\\f{12}m\\f{4}\\sY\\N",
+        "\\f{12}m\\f{4}\\sZ\\N",
+        "\\f{12}m\\f{4}\\stot\\N"
+    };
   
-  sprintf(buf,"Box-%c (nm)",'X'+idim);
-  fp = xvgropen(fn,"Average dipole moment per slab",buf,"\\f{12}m\\f{4} (D)",
-                oenv);
-  xvgr_legend(fp,DIM,leg_dim,oenv); 
-  for(i=0; (i<nslice); i++) {
-    mutot = norm(slab_dipole[i])/nframes;
-    fprintf(fp,"%10.3f  %10.3f  %10.3f  %10.3f  %10.3f\n",
-           ((i+0.5)*box[idim][idim])/nslice,
-           slab_dipole[i][XX]/nframes,
-           slab_dipole[i][YY]/nframes,
-           slab_dipole[i][ZZ]/nframes,
-           mutot);
-  }
-  ffclose(fp);
-  do_view(oenv,fn,"-autoscale xy -nxy");
+    sprintf(buf,"Box-%c (nm)",'X'+idim);
+    fp = xvgropen(fn,"Average dipole moment per slab",buf,"\\f{12}m\\f{4} (D)",
+                  oenv);
+    xvgr_legend(fp,DIM,leg_dim,oenv); 
+    for(i=0; (i<nslice); i++) {
+        mutot = norm(slab_dipole[i])/nframes;
+        fprintf(fp,"%10.3f  %10.3f  %10.3f  %10.3f  %10.3f\n",
+                ((i+0.5)*box[idim][idim])/nslice,
+                slab_dipole[i][XX]/nframes,
+                slab_dipole[i][YY]/nframes,
+                slab_dipole[i][ZZ]/nframes,
+                mutot);
+    }
+    ffclose(fp);
+    do_view(oenv,fn,"-autoscale xy -nxy");
 }
                            
 static void compute_avercos(int n,rvec dip[],real *dd,rvec axis,gmx_bool bPairs)
 {
-  int    i,j,k;
-  double dc,dc1,d,n5,ddc1,ddc2,ddc3;
-  rvec   xxx = { 1, 0, 0 };
-  rvec   yyy = { 0, 1, 0 };
-  rvec   zzz = { 0, 0, 1 };
+    int    i,j,k;
+    double dc,dc1,d,n5,ddc1,ddc2,ddc3;
+    rvec   xxx = { 1, 0, 0 };
+    rvec   yyy = { 0, 1, 0 };
+    rvec   zzz = { 0, 0, 1 };
   
-  d=0;
-  ddc1 = ddc2 = ddc3 = 0;
-  for(i=k=0; (i<n); i++) {
-    ddc1 += fabs(cos_angle(dip[i],xxx));
-    ddc2 += fabs(cos_angle(dip[i],yyy));
-    ddc3 += fabs(cos_angle(dip[i],zzz));
-    if (bPairs) 
-      for(j=i+1; (j<n); j++,k++) {
-       dc  = cos_angle(dip[i],dip[j]);
-       d  += fabs(dc);
-      }
-  }
-  *dd  = d/k;
-  axis[XX] = ddc1/n;
-  axis[YY] = ddc2/n;
-  axis[ZZ] = ddc3/n;
+    d=0;
+    ddc1 = ddc2 = ddc3 = 0;
+    for(i=k=0; (i<n); i++) 
+    {
+        ddc1 += fabs(cos_angle(dip[i],xxx));
+        ddc2 += fabs(cos_angle(dip[i],yyy));
+        ddc3 += fabs(cos_angle(dip[i],zzz));
+        if (bPairs) 
+            for(j=i+1; (j<n); j++,k++) 
+            {
+                dc  = cos_angle(dip[i],dip[j]);
+                d  += fabs(dc);
+            }
+    }
+    *dd  = d/k;
+    axis[XX] = ddc1/n;
+    axis[YY] = ddc2/n;
+    axis[ZZ] = ddc3/n;
 }
 
 static void do_dip(t_topology *top,int ePBC,real volume,
-                  const char *fn,
-                  const char *out_mtot,const char *out_eps,
+                   const char *fn,
+                   const char *out_mtot,const char *out_eps,
                    const char *out_aver, const char *dipdist,
-                  const char *cosaver, const char *fndip3d,
-                  const char *fnadip,  gmx_bool bPairs,
-                  const char *corrtype,const char *corf,
-                  gmx_bool bGkr,     const char *gkrfn,
-                  gmx_bool bPhi,     int  *nlevels,  int ndegrees,
-                  int  ncos,
-                  const char *cmap,    real rcmax,
-                  gmx_bool bQuad,    const char *quadfn,
-                  gmx_bool bMU,      const char *mufn,
-                  int  *gnx,     int  *molindex[],
-                  real mu_max,   real mu_aver,
-                  real epsilonRF,real temp,
-                  int  *gkatom,  int skip,
-                  gmx_bool bSlab,    int nslices,
-                  const char *axtitle, const char *slabfn,
+                   const char *cosaver, const char *fndip3d,
+                   const char *fnadip,  gmx_bool bPairs,
+                   const char *corrtype,const char *corf,
+                   gmx_bool bGkr,     const char *gkrfn,
+                   gmx_bool bPhi,     int  *nlevels,  int ndegrees,
+                   int  ncos,
+                   const char *cmap,    real rcmax,
+                   gmx_bool bQuad,    const char *quadfn,
+                   gmx_bool bMU,      const char *mufn,
+                   int  *gnx,     int  *molindex[],
+                   real mu_max,   real mu_aver,
+                   real epsilonRF,real temp,
+                   int  *gkatom,  int skip,
+                   gmx_bool bSlab,    int nslices,
+                   const char *axtitle, const char *slabfn,
                    const output_env_t oenv)
 {
-  const char *leg_mtot[] = { 
-    "M\\sx \\N", 
-    "M\\sy \\N",
-    "M\\sz \\N",
-    "|M\\stot \\N|"
-  };
+    const char *leg_mtot[] = { 
+        "M\\sx \\N", 
+        "M\\sy \\N",
+        "M\\sz \\N",
+        "|M\\stot \\N|"
+    };
 #define NLEGMTOT asize(leg_mtot)
-  const char *leg_eps[] = { 
-    "epsilon",
-    "G\\sk",
-    "g\\sk"
-  };
+    const char *leg_eps[] = { 
+        "epsilon",
+        "G\\sk",
+        "g\\sk"
+    };
 #define NLEGEPS asize(leg_eps)
-  const char *leg_aver[] = { 
-    "< |M|\\S2\\N >", 
-    "< |M| >\\S2\\N",
-    "< |M|\\S2\\N > - < |M| >\\S2\\N",
-    "< |M| >\\S2\\N / < |M|\\S2\\N >"
-  };
+    const char *leg_aver[] = { 
+        "< |M|\\S2\\N >", 
+        "< |M| >\\S2\\N",
+        "< |M|\\S2\\N > - < |M| >\\S2\\N",
+        "< |M| >\\S2\\N / < |M|\\S2\\N >"
+    };
 #define NLEGAVER asize(leg_aver)
-  const char *leg_cosaver[] = {
-    "\\f{4}<|cos\\f{12}q\\f{4}\\sij\\N|>",
-    "RMSD cos",
-    "\\f{4}<|cos\\f{12}q\\f{4}\\siX\\N|>",
-    "\\f{4}<|cos\\f{12}q\\f{4}\\siY\\N|>",
-    "\\f{4}<|cos\\f{12}q\\f{4}\\siZ\\N|>"
-  };
+    const char *leg_cosaver[] = {
+        "\\f{4}<|cos\\f{12}q\\f{4}\\sij\\N|>",
+        "RMSD cos",
+        "\\f{4}<|cos\\f{12}q\\f{4}\\siX\\N|>",
+        "\\f{4}<|cos\\f{12}q\\f{4}\\siY\\N|>",
+        "\\f{4}<|cos\\f{12}q\\f{4}\\siZ\\N|>"
+    };
 #define NLEGCOSAVER asize(leg_cosaver)
-  const char *leg_adip[] = {
-    "<mu>",
-    "Std. Dev.",
-    "Error"
-  };
+    const char *leg_adip[] = {
+        "<mu>",
+        "Std. Dev.",
+        "Error"
+    };
 #define NLEGADIP asize(leg_adip)
 
-  FILE       *outdd,*outmtot,*outaver,*outeps,*caver=NULL;
-  FILE       *dip3d=NULL,*adip=NULL;
-  rvec       *x,*dipole=NULL,mu_t,quad,*dipsp=NULL;
-  t_gkrbin   *gkrbin = NULL;
-  gmx_enxnm_t *enm=NULL;
-  t_enxframe *fr;
-  int        nframes=1000,nre,timecheck=0,ncolour=0;
-  ener_file_t fmu=NULL;
-  int        i,j,k,n,m,natom=0,nmol,gnx_tot,teller,tel3;
-  t_trxstatus *status;
-  int        *dipole_bin,ndipbin,ibin,iVol,step,idim=-1;
-  unsigned long mode;
-  char       buf[STRLEN];
-  real       rcut=0,t,t0,t1,dt,lambda,dd,rms_cos;
-  rvec       dipaxis;
-  matrix     box;
-  gmx_bool       bCorr,bTotal,bCont;
-  double     M_diff=0,epsilon,invtel,vol_aver;
-  double     mu_ave,mu_mol,M2_ave=0,M_ave2=0,M_av[DIM],M_av2[DIM];
-  double     M[3],M2[3],M4[3],Gk=0,g_k=0;
-  gmx_stats_t Mx,My,Mz,Msq,Vol,*Qlsq,mulsq,muframelsq=NULL;
-  ivec       iMu;
-  real       **muall=NULL;
-  rvec       *slab_dipoles=NULL;
-  t_atom     *atom=NULL;
-  t_block    *mols=NULL;
-  gmx_rmpbc_t gpbc=NULL;
-
-  gnx_tot = gnx[0];
-  if (ncos > 1) {
-    gnx_tot += gnx[1];
-  }
-
-  vol_aver = 0.0;
+    FILE       *outdd,*outmtot,*outaver,*outeps,*caver=NULL;
+    FILE       *dip3d=NULL,*adip=NULL;
+    rvec       *x,*dipole=NULL,mu_t,quad,*dipsp=NULL;
+    t_gkrbin   *gkrbin = NULL;
+    gmx_enxnm_t *enm=NULL;
+    t_enxframe *fr;
+    int        nframes=1000,nre,timecheck=0,ncolour=0;
+    ener_file_t fmu=NULL;
+    int        i,j,k,n,m,natom=0,nmol,gnx_tot,teller,tel3;
+    t_trxstatus *status;
+    int        *dipole_bin,ndipbin,ibin,iVol,step,idim=-1;
+    unsigned long mode;
+    char       buf[STRLEN];
+    real       rcut=0,t,t0,t1,dt,lambda,dd,rms_cos;
+    rvec       dipaxis;
+    matrix     box;
+    gmx_bool       bCorr,bTotal,bCont;
+    double     M_diff=0,epsilon,invtel,vol_aver;
+    double     mu_ave,mu_mol,M2_ave=0,M_ave2=0,M_av[DIM],M_av2[DIM];
+    double     M[3],M2[3],M4[3],Gk=0,g_k=0;
+    gmx_stats_t Mx,My,Mz,Msq,Vol,*Qlsq,mulsq,muframelsq=NULL;
+    ivec       iMu;
+    real       **muall=NULL;
+    rvec       *slab_dipoles=NULL;
+    t_atom     *atom=NULL;
+    t_block    *mols=NULL;
+    gmx_rmpbc_t gpbc=NULL;
+
+    gnx_tot = gnx[0];
+    if (ncos > 1) {
+        gnx_tot += gnx[1];
+    }
+
+    vol_aver = 0.0;
       
-  iVol=-1;
-  if (bMU) {
-    fmu = open_enx(mufn,"r");
-    do_enxnms(fmu,&nre,&enm);
-
-    /* Determine the indexes of the energy grps we need */
-    for (i=0; (i<nre); i++) {
-      if (strstr(enm[i].name,"Volume"))
-       iVol=i;
-      else if (strstr(enm[i].name,"Mu-X"))
-       iMu[XX]=i;
-      else if (strstr(enm[i].name,"Mu-Y"))
-       iMu[YY]=i;
-      else if (strstr(enm[i].name,"Mu-Z"))
-       iMu[ZZ]=i;
+    iVol=-1;
+    if (bMU) 
+    {
+        fmu = open_enx(mufn,"r");
+        do_enxnms(fmu,&nre,&enm);
+
+        /* Determine the indexes of the energy grps we need */
+        for (i=0; (i<nre); i++) {
+            if (strstr(enm[i].name,"Volume"))
+                iVol=i;
+            else if (strstr(enm[i].name,"Mu-X"))
+                iMu[XX]=i;
+            else if (strstr(enm[i].name,"Mu-Y"))
+                iMu[YY]=i;
+            else if (strstr(enm[i].name,"Mu-Z"))
+                iMu[ZZ]=i;
+        }
     }
-  }
-  else {
-    atom = top->atoms.atom;
-    mols = &(top->mols);
-  }
-  
-  if (iVol == -1)
-    printf("Using Volume from topology: %g nm^3\n",volume);
-
-  /* Correlation stuff */ 
-  bCorr  = (corrtype[0] != 'n');
-  bTotal = (corrtype[0] == 't');
-  if (bCorr) {
-    if (bTotal) {
-      snew(muall,1);
-      snew(muall[0],nframes*DIM);
+    else 
+    {
+        atom = top->atoms.atom;
+        mols = &(top->mols);
     }
-    else {
-      snew(muall,gnx[0]);
-      for(i=0; (i<gnx[0]); i++)
-       snew(muall[i],nframes*DIM);
+  
+    if (iVol == -1)
+        printf("Using Volume from topology: %g nm^3\n",volume);
+
+    /* Correlation stuff */ 
+    bCorr  = (corrtype[0] != 'n');
+    bTotal = (corrtype[0] == 't');
+    if (bCorr) 
+    {
+        if (bTotal) 
+        {
+            snew(muall,1);
+            snew(muall[0],nframes*DIM);
+        }
+        else 
+        {
+            snew(muall,gnx[0]);
+            for(i=0; (i<gnx[0]); i++)
+                snew(muall[i],nframes*DIM);
+        }
     }
-  }
-
-  /* Allocate array which contains for every molecule in a frame the
-   * dipole moment.
-   */
-  if (!bMU)
-    snew(dipole,gnx_tot);
-
-  /* Statistics */
-  snew(Qlsq,DIM);
-  for(i=0; (i<DIM); i++) 
-    Qlsq[i] = gmx_stats_init();
-  mulsq = gmx_stats_init();
+
+    /* Allocate array which contains for every molecule in a frame the
+     * dipole moment.
+     */
+    if (!bMU)
+        snew(dipole,gnx_tot);
+
+    /* Statistics */
+    snew(Qlsq,DIM);
+    for(i=0; (i<DIM); i++) 
+        Qlsq[i] = gmx_stats_init();
+    mulsq = gmx_stats_init();
   
-  /* Open all the files */
-  outmtot = xvgropen(out_mtot,
-                    "Total dipole moment of the simulation box vs. time",
-                    "Time (ps)","Total Dipole Moment (Debye)",oenv);
-  outeps  = xvgropen(out_eps,"Epsilon and Kirkwood factors",
-                    "Time (ps)","",oenv);
-  outaver = xvgropen(out_aver,"Total dipole moment",
-                    "Time (ps)","D",oenv);
-  if (bSlab) {
-    idim = axtitle[0] - 'X';
-    if ((idim < 0) || (idim >= DIM))
-      idim = axtitle[0] - 'x';
-    if ((idim < 0) || (idim >= DIM))
-      bSlab = FALSE;
-    if (nslices < 2)
-      bSlab = FALSE;
-    fprintf(stderr,"axtitle = %s, nslices = %d, idim = %d\n",
-           axtitle,nslices,idim);
-    if (bSlab) {
-      snew(slab_dipoles,nslices);
-      fprintf(stderr,"Doing slab analysis\n");
+    /* Open all the files */
+    outmtot = xvgropen(out_mtot,
+                       "Total dipole moment of the simulation box vs. time",
+                       "Time (ps)","Total Dipole Moment (Debye)",oenv);
+    outeps  = xvgropen(out_eps,"Epsilon and Kirkwood factors",
+                       "Time (ps)","",oenv);
+    outaver = xvgropen(out_aver,"Total dipole moment",
+                       "Time (ps)","D",oenv);
+    if (bSlab) 
+    {
+        idim = axtitle[0] - 'X';
+        if ((idim < 0) || (idim >= DIM))
+            idim = axtitle[0] - 'x';
+        if ((idim < 0) || (idim >= DIM))
+            bSlab = FALSE;
+        if (nslices < 2)
+            bSlab = FALSE;
+        fprintf(stderr,"axtitle = %s, nslices = %d, idim = %d\n",
+                axtitle,nslices,idim);
+        if (bSlab) 
+        {
+            snew(slab_dipoles,nslices);
+            fprintf(stderr,"Doing slab analysis\n");
+        }
     }
-  }
   
-  if (fnadip) {
-    adip = xvgropen(fnadip, "Average molecular dipole","Dipole (D)","",oenv);
-    xvgr_legend(adip,NLEGADIP,leg_adip, oenv);
+    if (fnadip) 
+    {
+        adip = xvgropen(fnadip, "Average molecular dipole","Dipole (D)","",oenv);
+        xvgr_legend(adip,NLEGADIP,leg_adip, oenv);
   
-  }
-  if (cosaver) {
-    caver = xvgropen(cosaver,bPairs ? "Average pair orientation" :
-                    "Average absolute dipole orientation","Time (ps)","",oenv);
-    xvgr_legend(caver,NLEGCOSAVER,bPairs ? leg_cosaver : &(leg_cosaver[1]),
-                oenv);
-  }
+    }
+    if (cosaver) 
+    {
+        caver = xvgropen(cosaver,bPairs ? "Average pair orientation" :
+                         "Average absolute dipole orientation","Time (ps)","",oenv);
+        xvgr_legend(caver,NLEGCOSAVER,bPairs ? leg_cosaver : &(leg_cosaver[1]),
+                    oenv);
+    }
     
-  if (fndip3d) {
-    snew(dipsp,gnx_tot);
+    if (fndip3d) 
+    {
+        snew(dipsp,gnx_tot);
   
-    /* we need a dummy file for gnuplot */
-    dip3d = (FILE *)ffopen("dummy.dat","w");
-    fprintf(dip3d,"%f %f %f", 0.0,0.0,0.0);
-    ffclose(dip3d);
-
-    dip3d = (FILE *)ffopen(fndip3d,"w");
-    fprintf(dip3d,"# This file was created by %s\n",Program());
-    fprintf(dip3d,"# which is part of G R O M A C S:\n");
-    fprintf(dip3d,"#\n");
-  }
+        /* we need a dummy file for gnuplot */
+        dip3d = (FILE *)ffopen("dummy.dat","w");
+        fprintf(dip3d,"%f %f %f", 0.0,0.0,0.0);
+        ffclose(dip3d);
+
+        dip3d = (FILE *)ffopen(fndip3d,"w");
+        fprintf(dip3d,"# This file was created by %s\n",Program());
+        fprintf(dip3d,"# which is part of G R O M A C S:\n");
+        fprintf(dip3d,"#\n");
+    }
   
-  /* Write legends to all the files */
-  xvgr_legend(outmtot,NLEGMTOT,leg_mtot,oenv);
-  xvgr_legend(outaver,NLEGAVER,leg_aver,oenv);
+    /* Write legends to all the files */
+    xvgr_legend(outmtot,NLEGMTOT,leg_mtot,oenv);
+    xvgr_legend(outaver,NLEGAVER,leg_aver,oenv);
   
-  if (bMU && (mu_aver == -1))
-    xvgr_legend(outeps,NLEGEPS-2,leg_eps,oenv);
-  else
-    xvgr_legend(outeps,NLEGEPS,leg_eps,oenv);
+    if (bMU && (mu_aver == -1))
+        xvgr_legend(outeps,NLEGEPS-2,leg_eps,oenv);
+    else
+        xvgr_legend(outeps,NLEGEPS,leg_eps,oenv);
     
-  snew(fr,1);
-  clear_rvec(mu_t);
-  teller = 0;
-  /* Read the first frame from energy or traj file */
-  if (bMU)
-    do {
-      bCont = read_mu_from_enx(fmu,iVol,iMu,mu_t,&volume,&t,nre,fr);
-      if (bCont) {  
-       timecheck=check_times(t);
-       if (timecheck < 0)
-         teller++;
-       if ((teller % 10) == 0)
-         fprintf(stderr,"\r Skipping Frame %6d, time: %8.3f", teller, t);
-      }
-      else {
-       printf("End of %s reached\n",mufn);
-       break;
-      }
-    } while (bCont && (timecheck < 0));
-  else
-    natom  = read_first_x(oenv,&status,fn,&t,&x,box);
-  
-  /* Calculate spacing for dipole bin (simple histogram) */
-  ndipbin = 1+(mu_max/0.01);
-  snew(dipole_bin, ndipbin);
-  epsilon    = 0.0;
-  mu_ave     = 0.0;
-  for(m=0; (m<DIM); m++) {
-    M[m] = M2[m] = M4[m] = 0.0;
-  }
+    snew(fr,1);
+    clear_rvec(mu_t);
+    teller = 0;
+    /* Read the first frame from energy or traj file */
+    if (bMU)
+        do 
+        {
+            bCont = read_mu_from_enx(fmu,iVol,iMu,mu_t,&volume,&t,nre,fr);
+            if (bCont) 
+            {  
+                timecheck=check_times(t);
+                if (timecheck < 0)
+                    teller++;
+                if ((teller % 10) == 0)
+                    fprintf(stderr,"\r Skipping Frame %6d, time: %8.3f", teller, t);
+            }
+            else 
+            {
+                printf("End of %s reached\n",mufn);
+                break;
+            }
+        } while (bCont && (timecheck < 0));
+    else
+        natom  = read_first_x(oenv,&status,fn,&t,&x,box);
   
-  if (bGkr) {
-    /* Use 0.7 iso 0.5 to account for pressure scaling */
-    /*  rcut   = 0.7*sqrt(max_cutoff2(box)); */
-    rcut   = 0.7*sqrt(sqr(box[XX][XX])+sqr(box[YY][YY])+sqr(box[ZZ][ZZ]));
-
-    gkrbin = mk_gkrbin(rcut,rcmax,bPhi,ndegrees); 
-  }
-  gpbc = gmx_rmpbc_init(&top->idef,ePBC,natom,box);
-
-  /* Start while loop over frames */
-  t1 = t0 = t;
-  teller = 0;
-  do {
-    if (bCorr && (teller >= nframes)) {
-      nframes += 1000;
-      if (bTotal) {
-       srenew(muall[0],nframes*DIM);
-      }
-      else {
-       for(i=0; (i<gnx_tot); i++)
-         srenew(muall[i],nframes*DIM);
-      }
+    /* Calculate spacing for dipole bin (simple histogram) */
+    ndipbin = 1+(mu_max/0.01);
+    snew(dipole_bin, ndipbin);
+    epsilon    = 0.0;
+    mu_ave     = 0.0;
+    for(m=0; (m<DIM); m++) 
+    {
+        M[m] = M2[m] = M4[m] = 0.0;
     }
-    t1 = t;
+  
+    if (bGkr) 
+    {
+        /* Use 0.7 iso 0.5 to account for pressure scaling */
+        /*  rcut   = 0.7*sqrt(max_cutoff2(box)); */
+        rcut   = 0.7*sqrt(sqr(box[XX][XX])+sqr(box[YY][YY])+sqr(box[ZZ][ZZ]));
 
-    if (bMU) {
-      /* Copy rvec into double precision local variable */
-      for(m=0; (m<DIM); m++)
-       M_av[m]  = mu_t[m];
+        gkrbin = mk_gkrbin(rcut,rcmax,bPhi,ndegrees); 
     }
-    else {
-      /* Initialise */
-      for(m=0; (m<DIM); m++) {
-       M_av[m] = 0;
-       M_av2[m] = 0;
-      }
-      gmx_rmpbc(gpbc,natom,box,x);
+    gpbc = gmx_rmpbc_init(&top->idef,ePBC,natom,box);
+
+    /* Start while loop over frames */
+    t1 = t0 = t;
+    teller = 0;
+    do 
+    {
+        if (bCorr && (teller >= nframes)) 
+        {
+            nframes += 1000;
+            if (bTotal) 
+            {
+                srenew(muall[0],nframes*DIM);
+            }
+            else 
+            {
+                for(i=0; (i<gnx_tot); i++)
+                    srenew(muall[i],nframes*DIM);
+            }
+        }
+        t1 = t;
+
+        muframelsq = gmx_stats_init();
+    
+        if (bMU) 
+        {
+            /* Copy rvec into double precision local variable */
+            for(m=0; (m<DIM); m++)
+                M_av[m]  = mu_t[m];
+        }
+        else 
+        {
+            /* Initialise */
+            for(m=0; (m<DIM); m++) 
+            {
+                M_av[m] = 0;
+                M_av2[m] = 0;
+            }
+            gmx_rmpbc(gpbc,natom,box,x);
       
-      muframelsq = gmx_stats_init();
-      /* Begin loop of all molecules in frame */
-      for(n=0; (n<ncos); n++) {
-       for(i=0; (i<gnx[n]); i++) {
-         int gi,ind0,ind1;
+            /* Begin loop of all molecules in frame */
+            for(n=0; (n<ncos); n++) 
+            {
+                for(i=0; (i<gnx[n]); i++) 
+                {
+                    int gi,ind0,ind1;
          
-         ind0  = mols->index[molindex[n][i]];
-         ind1  = mols->index[molindex[n][i]+1];
+                    ind0  = mols->index[molindex[n][i]];
+                    ind1  = mols->index[molindex[n][i]+1];
          
-         mol_dip(ind0,ind1,x,atom,dipole[i]);
-         gmx_stats_add_point(mulsq,0,norm(dipole[i]),0,0);
-         gmx_stats_add_point(muframelsq,0,norm(dipole[i]),0,0);
-         if (bSlab) 
-           update_slab_dipoles(ind0,ind1,x,
-                               dipole[i],idim,nslices,slab_dipoles,box);
-         if (bQuad) {
-           mol_quad(ind0,ind1,x,atom,quad);
-           for(m=0; (m<DIM); m++)
-             gmx_stats_add_point(Qlsq[m],0,quad[m],0,0);
-         }
-         if (bCorr && !bTotal) {
-           tel3=DIM*teller;
-           muall[i][tel3+XX] = dipole[i][XX];
-           muall[i][tel3+YY] = dipole[i][YY];
-           muall[i][tel3+ZZ] = dipole[i][ZZ];
-         }
-         mu_mol = 0.0;
-         for(m=0; (m<DIM); m++) {
-           M_av[m]  += dipole[i][m];               /* M per frame */
-           mu_mol   += dipole[i][m]*dipole[i][m];  /* calc. mu for distribution */
-         }
-         mu_mol = sqrt(mu_mol);
+                    mol_dip(ind0,ind1,x,atom,dipole[i]);
+                    gmx_stats_add_point(mulsq,0,norm(dipole[i]),0,0);
+                    gmx_stats_add_point(muframelsq,0,norm(dipole[i]),0,0);
+                    if (bSlab) 
+                        update_slab_dipoles(ind0,ind1,x,
+                                            dipole[i],idim,nslices,slab_dipoles,box);
+                    if (bQuad) 
+                    {
+                        mol_quad(ind0,ind1,x,atom,quad);
+                        for(m=0; (m<DIM); m++)
+                            gmx_stats_add_point(Qlsq[m],0,quad[m],0,0);
+                    }
+                    if (bCorr && !bTotal) 
+                    {
+                        tel3=DIM*teller;
+                        muall[i][tel3+XX] = dipole[i][XX];
+                        muall[i][tel3+YY] = dipole[i][YY];
+                        muall[i][tel3+ZZ] = dipole[i][ZZ];
+                    }
+                    mu_mol = 0.0;
+                    for(m=0; (m<DIM); m++) 
+                    {
+                        M_av[m]  += dipole[i][m];               /* M per frame */
+                        mu_mol   += dipole[i][m]*dipole[i][m];  /* calc. mu for distribution */
+                    }
+                    mu_mol = sqrt(mu_mol);
          
-         mu_ave += mu_mol;                         /* calc. the average mu */
+                    mu_ave += mu_mol;                         /* calc. the average mu */
          
-         /* Update the dipole distribution */
-         ibin = (int)(ndipbin*mu_mol/mu_max + 0.5);
-         if (ibin < ndipbin)
-           dipole_bin[ibin]++;
+                    /* Update the dipole distribution */
+                    ibin = (int)(ndipbin*mu_mol/mu_max + 0.5);
+                    if (ibin < ndipbin)
+                        dipole_bin[ibin]++;
          
-         if (fndip3d) {
-           rvec2sprvec(dipole[i],dipsp[i]);
+                    if (fndip3d) 
+                    {
+                        rvec2sprvec(dipole[i],dipsp[i]);
            
-           if (dipsp[i][YY] > -M_PI && dipsp[i][YY] < -0.5*M_PI) {
-             if (dipsp[i][ZZ] < 0.5 * M_PI) {
-               ncolour = 1;
-             } else {
-               ncolour = 2;
-             }
-           }else if (dipsp[i][YY] > -0.5*M_PI && dipsp[i][YY] < 0.0*M_PI) {
-             if (dipsp[i][ZZ] < 0.5 * M_PI) {
-               ncolour = 3;
-             } else {
-               ncolour = 4;
-             }       
-           }else if (dipsp[i][YY] > 0.0 && dipsp[i][YY] < 0.5*M_PI) {
-             if (dipsp[i][ZZ] < 0.5 * M_PI) {
-               ncolour = 5;
-             } else {
-               ncolour = 6;
-             }      
-           }else if (dipsp[i][YY] > 0.5*M_PI && dipsp[i][YY] < M_PI) {
-             if (dipsp[i][ZZ] < 0.5 * M_PI) {
-               ncolour = 7;
-             } else {
-               ncolour = 8;
-             }
-           }
-           if (dip3d)
-             fprintf(dip3d,"set arrow %d from %f, %f, %f to %f, %f, %f lt %d  # %d %d\n", 
-                     i+1,
-                     x[ind0][XX],
-                     x[ind0][YY],
-                     x[ind0][ZZ],
-                     x[ind0][XX]+dipole[i][XX]/25, 
-                     x[ind0][YY]+dipole[i][YY]/25, 
-                     x[ind0][ZZ]+dipole[i][ZZ]/25, 
-                     ncolour, ind0, i);
-         }
-       } /* End loop of all molecules in frame */
+                        if (dipsp[i][YY] > -M_PI && dipsp[i][YY] < -0.5*M_PI) {
+                            if (dipsp[i][ZZ] < 0.5 * M_PI) 
+                            {
+                                ncolour = 1;
+                            } 
+                            else 
+                            {
+                                ncolour = 2;
+                            }
+                        }
+                        else if (dipsp[i][YY] > -0.5*M_PI && dipsp[i][YY] < 0.0*M_PI) 
+                        {
+                            if (dipsp[i][ZZ] < 0.5 * M_PI) 
+                            {
+                                ncolour = 3;
+                            } 
+                            else 
+                            {
+                                ncolour = 4;
+                            }       
+                        }else if (dipsp[i][YY] > 0.0 && dipsp[i][YY] < 0.5*M_PI) {
+                            if (dipsp[i][ZZ] < 0.5 * M_PI) {
+                                ncolour = 5;
+                            } else {
+                                ncolour = 6;
+                            }      
+                        }
+                        else if (dipsp[i][YY] > 0.5*M_PI && dipsp[i][YY] < M_PI) 
+                        {
+                            if (dipsp[i][ZZ] < 0.5 * M_PI) 
+                            {
+                                ncolour = 7;
+                            } 
+                            else 
+                            {
+                                ncolour = 8;
+                            }
+                        }
+                        if (dip3d)
+                            fprintf(dip3d,"set arrow %d from %f, %f, %f to %f, %f, %f lt %d  # %d %d\n", 
+                                    i+1,
+                                    x[ind0][XX],
+                                    x[ind0][YY],
+                                    x[ind0][ZZ],
+                                    x[ind0][XX]+dipole[i][XX]/25, 
+                                    x[ind0][YY]+dipole[i][YY]/25, 
+                                    x[ind0][ZZ]+dipole[i][ZZ]/25, 
+                                    ncolour, ind0, i);
+                    }
+                } /* End loop of all molecules in frame */
        
-       if (dip3d) {
-         fprintf(dip3d,"set title \"t = %4.3f\"\n",t);
-         fprintf(dip3d,"set xrange [0.0:%4.2f]\n",box[XX][XX]);
-         fprintf(dip3d,"set yrange [0.0:%4.2f]\n",box[YY][YY]);
-         fprintf(dip3d,"set zrange [0.0:%4.2f]\n\n",box[ZZ][ZZ]);
-         fprintf(dip3d,"splot 'dummy.dat' using 1:2:3 w vec\n");
-         fprintf(dip3d,"pause -1 'Hit return to continue'\n");
-       }
-      }
-    }
-    /* Compute square of total dipole */
-    for(m=0; (m<DIM); m++)
-      M_av2[m] = M_av[m]*M_av[m];
+                if (dip3d) 
+                {
+                    fprintf(dip3d,"set title \"t = %4.3f\"\n",t);
+                    fprintf(dip3d,"set xrange [0.0:%4.2f]\n",box[XX][XX]);
+                    fprintf(dip3d,"set yrange [0.0:%4.2f]\n",box[YY][YY]);
+                    fprintf(dip3d,"set zrange [0.0:%4.2f]\n\n",box[ZZ][ZZ]);
+                    fprintf(dip3d,"splot 'dummy.dat' using 1:2:3 w vec\n");
+                    fprintf(dip3d,"pause -1 'Hit return to continue'\n");
+                }
+            }
+        }
+        /* Compute square of total dipole */
+        for(m=0; (m<DIM); m++)
+            M_av2[m] = M_av[m]*M_av[m];
     
-    if (cosaver) {
-      compute_avercos(gnx_tot,dipole,&dd,dipaxis,bPairs);
-      rms_cos = sqrt(sqr(dipaxis[XX]-0.5)+
-                    sqr(dipaxis[YY]-0.5)+
-                    sqr(dipaxis[ZZ]-0.5));
-      if (bPairs) 
-       fprintf(caver,"%10.3e  %10.3e  %10.3e  %10.3e  %10.3e  %10.3e\n",
-               t,dd,rms_cos,dipaxis[XX],dipaxis[YY],dipaxis[ZZ]);
-      else
-       fprintf(caver,"%10.3e  %10.3e  %10.3e  %10.3e  %10.3e\n",
-               t,rms_cos,dipaxis[XX],dipaxis[YY],dipaxis[ZZ]);
-    }
+        if (cosaver) 
+        {
+            compute_avercos(gnx_tot,dipole,&dd,dipaxis,bPairs);
+            rms_cos = sqrt(sqr(dipaxis[XX]-0.5)+
+                           sqr(dipaxis[YY]-0.5)+
+                           sqr(dipaxis[ZZ]-0.5));
+            if (bPairs) 
+                fprintf(caver,"%10.3e  %10.3e  %10.3e  %10.3e  %10.3e  %10.3e\n",
+                        t,dd,rms_cos,dipaxis[XX],dipaxis[YY],dipaxis[ZZ]);
+            else
+                fprintf(caver,"%10.3e  %10.3e  %10.3e  %10.3e  %10.3e\n",
+                        t,rms_cos,dipaxis[XX],dipaxis[YY],dipaxis[ZZ]);
+        }
     
-    if (bGkr) {
-      do_gkr(gkrbin,ncos,gnx,molindex,mols->index,x,dipole,ePBC,box,
-            atom,gkatom);
-    }
+        if (bGkr) 
+        {
+            do_gkr(gkrbin,ncos,gnx,molindex,mols->index,x,dipole,ePBC,box,
+                   atom,gkatom);
+        }
     
-    if (bTotal) {
-      tel3 = DIM*teller;
-      muall[0][tel3+XX] = M_av[XX];
-      muall[0][tel3+YY] = M_av[YY];
-      muall[0][tel3+ZZ] = M_av[ZZ];
-    }
-
-    /* Write to file the total dipole moment of the box, and its components 
-     * for this frame.
-     */
-    if ((skip == 0) || ((teller % skip) == 0))
-      fprintf(outmtot,"%10g  %12.8e %12.8e %12.8e %12.8e\n",
-             t,M_av[XX],M_av[YY],M_av[ZZ],
-             sqrt(M_av2[XX]+M_av2[YY]+M_av2[ZZ]));
-
-    for(m=0; (m<DIM); m++) {
-      M[m]  += M_av[m];
-      M2[m] += M_av2[m];
-      M4[m] += sqr(M_av2[m]);
-    }
-    /* Increment loop counter */
-    teller++;
+        if (bTotal) 
+        {
+            tel3 = DIM*teller;
+            muall[0][tel3+XX] = M_av[XX];
+            muall[0][tel3+YY] = M_av[YY];
+            muall[0][tel3+ZZ] = M_av[ZZ];
+        }
+
+        /* Write to file the total dipole moment of the box, and its components 
+         * for this frame.
+         */
+        if ((skip == 0) || ((teller % skip) == 0))
+            fprintf(outmtot,"%10g  %12.8e %12.8e %12.8e %12.8e\n",
+                    t,M_av[XX],M_av[YY],M_av[ZZ],
+                    sqrt(M_av2[XX]+M_av2[YY]+M_av2[ZZ]));
+
+        for(m=0; (m<DIM); m++) 
+        {
+            M[m]  += M_av[m];
+            M2[m] += M_av2[m];
+            M4[m] += sqr(M_av2[m]);
+        }
+        /* Increment loop counter */
+        teller++;
     
-    /* Calculate for output the running averages */
-    invtel  = 1.0/teller;
-    M2_ave  = (M2[XX]+M2[YY]+M2[ZZ])*invtel;
-    M_ave2  = invtel*(invtel*(M[XX]*M[XX] + M[YY]*M[YY] + M[ZZ]*M[ZZ]));
-    M_diff  = M2_ave - M_ave2;
-
-    /* Compute volume from box in traj, else we use the one from above */
-    if (!bMU)
-      volume  = det(box);
-    vol_aver += volume;
+        /* Calculate for output the running averages */
+        invtel  = 1.0/teller;
+        M2_ave  = (M2[XX]+M2[YY]+M2[ZZ])*invtel;
+        M_ave2  = invtel*(invtel*(M[XX]*M[XX] + M[YY]*M[YY] + M[ZZ]*M[ZZ]));
+        M_diff  = M2_ave - M_ave2;
+
+        /* Compute volume from box in traj, else we use the one from above */
+        if (!bMU)
+            volume  = det(box);
+        vol_aver += volume;
     
-    epsilon = calc_eps(M_diff,(vol_aver/teller),epsilonRF,temp);
+        epsilon = calc_eps(M_diff,(vol_aver/teller),epsilonRF,temp);
 
-    /* Calculate running average for dipole */
-    if (mu_ave != 0) 
-      mu_aver = (mu_ave/gnx_tot)*invtel;
+        /* Calculate running average for dipole */
+        if (mu_ave != 0) 
+            mu_aver = (mu_ave/gnx_tot)*invtel;
     
-    if ((skip == 0) || ((teller % skip) == 0)) {
-      /* Write to file < |M|^2 >, |< M >|^2. And the difference between 
-       * the two. Here M is sum mu_i. Further write the finite system
-       * Kirkwood G factor and epsilon.
-       */
-      fprintf(outaver,"%10g  %10.3e %10.3e %10.3e %10.3e\n",
-             t,M2_ave,M_ave2,M_diff,M_ave2/M2_ave);
+        if ((skip == 0) || ((teller % skip) == 0)) 
+        {
+            /* Write to file < |M|^2 >, |< M >|^2. And the difference between 
+             * the two. Here M is sum mu_i. Further write the finite system
+             * Kirkwood G factor and epsilon.
+             */
+            fprintf(outaver,"%10g  %10.3e %10.3e %10.3e %10.3e\n",
+                    t,M2_ave,M_ave2,M_diff,M_ave2/M2_ave);
       
-      if (fnadip) {
-       real aver;
-       gmx_stats_get_average(muframelsq,&aver);
-       fprintf(adip, "%10g %f \n", t,aver);
-      }
-      /*if (dipole)
-       printf("%f %f\n", norm(dipole[0]), norm(dipole[1]));
-      */      
-      if (!bMU || (mu_aver != -1)) {
-       /* Finite system Kirkwood G-factor */
-       Gk = M_diff/(gnx_tot*mu_aver*mu_aver);
-       /* Infinite system Kirkwood G-factor */
-       if (epsilonRF == 0.0) 
-         g_k = ((2*epsilon+1)*Gk/(3*epsilon));
-       else 
-         g_k = ((2*epsilonRF+epsilon)*(2*epsilon+1)*
-                Gk/(3*epsilon*(2*epsilonRF+1)));
+            if (fnadip) 
+            {
+                real aver;
+                gmx_stats_get_average(muframelsq,&aver);
+                fprintf(adip, "%10g %f \n", t,aver);
+            }
+            /*if (dipole)
+              printf("%f %f\n", norm(dipole[0]), norm(dipole[1]));
+            */      
+            if (!bMU || (mu_aver != -1)) 
+            {
+                /* Finite system Kirkwood G-factor */
+                Gk = M_diff/(gnx_tot*mu_aver*mu_aver);
+                /* Infinite system Kirkwood G-factor */
+                if (epsilonRF == 0.0) 
+                    g_k = ((2*epsilon+1)*Gk/(3*epsilon));
+                else 
+                    g_k = ((2*epsilonRF+epsilon)*(2*epsilon+1)*
+                           Gk/(3*epsilon*(2*epsilonRF+1)));
        
-       fprintf(outeps,"%10g  %10.3e %10.3e %10.3e\n",t,epsilon,Gk,g_k);
+                fprintf(outeps,"%10g  %10.3e %10.3e %10.3e\n",t,epsilon,Gk,g_k);
 
-      }
-      else 
-       fprintf(outeps,"%10g  %12.8e\n",t,epsilon);
-    }
+            }
+            else 
+                fprintf(outeps,"%10g  %12.8e\n",t,epsilon);
+        }
+        gmx_stats_done(muframelsq);
     
-    if (bMU)
-      bCont = read_mu_from_enx(fmu,iVol,iMu,mu_t,&volume,&t,nre,fr); 
-    else
-      bCont = read_next_x(oenv,status,&t,natom,x,box);
-  } while (bCont);
+        if (bMU)
+            bCont = read_mu_from_enx(fmu,iVol,iMu,mu_t,&volume,&t,nre,fr); 
+        else
+            bCont = read_next_x(oenv,status,&t,natom,x,box);
+    } while (bCont);
   
-  gmx_rmpbc_done(gpbc);
+    gmx_rmpbc_done(gpbc);
 
-  if (!bMU)
-    close_trj(status);
+    if (!bMU)
+        close_trj(status);
     
-  ffclose(outmtot);
-  ffclose(outaver);
-  ffclose(outeps);
-
-  if (fnadip)
-    ffclose(adip);
-
-  if (cosaver)
-    ffclose(caver);
-
-  if (dip3d) {
-    fprintf(dip3d,"set xrange [0.0:%4.2f]\n",box[XX][XX]);
-    fprintf(dip3d,"set yrange [0.0:%4.2f]\n",box[YY][YY]);
-    fprintf(dip3d,"set zrange [0.0:%4.2f]\n\n",box[ZZ][ZZ]);
-    fprintf(dip3d,"splot 'dummy.dat' using 1:2:3 w vec\n");
-    fprintf(dip3d,"pause -1 'Hit return to continue'\n");
-    ffclose(dip3d);
-  }
-
-  if (bSlab) {
-    dump_slab_dipoles(slabfn,idim,nslices,slab_dipoles,box,teller,oenv);
-    sfree(slab_dipoles);
-  }
+    ffclose(outmtot);
+    ffclose(outaver);
+    ffclose(outeps);
+
+    if (fnadip)
+        ffclose(adip);
+
+    if (cosaver)
+        ffclose(caver);
+
+    if (dip3d) {
+        fprintf(dip3d,"set xrange [0.0:%4.2f]\n",box[XX][XX]);
+        fprintf(dip3d,"set yrange [0.0:%4.2f]\n",box[YY][YY]);
+        fprintf(dip3d,"set zrange [0.0:%4.2f]\n\n",box[ZZ][ZZ]);
+        fprintf(dip3d,"splot 'dummy.dat' using 1:2:3 w vec\n");
+        fprintf(dip3d,"pause -1 'Hit return to continue'\n");
+        ffclose(dip3d);
+    }
+
+    if (bSlab) {
+        dump_slab_dipoles(slabfn,idim,nslices,slab_dipoles,box,teller,oenv);
+        sfree(slab_dipoles);
+    }
   
-  vol_aver /= teller;
-  printf("Average volume over run is %g\n",vol_aver);
-  if (bGkr) {
-    print_gkrbin(gkrfn,gkrbin,gnx[0],teller,vol_aver,oenv);
-    print_cmap(cmap,gkrbin,nlevels);
-  }
-  /* Autocorrelation function */  
-  if (bCorr) {
-    if (teller < 2) {
-      printf("Not enough frames for autocorrelation\n");
+    vol_aver /= teller;
+    printf("Average volume over run is %g\n",vol_aver);
+    if (bGkr) {
+        print_gkrbin(gkrfn,gkrbin,gnx[0],teller,vol_aver,oenv);
+        print_cmap(cmap,gkrbin,nlevels);
     }
-    else {
-      dt=(t1 - t0)/(teller-1);
-      printf("t0 %g, t %g, teller %d\n", t0,t,teller);
+    /* Autocorrelation function */  
+    if (bCorr) {
+        if (teller < 2) {
+            printf("Not enough frames for autocorrelation\n");
+        }
+        else {
+            dt=(t1 - t0)/(teller-1);
+            printf("t0 %g, t %g, teller %d\n", t0,t,teller);
       
-      mode = eacVector;
-
-      if (bTotal)
-       do_autocorr(corf,oenv,"Autocorrelation Function of Total Dipole",
-                   teller,1,muall,dt,mode,TRUE);
-      else
-       do_autocorr(corf,oenv,"Dipole Autocorrelation Function",
-                   teller,gnx_tot,muall,dt,
-                   mode,strcmp(corrtype,"molsep"));
+            mode = eacVector;
+
+            if (bTotal)
+                do_autocorr(corf,oenv,"Autocorrelation Function of Total Dipole",
+                            teller,1,muall,dt,mode,TRUE);
+            else
+                do_autocorr(corf,oenv,"Dipole Autocorrelation Function",
+                            teller,gnx_tot,muall,dt,
+                            mode,strcmp(corrtype,"molsep"));
+        }
     }
-  }
-  if (!bMU) {
-    real aver,sigma,error,lsq;
-
-    gmx_stats_get_ase(mulsq,&aver,&sigma,&error);
-    printf("\nDipole moment (Debye)\n");
-    printf("---------------------\n");
-    printf("Average  = %8.4f  Std. Dev. = %8.4f  Error = %8.4f\n",
-          aver,sigma,error);
-    if (bQuad) {
-      rvec a,s,e;
-      int mm;
-      for(m=0; (m<DIM); m++)
-       gmx_stats_get_ase(mulsq,&(a[m]),&(s[m]),&(e[m]));
+    if (!bMU) {
+        real aver,sigma,error,lsq;
+
+        gmx_stats_get_ase(mulsq,&aver,&sigma,&error);
+        printf("\nDipole moment (Debye)\n");
+        printf("---------------------\n");
+        printf("Average  = %8.4f  Std. Dev. = %8.4f  Error = %8.4f\n",
+               aver,sigma,error);
+        if (bQuad) {
+            rvec a,s,e;
+            int mm;
+            for(m=0; (m<DIM); m++)
+                gmx_stats_get_ase(mulsq,&(a[m]),&(s[m]),&(e[m]));
     
-      printf("\nQuadrupole moment (Debye-Ang)\n");
-      printf("-----------------------------\n");
-      printf("Averages  = %8.4f  %8.4f  %8.4f\n",a[XX],a[YY],a[ZZ]);
-      printf("Std. Dev. = %8.4f  %8.4f  %8.4f\n",s[XX],s[YY],s[ZZ]);
-      printf("Error     = %8.4f  %8.4f  %8.4f\n",e[XX],e[YY],e[ZZ]);
+            printf("\nQuadrupole moment (Debye-Ang)\n");
+            printf("-----------------------------\n");
+            printf("Averages  = %8.4f  %8.4f  %8.4f\n",a[XX],a[YY],a[ZZ]);
+            printf("Std. Dev. = %8.4f  %8.4f  %8.4f\n",s[XX],s[YY],s[ZZ]);
+            printf("Error     = %8.4f  %8.4f  %8.4f\n",e[XX],e[YY],e[ZZ]);
+        }
+        printf("\n");
     }
-    printf("\n");
-  }
-  printf("The following averages for the complete trajectory have been calculated:\n\n");
-  printf(" Total < M_x > = %g Debye\n", M[XX]/teller);
-  printf(" Total < M_y > = %g Debye\n", M[YY]/teller);
-  printf(" Total < M_z > = %g Debye\n\n", M[ZZ]/teller);
+    printf("The following averages for the complete trajectory have been calculated:\n\n");
+    printf(" Total < M_x > = %g Debye\n", M[XX]/teller);
+    printf(" Total < M_y > = %g Debye\n", M[YY]/teller);
+    printf(" Total < M_z > = %g Debye\n\n", M[ZZ]/teller);
 
-  printf(" Total < M_x^2 > = %g Debye^2\n", M2[XX]/teller);
-  printf(" Total < M_y^2 > = %g Debye^2\n", M2[YY]/teller);
-  printf(" Total < M_z^2 > = %g Debye^2\n\n", M2[ZZ]/teller);
+    printf(" Total < M_x^2 > = %g Debye^2\n", M2[XX]/teller);
+    printf(" Total < M_y^2 > = %g Debye^2\n", M2[YY]/teller);
+    printf(" Total < M_z^2 > = %g Debye^2\n\n", M2[ZZ]/teller);
 
-  printf(" Total < |M|^2 > = %g Debye^2\n", M2_ave);
-  printf(" Total |< M >|^2 = %g Debye^2\n\n", M_ave2);
+    printf(" Total < |M|^2 > = %g Debye^2\n", M2_ave);
+    printf(" Total |< M >|^2 = %g Debye^2\n\n", M_ave2);
 
-  printf(" < |M|^2 > - |< M >|^2 = %g Debye^2\n\n", M_diff);
+    printf(" < |M|^2 > - |< M >|^2 = %g Debye^2\n\n", M_diff);
   
-  if (!bMU || (mu_aver != -1)) {
-    printf("Finite system Kirkwood g factor G_k = %g\n", Gk);
-    printf("Infinite system Kirkwood g factor g_k = %g\n\n", g_k);
-  }
-  printf("Epsilon = %g\n", epsilon);
-
-  if (!bMU) {
-    /* Write to file the dipole moment distibution during the simulation.
-     */
-    outdd=xvgropen(dipdist,"Dipole Moment Distribution","mu (Debye)","",oenv);
-    for(i=0; (i<ndipbin); i++)
-      fprintf(outdd,"%10g  %10f\n",
-             (i*mu_max)/ndipbin,dipole_bin[i]/(double)teller);
-    ffclose(outdd);
-    sfree(dipole_bin);
-  }
-  if (bGkr) 
-    done_gkrbin(&gkrbin);
+    if (!bMU || (mu_aver != -1)) {
+        printf("Finite system Kirkwood g factor G_k = %g\n", Gk);
+        printf("Infinite system Kirkwood g factor g_k = %g\n\n", g_k);
+    }
+    printf("Epsilon = %g\n", epsilon);
+
+    if (!bMU) {
+        /* Write to file the dipole moment distibution during the simulation.
+         */
+        outdd=xvgropen(dipdist,"Dipole Moment Distribution","mu (Debye)","",oenv);
+        for(i=0; (i<ndipbin); i++)
+            fprintf(outdd,"%10g  %10f\n",
+                    (i*mu_max)/ndipbin,dipole_bin[i]/(double)teller);
+        ffclose(outdd);
+        sfree(dipole_bin);
+    }
+    if (bGkr) 
+        done_gkrbin(&gkrbin);
 }
 
 void dipole_atom2molindex(int *n,int *index,t_block *mols)
 {
-  int nmol,i,j,m;
-
-  nmol = 0;
-  i=0;
-  while (i < *n) {
-    m=0;
-    while(m < mols->nr && index[i] != mols->index[m])
-      m++;
-    if (m == mols->nr)
-      gmx_fatal(FARGS,"index[%d]=%d does not correspond to the first atom of a molecule",i+1,index[i]+1);
-    for(j=mols->index[m]; j<mols->index[m+1]; j++) {
-      if (i >= *n || index[i] != j)
-       gmx_fatal(FARGS,"The index group is not a set of whole molecules");
-      i++;
+    int nmol,i,j,m;
+
+    nmol = 0;
+    i=0;
+    while (i < *n) {
+        m=0;
+        while(m < mols->nr && index[i] != mols->index[m])
+            m++;
+        if (m == mols->nr)
+            gmx_fatal(FARGS,"index[%d]=%d does not correspond to the first atom of a molecule",i+1,index[i]+1);
+        for(j=mols->index[m]; j<mols->index[m+1]; j++) {
+            if (i >= *n || index[i] != j)
+                gmx_fatal(FARGS,"The index group is not a set of whole molecules");
+            i++;
+        }
+        /* Modify the index in place */
+        index[nmol++] = m;
     }
-    /* Modify the index in place */
-    index[nmol++] = m;
-  }
-  printf("There are %d molecules in the selection\n",nmol);
+    printf("There are %d molecules in the selection\n",nmol);
 
-  *n = nmol;
+    *n = nmol;
 }
 int gmx_dipoles(int argc,char *argv[])
 {
-  const char *desc[] = {
-    "g_dipoles computes the total dipole plus fluctuations of a simulation",
-    "system. From this you can compute e.g. the dielectric constant for",
-    "low dielectric media.",
-    "For molecules with a net charge, the net charge is subtracted at",
-    "center of mass of the molecule.[PAR]",
-    "The file Mtot.xvg contains the total dipole moment of a frame, the",
-    "components as well as the norm of the vector.",
-    "The file aver.xvg contains < |Mu|^2 > and |< Mu >|^2 during the",
-    "simulation.",
-    "The file dipdist.xvg contains the distribution of dipole moments during",
-    "the simulation",
-    "The mu_max is used as the highest value in the distribution graph.[PAR]",
-    "Furthermore the dipole autocorrelation function will be computed when",
-    "option -corr is used. The output file name is given with the [TT]-c[tt]",
-    "option.",
-    "The correlation functions can be averaged over all molecules",
-    "([TT]mol[tt]), plotted per molecule separately ([TT]molsep[tt])",
-    "or it can be computed over the total dipole moment of the simulation box",
-    "([TT]total[tt]).[PAR]",
-    "Option [TT]-g[tt] produces a plot of the distance dependent Kirkwood",
-    "G-factor, as well as the average cosine of the angle between the dipoles",
-    "as a function of the distance. The plot also includes gOO and hOO",
-    "according to Nymand & Linse, JCP 112 (2000) pp 6386-6395. In the same plot",
-    "we also include the energy per scale computed by taking the inner product of",
-    "the dipoles divided by the distance to the third power.[PAR]",
-    "[PAR]",
-    "EXAMPLES[PAR]",
-    "g_dipoles -corr mol -P1 -o dip_sqr -mu 2.273 -mumax 5.0 -nofft[PAR]",
-    "This will calculate the autocorrelation function of the molecular",
-    "dipoles using a first order Legendre polynomial of the angle of the",
-    "dipole vector and itself a time t later. For this calculation 1001",
-    "frames will be used. Further the dielectric constant will be calculated",
-    "using an epsilonRF of infinity (default), temperature of 300 K (default) and",
-    "an average dipole moment of the molecule of 2.273 (SPC). For the",
-    "distribution function a maximum of 5.0 will be used."
-  };
-  real mu_max=5, mu_aver=-1,rcmax=0;
-  real epsilonRF=0.0, temp=300;
-  gmx_bool bAverCorr=FALSE,bMolCorr=FALSE,bPairs=TRUE,bPhi=FALSE;
-  const char *corrtype[]={NULL, "none", "mol", "molsep", "total", NULL};
-  const char *axtitle="Z";
-  int  nslices = 10;      /* nr of slices defined       */
-  int  skip=0,nFA=0,nFB=0,ncos=1;
-  int  nlevels=20,ndegrees=90;
-  output_env_t oenv;
-  t_pargs pa[] = {
-    { "-mu",       FALSE, etREAL, {&mu_aver},
-      "dipole of a single molecule (in Debye)" },
-    { "-mumax",    FALSE, etREAL, {&mu_max},
-      "max dipole in Debye (for histrogram)" },
-    { "-epsilonRF",FALSE, etREAL, {&epsilonRF},
-      "epsilon of the reaction field used during the simulation, needed for dielectric constant calculation. WARNING: 0.0 means infinity (default)" },
-    { "-skip",     FALSE, etINT, {&skip},
-      "Skip steps in the output (but not in the computations)" },
-    { "-temp",     FALSE, etREAL, {&temp},
-      "Average temperature of the simulation (needed for dielectric constant calculation)" },
-    { "-corr",     FALSE, etENUM, {corrtype},
-      "Correlation function to calculate" },
-    { "-pairs",    FALSE, etBOOL, {&bPairs},
-      "Calculate |cos theta| between all pairs of molecules. May be slow" },
-    { "-ncos",     FALSE, etINT, {&ncos},
-      "Must be 1 or 2. Determines whether the <cos> is computed between all mole cules in one group, or between molecules in two different groups. This turns on the -gkr flag." }, 
-    { "-axis",     FALSE, etSTR, {&axtitle}, 
-      "Take the normal on the computational box in direction X, Y or Z." },
-    { "-sl",       FALSE, etINT, {&nslices},
-      "Divide the box in #nr slices." },
-    { "-gkratom",  FALSE, etINT, {&nFA},
-      "Use the n-th atom of a molecule (starting from 1) to calculate the distance between molecules rather than the center of charge (when 0) in the calculation of distance dependent Kirkwood factors" },
-    { "-gkratom2", FALSE, etINT, {&nFB},
-      "Same as previous option in case ncos = 2, i.e. dipole interaction between two groups of molecules" },
-    { "-rcmax",    FALSE, etREAL, {&rcmax},
-      "Maximum distance to use in the dipole orientation distribution (with ncos == 2). If zero, a criterium based on the box length will be used." },
-    { "-phi",      FALSE, etBOOL, {&bPhi},
-      "Plot the 'torsion angle' defined as the rotation of the two dipole vectors around the distance vector between the two molecules in the xpm file from the -cmap option. By default the cosine of the angle between the dipoles is plotted." },
-    { "-nlevels",  FALSE, etINT, {&nlevels},
-      "Number of colors in the cmap output" },
-    { "-ndegrees", FALSE, etINT, {&ndegrees},
-      "Number of divisions on the y-axis in the camp output (for 180 degrees)" }
-  };
-  int          *gnx;
-  int          nFF[2];
-  atom_id      **grpindex;
-  char         **grpname=NULL;
-  gmx_bool         bCorr,bQuad,bGkr,bMU,bSlab;  
-  t_filenm fnm[] = {
-    { efEDR, "-en", NULL,         ffOPTRD },
-    { efTRX, "-f", NULL,           ffREAD },
-    { efTPX, NULL, NULL,           ffREAD },
-    { efNDX, NULL, NULL,           ffOPTRD },
-    { efXVG, "-o",   "Mtot",       ffWRITE },
-    { efXVG, "-eps", "epsilon",    ffWRITE },
-    { efXVG, "-a",   "aver",       ffWRITE },
-    { efXVG, "-d",   "dipdist",    ffWRITE },
-    { efXVG, "-c",   "dipcorr",    ffOPTWR },
-    { efXVG, "-g",   "gkr",        ffOPTWR },
-    { efXVG, "-adip","adip",       ffOPTWR },
-    { efXVG, "-dip3d", "dip3d",    ffOPTWR },
-    { efXVG, "-cos", "cosaver",    ffOPTWR },
-    { efXPM, "-cmap","cmap",       ffOPTWR },
-    { efXVG, "-q",   "quadrupole", ffOPTWR },
-    { efXVG, "-slab","slab",       ffOPTWR }
-  };
+    const char *desc[] = {
+        "g_dipoles computes the total dipole plus fluctuations of a simulation",
+        "system. From this you can compute e.g. the dielectric constant for",
+        "low dielectric media.",
+        "For molecules with a net charge, the net charge is subtracted at",
+        "center of mass of the molecule.[PAR]",
+        "The file Mtot.xvg contains the total dipole moment of a frame, the",
+        "components as well as the norm of the vector.",
+        "The file aver.xvg contains < |Mu|^2 > and |< Mu >|^2 during the",
+        "simulation.",
+        "The file dipdist.xvg contains the distribution of dipole moments during",
+        "the simulation",
+        "The mu_max is used as the highest value in the distribution graph.[PAR]",
+        "Furthermore the dipole autocorrelation function will be computed when",
+        "option -corr is used. The output file name is given with the [TT]-c[tt]",
+        "option.",
+        "The correlation functions can be averaged over all molecules",
+        "([TT]mol[tt]), plotted per molecule separately ([TT]molsep[tt])",
+        "or it can be computed over the total dipole moment of the simulation box",
+        "([TT]total[tt]).[PAR]",
+        "Option [TT]-g[tt] produces a plot of the distance dependent Kirkwood",
+        "G-factor, as well as the average cosine of the angle between the dipoles",
+        "as a function of the distance. The plot also includes gOO and hOO",
+        "according to Nymand & Linse, JCP 112 (2000) pp 6386-6395. In the same plot",
+        "we also include the energy per scale computed by taking the inner product of",
+        "the dipoles divided by the distance to the third power.[PAR]",
+        "[PAR]",
+        "EXAMPLES[PAR]",
+        "g_dipoles -corr mol -P1 -o dip_sqr -mu 2.273 -mumax 5.0 -nofft[PAR]",
+        "This will calculate the autocorrelation function of the molecular",
+        "dipoles using a first order Legendre polynomial of the angle of the",
+        "dipole vector and itself a time t later. For this calculation 1001",
+        "frames will be used. Further the dielectric constant will be calculated",
+        "using an epsilonRF of infinity (default), temperature of 300 K (default) and",
+        "an average dipole moment of the molecule of 2.273 (SPC). For the",
+        "distribution function a maximum of 5.0 will be used."
+    };
+    real mu_max=5, mu_aver=-1,rcmax=0;
+    real epsilonRF=0.0, temp=300;
+    gmx_bool bAverCorr=FALSE,bMolCorr=FALSE,bPairs=TRUE,bPhi=FALSE;
+    const char *corrtype[]={NULL, "none", "mol", "molsep", "total", NULL};
+    const char *axtitle="Z";
+    int  nslices = 10;      /* nr of slices defined       */
+    int  skip=0,nFA=0,nFB=0,ncos=1;
+    int  nlevels=20,ndegrees=90;
+    output_env_t oenv;
+    t_pargs pa[] = {
+        { "-mu",       FALSE, etREAL, {&mu_aver},
+          "dipole of a single molecule (in Debye)" },
+        { "-mumax",    FALSE, etREAL, {&mu_max},
+          "max dipole in Debye (for histrogram)" },
+        { "-epsilonRF",FALSE, etREAL, {&epsilonRF},
+          "epsilon of the reaction field used during the simulation, needed for dielectric constant calculation. WARNING: 0.0 means infinity (default)" },
+        { "-skip",     FALSE, etINT, {&skip},
+          "Skip steps in the output (but not in the computations)" },
+        { "-temp",     FALSE, etREAL, {&temp},
+          "Average temperature of the simulation (needed for dielectric constant calculation)" },
+        { "-corr",     FALSE, etENUM, {corrtype},
+          "Correlation function to calculate" },
+        { "-pairs",    FALSE, etBOOL, {&bPairs},
+          "Calculate |cos theta| between all pairs of molecules. May be slow" },
+        { "-ncos",     FALSE, etINT, {&ncos},
+          "Must be 1 or 2. Determines whether the <cos> is computed between all mole cules in one group, or between molecules in two different groups. This turns on the -gkr flag." }, 
+        { "-axis",     FALSE, etSTR, {&axtitle}, 
+          "Take the normal on the computational box in direction X, Y or Z." },
+        { "-sl",       FALSE, etINT, {&nslices},
+          "Divide the box in #nr slices." },
+        { "-gkratom",  FALSE, etINT, {&nFA},
+          "Use the n-th atom of a molecule (starting from 1) to calculate the distance between molecules rather than the center of charge (when 0) in the calculation of distance dependent Kirkwood factors" },
+        { "-gkratom2", FALSE, etINT, {&nFB},
+          "Same as previous option in case ncos = 2, i.e. dipole interaction between two groups of molecules" },
+        { "-rcmax",    FALSE, etREAL, {&rcmax},
+          "Maximum distance to use in the dipole orientation distribution (with ncos == 2). If zero, a criterium based on the box length will be used." },
+        { "-phi",      FALSE, etBOOL, {&bPhi},
+          "Plot the 'torsion angle' defined as the rotation of the two dipole vectors around the distance vector between the two molecules in the xpm file from the -cmap option. By default the cosine of the angle between the dipoles is plotted." },
+        { "-nlevels",  FALSE, etINT, {&nlevels},
+          "Number of colors in the cmap output" },
+        { "-ndegrees", FALSE, etINT, {&ndegrees},
+          "Number of divisions on the y-axis in the camp output (for 180 degrees)" }
+    };
+    int          *gnx;
+    int          nFF[2];
+    atom_id      **grpindex;
+    char         **grpname=NULL;
+    gmx_bool         bCorr,bQuad,bGkr,bMU,bSlab;  
+    t_filenm fnm[] = {
+        { efEDR, "-en", NULL,         ffOPTRD },
+        { efTRX, "-f", NULL,           ffREAD },
+        { efTPX, NULL, NULL,           ffREAD },
+        { efNDX, NULL, NULL,           ffOPTRD },
+        { efXVG, "-o",   "Mtot",       ffWRITE },
+        { efXVG, "-eps", "epsilon",    ffWRITE },
+        { efXVG, "-a",   "aver",       ffWRITE },
+        { efXVG, "-d",   "dipdist",    ffWRITE },
+        { efXVG, "-c",   "dipcorr",    ffOPTWR },
+        { efXVG, "-g",   "gkr",        ffOPTWR },
+        { efXVG, "-adip","adip",       ffOPTWR },
+        { efXVG, "-dip3d", "dip3d",    ffOPTWR },
+        { efXVG, "-cos", "cosaver",    ffOPTWR },
+        { efXPM, "-cmap","cmap",       ffOPTWR },
+        { efXVG, "-q",   "quadrupole", ffOPTWR },
+        { efXVG, "-slab","slab",       ffOPTWR }
+    };
 #define NFILE asize(fnm)
-  int     npargs;
-  t_pargs *ppa;
-  t_topology *top;
-  int     ePBC;
-  int     k,natoms;
-  matrix  box;
+    int     npargs;
+    t_pargs *ppa;
+    t_topology *top;
+    int     ePBC;
+    int     k,natoms;
+    matrix  box;
   
-  CopyRight(stderr,argv[0]);
-  npargs = asize(pa);
-  ppa    = add_acf_pargs(&npargs,pa);
-  parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_CAN_VIEW | PCA_BE_NICE,
-                   NFILE,fnm,npargs,ppa,asize(desc),desc,0,NULL,&oenv);
-
-  printf("Using %g as mu_max and %g as the dipole moment.\n", 
-         mu_max,mu_aver);
-  if (epsilonRF == 0.0)
-    printf("WARNING: EpsilonRF = 0.0, this really means EpsilonRF = infinity\n");
-
-  bMU   = opt2bSet("-en",NFILE,fnm);
-  bQuad = opt2bSet("-q",NFILE,fnm);
-  bGkr  = opt2bSet("-g",NFILE,fnm);
-  if (opt2parg_bSet("-ncos",asize(pa),pa)) {
-    if ((ncos != 1) && (ncos != 2)) 
-      gmx_fatal(FARGS,"ncos has to be either 1 or 2");
-    bGkr = TRUE;
-  }
-  bSlab = (opt2bSet("-slab",NFILE,fnm) || opt2parg_bSet("-sl",asize(pa),pa) ||
-          opt2parg_bSet("-axis",asize(pa),pa));
-  if (bMU) {
-    bAverCorr = TRUE;
-    if (bQuad) {
-      printf("WARNING: Can not determine quadrupoles from energy file\n");
-      bQuad = FALSE;
+    CopyRight(stderr,argv[0]);
+    npargs = asize(pa);
+    ppa    = add_acf_pargs(&npargs,pa);
+    parse_common_args(&argc,argv,PCA_CAN_TIME | PCA_CAN_VIEW | PCA_BE_NICE,
+                      NFILE,fnm,npargs,ppa,asize(desc),desc,0,NULL,&oenv);
+
+    printf("Using %g as mu_max and %g as the dipole moment.\n", 
+           mu_max,mu_aver);
+    if (epsilonRF == 0.0)
+        printf("WARNING: EpsilonRF = 0.0, this really means EpsilonRF = infinity\n");
+
+    bMU   = opt2bSet("-en",NFILE,fnm);
+    bQuad = opt2bSet("-q",NFILE,fnm);
+    bGkr  = opt2bSet("-g",NFILE,fnm);
+    if (opt2parg_bSet("-ncos",asize(pa),pa)) {
+        if ((ncos != 1) && (ncos != 2)) 
+            gmx_fatal(FARGS,"ncos has to be either 1 or 2");
+        bGkr = TRUE;
     }
-    if (bGkr) {
-      printf("WARNING: Can not determine Gk(r) from energy file\n");
-      bGkr  = FALSE;
-      ncos = 1;
+    bSlab = (opt2bSet("-slab",NFILE,fnm) || opt2parg_bSet("-sl",asize(pa),pa) ||
+             opt2parg_bSet("-axis",asize(pa),pa));
+    if (bMU) {
+        bAverCorr = TRUE;
+        if (bQuad) {
+            printf("WARNING: Can not determine quadrupoles from energy file\n");
+            bQuad = FALSE;
+        }
+        if (bGkr) {
+            printf("WARNING: Can not determine Gk(r) from energy file\n");
+            bGkr  = FALSE;
+            ncos = 1;
+        }
+        if (mu_aver == -1) 
+            printf("WARNING: Can not calculate Gk and gk, since you did\n"
+                   "         not enter a valid dipole for the molecules\n");
     }
-    if (mu_aver == -1) 
-      printf("WARNING: Can not calculate Gk and gk, since you did\n"
-            "         not enter a valid dipole for the molecules\n");
-  }
-
-  snew(top,1);
-  ePBC = read_tpx_top(ftp2fn(efTPX,NFILE,fnm),NULL,box,
-                     &natoms,NULL,NULL,NULL,top);
+
+    snew(top,1);
+    ePBC = read_tpx_top(ftp2fn(efTPX,NFILE,fnm),NULL,box,
+                        &natoms,NULL,NULL,NULL,top);
   
-  snew(gnx,ncos);
-  snew(grpname,ncos);
-  snew(grpindex,ncos);
-  get_index(&top->atoms,ftp2fn_null(efNDX,NFILE,fnm),
-            ncos,gnx,grpindex,grpname);
-  for(k=0; (k<ncos); k++) {
-    dipole_atom2molindex(&gnx[k],grpindex[k],&(top->mols));
-    neutralize_mols(gnx[k],grpindex[k],&(top->mols),top->atoms.atom);
-  }
-  nFF[0] = nFA;
-  nFF[1] = nFB;
-  do_dip(top,ePBC,det(box),ftp2fn(efTRX,NFILE,fnm),
-        opt2fn("-o",NFILE,fnm),opt2fn("-eps",NFILE,fnm),
-        opt2fn("-a",NFILE,fnm),opt2fn("-d",NFILE,fnm),
-        opt2fn_null("-cos",NFILE,fnm),
-        opt2fn_null("-dip3d",NFILE,fnm),opt2fn_null("-adip",NFILE,fnm),
-        bPairs,corrtype[0],
-        opt2fn("-c",NFILE,fnm),
-        bGkr,    opt2fn("-g",NFILE,fnm),
-        bPhi,    &nlevels,  ndegrees,
-        ncos,
-        opt2fn("-cmap",NFILE,fnm),rcmax,
-        bQuad,   opt2fn("-q",NFILE,fnm),
-        bMU,     opt2fn("-en",NFILE,fnm),
-        gnx,grpindex,mu_max,mu_aver,epsilonRF,temp,nFF,skip,
-        bSlab,nslices,axtitle,opt2fn("-slab",NFILE,fnm),oenv);
+    snew(gnx,ncos);
+    snew(grpname,ncos);
+    snew(grpindex,ncos);
+    get_index(&top->atoms,ftp2fn_null(efNDX,NFILE,fnm),
+              ncos,gnx,grpindex,grpname);
+    for(k=0; (k<ncos); k++) 
+    {
+        dipole_atom2molindex(&gnx[k],grpindex[k],&(top->mols));
+        neutralize_mols(gnx[k],grpindex[k],&(top->mols),top->atoms.atom);
+    }
+    nFF[0] = nFA;
+    nFF[1] = nFB;
+    do_dip(top,ePBC,det(box),ftp2fn(efTRX,NFILE,fnm),
+           opt2fn("-o",NFILE,fnm),opt2fn("-eps",NFILE,fnm),
+           opt2fn("-a",NFILE,fnm),opt2fn("-d",NFILE,fnm),
+           opt2fn_null("-cos",NFILE,fnm),
+           opt2fn_null("-dip3d",NFILE,fnm),opt2fn_null("-adip",NFILE,fnm),
+           bPairs,corrtype[0],
+           opt2fn("-c",NFILE,fnm),
+           bGkr,    opt2fn("-g",NFILE,fnm),
+           bPhi,    &nlevels,  ndegrees,
+           ncos,
+           opt2fn("-cmap",NFILE,fnm),rcmax,
+           bQuad,   opt2fn("-q",NFILE,fnm),
+           bMU,     opt2fn("-en",NFILE,fnm),
+           gnx,grpindex,mu_max,mu_aver,epsilonRF,temp,nFF,skip,
+           bSlab,nslices,axtitle,opt2fn("-slab",NFILE,fnm),oenv);
   
-  do_view(oenv,opt2fn("-o",NFILE,fnm),"-autoscale xy -nxy");
-  do_view(oenv,opt2fn("-eps",NFILE,fnm),"-autoscale xy -nxy");
-  do_view(oenv,opt2fn("-a",NFILE,fnm),"-autoscale xy -nxy");
-  do_view(oenv,opt2fn("-d",NFILE,fnm),"-autoscale xy");
-  do_view(oenv,opt2fn("-c",NFILE,fnm),"-autoscale xy");
+    do_view(oenv,opt2fn("-o",NFILE,fnm),"-autoscale xy -nxy");
+    do_view(oenv,opt2fn("-eps",NFILE,fnm),"-autoscale xy -nxy");
+    do_view(oenv,opt2fn("-a",NFILE,fnm),"-autoscale xy -nxy");
+    do_view(oenv,opt2fn("-d",NFILE,fnm),"-autoscale xy");
+    do_view(oenv,opt2fn("-c",NFILE,fnm),"-autoscale xy");
 
-  thanx(stderr);
+    thanx(stderr);
   
-  return 0;
+    return 0;
 }
index d2f587766e937b462e6caa297b792cacb8c93c9a..09071ff85ad9024edf039ed7d7bf27cf229ce0bb 100644 (file)
@@ -500,6 +500,10 @@ int gmx_eneconv(int argc,char *argv[])
   int        *cont_type;
   gmx_bool       bNewFile,bFirst,bNewOutput;
   output_env_t oenv;
+  gmx_bool   warned_about_dh=FALSE;
+  t_enxblock *blocks=NULL;
+  int nblocks=0;
+  int nblocks_alloc=0;
   
   t_filenm fnm[] = {
     { efEDR, "-f", NULL,    ffRDMULT },
@@ -513,6 +517,7 @@ int gmx_eneconv(int argc,char *argv[])
   static gmx_bool  bSort=TRUE,bError=TRUE;
   static real  begin=-1;
   static real  end=-1;
+  gmx_bool  remove_dh=FALSE;
   
   t_pargs pa[] = {
     { "-b",        FALSE, etREAL, {&begin},
@@ -527,6 +532,8 @@ int gmx_eneconv(int argc,char *argv[])
       "Change starting time interactively" },
     { "-sort",     FALSE, etBOOL, {&bSort},
       "Sort energy files (not frames)"},
+    { "-rmdh",     FALSE, etBOOL, {&remove_dh},
+      "Remove free energy block data" },
     { "-scalefac", FALSE, etREAL, {&scalefac},
       "Multiply energy component by this factor" },
     { "-error",    FALSE, etBOOL, {&bError},
@@ -690,6 +697,72 @@ int gmx_eneconv(int argc,char *argv[])
        fro->nblock       = fr->nblock;
        /*fro->nr           = fr->nr;*/
        fro->block        = fr->block;
+
+        /* check if we have blocks with delta_h data and are throwing 
+           away data */
+        if (fro->nblock > 0)
+        {
+            if (remove_dh)
+            {
+                int i;
+                if (!blocks || nblocks_alloc < fr->nblock)
+                {
+                    /* we pre-allocate the blocks */
+                    nblocks_alloc=fr->nblock;
+                    snew(blocks, nblocks_alloc);
+                }
+                nblocks=0; /* number of blocks so far */
+
+                for(i=0;i<fr->nblock;i++)
+                {
+                    if ( (fr->block[i].id != enxDHCOLL) &&
+                         (fr->block[i].id != enxDH) &&
+                         (fr->block[i].id != enxDHHIST) )
+                    {
+                        /* copy everything verbatim */
+                        blocks[nblocks] = fr->block[i];
+                        nblocks++;
+                    }
+                }
+                /* now set the block pointer to the new blocks */
+                fro->nblock = nblocks;
+                fro->block  = blocks;
+            }
+            else if (delta_t > 0)
+            {
+                if (!warned_about_dh) 
+                {
+                    for(i=0;i<fr->nblock;i++)
+                    {
+                        if (fr->block[i].id == enxDH ||
+                            fr->block[i].id == enxDHHIST)
+                        {
+                            int size;
+                            if (fr->block[i].id == enxDH )
+                            {
+                                size=fr->block[i].sub[2].nr;
+                            }
+                            else
+                            {
+                                size=fr->nsteps;
+                            }
+                            if (size>0)
+                            {
+                                printf("\nWARNING: %s contains delta H blocks or histograms for which\n"
+                                       "         some data is thrown away on a block-by-block basis, where each block\n"
+                                       "         contains up to %d samples.\n"
+                                       "         This is almost certainly not what you want.\n"
+                                       "         Use the -rmdh option to throw all delta H samples away.\n"
+                                       "         Use g_energy -odh option to extract these samples.\n",
+                                       fnms[f], size);
+                                warned_about_dh=TRUE;
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
        
        do_enx(out,fro);
        if (noutfr % 1000 == 0)
index 9d81e5db38cb04acbe169c3a40f4111655abd2a1..86df2a18ff74603854ea486c1efba8c3885636b9 100644 (file)
 #include "main.h"
 #include "gmx_ana.h"
 
-#ifdef GMX_LIB_MPI
-#include <mpi.h>
-#endif
-#ifdef GMX_THREADS
-#include "tmpi.h"
-#endif
-
-/* afm stuf */
-#include "pull.h"
-
-/* We use the same defines as in mvdata.c here */
-#define  block_bc(cr,   d) gmx_bcast(     sizeof(d),     &(d),(cr))
-#define nblock_bc(cr,nr,d) gmx_bcast((nr)*sizeof((d)[0]), (d),(cr))
-#define   snew_bc(cr,d,nr) { if (!MASTER(cr)) snew((d),(nr)); }
-
-/* The following two variables and the signal_handler function
- * is used from pme.c as well
- */
-
-typedef struct {
-       t_state s;
-       rvec    *f;
-       real    epot;
-       real    fnorm;
-       real    fmax;
-       int     a_fmax;
-} em_state_t;
-
-typedef struct {
-       int    it_xy;
-       int    it_z;
-       int    xy_step;
-       int    z_step;
-       rvec    xmin;
-       rvec    xmax;
-       rvec    *geom_cent;
-       int    pieces;
-       int    *nidx;
-       atom_id **subindex;
-} pos_ins_t;
-
-typedef struct {
-       int             id;
-       char    *name;
-       int     nr;
-       int     natoms;     /*nr of atoms per lipid*/
-       int     mol1;       /*id of the first lipid molecule*/
-       real    area;
-} lip_t;
-
-typedef struct {
-       char    *name;
-       t_block mem_at;
-       int             *mol_id;
-       int             nmol;
-       real    lip_area;
-       real    zmin;
-       real    zmax;
-       real    zmed;
-} mem_t;
-
-typedef struct {
-       int             *mol;
-       int             *block;
-       int     nr;
-} rm_t;
-
-int search_string(char *s,int ng,char ***gn)
-{
-       int i;
-
-       for(i=0; (i<ng); i++)
-               if (gmx_strcasecmp(s,*gn[i]) == 0)
-                       return i;
-
-       gmx_fatal(FARGS,"Group %s not found in indexfile.\nMaybe you have non-default groups in your mdp file, while not using the '-n' option of grompp.\nIn that case use the '-n' option.\n",s);
-
-       return -1;
-}
-
-int get_mol_id(int at,int nmblock,gmx_molblock_t *mblock, int *type, int *block)
-{
-       int mol_id=0;
-       int i;
-
-       for(i=0;i<nmblock;i++)
-       {
-               if(at<(mblock[i].nmol*mblock[i].natoms_mol))
-               {
-                       mol_id+=at/mblock[i].natoms_mol;
-                       *type = mblock[i].type;
-                       *block = i;
-                       return mol_id;
-               } else {
-                       at-= mblock[i].nmol*mblock[i].natoms_mol;
-                       mol_id+=mblock[i].nmol;
-               }
-       }
-
-       gmx_fatal(FARGS,"Something is wrong in mol ids, at %d, mol_id %d",at,mol_id);
-
-       return -1;
-}
-
-int get_block(int mol_id,int nmblock,gmx_molblock_t *mblock)
-{
-       int i;
-       int nmol=0;
-
-       for(i=0;i<nmblock;i++)
-       {
-               nmol+=mblock[i].nmol;
-               if(mol_id<nmol)
-                       return i;
-       }
-
-       gmx_fatal(FARGS,"mol_id %d larger than total number of molecules %d.\n",mol_id,nmol);
-
-       return -1;
-}
-
-int get_tpr_version(const char *infile)
-{
-       char    buf[STRLEN];
-       gmx_bool        bDouble;
-       int     precision,fver;
-        t_fileio *fio;
-
-       fio = open_tpx(infile,"r");
-       gmx_fio_checktype(fio);
-
-       precision = sizeof(real);
-
-       gmx_fio_do_string(fio,buf);
-       if (strncmp(buf,"VERSION",7))
-               gmx_fatal(FARGS,"Can not read file %s,\n"
-                               "             this file is from a Gromacs version which is older than 2.0\n"
-                               "             Make a new one with grompp or use a gro or pdb file, if possible",
-                               gmx_fio_getname(fio));
-       gmx_fio_do_int(fio,precision);
-       bDouble = (precision == sizeof(double));
-       if ((precision != sizeof(float)) && !bDouble)
-               gmx_fatal(FARGS,"Unknown precision in file %s: real is %d bytes "
-                               "instead of %d or %d",
-                               gmx_fio_getname(fio),precision,sizeof(float),sizeof(double));
-       gmx_fio_setprecision(fio,bDouble);
-       fprintf(stderr,"Reading file %s, %s (%s precision)\n",
-                       gmx_fio_getname(fio),buf,bDouble ? "double" : "single");
-
-       gmx_fio_do_int(fio,fver);
-
-       close_tpx(fio);
-
-       return fver;
-}
-
-void set_inbox(int natom, rvec *x)
-{
-       rvec tmp;
-       int  i;
-
-       tmp[XX]=tmp[YY]=tmp[ZZ]=0.0;
-       for(i=0;i<natom;i++)
-       {
-               if(x[i][XX]<tmp[XX])            tmp[XX]=x[i][XX];
-               if(x[i][YY]<tmp[YY])            tmp[YY]=x[i][YY];
-               if(x[i][ZZ]<tmp[ZZ])            tmp[ZZ]=x[i][ZZ];
-       }
-
-       for(i=0;i<natom;i++)
-                       rvec_inc(x[i],tmp);
-}
-
-int get_mtype_list(t_block *at, gmx_mtop_t *mtop, t_block *tlist)
-{
-       int i,j,nr,mol_id;
-        int type=0,block=0;
-       gmx_bool bNEW;
-
-       nr=0;
-       snew(tlist->index,at->nr);
-       for (i=0;i<at->nr;i++)
-       {
-               bNEW=TRUE;
-               mol_id = get_mol_id(at->index[i],mtop->nmolblock,mtop->molblock,&type,&block);
-               for(j=0;j<nr;j++)
-               {
-                       if(tlist->index[j]==type)
-                                               bNEW=FALSE;
-               }
-               if(bNEW==TRUE)
-               {
-                       tlist->index[nr]=type;
-                       nr++;
-               }
-       }
-
-       srenew(tlist->index,nr);
-       return nr;
-}
-
-void check_types(t_block *ins_at,t_block *rest_at,gmx_mtop_t *mtop)
-{
-       t_block         *ins_mtype,*rest_mtype;
-       int                     i,j;
-
-       snew(ins_mtype,1);
-       snew(rest_mtype,1);
-    ins_mtype->nr  = get_mtype_list(ins_at , mtop, ins_mtype );
-    rest_mtype->nr = get_mtype_list(rest_at, mtop, rest_mtype);
-
-    for(i=0;i<ins_mtype->nr;i++)
-    {
-       for(j=0;j<rest_mtype->nr;j++)
-       {
-               if(ins_mtype->index[i]==rest_mtype->index[j])
-                       gmx_fatal(FARGS,"Moleculetype %s is found both in the group to insert and the rest of the system.\n"
-                                       "Because we need to exclude all interactions between the atoms in the group to\n"
-                                       "insert, the same moleculetype can not be used in both groups. Change the\n"
-                                       "moleculetype of the molecules %s in the inserted group. Do not forget to provide\n"
-                                       "an appropriate *.itp file",*(mtop->moltype[rest_mtype->index[j]].name),
-                                       *(mtop->moltype[rest_mtype->index[j]].name));
-       }
-    }
-
-    sfree(ins_mtype->index);
-    sfree(rest_mtype->index);
-    sfree(ins_mtype);
-    sfree(rest_mtype);
-}
-
-int init_ins_at(t_block *ins_at,t_block *rest_at,t_state *state, pos_ins_t *pos_ins,gmx_groups_t *groups,int ins_grp_id, real xy_max)
-{
-       int i,gid,c=0;
-       real x,xmin,xmax,y,ymin,ymax,z,zmin,zmax;
-
-       snew(rest_at->index,state->natoms);
-
-       xmin=xmax=state->x[ins_at->index[0]][XX];
-       ymin=ymax=state->x[ins_at->index[0]][YY];
-       zmin=zmax=state->x[ins_at->index[0]][ZZ];
-
-       for(i=0;i<state->natoms;i++)
-       {
-               gid = groups->grpnr[egcFREEZE][i];
-               if(groups->grps[egcFREEZE].nm_ind[gid]==ins_grp_id)
-               {
-                       x=state->x[i][XX];
-                       if (x<xmin)                     xmin=x;
-                       if (x>xmax)                     xmax=x;
-                       y=state->x[i][YY];
-                       if (y<ymin)                             ymin=y;
-                       if (y>ymax)                             ymax=y;
-                       z=state->x[i][ZZ];
-                       if (z<zmin)                             zmin=z;
-                       if (z>zmax)                             zmax=z;
-               } else {
-                       rest_at->index[c]=i;
-                       c++;
-               }
-       }
-
-       rest_at->nr=c;
-       srenew(rest_at->index,c);
-
-       if(xy_max>1.000001)
-       {
-               pos_ins->xmin[XX]=xmin-((xmax-xmin)*xy_max-(xmax-xmin))/2;
-               pos_ins->xmin[YY]=ymin-((ymax-ymin)*xy_max-(ymax-ymin))/2;
-
-               pos_ins->xmax[XX]=xmax+((xmax-xmin)*xy_max-(xmax-xmin))/2;
-               pos_ins->xmax[YY]=ymax+((ymax-ymin)*xy_max-(ymax-ymin))/2;
-       } else {
-               pos_ins->xmin[XX]=xmin;
-               pos_ins->xmin[YY]=ymin;
-
-               pos_ins->xmax[XX]=xmax;
-               pos_ins->xmax[YY]=ymax;
-       }
-
-       /* 6.0 is estimated thickness of bilayer */
-       if( (zmax-zmin) < 6.0 )
-       {
-               pos_ins->xmin[ZZ]=zmin+(zmax-zmin)/2.0-3.0;
-               pos_ins->xmax[ZZ]=zmin+(zmax-zmin)/2.0+3.0;
-       } else {
-               pos_ins->xmin[ZZ]=zmin;
-               pos_ins->xmax[ZZ]=zmax;
-       }
-
-       return c;
-}
-
-real est_prot_area(pos_ins_t *pos_ins,rvec *r,t_block *ins_at, mem_t *mem_p)
-{
-       real x,y,dx=0.15,dy=0.15,area=0.0;
-       real add;
-       int c,at;
-
-       for(x=pos_ins->xmin[XX];x<pos_ins->xmax[XX];x+=dx)
-       {
-               for(y=pos_ins->xmin[YY];y<pos_ins->xmax[YY];y+=dy)
-               {
-                       c=0;
-                       add=0.0;
-                       do
-                       {
-                               at=ins_at->index[c];
-                               if ( (r[at][XX]>=x) && (r[at][XX]<x+dx) &&
-                                               (r[at][YY]>=y) && (r[at][YY]<y+dy) &&
-                                               (r[at][ZZ]>mem_p->zmin+1.0) && (r[at][ZZ]<mem_p->zmax-1.0) )
-                                       add=1.0;
-                               c++;
-                       } while ( (c<ins_at->nr) && (add<0.5) );
-                       area+=add;
-               }
-       }
-       area=area*dx*dy;
-
-       return area;
-}
-
-void init_lip(matrix box, gmx_mtop_t *mtop, lip_t *lip)
-{
-       int i;
-       real mem_area;
-       int mol1=0;
-
-       mem_area = box[XX][XX]*box[YY][YY]-box[XX][YY]*box[YY][XX];
-       for(i=0;i<mtop->nmolblock;i++)
-       {
-               if(mtop->molblock[i].type == lip->id)
-               {
-                       lip->nr=mtop->molblock[i].nmol;
-                       lip->natoms=mtop->molblock[i].natoms_mol;
-               }
-       }
-       lip->area=2.0*mem_area/(double)lip->nr;
-
-       for (i=0;i<lip->id;i++)
-               mol1+=mtop->molblock[i].nmol;
-       lip->mol1=mol1;
-}
-
-int init_mem_at(mem_t *mem_p, gmx_mtop_t *mtop, rvec *r, matrix box, pos_ins_t *pos_ins)
-{
-       int i,j,at,mol,nmol,nmolbox,count;
-       t_block *mem_a;
-       real z,zmin,zmax,mem_area;
-       gmx_bool bNew;
-       atom_id *mol_id;
-       int type=0,block=0;
-
-       nmol=count=0;
-       mem_a=&(mem_p->mem_at);
-       snew(mol_id,mem_a->nr);
-/*     snew(index,mem_a->nr); */
-       zmin=pos_ins->xmax[ZZ];
-       zmax=pos_ins->xmin[ZZ];
-       for(i=0;i<mem_a->nr;i++)
-       {
-               at=mem_a->index[i];
-               if(     (r[at][XX]>pos_ins->xmin[XX]) && (r[at][XX]<pos_ins->xmax[XX]) &&
-                       (r[at][YY]>pos_ins->xmin[YY]) && (r[at][YY]<pos_ins->xmax[YY]) &&
-                       (r[at][ZZ]>pos_ins->xmin[ZZ]) && (r[at][ZZ]<pos_ins->xmax[ZZ]) )
-               {
-                       mol = get_mol_id(at,mtop->nmolblock,mtop->molblock,&type,&block);
-
-                       bNew=TRUE;
-                       for(j=0;j<nmol;j++)
-                               if(mol == mol_id[j])
-                                       bNew=FALSE;
-
-                       if(bNew)
-                       {
-                               mol_id[nmol]=mol;
-                               nmol++;
-                       }
-
-                       z=r[at][ZZ];
-                       if(z<zmin)                                      zmin=z;
-                       if(z>zmax)                                      zmax=z;
-
-/*                     index[count]=at;*/
-                       count++;
-               }
-       }
-
-       mem_p->nmol=nmol;
-       srenew(mol_id,nmol);
-       mem_p->mol_id=mol_id;
-/*     srenew(index,count);*/
-/*     mem_p->mem_at.nr=count;*/
-/*     sfree(mem_p->mem_at.index);*/
-/*     mem_p->mem_at.index=index;*/
-
-       if((zmax-zmin)>(box[ZZ][ZZ]-0.5))
-               gmx_fatal(FARGS,"Something is wrong with your membrane. Max and min z values are %f and %f.\n"
-                               "Maybe your membrane is not centered in the box, but located at the box edge in the z-direction,\n"
-                               "so that one membrane is distributed over two periodic box images. Another possibility is that\n"
-                               "your water layer is not thick enough.\n",zmax,zmin);
-       mem_p->zmin=zmin;
-       mem_p->zmax=zmax;
-       mem_p->zmed=(zmax-zmin)/2+zmin;
-
-       /*number of membrane molecules in protein box*/
-       nmolbox = count/mtop->molblock[block].natoms_mol;
-       /*mem_area = box[XX][XX]*box[YY][YY]-box[XX][YY]*box[YY][XX];
-       mem_p->lip_area = 2.0*mem_area/(double)mem_p->nmol;*/
-       mem_area = (pos_ins->xmax[XX]-pos_ins->xmin[XX])*(pos_ins->xmax[YY]-pos_ins->xmin[YY]);
-       mem_p->lip_area = 2.0*mem_area/(double)nmolbox;
-
-       return mem_p->mem_at.nr;
-}
-
-void init_resize(t_block *ins_at,rvec *r_ins,pos_ins_t *pos_ins,mem_t *mem_p,rvec *r, gmx_bool bALLOW_ASYMMETRY)
-{
-       int i,j,at,c,outsidesum,gctr=0;
-    int idxsum=0;
-
-    /*sanity check*/
-    for (i=0;i<pos_ins->pieces;i++)
-          idxsum+=pos_ins->nidx[i];
-    if (idxsum!=ins_at->nr)
-          gmx_fatal(FARGS,"Piecewise sum of inserted atoms not same as size of group selected to insert.");
-
-    snew(pos_ins->geom_cent,pos_ins->pieces);
-    for (i=0;i<pos_ins->pieces;i++)
-    {
-       c=0;
-       outsidesum=0;
-       for(j=0;j<DIM;j++)
-               pos_ins->geom_cent[i][j]=0;
-
-       for(j=0;j<DIM;j++)
-               pos_ins->geom_cent[i][j]=0;
-       for (j=0;j<pos_ins->nidx[i];j++)
-       {
-               at=pos_ins->subindex[i][j];
-               copy_rvec(r[at],r_ins[gctr]);
-               if( (r_ins[gctr][ZZ]<mem_p->zmax) && (r_ins[gctr][ZZ]>mem_p->zmin) )
-               {
-                       rvec_inc(pos_ins->geom_cent[i],r_ins[gctr]);
-                       c++;
-               }
-               else
-                       outsidesum++;
-               gctr++;
-       }
-       if (c>0)
-               svmul(1/(double)c,pos_ins->geom_cent[i],pos_ins->geom_cent[i]);
-       if (!bALLOW_ASYMMETRY)
-               pos_ins->geom_cent[i][ZZ]=mem_p->zmed;
-
-       fprintf(stderr,"Embedding piece %d with center of geometry: %f %f %f\n",i,pos_ins->geom_cent[i][XX],pos_ins->geom_cent[i][YY],pos_ins->geom_cent[i][ZZ]);
-    }
-    fprintf(stderr,"\n");
-}
-
-void resize(t_block *ins_at, rvec *r_ins, rvec *r, pos_ins_t *pos_ins,rvec fac)
-{
-       int i,j,k,at,c=0;
-       for (k=0;k<pos_ins->pieces;k++)
-               for(i=0;i<pos_ins->nidx[k];i++)
-               {
-                       at=pos_ins->subindex[k][i];
-                       for(j=0;j<DIM;j++)
-                               r[at][j]=pos_ins->geom_cent[k][j]+fac[j]*(r_ins[c][j]-pos_ins->geom_cent[k][j]);
-                       c++;
-               }
-}
-
-int gen_rm_list(rm_t *rm_p,t_block *ins_at,t_block *rest_at,t_pbc *pbc, gmx_mtop_t *mtop,
-               rvec *r, rvec *r_ins, mem_t *mem_p, pos_ins_t *pos_ins, real probe_rad, int low_up_rm, gmx_bool bALLOW_ASYMMETRY)
-{
-       int i,j,k,l,at,at2,mol_id;
-        int type=0,block=0;
-       int nrm,nupper,nlower;
-       real r_min_rad,z_lip,min_norm;
-       gmx_bool bRM;
-       rvec dr,dr_tmp;
-       real *dist;
-       int *order;
-
-       r_min_rad=probe_rad*probe_rad;
-       snew(rm_p->mol,mtop->mols.nr);
-       snew(rm_p->block,mtop->mols.nr);
-       nrm=nupper=0;
-       nlower=low_up_rm;
-       for(i=0;i<ins_at->nr;i++)
-       {
-               at=ins_at->index[i];
-               for(j=0;j<rest_at->nr;j++)
-               {
-                       at2=rest_at->index[j];
-                       pbc_dx(pbc,r[at],r[at2],dr);
-
-                       if(norm2(dr)<r_min_rad)
-                       {
-                               mol_id = get_mol_id(at2,mtop->nmolblock,mtop->molblock,&type,&block);
-                               bRM=TRUE;
-                               for(l=0;l<nrm;l++)
-                                       if(rm_p->mol[l]==mol_id)
-                                               bRM=FALSE;
-                               if(bRM)
-                               {
-                                       /*fprintf(stderr,"%d wordt toegevoegd\n",mol_id);*/
-                                       rm_p->mol[nrm]=mol_id;
-                                       rm_p->block[nrm]=block;
-                                       nrm++;
-                                       z_lip=0.0;
-                                       for(l=0;l<mem_p->nmol;l++)
-                                       {
-                                               if(mol_id==mem_p->mol_id[l])
-                                               {
-                                                       for(k=mtop->mols.index[mol_id];k<mtop->mols.index[mol_id+1];k++)
-                                                               z_lip+=r[k][ZZ];
-                                                       z_lip/=mtop->molblock[block].natoms_mol;
-                                                       if(z_lip<mem_p->zmed)
-                                                               nlower++;
-                                                       else
-                                                               nupper++;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /*make sure equal number of lipids from upper and lower layer are removed */
-       if( (nupper!=nlower) && (!bALLOW_ASYMMETRY) )
-       {
-               snew(dist,mem_p->nmol);
-               snew(order,mem_p->nmol);
-               for(i=0;i<mem_p->nmol;i++)
-               {
-                       at = mtop->mols.index[mem_p->mol_id[i]];
-                       pbc_dx(pbc,r[at],pos_ins->geom_cent[0],dr);
-                       if (pos_ins->pieces>1)
-                       {
-                               /*minimum dr value*/
-                               min_norm=norm2(dr);
-                               for (k=1;k<pos_ins->pieces;k++)
-                               {
-                                       pbc_dx(pbc,r[at],pos_ins->geom_cent[k],dr_tmp);
-                                       if (norm2(dr_tmp) < min_norm)
-                                       {
-                                               min_norm=norm2(dr_tmp);
-                                               copy_rvec(dr_tmp,dr);
-                                       }
-                               }
-                       }
-                       dist[i]=dr[XX]*dr[XX]+dr[YY]*dr[YY];
-                       j=i-1;
-                       while (j>=0 && dist[i]<dist[order[j]])
-                       {
-                               order[j+1]=order[j];
-                               j--;
-                       }
-                       order[j+1]=i;
-               }
-
-               i=0;
-               while(nupper!=nlower)
-               {
-                       mol_id=mem_p->mol_id[order[i]];
-                       block=get_block(mol_id,mtop->nmolblock,mtop->molblock);
-
-                       bRM=TRUE;
-                       for(l=0;l<nrm;l++)
-                               if(rm_p->mol[l]==mol_id)
-                                       bRM=FALSE;
-                       if(bRM)
-                       {
-                               z_lip=0;
-                               for(k=mtop->mols.index[mol_id];k<mtop->mols.index[mol_id+1];k++)
-                                       z_lip+=r[k][ZZ];
-                               z_lip/=mtop->molblock[block].natoms_mol;
-                               if(nupper>nlower && z_lip<mem_p->zmed)
-                               {
-                                       rm_p->mol[nrm]=mol_id;
-                                       rm_p->block[nrm]=block;
-                                       nrm++;
-                                       nlower++;
-                               }
-                               else if (nupper<nlower && z_lip>mem_p->zmed)
-                               {
-                                       rm_p->mol[nrm]=mol_id;
-                                       rm_p->block[nrm]=block;
-                                       nrm++;
-                                       nupper++;
-                               }
-                       }
-                       i++;
-
-                       if(i>mem_p->nmol)
-                               gmx_fatal(FARGS,"Trying to remove more lipid molecules than there are in the membrane");
-               }
-               sfree(dist);
-               sfree(order);
-       }
-
-       rm_p->nr=nrm;
-       srenew(rm_p->mol,nrm);
-       srenew(rm_p->block,nrm);
-
-       return nupper+nlower;
-}
-
-void rm_group(t_inputrec *ir, gmx_groups_t *groups, gmx_mtop_t *mtop, rm_t *rm_p, t_state *state, t_block *ins_at, pos_ins_t *pos_ins)
-{
-       int i,j,k,n,rm,mol_id,at,block;
-       rvec *x_tmp,*v_tmp;
-       atom_id *list,*new_mols;
-       unsigned char  *new_egrp[egcNR];
-       gmx_bool bRM;
-
-       snew(list,state->natoms);
-       n=0;
-       for(i=0;i<rm_p->nr;i++)
-       {
-               mol_id=rm_p->mol[i];
-               at=mtop->mols.index[mol_id];
-               block =rm_p->block[i];
-               mtop->molblock[block].nmol--;
-               for(j=0;j<mtop->molblock[block].natoms_mol;j++)
-               {
-                       list[n]=at+j;
-                       n++;
-               }
-
-               mtop->mols.index[mol_id]=-1;
-       }
-
-       mtop->mols.nr-=rm_p->nr;
-       mtop->mols.nalloc_index-=rm_p->nr;
-       snew(new_mols,mtop->mols.nr);
-       for(i=0;i<mtop->mols.nr+rm_p->nr;i++)
-       {
-               j=0;
-               if(mtop->mols.index[i]!=-1)
-               {
-                       new_mols[j]=mtop->mols.index[i];
-                       j++;
-               }
-       }
-       sfree(mtop->mols.index);
-       mtop->mols.index=new_mols;
-
-
-       mtop->natoms-=n;
-       state->natoms-=n;
-       state->nalloc=state->natoms;
-       snew(x_tmp,state->nalloc);
-       snew(v_tmp,state->nalloc);
-
-       for(i=0;i<egcNR;i++)
-       {
-               if(groups->grpnr[i]!=NULL)
-               {
-                       groups->ngrpnr[i]=state->natoms;
-                       snew(new_egrp[i],state->natoms);
-               }
-       }
-
-       rm=0;
-       for (i=0;i<state->natoms+n;i++)
-       {
-               bRM=FALSE;
-               for(j=0;j<n;j++)
-               {
-                       if(i==list[j])
-                       {
-                               bRM=TRUE;
-                               rm++;
-                       }
-               }
-
-               if(!bRM)
-               {
-                       for(j=0;j<egcNR;j++)
-                       {
-                               if(groups->grpnr[j]!=NULL)
-                               {
-                                       new_egrp[j][i-rm]=groups->grpnr[j][i];
-                               }
-                       }
-                       copy_rvec(state->x[i],x_tmp[i-rm]);
-                       copy_rvec(state->v[i],v_tmp[i-rm]);
-                       for(j=0;j<ins_at->nr;j++)
-                       {
-                               if (i==ins_at->index[j])
-                                       ins_at->index[j]=i-rm;
-                       }
-                       for(j=0;j<pos_ins->pieces;j++)
-                       {
-                               for(k=0;k<pos_ins->nidx[j];k++)
-                               {
-                                       if (i==pos_ins->subindex[j][k])
-                                               pos_ins->subindex[j][k]=i-rm;
-                               }
-                       }
-               }
-       }
-       sfree(state->x);
-       state->x=x_tmp;
-       sfree(state->v);
-       state->v=v_tmp;
-
-       for(i=0;i<egcNR;i++)
-       {
-               if(groups->grpnr[i]!=NULL)
-               {
-                       sfree(groups->grpnr[i]);
-                       groups->grpnr[i]=new_egrp[i];
-               }
-       }
-}
-
-int rm_bonded(t_block *ins_at, gmx_mtop_t *mtop)
-{
-       int i,j,m;
-       int type,natom,nmol,at,atom1=0,rm_at=0;
-       gmx_bool *bRM,bINS;
-       /*this routine lives dangerously by assuming that all molecules of a given type are in order in the structure*/
-       /*this routine does not live as dangerously as it seems. There is namely a check in mdrunner_membed to make
-         *sure that g_membed exits with a warning when there are molecules of the same type not in the 
-        *ins_at index group. MGWolf 050710 */
-
-
-       snew(bRM,mtop->nmoltype);
-       for (i=0;i<mtop->nmoltype;i++)
-       {
-               bRM[i]=TRUE;
-       }
-
-       for (i=0;i<mtop->nmolblock;i++) 
-       {
-           /*loop over molecule blocks*/
-               type        =mtop->molblock[i].type;
-               natom       =mtop->molblock[i].natoms_mol;
-               nmol            =mtop->molblock[i].nmol;
-
-               for(j=0;j<natom*nmol && bRM[type]==TRUE;j++) 
-               {
-                   /*loop over atoms in the block*/
-                       at=j+atom1; /*atom index = block index + offset*/
-                       bINS=FALSE;
-
-                       for (m=0;(m<ins_at->nr) && (bINS==FALSE);m++)
-                       {
-                           /*loop over atoms in insertion index group to determine if we're inserting one*/
-                               if(at==ins_at->index[m])
-                               {
-                                       bINS=TRUE;
-                               }
-                       }
-                       bRM[type]=bINS;
-               }
-               atom1+=natom*nmol; /*update offset*/
-               if(bRM[type])
-               {
-                       rm_at+=natom*nmol; /*increment bonded removal counter by # atoms in block*/
-               }
-       }
-
-       for(i=0;i<mtop->nmoltype;i++)
-       {
-               if(bRM[i])
-               {
-                       for(j=0;j<F_LJ;j++)
-                       {
-                               mtop->moltype[i].ilist[j].nr=0;
-                       }
-                       for(j=F_POSRES;j<=F_VSITEN;j++)
-                       {
-                               mtop->moltype[i].ilist[j].nr=0;
-                       }
-               }
-       }
-       sfree(bRM);
-
-       return rm_at;
-}
-
-void top_update(const char *topfile, char *ins, rm_t *rm_p, gmx_mtop_t *mtop)
-{
-#define TEMP_FILENM "temp.top"
-       int     bMolecules=0;
-       FILE    *fpin,*fpout;
-       char    buf[STRLEN],buf2[STRLEN],*temp;
-       int             i,*nmol_rm,nmol,line;
-
-       fpin  = ffopen(topfile,"r");
-       fpout = ffopen(TEMP_FILENM,"w");
-
-       snew(nmol_rm,mtop->nmoltype);
-       for(i=0;i<rm_p->nr;i++)
-               nmol_rm[rm_p->block[i]]++;
-
-       line=0;
-       while(fgets(buf,STRLEN,fpin))
-       {
-               line++;
-               if(buf[0]!=';')
-               {
-                       strcpy(buf2,buf);
-                       if ((temp=strchr(buf2,'\n')) != NULL)
-                               temp[0]='\0';
-                       ltrim(buf2);
-
-                       if (buf2[0]=='[')
-                       {
-                               buf2[0]=' ';
-                               if ((temp=strchr(buf2,'\n')) != NULL)
-                                       temp[0]='\0';
-                               rtrim(buf2);
-                               if (buf2[strlen(buf2)-1]==']')
-                               {
-                                       buf2[strlen(buf2)-1]='\0';
-                                       ltrim(buf2);
-                                       rtrim(buf2);
-                                       if (gmx_strcasecmp(buf2,"molecules")==0)
-                                               bMolecules=1;
-                               }
-                               fprintf(fpout,"%s",buf);
-                       } else if (bMolecules==1)
-                       {
-                               for(i=0;i<mtop->nmolblock;i++)
-                               {
-                                       nmol=mtop->molblock[i].nmol;
-                                       sprintf(buf,"%-15s %5d\n",*(mtop->moltype[mtop->molblock[i].type].name),nmol);
-                                       fprintf(fpout,"%s",buf);
-                               }
-                               bMolecules=2;
-                       } else if (bMolecules==2)
-                       {
-                               /* print nothing */
-                       } else 
-                       {
-                               fprintf(fpout,"%s",buf);
-                       }
-               } else 
-               {
-                       fprintf(fpout,"%s",buf);
-               }
-       }
-
-       fclose(fpout);
-       /* use ffopen to generate backup of topinout */
-       fpout=ffopen(topfile,"w");
-       fclose(fpout);
-       rename(TEMP_FILENM,topfile);
-#undef TEMP_FILENM
-}
-
-void md_print_warning(const t_commrec *cr,FILE *fplog,const char *buf)
-{
-    if (MASTER(cr))
-    {
-        fprintf(stderr,"\n%s\n",buf);
-    }
-    if (fplog)
-    {
-        fprintf(fplog,"\n%s\n",buf);
-    }
-}
-
-/*  simulation conditions to transmit. Keep in mind that they are
-    transmitted to other nodes through an MPI_Reduce after
-    casting them to a real (so the signals can be sent together with other
-    data). This means that the only meaningful values are positive,
-    negative or zero. */
-enum { eglsNABNSB, eglsCHKPT, eglsSTOPCOND, eglsRESETCOUNTERS, eglsNR };
-/* Is the signal in one simulation independent of other simulations? */
-gmx_bool gs_simlocal[eglsNR] = { TRUE, FALSE, FALSE, TRUE };
-
-typedef struct {
-    int nstms;       /* The frequency for intersimulation communication */
-    int sig[eglsNR]; /* The signal set by one process in do_md */
-    int set[eglsNR]; /* The communicated signal, equal for all processes */
-} globsig_t;
-
-
-static int multisim_min(const gmx_multisim_t *ms,int nmin,int n)
-{
-    int  *buf;
-    gmx_bool bPos,bEqual;
-    int  s,d;
-
-    snew(buf,ms->nsim);
-    buf[ms->sim] = n;
-    gmx_sumi_sim(ms->nsim,buf,ms);
-    bPos   = TRUE;
-    bEqual = TRUE;
-    for(s=0; s<ms->nsim; s++)
-    {
-        bPos   = bPos   && (buf[s] > 0);
-        bEqual = bEqual && (buf[s] == buf[0]);
-    }
-    if (bPos)
-    {
-        if (bEqual)
-        {
-            nmin = min(nmin,buf[0]);
-        }
-        else
-        {
-            /* Find the least common multiple */
-            for(d=2; d<nmin; d++)
-            {
-                s = 0;
-                while (s < ms->nsim && d % buf[s] == 0)
-                {
-                    s++;
-                }
-                if (s == ms->nsim)
-                {
-                    /* We found the LCM and it is less than nmin */
-                    nmin = d;
-                    break;
-                }
-            }
-        }
-    }
-    sfree(buf);
-
-    return nmin;
-}
-
-static int multisim_nstsimsync(const t_commrec *cr,
-                               const t_inputrec *ir,int repl_ex_nst)
-{
-    int nmin;
-
-    if (MASTER(cr))
-    {
-        nmin = INT_MAX;
-        nmin = multisim_min(cr->ms,nmin,ir->nstlist);
-        nmin = multisim_min(cr->ms,nmin,ir->nstcalcenergy);
-        nmin = multisim_min(cr->ms,nmin,repl_ex_nst);
-        if (nmin == INT_MAX)
-        {
-            gmx_fatal(FARGS,"Can not find an appropriate interval for inter-simulation communication, since nstlist, nstcalcenergy and -replex are all <= 0");
-        }
-        /* Avoid inter-simulation communication at every (second) step */
-        if (nmin <= 2)
-        {
-            nmin = 10;
-        }
-    }
-
-    gmx_bcast(sizeof(int),&nmin,cr);
-
-    return nmin;
-}
-
-static void init_global_signals(globsig_t *gs,const t_commrec *cr,
-                                const t_inputrec *ir,int repl_ex_nst)
-{
-    int i;
-
-    if (MULTISIM(cr))
-    {
-        gs->nstms = multisim_nstsimsync(cr,ir,repl_ex_nst);
-        if (debug)
-        {
-            fprintf(debug,"Syncing simulations for checkpointing and termination every %d steps\n",gs->nstms);
-        }
-    }
-    else
-    {
-        gs->nstms = 1;
-    }
-
-    for(i=0; i<eglsNR; i++)
-    {
-        gs->sig[i] = 0;
-        gs->set[i] = 0;
-    }
-}
-
-static void copy_coupling_state(t_state *statea,t_state *stateb,
-                                gmx_ekindata_t *ekinda,gmx_ekindata_t *ekindb, t_grpopts* opts)
-{
-
-    /* MRS note -- might be able to get rid of some of the arguments.  Look over it when it's all debugged */
-
-    int i,j,nc;
-
-    /* Make sure we have enough space for x and v */
-    if (statea->nalloc > stateb->nalloc)
-    {
-        stateb->nalloc = statea->nalloc;
-        srenew(stateb->x,stateb->nalloc);
-        srenew(stateb->v,stateb->nalloc);
-    }
-
-    stateb->natoms     = statea->natoms;
-    stateb->ngtc       = statea->ngtc;
-    stateb->nnhpres    = statea->nnhpres;
-    stateb->veta       = statea->veta;
-    if (ekinda)
-    {
-        copy_mat(ekinda->ekin,ekindb->ekin);
-        for (i=0; i<stateb->ngtc; i++)
-        {
-            ekindb->tcstat[i].T = ekinda->tcstat[i].T;
-            ekindb->tcstat[i].Th = ekinda->tcstat[i].Th;
-            copy_mat(ekinda->tcstat[i].ekinh,ekindb->tcstat[i].ekinh);
-            copy_mat(ekinda->tcstat[i].ekinf,ekindb->tcstat[i].ekinf);
-            ekindb->tcstat[i].ekinscalef_nhc =  ekinda->tcstat[i].ekinscalef_nhc;
-            ekindb->tcstat[i].ekinscaleh_nhc =  ekinda->tcstat[i].ekinscaleh_nhc;
-            ekindb->tcstat[i].vscale_nhc =  ekinda->tcstat[i].vscale_nhc;
-        }
-    }
-    copy_rvecn(statea->x,stateb->x,0,stateb->natoms);
-    copy_rvecn(statea->v,stateb->v,0,stateb->natoms);
-    copy_mat(statea->box,stateb->box);
-    copy_mat(statea->box_rel,stateb->box_rel);
-    copy_mat(statea->boxv,stateb->boxv);
-
-    for (i = 0; i<stateb->ngtc; i++)
-    {
-        nc = i*opts->nhchainlength;
-        for (j=0; j<opts->nhchainlength; j++)
-        {
-            stateb->nosehoover_xi[nc+j]  = statea->nosehoover_xi[nc+j];
-            stateb->nosehoover_vxi[nc+j] = statea->nosehoover_vxi[nc+j];
-        }
-    }
-    if (stateb->nhpres_xi != NULL)
-    {
-        for (i = 0; i<stateb->nnhpres; i++)
-        {
-            nc = i*opts->nhchainlength;
-            for (j=0; j<opts->nhchainlength; j++)
-            {
-                stateb->nhpres_xi[nc+j]  = statea->nhpres_xi[nc+j];
-                stateb->nhpres_vxi[nc+j] = statea->nhpres_vxi[nc+j];
-            }
-        }
-    }
-}
-
-static void compute_globals(FILE *fplog, gmx_global_stat_t gstat, t_commrec *cr, t_inputrec *ir,
-                            t_forcerec *fr, gmx_ekindata_t *ekind,
-                            t_state *state, t_state *state_global, t_mdatoms *mdatoms,
-                            t_nrnb *nrnb, t_vcm *vcm, gmx_wallcycle_t wcycle,
-                            gmx_enerdata_t *enerd,tensor force_vir, tensor shake_vir, tensor total_vir,
-                            tensor pres, rvec mu_tot, gmx_constr_t constr,
-                            globsig_t *gs,gmx_bool bInterSimGS,
-                            matrix box, gmx_mtop_t *top_global, real *pcurr,
-                            int natoms, gmx_bool *bSumEkinhOld, int flags)
-{
-    int  i,gsi;
-    real gs_buf[eglsNR];
-    tensor corr_vir,corr_pres;
-    gmx_bool bEner,bPres,bTemp;
-    gmx_bool bRerunMD, bStopCM, bGStat, bIterate,
-        bFirstIterate,bReadEkin,bEkinAveVel,bScaleEkin, bConstrain;
-    real prescorr,enercorr,dvdlcorr;
-
-    /* translate CGLO flags to gmx_booleans */
-    bRerunMD = flags & CGLO_RERUNMD;
-    bStopCM = flags & CGLO_STOPCM;
-    bGStat = flags & CGLO_GSTAT;
-    bReadEkin = (flags & CGLO_READEKIN);
-    bScaleEkin = (flags & CGLO_SCALEEKIN);
-    bEner = flags & CGLO_ENERGY;
-    bTemp = flags & CGLO_TEMPERATURE;
-    bPres  = (flags & CGLO_PRESSURE);
-    bConstrain = (flags & CGLO_CONSTRAINT);
-    bIterate = (flags & CGLO_ITERATE);
-    bFirstIterate = (flags & CGLO_FIRSTITERATE);
-
-    /* we calculate a full state kinetic energy either with full-step velocity verlet
-       or half step where we need the pressure */
-    bEkinAveVel = (ir->eI==eiVV || (ir->eI==eiVVAK && IR_NPT_TROTTER(ir) && bPres) || bReadEkin);
-
-    /* in initalization, it sums the shake virial in vv, and to
-       sums ekinh_old in leapfrog (or if we are calculating ekinh_old for other reasons */
-
-    /* ########## Kinetic energy  ############## */
-
-    if (bTemp)
-    {
-        /* Non-equilibrium MD: this is parallellized, but only does communication
-         * when there really is NEMD.
-         */
-
-        if (PAR(cr) && (ekind->bNEMD))
-        {
-            accumulate_u(cr,&(ir->opts),ekind);
-        }
-        debug_gmx();
-        if (bReadEkin)
-        {
-            restore_ekinstate_from_state(cr,ekind,&state_global->ekinstate);
-        }
-        else
-        {
-
-            calc_ke_part(state,&(ir->opts),mdatoms,ekind,nrnb,bEkinAveVel,bIterate);
-        }
-
-        debug_gmx();
-
-        /* Calculate center of mass velocity if necessary, also parallellized */
-        if (bStopCM && !bRerunMD && bEner)
-        {
-            calc_vcm_grp(fplog,mdatoms->start,mdatoms->homenr,mdatoms,
-                         state->x,state->v,vcm);
-        }
-    }
-
-    if (bTemp || bPres || bEner || bConstrain)
-    {
-        if (!bGStat)
-        {
-            /* We will not sum ekinh_old,
-             * so signal that we still have to do it.
-             */
-            *bSumEkinhOld = TRUE;
-
-        }
-        else
-        {
-            if (gs != NULL)
-            {
-                for(i=0; i<eglsNR; i++)
-                {
-                    gs_buf[i] = gs->sig[i];
-                }
-            }
-            if (PAR(cr))
-            {
-                wallcycle_start(wcycle,ewcMoveE);
-                GMX_MPE_LOG(ev_global_stat_start);
-                global_stat(fplog,gstat,cr,enerd,force_vir,shake_vir,mu_tot,
-                            ir,ekind,constr,vcm,
-                            gs != NULL ? eglsNR : 0,gs_buf,
-                            top_global,state,
-                            *bSumEkinhOld,flags);
-                GMX_MPE_LOG(ev_global_stat_finish);
-                wallcycle_stop(wcycle,ewcMoveE);
-            }
-            if (gs != NULL)
-            {
-                if (MULTISIM(cr) && bInterSimGS)
-                {
-                    if (MASTER(cr))
-                    {
-                        /* Communicate the signals between the simulations */
-                        gmx_sum_sim(eglsNR,gs_buf,cr->ms);
-                    }
-                    /* Communicate the signals form the master to the others */
-                    gmx_bcast(eglsNR*sizeof(gs_buf[0]),gs_buf,cr);
-                }
-                for(i=0; i<eglsNR; i++)
-                {
-                    if (bInterSimGS || gs_simlocal[i])
-                    {
-                        /* Set the communicated signal only when it is non-zero,
-                         * since signals might not be processed at each MD step.
-                         */
-                        gsi = (gs_buf[i] >= 0 ?
-                               (int)(gs_buf[i] + 0.5) :
-                               (int)(gs_buf[i] - 0.5));
-                        if (gsi != 0)
-                        {
-                            gs->set[i] = gsi;
-                        }
-                        /* Turn off the local signal */
-                        gs->sig[i] = 0;
-                    }
-                }
-            }
-            *bSumEkinhOld = FALSE;
-        }
-    }
-
-    if (!ekind->bNEMD && debug && bTemp && (vcm->nr > 0))
-    {
-        correct_ekin(debug,
-                     mdatoms->start,mdatoms->start+mdatoms->homenr,
-                     state->v,vcm->group_p[0],
-                     mdatoms->massT,mdatoms->tmass,ekind->ekin);
-    }
-
-    if (bEner) {
-        /* Do center of mass motion removal */
-        if (bStopCM && !bRerunMD) /* is this correct?  Does it get called too often with this logic? */
-        {
-            check_cm_grp(fplog,vcm,ir,1);
-            do_stopcm_grp(fplog,mdatoms->start,mdatoms->homenr,mdatoms->cVCM,
-                          state->x,state->v,vcm);
-            inc_nrnb(nrnb,eNR_STOPCM,mdatoms->homenr);
-        }
-    }
-
-    if (bTemp)
-    {
-        /* Sum the kinetic energies of the groups & calc temp */
-        /* compute full step kinetic energies if vv, or if vv-avek and we are computing the pressure with IR_NPT_TROTTER */
-        /* three maincase:  VV with AveVel (md-vv), vv with AveEkin (md-vv-avek), leap with AveEkin (md).
-           Leap with AveVel is also an option for the future but not supported now.
-           bEkinAveVel: If TRUE, we simply multiply ekin by ekinscale to get a full step kinetic energy.
-           If FALSE, we average ekinh_old and ekinh*ekinscale_nhc to get an averaged half step kinetic energy.
-           bSaveEkinOld: If TRUE (in the case of iteration = bIterate is TRUE), we don't reset the ekinscale_nhc.
-           If FALSE, we go ahead and erase over it.
-        */
-        enerd->term[F_TEMP] = sum_ekin(&(ir->opts),ekind,&(enerd->term[F_DKDL]),
-                                       bEkinAveVel,bIterate,bScaleEkin);
-
-        enerd->term[F_EKIN] = trace(ekind->ekin);
-    }
-
-    /* ##########  Long range energy information ###### */
-
-    if (bEner || bPres || bConstrain)
-    {
-        calc_dispcorr(fplog,ir,fr,0,top_global->natoms,box,state->lambda,
-                      corr_pres,corr_vir,&prescorr,&enercorr,&dvdlcorr);
-    }
-
-    if (bEner && bFirstIterate)
-    {
-        enerd->term[F_DISPCORR] = enercorr;
-        enerd->term[F_EPOT] += enercorr;
-        enerd->term[F_DVDL] += dvdlcorr;
-        if (fr->efep != efepNO) {
-            enerd->dvdl_lin += dvdlcorr;
-        }
-    }
-
-    /* ########## Now pressure ############## */
-    if (bPres || bConstrain)
-    {
-
-        m_add(force_vir,shake_vir,total_vir);
-
-        /* Calculate pressure and apply LR correction if PPPM is used.
-         * Use the box from last timestep since we already called update().
-         */
-
-        enerd->term[F_PRES] = calc_pres(fr->ePBC,ir->nwall,box,ekind->ekin,total_vir,pres,
-                                        (fr->eeltype==eelPPPM)?enerd->term[F_COUL_RECIP]:0.0);
-
-        /* Calculate long range corrections to pressure and energy */
-        /* this adds to enerd->term[F_PRES] and enerd->term[F_ETOT],
-           and computes enerd->term[F_DISPCORR].  Also modifies the
-           total_vir and pres tesors */
-
-        m_add(total_vir,corr_vir,total_vir);
-        m_add(pres,corr_pres,pres);
-        enerd->term[F_PDISPCORR] = prescorr;
-        enerd->term[F_PRES] += prescorr;
-        *pcurr = enerd->term[F_PRES];
-        /* calculate temperature using virial */
-        enerd->term[F_VTEMP] = calc_temp(trace(total_vir),ir->opts.nrdf[0]);
-
-    }
-}
-
-
-/* Definitions for convergence of iterated constraints */
-
-/* iterate constraints up to 50 times  */
-#define MAXITERCONST       50
-
-/* data type */
-typedef struct
-{
-    real f,fprev,x,xprev;
-    int iter_i;
-    gmx_bool bIterate;
-    real allrelerr[MAXITERCONST+2];
-    int num_close; /* number of "close" violations, caused by limited precision. */
-} gmx_iterate_t;
-
-#ifdef GMX_DOUBLE
-#define CONVERGEITER  0.000000001
-#define CLOSE_ENOUGH  0.000001000
-#else
-#define CONVERGEITER  0.0001
-#define CLOSE_ENOUGH  0.0050
-#endif
-
-/* we want to keep track of the close calls.  If there are too many, there might be some other issues.
-   so we make sure that it's either less than some predetermined number, or if more than that number,
-   only some small fraction of the total. */
-#define MAX_NUMBER_CLOSE        50
-#define FRACTION_CLOSE       0.001
-
-/* maximum length of cyclic traps to check, emerging from limited numerical precision  */
-#define CYCLEMAX            20
-
-static void gmx_iterate_init(gmx_iterate_t *iterate,gmx_bool bIterate)
-{
-    int i;
-
-    iterate->iter_i = 0;
-    iterate->bIterate = bIterate;
-    iterate->num_close = 0;
-    for (i=0;i<MAXITERCONST+2;i++)
-    {
-        iterate->allrelerr[i] = 0;
-    }
-}
-
-static gmx_bool done_iterating(const t_commrec *cr,FILE *fplog, int nsteps, gmx_iterate_t *iterate, gmx_bool bFirstIterate, real fom, real *newf)
-{
-    /* monitor convergence, and use a secant search to propose new
-       values.
-                                                                  x_{i} - x_{i-1}
-       The secant method computes x_{i+1} = x_{i} - f(x_{i}) * ---------------------
-                                                                f(x_{i}) - f(x_{i-1})
-
-       The function we are trying to zero is fom-x, where fom is the
-       "figure of merit" which is the pressure (or the veta value) we
-       would get by putting in an old value of the pressure or veta into
-       the incrementor function for the step or half step.  I have
-       verified that this gives the same answer as self consistent
-       iteration, usually in many fewer steps, especially for small tau_p.
-
-       We could possibly eliminate an iteration with proper use
-       of the value from the previous step, but that would take a bit
-       more bookkeeping, especially for veta, since tests indicate the
-       function of veta on the last step is not sufficiently close to
-       guarantee convergence this step. This is
-       good enough for now.  On my tests, I could use tau_p down to
-       0.02, which is smaller that would ever be necessary in
-       practice. Generally, 3-5 iterations will be sufficient */
-
-    real relerr,err;
-    char buf[256];
-    int i;
-    gmx_bool incycle;
-
-    if (bFirstIterate)
-    {
-        iterate->x = fom;
-        iterate->f = fom-iterate->x;
-        iterate->xprev = 0;
-        iterate->fprev = 0;
-        *newf = fom;
-    }
-    else
-    {
-        iterate->f = fom-iterate->x; /* we want to zero this difference */
-        if ((iterate->iter_i > 1) && (iterate->iter_i < MAXITERCONST))
-        {
-            if (iterate->f==iterate->fprev)
-            {
-                *newf = iterate->f;
-            }
-            else
-            {
-                *newf = iterate->x - (iterate->x-iterate->xprev)*(iterate->f)/(iterate->f-iterate->fprev);
-            }
-        }
-        else
-        {
-            /* just use self-consistent iteration the first step to initialize, or
-               if it's not converging (which happens occasionally -- need to investigate why) */
-            *newf = fom;
-        }
-    }
-    /* Consider a slight shortcut allowing us to exit one sooner -- we check the
-       difference between the closest of x and xprev to the new
-       value. To be 100% certain, we should check the difference between
-       the last result, and the previous result, or
-
-       relerr = (fabs((x-xprev)/fom));
-
-       but this is pretty much never necessary under typical conditions.
-       Checking numerically, it seems to lead to almost exactly the same
-       trajectories, but there are small differences out a few decimal
-       places in the pressure, and eventually in the v_eta, but it could
-       save an interation.
-
-       if (fabs(*newf-x) < fabs(*newf - xprev)) { xmin = x;} else { xmin = xprev;}
-       relerr = (fabs((*newf-xmin) / *newf));
-    */
-
-    err = fabs((iterate->f-iterate->fprev));
-    relerr = fabs(err/fom);
-
-    iterate->allrelerr[iterate->iter_i] = relerr;
-
-    if (iterate->iter_i > 0)
-    {
-        if (debug)
-        {
-            fprintf(debug,"Iterating NPT constraints: %6i %20.12f%14.6g%20.12f\n",
-                    iterate->iter_i,fom,relerr,*newf);
-        }
-
-        if ((relerr < CONVERGEITER) || (err < CONVERGEITER) || (fom==0) || ((iterate->x == iterate->xprev) && iterate->iter_i > 1))
-        {
-            iterate->bIterate = FALSE;
-            if (debug)
-            {
-                fprintf(debug,"Iterating NPT constraints: CONVERGED\n");
-            }
-            return TRUE;
-        }
-        if (iterate->iter_i > MAXITERCONST)
-        {
-            if (relerr < CLOSE_ENOUGH)
-            {
-                incycle = FALSE;
-                for (i=1;i<CYCLEMAX;i++) {
-                    if ((iterate->allrelerr[iterate->iter_i-(1+i)] == iterate->allrelerr[iterate->iter_i-1]) &&
-                        (iterate->allrelerr[iterate->iter_i-(1+i)] == iterate->allrelerr[iterate->iter_i-(1+2*i)])) {
-                        incycle = TRUE;
-                        if (debug)
-                        {
-                            fprintf(debug,"Exiting from an NPT iterating cycle of length %d\n",i);
-                        }
-                        break;
-                    }
-                }
-
-                if (incycle) {
-                    /* step 1: trapped in a numerical attractor */
-                    /* we are trapped in a numerical attractor, and can't converge any more, and are close to the final result.
-                       Better to give up convergence here than have the simulation die.
-                    */
-                    iterate->num_close++;
-                    return TRUE;
-                }
-                else
-                {
-                    /* Step #2: test if we are reasonably close for other reasons, then monitor the number.  If not, die */
-
-                    /* how many close calls have we had?  If less than a few, we're OK */
-                    if (iterate->num_close < MAX_NUMBER_CLOSE)
-                    {
-                        sprintf(buf,"Slight numerical convergence deviation with NPT at step %d, relative error only %10.5g, likely not a problem, continuing\n",nsteps,relerr);
-                        md_print_warning(cr,fplog,buf);
-                        iterate->num_close++;
-                        return TRUE;
-                        /* if more than a few, check the total fraction.  If too high, die. */
-                    } else if (iterate->num_close/(double)nsteps > FRACTION_CLOSE) {
-                        gmx_fatal(FARGS,"Could not converge NPT constraints, too many exceptions (%d%%\n",iterate->num_close/(double)nsteps);
-                    }
-                }
-            }
-            else
-            {
-                gmx_fatal(FARGS,"Could not converge NPT constraints\n");
-            }
-        }
-    }
-
-    iterate->xprev = iterate->x;
-    iterate->x = *newf;
-    iterate->fprev = iterate->f;
-    iterate->iter_i++;
-
-    return FALSE;
-}
-
-static void check_nst_param(FILE *fplog,t_commrec *cr,
-                            const char *desc_nst,int nst,
-                            const char *desc_p,int *p)
-{
-    char buf[STRLEN];
-
-    if (*p > 0 && *p % nst != 0)
-    {
-        /* Round up to the next multiple of nst */
-        *p = ((*p)/nst + 1)*nst;
-        sprintf(buf,"NOTE: %s changes %s to %d\n",desc_nst,desc_p,*p);
-        md_print_warning(cr,fplog,buf);
-    }
-}
-
-static void reset_all_counters(FILE *fplog,t_commrec *cr,
-                               gmx_large_int_t step,
-                               gmx_large_int_t *step_rel,t_inputrec *ir,
-                               gmx_wallcycle_t wcycle,t_nrnb *nrnb,
-                               gmx_runtime_t *runtime)
-{
-    char buf[STRLEN],sbuf[STEPSTRSIZE];
-
-    /* Reset all the counters related to performance over the run */
-    sprintf(buf,"Step %s: resetting all time and cycle counters\n",
-            gmx_step_str(step,sbuf));
-    md_print_warning(cr,fplog,buf);
-
-    wallcycle_stop(wcycle,ewcRUN);
-    wallcycle_reset_all(wcycle);
-    if (DOMAINDECOMP(cr))
-    {
-        reset_dd_statistics_counters(cr->dd);
-    }
-    init_nrnb(nrnb);
-    ir->init_step += *step_rel;
-    ir->nsteps    -= *step_rel;
-    *step_rel = 0;
-    wallcycle_start(wcycle,ewcRUN);
-    runtime_start(runtime);
-    print_date_and_time(fplog,cr->nodeid,"Restarted time",runtime);
-}
-
-static int check_nstglobalcomm(FILE *fplog,t_commrec *cr,
-                               int nstglobalcomm,t_inputrec *ir)
-{
-    char buf[STRLEN];
-
-    if (!EI_DYNAMICS(ir->eI))
-    {
-        nstglobalcomm = 1;
-    }
-
-    if (nstglobalcomm == -1)
-    {
-        if (ir->nstcalcenergy == 0 && ir->nstlist == 0)
-        {
-            nstglobalcomm = 10;
-            if (ir->nstenergy > 0 && ir->nstenergy < nstglobalcomm)
-            {
-                nstglobalcomm = ir->nstenergy;
-            }
-        }
-        else
-        {
-            /* We assume that if nstcalcenergy > nstlist,
-             * nstcalcenergy is a multiple of nstlist.
-             */
-            if (ir->nstcalcenergy == 0 ||
-                (ir->nstlist > 0 && ir->nstlist < ir->nstcalcenergy))
-            {
-                nstglobalcomm = ir->nstlist;
-            }
-            else
-            {
-                nstglobalcomm = ir->nstcalcenergy;
-            }
-        }
-    }
-    else
-    {
-        if (ir->nstlist > 0 &&
-            nstglobalcomm > ir->nstlist && nstglobalcomm % ir->nstlist != 0)
-        {
-            nstglobalcomm = (nstglobalcomm / ir->nstlist)*ir->nstlist;
-            sprintf(buf,"WARNING: nstglobalcomm is larger than nstlist, but not a multiple, setting it to %d\n",nstglobalcomm);
-            md_print_warning(cr,fplog,buf);
-        }
-        if (nstglobalcomm > ir->nstcalcenergy)
-        {
-            check_nst_param(fplog,cr,"-gcom",nstglobalcomm,
-                            "nstcalcenergy",&ir->nstcalcenergy);
-        }
-
-        check_nst_param(fplog,cr,"-gcom",nstglobalcomm,
-                        "nstenergy",&ir->nstenergy);
-
-        check_nst_param(fplog,cr,"-gcom",nstglobalcomm,
-                        "nstlog",&ir->nstlog);
-    }
-
-    if (ir->comm_mode != ecmNO && ir->nstcomm < nstglobalcomm)
-    {
-        sprintf(buf,"WARNING: Changing nstcomm from %d to %d\n",
-                ir->nstcomm,nstglobalcomm);
-        md_print_warning(cr,fplog,buf);
-        ir->nstcomm = nstglobalcomm;
-    }
-
-    return nstglobalcomm;
-}
-
-void check_ir_old_tpx_versions(t_commrec *cr,FILE *fplog,
-                               t_inputrec *ir,gmx_mtop_t *mtop)
-{
-    /* Check required for old tpx files */
-    if (IR_TWINRANGE(*ir) && ir->nstlist > 1 &&
-        ir->nstcalcenergy % ir->nstlist != 0)
-    {
-        md_print_warning(cr,fplog,"Old tpr file with twin-range settings: modifying energy calculation and/or T/P-coupling frequencies");
-
-        if (gmx_mtop_ftype_count(mtop,F_CONSTR) +
-            gmx_mtop_ftype_count(mtop,F_CONSTRNC) > 0 &&
-            ir->eConstrAlg == econtSHAKE)
-        {
-            md_print_warning(cr,fplog,"With twin-range cut-off's and SHAKE the virial and pressure are incorrect");
-            if (ir->epc != epcNO)
-            {
-                gmx_fatal(FARGS,"Can not do pressure coupling with twin-range cut-off's and SHAKE");
-            }
-        }
-        check_nst_param(fplog,cr,"nstlist",ir->nstlist,
-                        "nstcalcenergy",&ir->nstcalcenergy);
-       check_nst_param(fplog,cr,"nstcalcenergy",ir->nstcalcenergy,
-                       "nstenergy",&ir->nstenergy);
-        check_nst_param(fplog,cr,"nstcalcenergy",ir->nstcalcenergy,
-                        "nstlog",&ir->nstlog);
-        if (ir->efep != efepNO)
-        {
-            check_nst_param(fplog,cr,"nstcalcenergy",ir->nstcalcenergy,
-                            "nstdhdl",&ir->nstdhdl);
-        }
-    }
-}
-
-typedef struct {
-    gmx_bool       bGStatEveryStep;
-    gmx_large_int_t step_ns;
-    gmx_large_int_t step_nscheck;
-    gmx_large_int_t nns;
-    matrix     scale_tot;
-    int        nabnsb;
-    double     s1;
-    double     s2;
-    double     ab;
-    double     lt_runav;
-    double     lt_runav2;
-} gmx_nlheur_t;
-
-static void reset_nlistheuristics(gmx_nlheur_t *nlh,gmx_large_int_t step)
-{
-    nlh->lt_runav  = 0;
-    nlh->lt_runav2 = 0;
-    nlh->step_nscheck = step;
-}
-
-static void init_nlistheuristics(gmx_nlheur_t *nlh,
-                                 gmx_bool bGStatEveryStep,gmx_large_int_t step)
-{
-    nlh->bGStatEveryStep = bGStatEveryStep;
-    nlh->nns       = 0;
-    nlh->nabnsb    = 0;
-    nlh->s1        = 0;
-    nlh->s2        = 0;
-    nlh->ab        = 0;
-
-    reset_nlistheuristics(nlh,step);
-}
-
-static void update_nliststatistics(gmx_nlheur_t *nlh,gmx_large_int_t step)
-{
-    gmx_large_int_t nl_lt;
-    char sbuf[STEPSTRSIZE],sbuf2[STEPSTRSIZE];
-
-    /* Determine the neighbor list life time */
-    nl_lt = step - nlh->step_ns;
-    if (debug)
-    {
-        fprintf(debug,"%d atoms beyond ns buffer, updating neighbor list after %s steps\n",nlh->nabnsb,gmx_step_str(nl_lt,sbuf));
-    }
-    nlh->nns++;
-    nlh->s1 += nl_lt;
-    nlh->s2 += nl_lt*nl_lt;
-    nlh->ab += nlh->nabnsb;
-    if (nlh->lt_runav == 0)
-    {
-        nlh->lt_runav  = nl_lt;
-        /* Initialize the fluctuation average
-         * such that at startup we check after 0 steps.
-         */
-        nlh->lt_runav2 = sqr(nl_lt/2.0);
-    }
-    /* Running average with 0.9 gives an exp. history of 9.5 */
-    nlh->lt_runav2 = 0.9*nlh->lt_runav2 + 0.1*sqr(nlh->lt_runav - nl_lt);
-    nlh->lt_runav  = 0.9*nlh->lt_runav  + 0.1*nl_lt;
-    if (nlh->bGStatEveryStep)
-    {
-        /* Always check the nlist validity */
-        nlh->step_nscheck = step;
-    }
-    else
-    {
-        /* We check after:  <life time> - 2*sigma
-         * The factor 2 is quite conservative,
-         * but we assume that with nstlist=-1 the user
-         * prefers exact integration over performance.
-         */
-        nlh->step_nscheck = step
-                  + (int)(nlh->lt_runav - 2.0*sqrt(nlh->lt_runav2)) - 1;
-    }
-    if (debug)
-    {
-        fprintf(debug,"nlist life time %s run av. %4.1f sig %3.1f check %s check with -gcom %d\n",
-                gmx_step_str(nl_lt,sbuf),nlh->lt_runav,sqrt(nlh->lt_runav2),
-                gmx_step_str(nlh->step_nscheck-step+1,sbuf2),
-                (int)(nlh->lt_runav - 2.0*sqrt(nlh->lt_runav2)));
-    }
-}
-
-static void set_nlistheuristics(gmx_nlheur_t *nlh,gmx_bool bReset,gmx_large_int_t step)
-{
-    int d;
-
-    if (bReset)
-    {
-        reset_nlistheuristics(nlh,step);
-    }
-    else
-    {
-        update_nliststatistics(nlh,step);
-    }
-
-    nlh->step_ns = step;
-    /* Initialize the cumulative coordinate scaling matrix */
-    clear_mat(nlh->scale_tot);
-    for(d=0; d<DIM; d++)
-    {
-        nlh->scale_tot[d][d] = 1.0;
-    }
-}
-
-double do_md_membed(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
-             const output_env_t oenv, gmx_bool bVerbose,gmx_bool bCompact,
-             int nstglobalcomm,
-             gmx_vsite_t *vsite,gmx_constr_t constr,
-             int stepout,t_inputrec *ir,
-             gmx_mtop_t *top_global,
-             t_fcdata *fcd,
-             t_state *state_global,
-             t_mdatoms *mdatoms,
-             t_nrnb *nrnb,gmx_wallcycle_t wcycle,
-             gmx_edsam_t ed,t_forcerec *fr,
-             int repl_ex_nst,int repl_ex_seed,
-             real cpt_period,real max_hours,
-             const char *deviceOptions,
-             unsigned long Flags,
-             gmx_runtime_t *runtime,
-             rvec fac, rvec *r_ins, pos_ins_t *pos_ins, t_block *ins_at,
-             real xy_step, real z_step, int it_xy, int it_z)
-{
-    gmx_mdoutf_t *outf;
-    gmx_large_int_t step,step_rel;
-    double     run_time;
-    double     t,t0,lam0;
-    gmx_bool       bGStatEveryStep,bGStat,bNstEner,bCalcEnerPres;
-    gmx_bool       bNS,bNStList,bSimAnn,bStopCM,bRerunMD,bNotLastFrame=FALSE,
-               bFirstStep,bStateFromTPX,bInitStep,bLastStep,
-               bBornRadii,bStartingFromCpt;
-    gmx_bool       bDoDHDL=FALSE;
-    gmx_bool       do_ene,do_log,do_verbose,bRerunWarnNoV=TRUE,
-               bForceUpdate=FALSE,bCPT;
-    int        mdof_flags;
-    gmx_bool       bMasterState;
-    int        force_flags,cglo_flags;
-    tensor     force_vir,shake_vir,total_vir,tmp_vir,pres;
-    int        i,m;
-    t_trxstatus *status;
-    rvec       mu_tot;
-    t_vcm      *vcm;
-    t_state    *bufstate=NULL;
-    matrix     *scale_tot,pcoupl_mu,M,ebox;
-    gmx_nlheur_t nlh;
-    t_trxframe rerun_fr;
-/*    gmx_repl_ex_t repl_ex=NULL;*/
-    int        nchkpt=1;
-
-    gmx_localtop_t *top;
-    t_mdebin *mdebin=NULL;
-    t_state    *state=NULL;
-    rvec       *f_global=NULL;
-    int        n_xtc=-1;
-    rvec       *x_xtc=NULL;
-    gmx_enerdata_t *enerd;
-    rvec       *f=NULL;
-    gmx_global_stat_t gstat;
-    gmx_update_t upd=NULL;
-    t_graph    *graph=NULL;
-    globsig_t   gs;
-
-    gmx_bool        bFFscan;
-    gmx_groups_t *groups;
-    gmx_ekindata_t *ekind, *ekind_save;
-    gmx_shellfc_t shellfc;
-    int         count,nconverged=0;
-    real        timestep=0;
-    double      tcount=0;
-    gmx_bool        bIonize=FALSE;
-    gmx_bool        bTCR=FALSE,bConverged=TRUE,bOK,bSumEkinhOld,bExchanged;
-    gmx_bool        bAppend;
-    gmx_bool        bResetCountersHalfMaxH=FALSE;
-    gmx_bool        bVV,bIterations,bIterate,bFirstIterate,bTemp,bPres,bTrotter;
-    real        temp0,dvdl;
-    int         a0,a1,ii;
-    rvec        *xcopy=NULL,*vcopy=NULL,*cbuf=NULL;
-    matrix      boxcopy={{0}},lastbox;
-       real        veta_save,pcurr,scalevir,tracevir;
-       real        vetanew = 0;
-    double      cycles;
-       real        last_conserved = 0;
-    real        last_ekin = 0;
-       t_extmass   MassQ;
-    int         **trotter_seq;
-    char        sbuf[STEPSTRSIZE],sbuf2[STEPSTRSIZE];
-    int         handled_stop_condition=gmx_stop_cond_none; /* compare to get_stop_condition*/
-    gmx_iterate_t iterate;
-#ifdef GMX_FAHCORE
-    /* Temporary addition for FAHCORE checkpointing */
-    int chkpt_ret;
-#endif
-
-    /* Check for special mdrun options */
-    bRerunMD = (Flags & MD_RERUN);
-    bIonize  = (Flags & MD_IONIZE);
-    bFFscan  = (Flags & MD_FFSCAN);
-    bAppend  = (Flags & MD_APPENDFILES);
-    bGStatEveryStep = FALSE;
-    if (Flags & MD_RESETCOUNTERSHALFWAY)
-    {
-        if (ir->nsteps > 0)
-        {
-            /* Signal to reset the counters half the simulation steps. */
-            wcycle_set_reset_counters(wcycle,ir->nsteps/2);
-        }
-        /* Signal to reset the counters halfway the simulation time. */
-        bResetCountersHalfMaxH = (max_hours > 0);
-    }
-
-    /* md-vv uses averaged full step velocities for T-control
-       md-vv-avek uses averaged half step velocities for T-control (but full step ekin for P control)
-       md uses averaged half step kinetic energies to determine temperature unless defined otherwise by GMX_EKIN_AVE_VEL; */
-    bVV = EI_VV(ir->eI);
-    if (bVV) /* to store the initial velocities while computing virial */
-    {
-        snew(cbuf,top_global->natoms);
-    }
-    /* all the iteratative cases - only if there are constraints */
-    bIterations = ((IR_NPT_TROTTER(ir)) && (constr) && (!bRerunMD));
-    bTrotter = (bVV && (IR_NPT_TROTTER(ir) || (IR_NVT_TROTTER(ir))));
-
-    if (bRerunMD)
-    {
-        /* Since we don't know if the frames read are related in any way,
-         * rebuild the neighborlist at every step.
-         */
-        ir->nstlist       = 1;
-        ir->nstcalcenergy = 1;
-        nstglobalcomm     = 1;
-    }
-
-    check_ir_old_tpx_versions(cr,fplog,ir,top_global);
-
-    nstglobalcomm = check_nstglobalcomm(fplog,cr,nstglobalcomm,ir);
-    /*bGStatEveryStep = (nstglobalcomm == 1);*/
-    bGStatEveryStep = FALSE;
-
-    if (!bGStatEveryStep && ir->nstlist == -1 && fplog != NULL)
-    {
-        fprintf(fplog,
-                "To reduce the energy communication with nstlist = -1\n"
-                "the neighbor list validity should not be checked at every step,\n"
-                "this means that exact integration is not guaranteed.\n"
-                "The neighbor list validity is checked after:\n"
-                "  <n.list life time> - 2*std.dev.(n.list life time)  steps.\n"
-                "In most cases this will result in exact integration.\n"
-                "This reduces the energy communication by a factor of 2 to 3.\n"
-                "If you want less energy communication, set nstlist > 3.\n\n");
-    }
-
-    if (bRerunMD || bFFscan)
-    {
-        ir->nstxtcout = 0;
-    }
-    groups = &top_global->groups;
-
-    /* Initial values */
-    init_md(fplog,cr,ir,oenv,&t,&t0,&state_global->lambda,&lam0,
-            nrnb,top_global,&upd,
-            nfile,fnm,&outf,&mdebin,
-            force_vir,shake_vir,mu_tot,&bSimAnn,&vcm,state_global,Flags);
-
-    clear_mat(total_vir);
-    clear_mat(pres);
-    /* Energy terms and groups */
-    snew(enerd,1);
-    init_enerdata(top_global->groups.grps[egcENER].nr,ir->n_flambda,enerd);
-    if (DOMAINDECOMP(cr))
-    {
-        f = NULL;
-    }
-    else
-    {
-        snew(f,top_global->natoms);
-    }
-
-    /* Kinetic energy data */
-    snew(ekind,1);
-    init_ekindata(fplog,top_global,&(ir->opts),ekind);
-    /* needed for iteration of constraints */
-    snew(ekind_save,1);
-    init_ekindata(fplog,top_global,&(ir->opts),ekind_save);
-    /* Copy the cos acceleration to the groups struct */
-    ekind->cosacc.cos_accel = ir->cos_accel;
-
-    gstat = global_stat_init(ir);
-    debug_gmx();
-
-    /* Check for polarizable models and flexible constraints */
-    shellfc = init_shell_flexcon(fplog,
-                                 top_global,n_flexible_constraints(constr),
-                                 (ir->bContinuation ||
-                                  (DOMAINDECOMP(cr) && !MASTER(cr))) ?
-                                 NULL : state_global->x);
-
-/*    if (DEFORM(*ir))
-    {
-#ifdef GMX_THREADS
-        tMPI_Thread_mutex_lock(&deform_init_box_mutex);
-#endif
-        set_deform_reference_box(upd,
-                                 deform_init_init_step_tpx,
-                                 deform_init_box_tpx);
-#ifdef GMX_THREADS
-        tMPI_Thread_mutex_unlock(&deform_init_box_mutex);
-#endif
-    }*/
-
-/*    {
-        double io = compute_io(ir,top_global->natoms,groups,mdebin->ebin->nener,1);
-        if ((io > 2000) && MASTER(cr))
-            fprintf(stderr,
-                    "\nWARNING: This run will generate roughly %.0f Mb of data\n\n",
-                    io);
-    }*/
-
-    if (DOMAINDECOMP(cr)) {
-        top = dd_init_local_top(top_global);
-
-        snew(state,1);
-        dd_init_local_state(cr->dd,state_global,state);
-
-        if (DDMASTER(cr->dd) && ir->nstfout) {
-            snew(f_global,state_global->natoms);
-        }
-    } else {
-        if (PAR(cr)) {
-            /* Initialize the particle decomposition and split the topology */
-            top = split_system(fplog,top_global,ir,cr);
-
-            pd_cg_range(cr,&fr->cg0,&fr->hcg);
-            pd_at_range(cr,&a0,&a1);
-        } else {
-            top = gmx_mtop_generate_local_top(top_global,ir);
-
-            a0 = 0;
-            a1 = top_global->natoms;
-        }
-
-        state = partdec_init_local_state(cr,state_global);
-        f_global = f;
-
-        atoms2md(top_global,ir,0,NULL,a0,a1-a0,mdatoms);
-
-        if (vsite) {
-            set_vsite_top(vsite,top,mdatoms,cr);
-        }
-
-        if (ir->ePBC != epbcNONE && !ir->bPeriodicMols) {
-            graph = mk_graph(fplog,&(top->idef),0,top_global->natoms,FALSE,FALSE);
-        }
-
-        if (shellfc) {
-            make_local_shells(cr,mdatoms,shellfc);
-        }
-
-        if (ir->pull && PAR(cr)) {
-            dd_make_local_pull_groups(NULL,ir->pull,mdatoms);
-        }
-    }
-
-    if (DOMAINDECOMP(cr))
-    {
-        /* Distribute the charge groups over the nodes from the master node */
-        dd_partition_system(fplog,ir->init_step,cr,TRUE,1,
-                            state_global,top_global,ir,
-                            state,&f,mdatoms,top,fr,
-                            vsite,shellfc,constr,
-                            nrnb,wcycle,FALSE);
-    }
-
-    update_mdatoms(mdatoms,state->lambda);
-
-    if (MASTER(cr))
-    {
-        if (opt2bSet("-cpi",nfile,fnm))
-        {
-            /* Update mdebin with energy history if appending to output files */
-            if ( Flags & MD_APPENDFILES )
-            {
-                restore_energyhistory_from_state(mdebin,&state_global->enerhist);
-            }
-            else
-            {
-                /* We might have read an energy history from checkpoint,
-                 * free the allocated memory and reset the counts.
-                 */
-                done_energyhistory(&state_global->enerhist);
-                init_energyhistory(&state_global->enerhist);
-            }
-        }
-        /* Set the initial energy history in state by updating once */
-        update_energyhistory(&state_global->enerhist,mdebin);
-    }
-
-    if ((state->flags & (1<<estLD_RNG)) && (Flags & MD_READ_RNG)) {
-        /* Set the random state if we read a checkpoint file */
-        set_stochd_state(upd,state);
-    }
-
-    /* Initialize constraints */
-    if (constr) {
-        if (!DOMAINDECOMP(cr))
-            set_constraints(constr,top,ir,mdatoms,cr);
-    }
-
-    /* Check whether we have to GCT stuff */
- /*   bTCR = ftp2bSet(efGCT,nfile,fnm);
-    if (bTCR) {
-        if (MASTER(cr)) {
-            fprintf(stderr,"Will do General Coupling Theory!\n");
-        }
-        gnx = top_global->mols.nr;
-        snew(grpindex,gnx);
-        for(i=0; (i<gnx); i++) {
-            grpindex[i] = i;
-        }
-    }*/
-
-/*    if (repl_ex_nst > 0 && MASTER(cr))
-        repl_ex = init_replica_exchange(fplog,cr->ms,state_global,ir,
-                                        repl_ex_nst,repl_ex_seed);*/
-
-    if (!ir->bContinuation && !bRerunMD)
-    {
-        if (mdatoms->cFREEZE && (state->flags & (1<<estV)))
-        {
-            /* Set the velocities of frozen particles to zero */
-            for(i=mdatoms->start; i<mdatoms->start+mdatoms->homenr; i++)
-            {
-                for(m=0; m<DIM; m++)
-                {
-                    if (ir->opts.nFreeze[mdatoms->cFREEZE[i]][m])
-                    {
-                        state->v[i][m] = 0;
-                    }
-                }
-            }
-        }
-
-        if (constr)
-        {
-            /* Constrain the initial coordinates and velocities */
-            do_constrain_first(fplog,constr,ir,mdatoms,state,f,
-                               graph,cr,nrnb,fr,top,shake_vir);
-        }
-        if (vsite)
-        {
-            /* Construct the virtual sites for the initial configuration */
-            construct_vsites(fplog,vsite,state->x,nrnb,ir->delta_t,NULL,
-                             top->idef.iparams,top->idef.il,
-                             fr->ePBC,fr->bMolPBC,graph,cr,state->box);
-        }
-    }
-
-    debug_gmx();
-
-    /* I'm assuming we need global communication the first time! MRS */
-    cglo_flags = (CGLO_TEMPERATURE | CGLO_GSTAT
-                  | (bVV ? CGLO_PRESSURE:0)
-                  | (bVV ? CGLO_CONSTRAINT:0)
-                  | (bRerunMD ? CGLO_RERUNMD:0)
-                  | ((Flags & MD_READ_EKIN) ? CGLO_READEKIN:0));
-
-    bSumEkinhOld = FALSE;
-    compute_globals(fplog,gstat,cr,ir,fr,ekind,state,state_global,mdatoms,nrnb,vcm,
-                    wcycle,enerd,force_vir,shake_vir,total_vir,pres,mu_tot,
-                    constr,NULL,FALSE,state->box,
-                    top_global,&pcurr,top_global->natoms,&bSumEkinhOld,cglo_flags);
-    if (ir->eI == eiVVAK) {
-        /* a second call to get the half step temperature initialized as well */
-        /* we do the same call as above, but turn the pressure off -- internally, this
-           is recognized as a velocity verlet half-step kinetic energy calculation.
-           This minimized excess variables, but perhaps loses some logic?*/
-
-        compute_globals(fplog,gstat,cr,ir,fr,ekind,state,state_global,mdatoms,nrnb,vcm,
-                        wcycle,enerd,force_vir,shake_vir,total_vir,pres,mu_tot,
-                        constr,NULL,FALSE,state->box,
-                        top_global,&pcurr,top_global->natoms,&bSumEkinhOld,
-                        cglo_flags &~ CGLO_PRESSURE);
-    }
-
-    /* Calculate the initial half step temperature, and save the ekinh_old */
-    if (!(Flags & MD_STARTFROMCPT))
-    {
-        for(i=0; (i<ir->opts.ngtc); i++)
-        {
-            copy_mat(ekind->tcstat[i].ekinh,ekind->tcstat[i].ekinh_old);
-        }
-    }
-    if (ir->eI != eiVV) 
-    {
-        enerd->term[F_TEMP] *= 2; /* result of averages being done over previous and current step,
-                                     and there is no previous step */
-    }
-    temp0 = enerd->term[F_TEMP];
-
-    /* if using an iterative algorithm, we need to create a working directory for the state. */
-    if (bIterations)
-    {
-            bufstate = init_bufstate(state);
-    }
-    if (bFFscan)
-    {
-        snew(xcopy,state->natoms);
-        snew(vcopy,state->natoms);
-        copy_rvecn(state->x,xcopy,0,state->natoms);
-        copy_rvecn(state->v,vcopy,0,state->natoms);
-        copy_mat(state->box,boxcopy);
-    }
-
-    /* need to make an initiation call to get the Trotter variables set, as well as other constants for non-trotter
-       temperature control */
-    trotter_seq = init_npt_vars(ir,state,&MassQ,bTrotter);
-
-    if (MASTER(cr))
-    {
-        if (constr && !ir->bContinuation && ir->eConstrAlg == econtLINCS)
-        {
-            fprintf(fplog,
-                    "RMS relative constraint deviation after constraining: %.2e\n",
-                    constr_rmsd(constr,FALSE));
-        }
-        fprintf(fplog,"Initial temperature: %g K\n",enerd->term[F_TEMP]);
-        if (bRerunMD)
-        {
-            fprintf(stderr,"starting md rerun '%s', reading coordinates from"
-                    " input trajectory '%s'\n\n",
-                    *(top_global->name),opt2fn("-rerun",nfile,fnm));
-            if (bVerbose)
-            {
-                fprintf(stderr,"Calculated time to finish depends on nsteps from "
-                        "run input file,\nwhich may not correspond to the time "
-                        "needed to process input trajectory.\n\n");
-            }
-        }
-        else
-        {
-            char tbuf[20];
-            fprintf(stderr,"starting mdrun '%s'\n",
-                    *(top_global->name));
-            if (ir->nsteps >= 0)
-            {
-                sprintf(tbuf,"%8.1f",(ir->init_step+ir->nsteps)*ir->delta_t);
-            }
-            else
-            {
-                sprintf(tbuf,"%s","infinite");
-            }
-            if (ir->init_step > 0)
-            {
-                fprintf(stderr,"%s steps, %s ps (continuing from step %s, %8.1f ps).\n",
-                        gmx_step_str(ir->init_step+ir->nsteps,sbuf),tbuf,
-                        gmx_step_str(ir->init_step,sbuf2),
-                        ir->init_step*ir->delta_t);
-            }
-            else
-            {
-                fprintf(stderr,"%s steps, %s ps.\n",
-                        gmx_step_str(ir->nsteps,sbuf),tbuf);
-            }
-        }
-        fprintf(fplog,"\n");
-    }
-
-    /* Set and write start time */
-    runtime_start(runtime);
-    print_date_and_time(fplog,cr->nodeid,"Started mdrun",runtime);
-    wallcycle_start(wcycle,ewcRUN);
-    if (fplog)
-        fprintf(fplog,"\n");
-
-    /* safest point to do file checkpointing is here.  More general point would be immediately before integrator call */
-/*#ifdef GMX_FAHCORE
-    chkpt_ret=fcCheckPointParallel( cr->nodeid,
-                                    NULL,0);
-    if ( chkpt_ret == 0 )
-        gmx_fatal( 3,__FILE__,__LINE__, "Checkpoint error on step %d\n", 0 );
-#endif*/
-
-    debug_gmx();
-    /***********************************************************
-     *
-     *             Loop over MD steps
-     *
-     ************************************************************/
-
-    /* if rerunMD then read coordinates and velocities from input trajectory */
-    if (bRerunMD)
-    {
-        if (getenv("GMX_FORCE_UPDATE"))
-        {
-            bForceUpdate = TRUE;
-        }
-
-        bNotLastFrame = read_first_frame(oenv,&status,
-                                         opt2fn("-rerun",nfile,fnm),
-                                         &rerun_fr,TRX_NEED_X | TRX_READ_V);
-        if (rerun_fr.natoms != top_global->natoms)
-        {
-            gmx_fatal(FARGS,
-                      "Number of atoms in trajectory (%d) does not match the "
-                      "run input file (%d)\n",
-                      rerun_fr.natoms,top_global->natoms);
-        }
-        if (ir->ePBC != epbcNONE)
-        {
-            if (!rerun_fr.bBox)
-            {
-                gmx_fatal(FARGS,"Rerun trajectory frame step %d time %f does not contain a box, while pbc is used",rerun_fr.step,rerun_fr.time);
-            }
-            if (max_cutoff2(ir->ePBC,rerun_fr.box) < sqr(fr->rlistlong))
-            {
-                gmx_fatal(FARGS,"Rerun trajectory frame step %d time %f has too small box dimensions",rerun_fr.step,rerun_fr.time);
-            }
-
-            /* Set the shift vectors.
-             * Necessary here when have a static box different from the tpr box.
-             */
-            calc_shifts(rerun_fr.box,fr->shift_vec);
-        }
-    }
-
-    /* loop over MD steps or if rerunMD to end of input trajectory */
-    bFirstStep = TRUE;
-    /* Skip the first Nose-Hoover integration when we get the state from tpx */
-    bStateFromTPX = !opt2bSet("-cpi",nfile,fnm);
-    bInitStep = bFirstStep && (bStateFromTPX || bVV);
-    bStartingFromCpt = (Flags & MD_STARTFROMCPT) && bInitStep;
-    bLastStep    = FALSE;
-    bSumEkinhOld = FALSE;
-    bExchanged   = FALSE;
-
-    init_global_signals(&gs,cr,ir,repl_ex_nst);
-
-    step = ir->init_step;
-    step_rel = 0;
-
-    if (ir->nstlist == -1)
-    {
-        init_nlistheuristics(&nlh,bGStatEveryStep,step);
-    }
-
-    bLastStep = (bRerunMD || (ir->nsteps >= 0 && step_rel > ir->nsteps));
-    while (!bLastStep || (bRerunMD && bNotLastFrame)) {
-
-        wallcycle_start(wcycle,ewcSTEP);
-
-        GMX_MPE_LOG(ev_timestep1);
-
-        if (bRerunMD) {
-            if (rerun_fr.bStep) {
-                step = rerun_fr.step;
-                step_rel = step - ir->init_step;
-            }
-            if (rerun_fr.bTime) {
-                t = rerun_fr.time;
-            }
-            else
-            {
-                t = step;
-            }
-        }
-        else
-        {
-            bLastStep = (step_rel == ir->nsteps);
-            t = t0 + step*ir->delta_t;
-        }
-
-        if (ir->efep != efepNO)
-        {
-            if (bRerunMD && rerun_fr.bLambda && (ir->delta_lambda!=0))
-            {
-                state_global->lambda = rerun_fr.lambda;
-            }
-            else
-            {
-                state_global->lambda = lam0 + step*ir->delta_lambda;
-            }
-            state->lambda = state_global->lambda;
-            bDoDHDL = do_per_step(step,ir->nstdhdl);
-        }
-
-        if (bSimAnn)
-        {
-            update_annealing_target_temp(&(ir->opts),t);
-        }
-
-        if (bRerunMD)
-        {
-            if (!(DOMAINDECOMP(cr) && !MASTER(cr)))
-            {
-                for(i=0; i<state_global->natoms; i++)
-                {
-                    copy_rvec(rerun_fr.x[i],state_global->x[i]);
-                }
-                if (rerun_fr.bV)
-                {
-                    for(i=0; i<state_global->natoms; i++)
-                    {
-                        copy_rvec(rerun_fr.v[i],state_global->v[i]);
-                    }
-                }
-                else
-                {
-                    for(i=0; i<state_global->natoms; i++)
-                    {
-                        clear_rvec(state_global->v[i]);
-                    }
-                    if (bRerunWarnNoV)
-                    {
-                        fprintf(stderr,"\nWARNING: Some frames do not contain velocities.\n"
-                                "         Ekin, temperature and pressure are incorrect,\n"
-                                "         the virial will be incorrect when constraints are present.\n"
-                                "\n");
-                        bRerunWarnNoV = FALSE;
-                    }
-                }
-            }
-            copy_mat(rerun_fr.box,state_global->box);
-            copy_mat(state_global->box,state->box);
-
-            if (vsite && (Flags & MD_RERUN_VSITE))
-            {
-                if (DOMAINDECOMP(cr))
-                {
-                    gmx_fatal(FARGS,"Vsite recalculation with -rerun is not implemented for domain decomposition, use particle decomposition");
-                }
-                if (graph)
-                {
-                    /* Following is necessary because the graph may get out of sync
-                     * with the coordinates if we only have every N'th coordinate set
-                     */
-                    mk_mshift(fplog,graph,fr->ePBC,state->box,state->x);
-                    shift_self(graph,state->box,state->x);
-                }
-                construct_vsites(fplog,vsite,state->x,nrnb,ir->delta_t,state->v,
-                                 top->idef.iparams,top->idef.il,
-                                 fr->ePBC,fr->bMolPBC,graph,cr,state->box);
-                if (graph)
-                {
-                    unshift_self(graph,state->box,state->x);
-                }
-            }
-        }
-
-        /* Stop Center of Mass motion */
-        bStopCM = (ir->comm_mode != ecmNO && do_per_step(step,ir->nstcomm));
-
-        /* Copy back starting coordinates in case we're doing a forcefield scan */
-        if (bFFscan)
-        {
-            for(ii=0; (ii<state->natoms); ii++)
-            {
-                copy_rvec(xcopy[ii],state->x[ii]);
-                copy_rvec(vcopy[ii],state->v[ii]);
-            }
-            copy_mat(boxcopy,state->box);
-        }
-
-        if (bRerunMD)
-        {
-            /* for rerun MD always do Neighbour Searching */
-            bNS = (bFirstStep || ir->nstlist != 0);
-            bNStList = bNS;
-        }
-        else
-        {
-            /* Determine whether or not to do Neighbour Searching and LR */
-            bNStList = (ir->nstlist > 0  && step % ir->nstlist == 0);
-
-            bNS = (bFirstStep || bExchanged || bNStList ||
-                   (ir->nstlist == -1 && nlh.nabnsb > 0));
-
-            if (bNS && ir->nstlist == -1)
-            {
-                set_nlistheuristics(&nlh,bFirstStep || bExchanged,step);
-            }
-        }
-
-        /* < 0 means stop at next step, > 0 means stop at next NS step */
-        if ( (gs.set[eglsSTOPCOND] < 0 ) ||
-             ( (gs.set[eglsSTOPCOND] > 0 ) && ( bNS || ir->nstlist==0)) )
-        {
-            bLastStep = TRUE;
-        }
-
-        /* Determine whether or not to update the Born radii if doing GB */
-        bBornRadii=bFirstStep;
-        if (ir->implicit_solvent && (step % ir->nstgbradii==0))
-        {
-            bBornRadii=TRUE;
-        }
-
-        do_log = do_per_step(step,ir->nstlog) || bFirstStep || bLastStep;
-        do_verbose = bVerbose &&
-                  (step % stepout == 0 || bFirstStep || bLastStep);
-
-        if (bNS && !(bFirstStep && ir->bContinuation && !bRerunMD))
-        {
-            if (bRerunMD)
-            {
-                bMasterState = TRUE;
-            }
-            else
-            {
-                bMasterState = FALSE;
-                /* Correct the new box if it is too skewed */
-                if (DYNAMIC_BOX(*ir))
-                {
-                    if (correct_box(fplog,step,state->box,graph))
-                    {
-                        bMasterState = TRUE;
-                    }
-                }
-                if (DOMAINDECOMP(cr) && bMasterState)
-                {
-                    dd_collect_state(cr->dd,state,state_global);
-                }
-            }
-
-            if (DOMAINDECOMP(cr))
-            {
-                /* Repartition the domain decomposition */
-                wallcycle_start(wcycle,ewcDOMDEC);
-                dd_partition_system(fplog,step,cr,
-                                    bMasterState,nstglobalcomm,
-                                    state_global,top_global,ir,
-                                    state,&f,mdatoms,top,fr,
-                                    vsite,shellfc,constr,
-                                    nrnb,wcycle,do_verbose);
-                wallcycle_stop(wcycle,ewcDOMDEC);
-                /* If using an iterative integrator, reallocate space to match the decomposition */
-            }
-        }
-
-        if (MASTER(cr) && do_log && !bFFscan)
-        {
-            print_ebin_header(fplog,step,t,state->lambda);
-        }
-
-        if (ir->efep != efepNO)
-        {
-            update_mdatoms(mdatoms,state->lambda);
-        }
-
-        if (bRerunMD && rerun_fr.bV)
-        {
-
-            /* We need the kinetic energy at minus the half step for determining
-             * the full step kinetic energy and possibly for T-coupling.*/
-            /* This may not be quite working correctly yet . . . . */
-            compute_globals(fplog,gstat,cr,ir,fr,ekind,state,state_global,mdatoms,nrnb,vcm,
-                            wcycle,enerd,NULL,NULL,NULL,NULL,mu_tot,
-                            constr,NULL,FALSE,state->box,
-                            top_global,&pcurr,top_global->natoms,&bSumEkinhOld,
-                            CGLO_RERUNMD | CGLO_GSTAT | CGLO_TEMPERATURE);
-        }
-        clear_mat(force_vir);
-
-        /* Ionize the atoms if necessary */
-/*        if (bIonize)
-        {
-            ionize(fplog,oenv,mdatoms,top_global,t,ir,state->x,state->v,
-                   mdatoms->start,mdatoms->start+mdatoms->homenr,state->box,cr);
-        }*/
-
-        /* Update force field in ffscan program */
-/*        if (bFFscan)
-        {
-            if (update_forcefield(fplog,
-                                  nfile,fnm,fr,
-                                  mdatoms->nr,state->x,state->box)) {
-                if (gmx_parallel_env_initialized())
-                {
-                    gmx_finalize();
-                }
-                exit(0);
-            }
-        }*/
-
-        GMX_MPE_LOG(ev_timestep2);
-
-        /* We write a checkpoint at this MD step when:
-         * either at an NS step when we signalled through gs,
-         * or at the last step (but not when we do not want confout),
-         * but never at the first step or with rerun.
-         */
-/*        bCPT = (((gs.set[eglsCHKPT] && bNS) ||
-                 (bLastStep && (Flags & MD_CONFOUT))) &&
-                step > ir->init_step && !bRerunMD);
-        if (bCPT)
-        {
-            gs.set[eglsCHKPT] = 0;
-        }*/
-
-        /* Determine the energy and pressure:
-         * at nstcalcenergy steps and at energy output steps (set below).
-         */
-        bNstEner = (bGStatEveryStep || do_per_step(step,ir->nstcalcenergy));
-        bCalcEnerPres = bNstEner;
-
-        /* Do we need global communication ? */
-        bGStat = (bCalcEnerPres || bStopCM ||
-                  (ir->nstlist == -1 && !bRerunMD && step >= nlh.step_nscheck));
-
-        do_ene = (do_per_step(step,ir->nstenergy) || bLastStep);
-
-        if (do_ene || do_log)
-        {
-            bCalcEnerPres = TRUE;
-            bGStat    = TRUE;
-        }
-
-        /* these CGLO_ options remain the same throughout the iteration */
-        cglo_flags = ((bRerunMD ? CGLO_RERUNMD : 0) |
-                      (bStopCM ? CGLO_STOPCM : 0) |
-                      (bGStat ? CGLO_GSTAT : 0)
-            );
-
-        force_flags = (GMX_FORCE_STATECHANGED |
-                       ((DYNAMIC_BOX(*ir) || bRerunMD) ? GMX_FORCE_DYNAMICBOX : 0) |
-                       GMX_FORCE_ALLFORCES |
-                       (bNStList ? GMX_FORCE_DOLR : 0) |
-                       GMX_FORCE_SEPLRF |
-                       (bCalcEnerPres ? GMX_FORCE_VIRIAL : 0) |
-                       (bDoDHDL ? GMX_FORCE_DHDL : 0)
-            );
-
-        if (shellfc)
-        {
-            /* Now is the time to relax the shells */
-            count=relax_shell_flexcon(fplog,cr,bVerbose,bFFscan ? step+1 : step,
-                                      ir,bNS,force_flags,
-                                      bStopCM,top,top_global,
-                                      constr,enerd,fcd,
-                                      state,f,force_vir,mdatoms,
-                                      nrnb,wcycle,graph,groups,
-                                      shellfc,fr,bBornRadii,t,mu_tot,
-                                      state->natoms,&bConverged,vsite,
-                                      outf->fp_field);
-            tcount+=count;
-
-            if (bConverged)
-            {
-                nconverged++;
-            }
-        }
-        else
-        {
-            /* The coordinates (x) are shifted (to get whole molecules)
-             * in do_force.
-             * This is parallellized as well, and does communication too.
-             * Check comments in sim_util.c
-             */
-
-            do_force(fplog,cr,ir,step,nrnb,wcycle,top,top_global,groups,
-                     state->box,state->x,&state->hist,
-                     f,force_vir,mdatoms,enerd,fcd,
-                     state->lambda,graph,
-                     fr,vsite,mu_tot,t,outf->fp_field,ed,bBornRadii,
-                     (bNS ? GMX_FORCE_NS : 0) | force_flags);
-        }
-
-        GMX_BARRIER(cr->mpi_comm_mygroup);
-
- /*       if (bTCR)
-        {
-            mu_aver = calc_mu_aver(cr,state->x,mdatoms->chargeA,
-                                   mu_tot,&top_global->mols,mdatoms,gnx,grpindex);
-        }
-
-        if (bTCR && bFirstStep)
-        {
-            tcr=init_coupling(fplog,nfile,fnm,cr,fr,mdatoms,&(top->idef));
-            fprintf(fplog,"Done init_coupling\n");
-            fflush(fplog);
-        }*/
-
-        /*  ############### START FIRST UPDATE HALF-STEP ############### */
-
-        if (bVV && !bStartingFromCpt && !bRerunMD)
-        {
-            if (ir->eI == eiVV)
-            {
-                if (bInitStep)
-                {
-                    /* if using velocity verlet with full time step Ekin,
-                     * take the first half step only to compute the
-                     * virial for the first step. From there,
-                     * revert back to the initial coordinates
-                     * so that the input is actually the initial step.
-                     */
-                    copy_rvecn(state->v,cbuf,0,state->natoms); /* should make this better for parallelizing? */
-                }
-
-                /* this is for NHC in the Ekin(t+dt/2) version of vv */
-                if (!bInitStep)
-                {
-                 trotter_update(ir,step,ekind,enerd,state,total_vir,mdatoms,&MassQ,trotter_seq,ettTSEQ2);
-                }
-
-               if (ir->eI == eiVVAK)
-               {
-                 update_tcouple(fplog,step,ir,state,ekind,wcycle,upd,&MassQ,mdatoms);
-               }
-
-                update_coords(fplog,step,ir,mdatoms,state,
-                              f,fr->bTwinRange && bNStList,fr->f_twin,fcd,
-                              ekind,M,wcycle,upd,bInitStep,etrtVELOCITY1,
-                              cr,nrnb,constr,&top->idef);
-
-                if (bIterations)
-                {
-                    gmx_iterate_init(&iterate,bIterations && !bInitStep);
-                }
-                /* for iterations, we save these vectors, as we will be self-consistently iterating
-                   the calculations */
-                /*#### UPDATE EXTENDED VARIABLES IN TROTTER FORMULATION */
-
-                /* save the state */
-                if (bIterations && iterate.bIterate) {
-                    copy_coupling_state(state,bufstate,ekind,ekind_save,&(ir->opts));
-                }
-            }
-
-            bFirstIterate = TRUE;
-            while (bFirstIterate || (bIterations && iterate.bIterate))
-            {
-                if (bIterations && iterate.bIterate)
-                {
-                    copy_coupling_state(bufstate,state,ekind_save,ekind,&(ir->opts));
-                    if (bFirstIterate && bTrotter)
-                    {
-                        /* The first time through, we need a decent first estimate
-                           of veta(t+dt) to compute the constraints.  Do
-                           this by computing the box volume part of the
-                           trotter integration at this time. Nothing else
-                           should be changed by this routine here.  If
-                           !(first time), we start with the previous value
-                           of veta.  */
-
-                        veta_save = state->veta;
-                        trotter_update(ir,step,ekind,enerd,state,total_vir,mdatoms,&MassQ,trotter_seq,ettTSEQ0);
-                        vetanew = state->veta;
-                        state->veta = veta_save;
-                    }
-                }
-
-                bOK = TRUE;
-                if ( !bRerunMD || rerun_fr.bV || bForceUpdate) {  /* Why is rerun_fr.bV here?  Unclear. */
-                    dvdl = 0;
-
-                    update_constraints(fplog,step,&dvdl,ir,ekind,mdatoms,state,graph,f,
-                                       &top->idef,shake_vir,NULL,
-                                       cr,nrnb,wcycle,upd,constr,
-                                       bInitStep,TRUE,bCalcEnerPres,vetanew);
-
-                    if (!bOK && !bFFscan)
-                    {
-                        gmx_fatal(FARGS,"Constraint error: Shake, Lincs or Settle could not solve the constrains");
-                    }
-
-                }
-                else if (graph)
-                { /* Need to unshift here if a do_force has been
-                     called in the previous step */
-                    unshift_self(graph,state->box,state->x);
-                }
-
-
-                if (bVV) {
-                    /* if VV, compute the pressure and constraints */
-                    /* if VV2, the pressure and constraints only if using pressure control.*/
-                    bPres = (ir->eI==eiVV || IR_NPT_TROTTER(ir));
-                    bTemp = ((ir->eI==eiVV &&(!bInitStep)) || (ir->eI==eiVVAK && IR_NPT_TROTTER(ir)));
-                    compute_globals(fplog,gstat,cr,ir,fr,ekind,state,state_global,mdatoms,nrnb,vcm,
-                                    wcycle,enerd,force_vir,shake_vir,total_vir,pres,mu_tot,
-                                    constr,NULL,FALSE,state->box,
-                                    top_global,&pcurr,top_global->natoms,&bSumEkinhOld,
-                                    cglo_flags
-                                    | CGLO_ENERGY
-                                    | (bTemp ? CGLO_TEMPERATURE:0)
-                                    | (bPres ? CGLO_PRESSURE : 0)
-                                    | (bPres ? CGLO_CONSTRAINT : 0)
-                                    | (iterate.bIterate ? CGLO_ITERATE : 0)
-                                    | (bFirstIterate ? CGLO_FIRSTITERATE : 0)
-                                    | CGLO_SCALEEKIN
-                        );
-                }
-                /* explanation of above:
-                   a) We compute Ekin at the full time step
-                   if 1) we are using the AveVel Ekin, and it's not the
-                   initial step, or 2) if we are using AveEkin, but need the full
-                   time step kinetic energy for the pressure.
-                   b) If we are using EkinAveEkin for the kinetic energy for the temperture control, we still feed in
-                   EkinAveVel because it's needed for the pressure */
-
-                /* temperature scaling and pressure scaling to produce the extended variables at t+dt */
-                if (bVV && !bInitStep)
-                {
-                 trotter_update(ir,step,ekind,enerd,state,total_vir,mdatoms,&MassQ, trotter_seq,ettTSEQ2);
-                }
-
-                if (bIterations &&
-                    done_iterating(cr,fplog,step,&iterate,bFirstIterate,
-                                   state->veta,&vetanew))
-                {
-                    break;
-                }
-                bFirstIterate = FALSE;
-            }
-
-            if (bTrotter && !bInitStep) {
-                copy_mat(shake_vir,state->svir_prev);
-                copy_mat(force_vir,state->fvir_prev);
-                if (IR_NVT_TROTTER(ir) && ir->eI==eiVV) {
-                    /* update temperature and kinetic energy now that step is over - this is the v(t+dt) point */
-                    enerd->term[F_TEMP] = sum_ekin(&(ir->opts),ekind,NULL,(ir->eI==eiVV),FALSE,FALSE);
-                    enerd->term[F_EKIN] = trace(ekind->ekin);
-                }
-            }
-            /* if it's the initial step, we performed this first step just to get the constraint virial */
-            if (bInitStep && ir->eI==eiVV) {
-                copy_rvecn(cbuf,state->v,0,state->natoms);
-            }
-
-            if (fr->bSepDVDL && fplog && do_log)
-            {
-                fprintf(fplog,sepdvdlformat,"Constraint",0.0,dvdl);
-            }
-            enerd->term[F_DHDL_CON] += dvdl;
-
-            GMX_MPE_LOG(ev_timestep1);
-
-        }
-
-        /* MRS -- now done iterating -- compute the conserved quantity */
-        if (bVV) {
-            last_conserved = 0;
-            if (IR_NVT_TROTTER(ir) || IR_NPT_TROTTER(ir))
-            {
-                last_conserved =
-                    NPT_energy(ir,state,&MassQ);
-                if ((ir->eDispCorr != edispcEnerPres) && (ir->eDispCorr != edispcAllEnerPres))
-                {
-                    last_conserved -= enerd->term[F_DISPCORR];
-                }
-            }
-            if (ir->eI==eiVV) {
-                last_ekin = enerd->term[F_EKIN]; /* does this get preserved through checkpointing? */
-            }
-        }
-
-        /* ########  END FIRST UPDATE STEP  ############## */
-        /* ########  If doing VV, we now have v(dt) ###### */
-
-        /* ################## START TRAJECTORY OUTPUT ################# */
-
-        /* Now we have the energies and forces corresponding to the
-         * coordinates at time t. We must output all of this before
-         * the update.
-         * for RerunMD t is read from input trajectory
-         */
-        GMX_MPE_LOG(ev_output_start);
-
-        mdof_flags = 0;
-        if (do_per_step(step,ir->nstxout)) { mdof_flags |= MDOF_X; }
-        if (do_per_step(step,ir->nstvout)) { mdof_flags |= MDOF_V; }
-        if (do_per_step(step,ir->nstfout)) { mdof_flags |= MDOF_F; }
-        if (do_per_step(step,ir->nstxtcout)) { mdof_flags |= MDOF_XTC; }
-/*        if (bCPT) { mdof_flags |= MDOF_CPT; };*/
-
-#ifdef GMX_FAHCORE
-        if (MASTER(cr))
-            fcReportProgress( ir->nsteps, step );
-
-        if (bLastStep)
-        {
-            /* Enforce writing positions and velocities at end of run */
-            mdof_flags |= (MDOF_X | MDOF_V);
-        }
-            /* sync bCPT and fc record-keeping */
-/*            if (bCPT && MASTER(cr))
-                fcRequestCheckPoint();*/
-#endif
-
-        if (mdof_flags != 0)
-        {
-            wallcycle_start(wcycle,ewcTRAJ);
-/*            if (bCPT)
-            {
-                if (state->flags & (1<<estLD_RNG))
-                {
-                    get_stochd_state(upd,state);
-                }
-                if (MASTER(cr))
-                {
-                    if (bSumEkinhOld)
-                    {
-                        state_global->ekinstate.bUpToDate = FALSE;
-                    }
-                    else
-                    {
-                        update_ekinstate(&state_global->ekinstate,ekind);
-                        state_global->ekinstate.bUpToDate = TRUE;
-                    }
-                    update_energyhistory(&state_global->enerhist,mdebin);
-                }
-            }*/
-            write_traj(fplog,cr,outf,mdof_flags,top_global,
-                       step,t,state,state_global,f,f_global,&n_xtc,&x_xtc);
-/*            if (bCPT)
-            {
-                nchkpt++;
-                bCPT = FALSE;
-            }*/
-            debug_gmx();
-            if (bLastStep && step_rel == ir->nsteps &&
-                (Flags & MD_CONFOUT) && MASTER(cr) &&
-                !bRerunMD && !bFFscan)
-            {
-                /* x and v have been collected in write_traj,
-                 * because a checkpoint file will always be written
-                 * at the last step.
-                 */
-                fprintf(stderr,"\nWriting final coordinates.\n");
-                if (ir->ePBC != epbcNONE && !ir->bPeriodicMols &&
-                    DOMAINDECOMP(cr))
-                {
-                    /* Make molecules whole only for confout writing */
-                    do_pbc_mtop(fplog,ir->ePBC,state->box,top_global,state_global->x);
-                }
-/*                write_sto_conf_mtop(ftp2fn(efSTO,nfile,fnm),
-                                    *top_global->name,top_global,
-                                    state_global->x,state_global->v,
-                                    ir->ePBC,state->box);*/
-                debug_gmx();
-            }
-            wallcycle_stop(wcycle,ewcTRAJ);
-        }
-        GMX_MPE_LOG(ev_output_finish);
-
-        /* kludge -- virial is lost with restart for NPT control. Must restart */
-        if (bStartingFromCpt && bVV)
-        {
-            copy_mat(state->svir_prev,shake_vir);
-            copy_mat(state->fvir_prev,force_vir);
-        }
-        /*  ################## END TRAJECTORY OUTPUT ################ */
-
-        /* Determine the pressure:
-         * always when we want exact averages in the energy file,
-         * at ns steps when we have pressure coupling,
-         * otherwise only at energy output steps (set below).
-         */
-
-        bNstEner = (bGStatEveryStep || do_per_step(step,ir->nstcalcenergy));
-        bCalcEnerPres = bNstEner;
-
-        /* Do we need global communication ? */
-        bGStat = (bGStatEveryStep || bStopCM || bNS ||
-                  (ir->nstlist == -1 && !bRerunMD && step >= nlh.step_nscheck));
-
-        do_ene = (do_per_step(step,ir->nstenergy) || bLastStep);
-
-        if (do_ene || do_log)
-        {
-            bCalcEnerPres = TRUE;
-            bGStat        = TRUE;
-        }
-
-        /* Determine the wallclock run time up till now */
-        run_time = gmx_gettime() - (double)runtime->real;
-
-        /* Check whether everything is still allright */
-        if (((int)gmx_get_stop_condition() > handled_stop_condition)
-#ifdef GMX_THREADS
-           && MASTER(cr)
-#endif
-           )
-        {
-            /* this is just make gs.sig compatible with the hack
-               of sending signals around by MPI_Reduce with together with
-               other floats */
-            if ( gmx_get_stop_condition() == gmx_stop_cond_next_ns )
-                gs.sig[eglsSTOPCOND]=1;
-            if ( gmx_get_stop_condition() == gmx_stop_cond_next )
-                gs.sig[eglsSTOPCOND]=-1;
-            /* < 0 means stop at next step, > 0 means stop at next NS step */
-            if (fplog)
-            {
-                fprintf(fplog,
-                        "\n\nReceived the %s signal, stopping at the next %sstep\n\n",
-                        gmx_get_signal_name(),
-                        gs.sig[eglsSTOPCOND]==1 ? "NS " : "");
-                fflush(fplog);
-            }
-            fprintf(stderr,
-                    "\n\nReceived the %s signal, stopping at the next %sstep\n\n",
-                    gmx_get_signal_name(),
-                    gs.sig[eglsSTOPCOND]==1 ? "NS " : "");
-            fflush(stderr);
-            handled_stop_condition=(int)gmx_get_stop_condition();
-        }
-        else if (MASTER(cr) && (bNS || ir->nstlist <= 0) &&
-                 (max_hours > 0 && run_time > max_hours*60.0*60.0*0.99) &&
-                 gs.sig[eglsSTOPCOND] == 0 && gs.set[eglsSTOPCOND] == 0)
-        {
-            /* Signal to terminate the run */
-            gs.sig[eglsSTOPCOND] = 1;
-            if (fplog)
-            {
-                fprintf(fplog,"\nStep %s: Run time exceeded %.3f hours, will terminate the run\n",gmx_step_str(step,sbuf),max_hours*0.99);
-            }
-            fprintf(stderr, "\nStep %s: Run time exceeded %.3f hours, will terminate the run\n",gmx_step_str(step,sbuf),max_hours*0.99);
-        }
-
-        if (bResetCountersHalfMaxH && MASTER(cr) &&
-            run_time > max_hours*60.0*60.0*0.495)
-        {
-            gs.sig[eglsRESETCOUNTERS] = 1;
-        }
-
-        if (ir->nstlist == -1 && !bRerunMD)
-        {
-            /* When bGStatEveryStep=FALSE, global_stat is only called
-             * when we check the atom displacements, not at NS steps.
-             * This means that also the bonded interaction count check is not
-             * performed immediately after NS. Therefore a few MD steps could
-             * be performed with missing interactions.
-             * But wrong energies are never written to file,
-             * since energies are only written after global_stat
-             * has been called.
-             */
-            if (step >= nlh.step_nscheck)
-            {
-                nlh.nabnsb = natoms_beyond_ns_buffer(ir,fr,&top->cgs,
-                                                     nlh.scale_tot,state->x);
-            }
-            else
-            {
-                /* This is not necessarily true,
-                 * but step_nscheck is determined quite conservatively.
-                 */
-                nlh.nabnsb = 0;
-            }
-        }
-
-        /* In parallel we only have to check for checkpointing in steps
-         * where we do global communication,
-         *  otherwise the other nodes don't know.
-         */
-        if (MASTER(cr) && ((bGStat || !PAR(cr)) &&
-                           cpt_period >= 0 &&
-                           (cpt_period == 0 ||
-                            run_time >= nchkpt*cpt_period*60.0)) &&
-            gs.set[eglsCHKPT] == 0)
-        {
-            gs.sig[eglsCHKPT] = 1;
-        }
-
-        if (bIterations)
-        {
-            gmx_iterate_init(&iterate,bIterations);
-        }
-
-        /* for iterations, we save these vectors, as we will be redoing the calculations */
-        if (bIterations && iterate.bIterate)
-        {
-            copy_coupling_state(state,bufstate,ekind,ekind_save,&(ir->opts));
-        }
-        bFirstIterate = TRUE;
-        while (bFirstIterate || (bIterations && iterate.bIterate))
-        {
-            /* We now restore these vectors to redo the calculation with improved extended variables */
-            if (bIterations)
-            {
-                copy_coupling_state(bufstate,state,ekind_save,ekind,&(ir->opts));
-            }
-
-            /* We make the decision to break or not -after- the calculation of Ekin and Pressure,
-               so scroll down for that logic */
-
-            /* #########   START SECOND UPDATE STEP ################# */
-            GMX_MPE_LOG(ev_update_start);
-            bOK = TRUE;
-            if (!bRerunMD || rerun_fr.bV || bForceUpdate)
-            {
-                wallcycle_start(wcycle,ewcUPDATE);
-                dvdl = 0;
-                /* Box is changed in update() when we do pressure coupling,
-                 * but we should still use the old box for energy corrections and when
-                 * writing it to the energy file, so it matches the trajectory files for
-                 * the same timestep above. Make a copy in a separate array.
-                 */
-                copy_mat(state->box,lastbox);
-                /* UPDATE PRESSURE VARIABLES IN TROTTER FORMULATION WITH CONSTRAINTS */
-                if (bTrotter)
-                {
-                    if (bIterations && iterate.bIterate)
-                    {
-                        if (bFirstIterate)
-                        {
-                            scalevir = 1;
-                        }
-                        else
-                        {
-                            /* we use a new value of scalevir to converge the iterations faster */
-                            scalevir = tracevir/trace(shake_vir);
-                        }
-                        msmul(shake_vir,scalevir,shake_vir);
-                        m_add(force_vir,shake_vir,total_vir);
-                        clear_mat(shake_vir);
-                    }
-                    trotter_update(ir,step,ekind,enerd,state,total_vir,mdatoms,&MassQ, trotter_seq,ettTSEQ3);
-                }
-                /* We can only do Berendsen coupling after we have summed
-                 * the kinetic energy or virial. Since the happens
-                 * in global_state after update, we should only do it at
-                 * step % nstlist = 1 with bGStatEveryStep=FALSE.
-                 */
-
-               if (ir->eI != eiVVAK)
-                {
-                 update_tcouple(fplog,step,ir,state,ekind,wcycle,upd,&MassQ,mdatoms);
-                }
-                update_pcouple(fplog,step,ir,state,pcoupl_mu,M,wcycle,
-                                upd,bInitStep);
-
-               if (bVV)
-               {
-                   /* velocity half-step update */
-                   update_coords(fplog,step,ir,mdatoms,state,f,fr->bTwinRange && bNStList,fr->f_twin,fcd,
-                                 ekind,M,wcycle,upd,FALSE,etrtVELOCITY2,cr,nrnb,constr,&top->idef);
-               }
-
-                /* Above, initialize just copies ekinh into ekin,
-                 * it doesn't copy position (for VV),
-                 * and entire integrator for MD.
-                 */
-
-                if (ir->eI==eiVVAK)
-                {
-                    copy_rvecn(state->x,cbuf,0,state->natoms);
-                }
-
-                update_coords(fplog,step,ir,mdatoms,state,f,fr->bTwinRange && bNStList,fr->f_twin,fcd,
-                              ekind,M,wcycle,upd,bInitStep,etrtPOSITION,cr,nrnb,constr,&top->idef);
-                wallcycle_stop(wcycle,ewcUPDATE);
-
-                update_constraints(fplog,step,&dvdl,ir,ekind,mdatoms,state,graph,f,
-                                   &top->idef,shake_vir,force_vir,
-                                   cr,nrnb,wcycle,upd,constr,
-                                   bInitStep,FALSE,bCalcEnerPres,state->veta);
-
-                if (ir->eI==eiVVAK)
-                {
-                    /* erase F_EKIN and F_TEMP here? */
-                    /* just compute the kinetic energy at the half step to perform a trotter step */
-                    compute_globals(fplog,gstat,cr,ir,fr,ekind,state,state_global,mdatoms,nrnb,vcm,
-                                    wcycle,enerd,force_vir,shake_vir,total_vir,pres,mu_tot,
-                                    constr,NULL,FALSE,lastbox,
-                                    top_global,&pcurr,top_global->natoms,&bSumEkinhOld,
-                                    cglo_flags | CGLO_TEMPERATURE | CGLO_CONSTRAINT
-                        );
-                    wallcycle_start(wcycle,ewcUPDATE);
-                    trotter_update(ir,step,ekind,enerd,state,total_vir,mdatoms,&MassQ, trotter_seq,ettTSEQ4);
-                    /* now we know the scaling, we can compute the positions again again */
-                    copy_rvecn(cbuf,state->x,0,state->natoms);
-
-                    update_coords(fplog,step,ir,mdatoms,state,f,fr->bTwinRange && bNStList,fr->f_twin,fcd,
-                                  ekind,M,wcycle,upd,bInitStep,etrtPOSITION,cr,nrnb,constr,&top->idef);
-                    wallcycle_stop(wcycle,ewcUPDATE);
-
-                    /* do we need an extra constraint here? just need to copy out of state->v to upd->xp? */
-                    /* are the small terms in the shake_vir here due
-                     * to numerical errors, or are they important
-                     * physically? I'm thinking they are just errors, but not completely sure.
-                     * For now, will call without actually constraining, constr=NULL*/
-                    update_constraints(fplog,step,&dvdl,ir,ekind,mdatoms,state,graph,f,
-                                       &top->idef,tmp_vir,force_vir,
-                                       cr,nrnb,wcycle,upd,NULL,
-                                       bInitStep,FALSE,bCalcEnerPres,state->veta);
-                }
-                if (!bOK && !bFFscan)
-                {
-                    gmx_fatal(FARGS,"Constraint error: Shake, Lincs or Settle could not solve the constrains");
-                }
-
-                if (fr->bSepDVDL && fplog && do_log)
-                {
-                    fprintf(fplog,sepdvdlformat,"Constraint",0.0,dvdl);
-                }
-                enerd->term[F_DHDL_CON] += dvdl;
-            }
-            else if (graph)
-            {
-                /* Need to unshift here */
-                unshift_self(graph,state->box,state->x);
-            }
-
-            GMX_BARRIER(cr->mpi_comm_mygroup);
-            GMX_MPE_LOG(ev_update_finish);
-
-            if (vsite != NULL)
-            {
-                wallcycle_start(wcycle,ewcVSITECONSTR);
-                if (graph != NULL)
-                {
-                    shift_self(graph,state->box,state->x);
-                }
-                construct_vsites(fplog,vsite,state->x,nrnb,ir->delta_t,state->v,
-                                 top->idef.iparams,top->idef.il,
-                                 fr->ePBC,fr->bMolPBC,graph,cr,state->box);
-
-                if (graph != NULL)
-                {
-                    unshift_self(graph,state->box,state->x);
-                }
-                wallcycle_stop(wcycle,ewcVSITECONSTR);
-            }
-
-            /* ############## IF NOT VV, Calculate globals HERE, also iterate constraints ############ */
-            if (ir->nstlist == -1 && bFirstIterate)
-            {
-                gs.sig[eglsNABNSB] = nlh.nabnsb;
-            }
-            compute_globals(fplog,gstat,cr,ir,fr,ekind,state,state_global,mdatoms,nrnb,vcm,
-                            wcycle,enerd,force_vir,shake_vir,total_vir,pres,mu_tot,
-                            constr,
-                            bFirstIterate ? &gs : NULL,(step % gs.nstms == 0),
-                            lastbox,
-                            top_global,&pcurr,top_global->natoms,&bSumEkinhOld,
-                            cglo_flags
-                            | (!EI_VV(ir->eI) ? CGLO_ENERGY : 0)
-                            | (!EI_VV(ir->eI) ? CGLO_TEMPERATURE : 0)
-                            | (!EI_VV(ir->eI) || bRerunMD ? CGLO_PRESSURE : 0)
-                            | (bIterations && iterate.bIterate ? CGLO_ITERATE : 0)
-                            | (bFirstIterate ? CGLO_FIRSTITERATE : 0)
-                            | CGLO_CONSTRAINT
-                );
-            if (ir->nstlist == -1 && bFirstIterate)
-            {
-                nlh.nabnsb = gs.set[eglsNABNSB];
-                gs.set[eglsNABNSB] = 0;
-            }
-            /* bIterate is set to keep it from eliminating the old ekin kinetic energy terms */
-            /* #############  END CALC EKIN AND PRESSURE ################# */
-
-            /* Note: this is OK, but there are some numerical precision issues with using the convergence of
-               the virial that should probably be addressed eventually. state->veta has better properies,
-               but what we actually need entering the new cycle is the new shake_vir value. Ideally, we could
-               generate the new shake_vir, but test the veta value for convergence.  This will take some thought. */
-
-            if (bIterations &&
-                done_iterating(cr,fplog,step,&iterate,bFirstIterate,
-                               trace(shake_vir),&tracevir))
-            {
-                break;
-            }
-            bFirstIterate = FALSE;
-        }
-
-        update_box(fplog,step,ir,mdatoms,state,graph,f,
-                   ir->nstlist==-1 ? &nlh.scale_tot : NULL,pcoupl_mu,nrnb,wcycle,upd,bInitStep,FALSE);
-
-        /* ################# END UPDATE STEP 2 ################# */
-        /* #### We now have r(t+dt) and v(t+dt/2)  ############# */
-
-        /* The coordinates (x) were unshifted in update */
-/*        if (bFFscan && (shellfc==NULL || bConverged))
-        {
-            if (print_forcefield(fplog,enerd->term,mdatoms->homenr,
-                                 f,NULL,xcopy,
-                                 &(top_global->mols),mdatoms->massT,pres))
-            {
-                if (gmx_parallel_env_initialized())
-                {
-                    gmx_finalize();
-                }
-                fprintf(stderr,"\n");
-                exit(0);
-            }
-        }*/
-        if (!bGStat)
-        {
-            /* We will not sum ekinh_old,
-             * so signal that we still have to do it.
-             */
-            bSumEkinhOld = TRUE;
-        }
-
-/*        if (bTCR)
-        {*/
-            /* Only do GCT when the relaxation of shells (minimization) has converged,
-             * otherwise we might be coupling to bogus energies.
-             * In parallel we must always do this, because the other sims might
-             * update the FF.
-             */
-
-            /* Since this is called with the new coordinates state->x, I assume
-             * we want the new box state->box too. / EL 20040121
-             */
-/*            do_coupling(fplog,oenv,nfile,fnm,tcr,t,step,enerd->term,fr,
-                        ir,MASTER(cr),
-                        mdatoms,&(top->idef),mu_aver,
-                        top_global->mols.nr,cr,
-                        state->box,total_vir,pres,
-                        mu_tot,state->x,f,bConverged);
-            debug_gmx();
-        }*/
-
-        /* #########  BEGIN PREPARING EDR OUTPUT  ###########  */
-
-        sum_dhdl(enerd,state->lambda,ir);
-        /* use the directly determined last velocity, not actually the averaged half steps */
-        if (bTrotter && ir->eI==eiVV)
-        {
-            enerd->term[F_EKIN] = last_ekin;
-        }
-        enerd->term[F_ETOT] = enerd->term[F_EPOT] + enerd->term[F_EKIN];
-
-        switch (ir->etc)
-        {
-        case etcNO:
-            break;
-        case etcBERENDSEN:
-            break;
-        case etcNOSEHOOVER:
-            if (IR_NVT_TROTTER(ir)) {
-                enerd->term[F_ECONSERVED] = enerd->term[F_ETOT] + last_conserved;
-            } else {
-                enerd->term[F_ECONSERVED] = enerd->term[F_ETOT] +
-                    NPT_energy(ir,state,&MassQ);
-            }
-            break;
-        case etcVRESCALE:
-            enerd->term[F_ECONSERVED] =
-                enerd->term[F_ETOT] + vrescale_energy(&(ir->opts),
-                                                      state->therm_integral);
-            break;
-        default:
-            break;
-        }
-
-        /* Check for excessively large energies */
-/*        if (bIonize)
-        {
-#ifdef GMX_DOUBLE
-            real etot_max = 1e200;
-#else
-            real etot_max = 1e30;
-#endif
-            if (fabs(enerd->term[F_ETOT]) > etot_max)
-            {
-                fprintf(stderr,"Energy too large (%g), giving up\n",
-                        enerd->term[F_ETOT]);
-            }
-        }*/
-        /* #########  END PREPARING EDR OUTPUT  ###########  */
-
-        /* Time for performance */
-        if (((step % stepout) == 0) || bLastStep)
-        {
-            runtime_upd_proc(runtime);
-        }
-
-        /* Output stuff */
-        if (MASTER(cr))
-        {
-            gmx_bool do_dr,do_or;
-
-            if (!(bStartingFromCpt && (EI_VV(ir->eI))))
-            {
-                if (bNstEner)
-                {
-                    upd_mdebin(mdebin,bDoDHDL,TRUE,
-                               t,mdatoms->tmass,enerd,state,lastbox,
-                               shake_vir,force_vir,total_vir,pres,
-                               ekind,mu_tot,constr);
-                }
-                else
-                {
-                    upd_mdebin_step(mdebin);
-                }
-
-                do_dr  = do_per_step(step,ir->nstdisreout);
-                do_or  = do_per_step(step,ir->nstorireout);
-
-                print_ebin(outf->fp_ene,do_ene,do_dr,do_or,do_log?fplog:NULL,
-                           step,t,
-                           eprNORMAL,bCompact,mdebin,fcd,groups,&(ir->opts));
-            }
-            if (ir->ePull != epullNO)
-            {
-                pull_print_output(ir->pull,step,t);
-            }
-
-            if (do_per_step(step,ir->nstlog))
-            {
-                if(fflush(fplog) != 0)
-                {
-                    gmx_fatal(FARGS,"Cannot flush logfile - maybe you are out of quota?");
-                }
-            }
-        }
-
-
-        /* Remaining runtime */
-        if (MULTIMASTER(cr) && (do_verbose || gmx_got_usr_signal() ))
-        {
-            if (shellfc)
-            {
-                fprintf(stderr,"\n");
-            }
-            print_time(stderr,runtime,step,ir,cr);
-        }
-
-               /* Set new positions for the group to embed */
-               if(!bLastStep){
-                       if(step_rel<=it_xy)
-                       {
-                               fac[0]+=xy_step;
-                               fac[1]+=xy_step;
-                       } else if (step_rel<=(it_xy+it_z))
-                       {
-                               fac[2]+=z_step;
-                       }
-                       resize(ins_at,r_ins,state_global->x,pos_ins,fac);
-               }
-
-        /* Replica exchange */
-/*        bExchanged = FALSE;
-        if ((repl_ex_nst > 0) && (step > 0) && !bLastStep &&
-            do_per_step(step,repl_ex_nst))
-        {
-            bExchanged = replica_exchange(fplog,cr,repl_ex,
-                                          state_global,enerd->term,
-                                          state,step,t);
-        }
-        if (bExchanged && PAR(cr))
-        {
-            if (DOMAINDECOMP(cr))
-            {
-                dd_partition_system(fplog,step,cr,TRUE,1,
-                                    state_global,top_global,ir,
-                                    state,&f,mdatoms,top,fr,
-                                    vsite,shellfc,constr,
-                                    nrnb,wcycle,FALSE);
-            }
-            else
-            {
-                bcast_state(cr,state,FALSE);
-            }
-        }*/
-
-        bFirstStep = FALSE;
-        bInitStep = FALSE;
-        bStartingFromCpt = FALSE;
-
-        /* #######  SET VARIABLES FOR NEXT ITERATION IF THEY STILL NEED IT ###### */
-        /* Complicated conditional when bGStatEveryStep=FALSE.
-         * We can not just use bGStat, since then the simulation results
-         * would depend on nstenergy and nstlog or step_nscheck.
-         */
-        if (((state->flags & (1<<estPRES_PREV)) ||
-             (state->flags & (1<<estSVIR_PREV)) ||
-             (state->flags & (1<<estFVIR_PREV))) &&
-            (bGStatEveryStep ||
-             (ir->nstlist > 0 && step % ir->nstlist == 0) ||
-             (ir->nstlist < 0 && nlh.nabnsb > 0) ||
-             (ir->nstlist == 0 && bGStat)))
-        {
-            /* Store the pressure in t_state for pressure coupling
-             * at the next MD step.
-             */
-            if (state->flags & (1<<estPRES_PREV))
-            {
-                copy_mat(pres,state->pres_prev);
-            }
-        }
-
-        /* #######  END SET VARIABLES FOR NEXT ITERATION ###### */
-
-        if (bRerunMD)
-        {
-            /* read next frame from input trajectory */
-            bNotLastFrame = read_next_frame(oenv,status,&rerun_fr);
-        }
-
-        if (!bRerunMD || !rerun_fr.bStep)
-        {
-            /* increase the MD step number */
-            step++;
-            step_rel++;
-        }
-
-        cycles = wallcycle_stop(wcycle,ewcSTEP);
-        if (DOMAINDECOMP(cr) && wcycle)
-        {
-            dd_cycles_add(cr->dd,cycles,ddCyclStep);
-        }
-
-        if (step_rel == wcycle_get_reset_counters(wcycle) ||
-            gs.set[eglsRESETCOUNTERS] != 0)
-        {
-            /* Reset all the counters related to performance over the run */
-            reset_all_counters(fplog,cr,step,&step_rel,ir,wcycle,nrnb,runtime);
-            wcycle_set_reset_counters(wcycle,-1);
-            bResetCountersHalfMaxH = FALSE;
-            gs.set[eglsRESETCOUNTERS] = 0;
-        }
-    }
-    /* End of main MD loop */
-    debug_gmx();
-    write_sto_conf_mtop(ftp2fn(efSTO,nfile,fnm),
-                                        *top_global->name,top_global,
-                                        state_global->x,state_global->v,
-                                        ir->ePBC,state->box);
-
-    /* Stop the time */
-    runtime_end(runtime);
-
-    if (bRerunMD)
-    {
-        close_trj(status);
-    }
-
-    if (!(cr->duty & DUTY_PME))
-    {
-        /* Tell the PME only node to finish */
-        gmx_pme_finish(cr);
-    }
-
-    if (MASTER(cr))
-    {
-        if (ir->nstcalcenergy > 0 && !bRerunMD)
-        {
-            print_ebin(outf->fp_ene,FALSE,FALSE,FALSE,fplog,step,t,
-                       eprAVER,FALSE,mdebin,fcd,groups,&(ir->opts));
-        }
-    }
-
-    done_mdoutf(outf);
-
-    debug_gmx();
-
-    if (ir->nstlist == -1 && nlh.nns > 0 && fplog)
-    {
-        fprintf(fplog,"Average neighborlist lifetime: %.1f steps, std.dev.: %.1f steps\n",nlh.s1/nlh.nns,sqrt(nlh.s2/nlh.nns - sqr(nlh.s1/nlh.nns)));
-        fprintf(fplog,"Average number of atoms that crossed the half buffer length: %.1f\n\n",nlh.ab/nlh.nns);
-    }
-
-    if (shellfc && fplog)
-    {
-        fprintf(fplog,"Fraction of iterations that converged:           %.2f %%\n",
-                (nconverged*100.0)/step_rel);
-        fprintf(fplog,"Average number of force evaluations per MD step: %.2f\n\n",
-                tcount/step_rel);
-    }
-
-/*    if (repl_ex_nst > 0 && MASTER(cr))
-    {
-        print_replica_exchange_statistics(fplog,repl_ex);
-    }*/
-
-    runtime->nsteps_done = step_rel;
-
-    return 0;
-}
-
-
-int mdrunner_membed(FILE *fplog,t_commrec *cr,int nfile,const t_filenm fnm[],
-             const output_env_t oenv, gmx_bool bVerbose,gmx_bool bCompact,
-             int nstglobalcomm,
-             ivec ddxyz,int dd_node_order,real rdd,real rconstr,
-             const char *dddlb_opt,real dlb_scale,
-             const char *ddcsx,const char *ddcsy,const char *ddcsz,
-             int nstepout,int resetstep,int nmultisim,int repl_ex_nst,int repl_ex_seed,
-             real pforce,real cpt_period,real max_hours,
-             const char *deviceOptions,
-             unsigned long Flags,
-             real xy_fac, real xy_max, real z_fac, real z_max,
-             int it_xy, int it_z, real probe_rad, int low_up_rm,
-             int pieces, gmx_bool bALLOW_ASYMMETRY, int maxwarn)
-{
-    double     nodetime=0,realtime;
-    t_inputrec *inputrec;
-    t_state    *state=NULL;
-    matrix     box;
-    gmx_ddbox_t ddbox;
-    int        npme_major,npme_minor;
-    real       tmpr1,tmpr2;
-    t_nrnb     *nrnb;
-    gmx_mtop_t *mtop=NULL;
-    t_mdatoms  *mdatoms=NULL;
-    t_forcerec *fr=NULL;
-    t_fcdata   *fcd=NULL;
-    real       ewaldcoeff=0;
-    gmx_pme_t  *pmedata=NULL;
-    gmx_vsite_t *vsite=NULL;
-    gmx_constr_t constr;
-    int        i,m,nChargePerturbed=-1,status,nalloc;
-    char       *gro;
-    gmx_wallcycle_t wcycle;
-    gmx_bool       bReadRNG,bReadEkin;
-    int        list;
-    gmx_runtime_t runtime;
-    int        rc;
-    gmx_large_int_t reset_counters;
-    gmx_edsam_t ed=NULL;
-    t_commrec   *cr_old=cr;
-    int        nthreads=1,nthreads_requested=1;
-
-
-       char                    *ins;
-       int                     rm_bonded_at,fr_id,fr_i=0,tmp_id,warn=0;
-       int                     ng,j,max_lip_rm,ins_grp_id,ins_nat,mem_nat,ntype,lip_rm,tpr_version;
-       real                    xy_step=0,z_step=0;
-       real                    prot_area;
-       rvec                    *r_ins=NULL,fac;
-       t_block                 *ins_at,*rest_at;
-       pos_ins_t               *pos_ins;
-       mem_t                   *mem_p;
-       rm_t                    *rm_p;
-       gmx_groups_t            *groups;
-       gmx_bool                        bExcl=FALSE;
-       t_atoms                 atoms;
-       t_pbc                   *pbc;
-       char                    **piecename=NULL;
-
-    /* CAUTION: threads may be started later on in this function, so
-       cr doesn't reflect the final parallel state right now */
-    snew(inputrec,1);
-    snew(mtop,1);
-
-    if (bVerbose && SIMMASTER(cr))
-    {
-        fprintf(stderr,"Getting Loaded...\n");
-    }
-
-    if (Flags & MD_APPENDFILES)
-    {
-        fplog = NULL;
-    }
-
-    snew(state,1);
-    if (MASTER(cr))
-    {
-        /* Read (nearly) all data required for the simulation */
-        read_tpx_state(ftp2fn(efTPX,nfile,fnm),inputrec,state,NULL,mtop);
-
-        /* NOW the threads will be started: */
-#ifdef GMX_THREADS
-#endif
-    }
-    /* END OF CAUTION: cr is now reliable */
-
-    if (PAR(cr))
-    {
-        /* now broadcast everything to the non-master nodes/threads: */
-        init_parallel(fplog, cr, inputrec, mtop);
-    }
-    /* now make sure the state is initialized and propagated */
-    set_state_entries(state,inputrec,cr->nnodes);
-
-    if (can_use_allvsall(inputrec,mtop,TRUE,cr,fplog))
-    {
-        /* All-vs-all loops do not work with domain decomposition */
-        Flags |= MD_PARTDEC;
-    }
-
-    if (!EEL_PME(inputrec->coulombtype) || (Flags & MD_PARTDEC))
-    {
-        cr->npmenodes = 0;
-    }
-
-       snew(ins_at,1);
-       snew(pos_ins,1);
-       if(MASTER(cr))
-       {
-               tpr_version = get_tpr_version(ftp2fn(efTPX,nfile,fnm));
-               if (tpr_version<58)
-                       gmx_fatal(FARGS,"Version of *.tpr file to old (%d). Rerun grompp with gromacs VERSION 4.0.3 or newer.\n",tpr_version);
-
-               if( inputrec->eI != eiMD )
-                       gmx_input("Change integrator to md in mdp file.");
-
-               if(PAR(cr))
-                       gmx_input("Sorry, parallel g_membed is not yet fully functrional.");
-
-               groups=&(mtop->groups);
-
-               atoms=gmx_mtop_global_atoms(mtop);
-               snew(mem_p,1);
-               fprintf(stderr,"\nSelect a group to embed in the membrane:\n");
-               get_index(&atoms,ftp2fn_null(efNDX,nfile,fnm),1,&(ins_at->nr),&(ins_at->index),&ins);
-               ins_grp_id = search_string(ins,groups->ngrpname,(groups->grpname));
-               fprintf(stderr,"\nSelect a group to embed %s into (e.g. the membrane):\n",ins);
-               get_index(&atoms,ftp2fn_null(efNDX,nfile,fnm),1,&(mem_p->mem_at.nr),&(mem_p->mem_at.index),&(mem_p->name));
-
-               pos_ins->pieces=pieces;
-               snew(pos_ins->nidx,pieces);
-               snew(pos_ins->subindex,pieces);
-               snew(piecename,pieces); 
-               if (pieces>1)
-               {
-                       fprintf(stderr,"\nSelect pieces to embed:\n");
-                       get_index(&atoms,ftp2fn_null(efNDX,nfile,fnm),pieces,pos_ins->nidx,pos_ins->subindex,piecename);
-               }
-               else
-               {       
-                       /*use whole embedded group*/
-                       snew(pos_ins->nidx,1);
-                       snew(pos_ins->subindex,1);
-                       pos_ins->nidx[0]=ins_at->nr;
-                       pos_ins->subindex[0]=ins_at->index;
-               }
-
-               if(probe_rad<0.2199999)
-               {
-                       warn++;
-                       fprintf(stderr,"\nWarning %d:\nA probe radius (-rad) smaller than 0.2 can result in overlap between waters "
-                                       "and the group to embed, which will result in Lincs errors etc.\nIf you are sure, you can increase maxwarn.\n\n",warn);
-               }
-
-               if(xy_fac<0.09999999)
-               {
-                       warn++;
-                       fprintf(stderr,"\nWarning %d:\nThe initial size of %s is probably too smal.\n"
-                                       "If you are sure, you can increase maxwarn.\n\n",warn,ins);
-               }
-
-               if(it_xy<1000)
-               {
-                       warn++;
-                       fprintf(stderr,"\nWarning %d;\nThe number of steps used to grow the xy-coordinates of %s (%d) is probably too small.\n"
-                                       "Increase -nxy or, if you are sure, you can increase maxwarn.\n\n",warn,ins,it_xy);
-               }
-
-               if( (it_z<100) && ( z_fac<0.99999999 || z_fac>1.0000001) )
-                {
-                        warn++;
-                        fprintf(stderr,"\nWarning %d;\nThe number of steps used to grow the z-coordinate of %s (%d) is probably too small.\n"
-                                       "Increase -nz or, if you are sure, you can increase maxwarn.\n\n",warn,ins,it_z);
-                }
-
-               if(it_xy+it_z>inputrec->nsteps)
-               {
-                       warn++;
-                       fprintf(stderr,"\nWarning %d:\nThe number of growth steps (-nxy + -nz) is larger than the number of steps in the tpr.\n"
-                                       "If you are sure, you can increase maxwarn.\n\n",warn);
-               }
-
-               fr_id=-1;
-               if( inputrec->opts.ngfrz==1)
-                       gmx_fatal(FARGS,"You did not specify \"%s\" as a freezegroup.",ins);
-               for(i=0;i<inputrec->opts.ngfrz;i++)
-               {
-                       tmp_id = mtop->groups.grps[egcFREEZE].nm_ind[i];
-                       if(ins_grp_id==tmp_id)
-                       {
-                               fr_id=tmp_id;
-                               fr_i=i;
-                       }
-               }
-               if (fr_id == -1 )
-                       gmx_fatal(FARGS,"\"%s\" not as freezegroup defined in the mdp-file.",ins);
-
-               for(i=0;i<DIM;i++)
-                       if( inputrec->opts.nFreeze[fr_i][i] != 1)
-                               gmx_fatal(FARGS,"freeze dimensions for %s are not Y Y Y\n",ins);
-
-               ng = groups->grps[egcENER].nr;
-               if (ng == 1)
-                       gmx_input("No energy groups defined. This is necessary for energy exclusion in the freeze group");
-
-               for(i=0;i<ng;i++)
-               {
-                       for(j=0;j<ng;j++)
-                       {
-                               if (inputrec->opts.egp_flags[ng*i+j] == EGP_EXCL)
-                               {
-                                       bExcl = TRUE;
-                                       if ( (groups->grps[egcENER].nm_ind[i] != ins_grp_id) || (groups->grps[egcENER].nm_ind[j] != ins_grp_id) )
-                                               gmx_fatal(FARGS,"Energy exclusions \"%s\" and  \"%s\" do not match the group to embed \"%s\"",
-                                                               *groups->grpname[groups->grps[egcENER].nm_ind[i]],
-                                                               *groups->grpname[groups->grps[egcENER].nm_ind[j]],ins);
-                               }
-                       }
-               }
-               if (!bExcl)
-                       gmx_input("No energy exclusion groups defined. This is necessary for energy exclusion in the freeze group");
-
-               /* Set all atoms in box*/
-               /*set_inbox(state->natoms,state->x);*/
-
-               /* Guess the area the protein will occupy in the membrane plane  Calculate area per lipid*/
-               snew(rest_at,1);
-               ins_nat = init_ins_at(ins_at,rest_at,state,pos_ins,groups,ins_grp_id,xy_max);
-               /* Check moleculetypes in insertion group */
-               check_types(ins_at,rest_at,mtop);
-
-               mem_nat = init_mem_at(mem_p,mtop,state->x,state->box,pos_ins);
-
-               prot_area = est_prot_area(pos_ins,state->x,ins_at,mem_p);
-               if ( (prot_area>7.5) && ( (state->box[XX][XX]*state->box[YY][YY]-state->box[XX][YY]*state->box[YY][XX])<50) )
-               {
-                       warn++;
-                       fprintf(stderr,"\nWarning %d:\nThe xy-area is very small compared to the area of the protein.\n"
-                                       "This might cause pressure problems during the growth phase. Just try with\n"
-                                       "current setup (-maxwarn + 1), but if pressure problems occur, lower the\n"
-                                       "compressibility in the mdp-file or use no pressure coupling at all.\n\n",warn);
-               }
-               if(warn>maxwarn)
-                                       gmx_fatal(FARGS,"Too many warnings.\n");
-
-               printf("The estimated area of the protein in the membrane is %.3f nm^2\n",prot_area);
-               printf("\nThere are %d lipids in the membrane part that overlaps the protein.\nThe area per lipid is %.4f nm^2.\n",mem_p->nmol,mem_p->lip_area);
-
-               /* Maximum number of lipids to be removed*/
-               max_lip_rm=(int)(2*prot_area/mem_p->lip_area);
-               printf("Maximum number of lipids that will be removed is %d.\n",max_lip_rm);
-
-               printf("\nWill resize the protein by a factor of %.3f in the xy plane and %.3f in the z direction.\n"
-                               "This resizing will be done with respect to the geometrical center of all protein atoms\n"
-                               "that span the membrane region, i.e. z between %.3f and %.3f\n\n",xy_fac,z_fac,mem_p->zmin,mem_p->zmax);
-
-               /* resize the protein by xy and by z if necessary*/
-               snew(r_ins,ins_at->nr);
-               init_resize(ins_at,r_ins,pos_ins,mem_p,state->x,bALLOW_ASYMMETRY);
-               fac[0]=fac[1]=xy_fac;
-               fac[2]=z_fac;
-
-               xy_step =(xy_max-xy_fac)/(double)(it_xy);
-               z_step  =(z_max-z_fac)/(double)(it_z-1);
-
-               resize(ins_at,r_ins,state->x,pos_ins,fac);
-
-               /* remove overlapping lipids and water from the membrane box*/
-               /*mark molecules to be removed*/
-               snew(pbc,1);
-               set_pbc(pbc,inputrec->ePBC,state->box);
-
-               snew(rm_p,1);
-               lip_rm = gen_rm_list(rm_p,ins_at,rest_at,pbc,mtop,state->x, r_ins, mem_p,pos_ins,probe_rad,low_up_rm,bALLOW_ASYMMETRY);
-        lip_rm -= low_up_rm;
-
-               if(fplog)
-                       for(i=0;i<rm_p->nr;i++)
-                               fprintf(fplog,"rm mol %d\n",rm_p->mol[i]);
-
-               for(i=0;i<mtop->nmolblock;i++)
-               {
-                       ntype=0;
-                       for(j=0;j<rm_p->nr;j++)
-                               if(rm_p->block[j]==i)
-                                       ntype++;
-                       printf("Will remove %d %s molecules\n",ntype,*(mtop->moltype[mtop->molblock[i].type].name));
-               }
-
-               if(lip_rm>max_lip_rm)
-               {
-                       warn++;
-                       fprintf(stderr,"\nWarning %d:\nTrying to remove a larger lipid area than the estimated protein area\n"
-                                       "Try making the -xyinit resize factor smaller. If you are sure about this increase maxwarn.\n\n",warn);
-               }
-
-               /*remove all lipids and waters overlapping and update all important structures*/
-               rm_group(inputrec,groups,mtop,rm_p,state,ins_at,pos_ins);
-
-               rm_bonded_at = rm_bonded(ins_at,mtop);
-               if (rm_bonded_at != ins_at->nr)
-               {
-                       fprintf(stderr,"Warning: The number of atoms for which the bonded interactions are removed is %d, "
-                                       "while %d atoms are embedded. Make sure that the atoms to be embedded are not in the same"
-                                       "molecule type as atoms that are not to be embedded.\n",rm_bonded_at,ins_at->nr);
-               }
-
-               if(warn>maxwarn)
-                       gmx_fatal(FARGS,"Too many warnings.\nIf you are sure these warnings are harmless, you can increase -maxwarn");
-
-               if (MASTER(cr))
-               {
-                       if (ftp2bSet(efTOP,nfile,fnm))
-                               top_update(opt2fn("-p",nfile,fnm),ins,rm_p,mtop);
-               }
-
-               sfree(pbc);
-               sfree(rest_at);
-       }
-
-#ifdef GMX_FAHCORE
-    fcRegisterSteps(inputrec->nsteps,inputrec->init_step);
-#endif
-
-    /* NMR restraints must be initialized before load_checkpoint,
-     * since with time averaging the history is added to t_state.
-     * For proper consistency check we therefore need to extend
-     * t_state here.
-     * So the PME-only nodes (if present) will also initialize
-     * the distance restraints.
-     */
-    snew(fcd,1);
-
-    /* This needs to be called before read_checkpoint to extend the state */
-    init_disres(fplog,mtop,inputrec,cr,Flags & MD_PARTDEC,fcd,state);
-
-    if (gmx_mtop_ftype_count(mtop,F_ORIRES) > 0)
-    {
-        if (PAR(cr) && !(Flags & MD_PARTDEC))
-        {
-            gmx_fatal(FARGS,"Orientation restraints do not work (yet) with domain decomposition, use particle decomposition (mdrun option -pd)");
-        }
-        /* Orientation restraints */
-        if (MASTER(cr))
-        {
-            init_orires(fplog,mtop,state->x,inputrec,cr->ms,&(fcd->orires),
-                        state);
-        }
-    }
-
-    if (DEFORM(*inputrec))
-    {
-        /* Store the deform reference box before reading the checkpoint */
-        if (SIMMASTER(cr))
-        {
-            copy_mat(state->box,box);
-        }
-        if (PAR(cr))
-        {
-            gmx_bcast(sizeof(box),box,cr);
-        }
-        /* Because we do not have the update struct available yet
-         * in which the reference values should be stored,
-         * we store them temporarily in static variables.
-         * This should be thread safe, since they are only written once
-         * and with identical values.
-         */
-/*        deform_init_init_step_tpx = inputrec->init_step;*/
-/*        copy_mat(box,deform_init_box_tpx);*/
-    }
-
-    if (opt2bSet("-cpi",nfile,fnm))
-    {
-        /* Check if checkpoint file exists before doing continuation.
-         * This way we can use identical input options for the first and subsequent runs...
-         */
-        if( gmx_fexist_master(opt2fn_master("-cpi",nfile,fnm,cr),cr) )
-        {
-            load_checkpoint(opt2fn_master("-cpi",nfile,fnm,cr),&fplog,
-                            cr,Flags & MD_PARTDEC,ddxyz,
-                            inputrec,state,&bReadRNG,&bReadEkin,
-                            (Flags & MD_APPENDFILES));
-
-            if (bReadRNG)
-            {
-                Flags |= MD_READ_RNG;
-            }
-            if (bReadEkin)
-            {
-                Flags |= MD_READ_EKIN;
-            }
-        }
-    }
-
-    if ((MASTER(cr) || (Flags & MD_SEPPOT)) && (Flags & MD_APPENDFILES))
-    {
-        gmx_log_open(ftp2fn(efLOG,nfile,fnm),cr,!(Flags & MD_SEPPOT),
-                             Flags,&fplog);
-    }
-
-    if (SIMMASTER(cr))
-    {
-        copy_mat(state->box,box);
-    }
-
-    if (PAR(cr))
-    {
-        gmx_bcast(sizeof(box),box,cr);
-    }
-
-    if (bVerbose && SIMMASTER(cr))
-    {
-        fprintf(stderr,"Loaded with Money\n\n");
-    }
-
-    if (PAR(cr) && !((Flags & MD_PARTDEC) || EI_TPI(inputrec->eI)))
-    {
-        cr->dd = init_domain_decomposition(fplog,cr,Flags,ddxyz,rdd,rconstr,
-                                           dddlb_opt,dlb_scale,
-                                           ddcsx,ddcsy,ddcsz,
-                                           mtop,inputrec,
-                                           box,state->x,
-                                           &ddbox,&npme_major,&npme_minor);
-
-        make_dd_communicators(fplog,cr,dd_node_order);
-
-        /* Set overallocation to avoid frequent reallocation of arrays */
-        set_over_alloc_dd(TRUE);
-    }
-    else
-    {
-        /* PME, if used, is done on all nodes with 1D decomposition */
-        cr->npmenodes = 0;
-        cr->duty = (DUTY_PP | DUTY_PME);
-        npme_major = cr->nnodes;
-        npme_minor = 1;
-
-        if (inputrec->ePBC == epbcSCREW)
-        {
-            gmx_fatal(FARGS,
-                      "pbc=%s is only implemented with domain decomposition",
-                      epbc_names[inputrec->ePBC]);
-        }
-    }
-
-    if (PAR(cr))
-    {
-        /* After possible communicator splitting in make_dd_communicators.
-         * we can set up the intra/inter node communication.
-         */
-        gmx_setup_nodecomm(fplog,cr);
-    }
-
-    wcycle = wallcycle_init(fplog,resetstep,cr);
-    if (PAR(cr))
-    {
-        /* Master synchronizes its value of reset_counters with all nodes
-         * including PME only nodes */
-        reset_counters = wcycle_get_reset_counters(wcycle);
-        gmx_bcast_sim(sizeof(reset_counters),&reset_counters,cr);
-        wcycle_set_reset_counters(wcycle, reset_counters);
-    }
-
-
-    snew(nrnb,1);
-    if (cr->duty & DUTY_PP)
-    {
-        /* For domain decomposition we allocate dynamically
-         * in dd_partition_system.
-         */
-        if (DOMAINDECOMP(cr))
-        {
-            bcast_state_setup(cr,state);
-        }
-        else
-        {
-            if (PAR(cr))
-            {
-                if (!MASTER(cr))
-                {
-                    snew(state,1);
-                }
-                bcast_state(cr,state,TRUE);
-            }
-        }
-
-        /* Dihedral Restraints */
-        if (gmx_mtop_ftype_count(mtop,F_DIHRES) > 0)
-        {
-            init_dihres(fplog,mtop,inputrec,fcd);
-        }
-
-        /* Initiate forcerecord */
-        fr = mk_forcerec();
-        init_forcerec(fplog,oenv,fr,fcd,inputrec,mtop,cr,box,FALSE,
-                      opt2fn("-table",nfile,fnm),
-                      opt2fn("-tablep",nfile,fnm),
-                      opt2fn("-tableb",nfile,fnm),FALSE,pforce);
-
-        /* version for PCA_NOT_READ_NODE (see md.c) */
-        /*init_forcerec(fplog,fr,fcd,inputrec,mtop,cr,box,FALSE,
-          "nofile","nofile","nofile",FALSE,pforce);
-          */
-        fr->bSepDVDL = ((Flags & MD_SEPPOT) == MD_SEPPOT);
-
-        /* Initialize QM-MM */
-        if(fr->bQMMM)
-        {
-            init_QMMMrec(cr,box,mtop,inputrec,fr);
-        }
-
-        /* Initialize the mdatoms structure.
-         * mdatoms is not filled with atom data,
-         * as this can not be done now with domain decomposition.
-         */
-        mdatoms = init_mdatoms(fplog,mtop,inputrec->efep!=efepNO);
-
-        /* Initialize the virtual site communication */
-        vsite = init_vsite(mtop,cr);
-
-        calc_shifts(box,fr->shift_vec);
-
-        /* With periodic molecules the charge groups should be whole at start up
-         * and the virtual sites should not be far from their proper positions.
-         */
-        if (!inputrec->bContinuation && MASTER(cr) &&
-            !(inputrec->ePBC != epbcNONE && inputrec->bPeriodicMols))
-        {
-            /* Make molecules whole at start of run */
-            if (fr->ePBC != epbcNONE)
-            {
-                do_pbc_first_mtop(fplog,inputrec->ePBC,box,mtop,state->x);
-            }
-            if (vsite)
-            {
-                /* Correct initial vsite positions are required
-                 * for the initial distribution in the domain decomposition
-                 * and for the initial shell prediction.
-                 */
-                construct_vsites_mtop(fplog,vsite,mtop,state->x);
-            }
-        }
-
-        /* Initiate PPPM if necessary */
-        if (fr->eeltype == eelPPPM)
-        {
-            if (mdatoms->nChargePerturbed)
-            {
-                gmx_fatal(FARGS,"Free energy with %s is not implemented",
-                          eel_names[fr->eeltype]);
-            }
-            status = gmx_pppm_init(fplog,cr,oenv,FALSE,TRUE,box,
-                                   getenv("GMXGHAT"),inputrec, (Flags & MD_REPRODUCIBLE));
-            if (status != 0)
-            {
-                gmx_fatal(FARGS,"Error %d initializing PPPM",status);
-            }
-        }
-
-        if (EEL_PME(fr->eeltype))
-        {
-            ewaldcoeff = fr->ewaldcoeff;
-            pmedata = &fr->pmedata;
-        }
-        else
-        {
-            pmedata = NULL;
-        }
-    }
-    else
-    {
-        /* This is a PME only node */
-
-        /* We don't need the state */
-        done_state(state);
-
-        ewaldcoeff = calc_ewaldcoeff(inputrec->rcoulomb, inputrec->ewald_rtol);
-        snew(pmedata,1);
-    }
-
-    /* Initiate PME if necessary,
-     * either on all nodes or on dedicated PME nodes only. */
-    if (EEL_PME(inputrec->coulombtype))
-    {
-        if (mdatoms)
-        {
-            nChargePerturbed = mdatoms->nChargePerturbed;
-        }
-        if (cr->npmenodes > 0)
-        {
-            /* The PME only nodes need to know nChargePerturbed */
-            gmx_bcast_sim(sizeof(nChargePerturbed),&nChargePerturbed,cr);
-        }
-        if (cr->duty & DUTY_PME)
-        {
-            status = gmx_pme_init(pmedata,cr,npme_major,npme_minor,inputrec,
-                                  mtop ? mtop->natoms : 0,nChargePerturbed,
-                                  (Flags & MD_REPRODUCIBLE));
-            if (status != 0)
-            {
-                gmx_fatal(FARGS,"Error %d initializing PME",status);
-            }
-        }
-    }
-
-
-/*    if (integrator[inputrec->eI].func == do_md
-#ifdef GMX_OPENMM
-        ||
-        integrator[inputrec->eI].func == do_md_openmm
-#endif
-        )
-    {*/
-        /* Turn on signal handling on all nodes */
-        /*
-         * (A user signal from the PME nodes (if any)
-         * is communicated to the PP nodes.
-         */
-        signal_handler_install();
-/*    }*/
-
-    if (cr->duty & DUTY_PP)
-    {
-        if (inputrec->ePull != epullNO)
-        {
-            /* Initialize pull code */
-            init_pull(fplog,inputrec,nfile,fnm,mtop,cr,oenv,
-                      EI_DYNAMICS(inputrec->eI) && MASTER(cr),Flags);
-        }
-
-        constr = init_constraints(fplog,mtop,inputrec,ed,state,cr);
-
-        if (DOMAINDECOMP(cr))
-        {
-            dd_init_bondeds(fplog,cr->dd,mtop,vsite,constr,inputrec,
-                            Flags & MD_DDBONDCHECK,fr->cginfo_mb);
-
-            set_dd_parameters(fplog,cr->dd,dlb_scale,inputrec,fr,&ddbox);
-
-            setup_dd_grid(fplog,cr->dd);
-        }
-
-        /* Now do whatever the user wants us to do (how flexible...) */
-        do_md_membed(fplog,cr,nfile,fnm,
-                                      oenv,bVerbose,bCompact,
-                                      nstglobalcomm,
-                                      vsite,constr,
-                                      nstepout,inputrec,mtop,
-                                      fcd,state,
-                                      mdatoms,nrnb,wcycle,ed,fr,
-                                      repl_ex_nst,repl_ex_seed,
-                                      cpt_period,max_hours,
-                                      deviceOptions,
-                                      Flags,
-                                      &runtime,
-                                      fac, r_ins, pos_ins, ins_at,
-                                      xy_step, z_step, it_xy, it_z);
-
-        if (inputrec->ePull != epullNO)
-        {
-            finish_pull(fplog,inputrec->pull);
-        }
-    }
-    else
-    {
-        /* do PME only */
-        gmx_pmeonly(*pmedata,cr,nrnb,wcycle,ewaldcoeff,FALSE,inputrec);
-    }
-
-    if (EI_DYNAMICS(inputrec->eI) || EI_TPI(inputrec->eI))
-    {
-        /* Some timing stats */
-        if (MASTER(cr))
-        {
-            if (runtime.proc == 0)
-            {
-                runtime.proc = runtime.real;
-            }
-        }
-        else
-        {
-            runtime.real = 0;
-        }
-    }
-
-    wallcycle_stop(wcycle,ewcRUN);
-
-    /* Finish up, write some stuff
-     * if rerunMD, don't write last frame again
-     */
-    finish_run(fplog,cr,ftp2fn(efSTO,nfile,fnm),
-               inputrec,nrnb,wcycle,&runtime,
-               EI_DYNAMICS(inputrec->eI) && !MULTISIM(cr));
-
-    /* Does what it says */
-    print_date_and_time(fplog,cr->nodeid,"Finished mdrun",&runtime);
-
-    /* Close logfile already here if we were appending to it */
-    if (MASTER(cr) && (Flags & MD_APPENDFILES))
-    {
-        gmx_log_close(fplog);
-    }
-
-    if (pieces>1)
-    {
-       sfree(piecename);
-    }
-
-    rc=(int)gmx_get_stop_condition();
-
-    return rc;
-}
-
-
 int gmx_membed(int argc,char *argv[])
 {
        const char *desc[] = {
@@ -4320,6 +120,7 @@ int gmx_membed(int argc,char *argv[])
        int maxwarn=0;
        int pieces=1;
         gmx_bool bALLOW_ASYMMETRY=FALSE;
+        gmx_bool bStart=FALSE;
         int nstepout=100;
         gmx_bool bVerbose=FALSE;
         char *mdrun_path=NULL;
@@ -4352,6 +153,8 @@ int gmx_membed(int argc,char *argv[])
                                "Number of lipids that will additionally be removed from the lower (negative number) or upper (positive number) membrane leaflet." },
                        { "-maxwarn", FALSE, etINT, {&maxwarn},         
                                "Maximum number of warning allowed" },
+                        { "-start",   FALSE, etBOOL, {&bStart},
+                                "Call mdrun with membed options" },
                        { "-stepout", FALSE, etINT, {&nstepout},
                                "HIDDENFrequency of writing the remaining runtime" },
                        { "-v",       FALSE, etBOOL,{&bVerbose},
@@ -4401,7 +204,12 @@ int gmx_membed(int argc,char *argv[])
        }
 
         printf("%s\n",buf);
-        system(buf);
+        if (bStart)
+        {
+                system(buf);
+        } else {
+                printf("You can membed your protein now by:\n%s\n",buf);
+        }
 
         fprintf(stderr,"Please cite:\nWolf et al, J Comp Chem 31 (2010) 2169-2174.\n");
 
index 3d58c45396dc7ec3a9d15766e2ec8c1cbaf0afe0..d2baf690a6317ded07125f293864c7a86a0a7544 100644 (file)
@@ -112,29 +112,6 @@ typedef struct
 } t_inputinfo;
 
 
-static void sep_line(FILE *fp)
-{
-    fprintf(fp, "\n------------------------------------------------------------\n");
-}
-
-
-
-static gmx_bool is_equal(real a, real b)
-{
-    real diff, eps=1.0e-6;
-    
-    
-    diff = a - b;
-    
-    if (diff < 0.0) diff = -diff;
-    
-    if (diff < eps)
-        return TRUE;
-    else
-        return FALSE;
-}
-
-
 /* Returns TRUE when atom is charged */
 static gmx_bool is_charge(real charge)
 {
@@ -446,6 +423,10 @@ static real estimate_reciprocal(
         real q[],           /* array of charges */
         int nr,             /* number of charges = size of the charge array */
         FILE *fp_out,
+        gmx_bool bVerbose,
+        unsigned int seed,  /* The seed for the random number generator */
+        int *nsamples,      /* Return the number of samples used if Monte Carlo
+                             * algorithm is used for self energy error estimate */
         t_commrec *cr)
 {
     real e_rec=0;   /* reciprocal error estimate */
@@ -468,31 +449,24 @@ static real estimate_reciprocal(
     real tmp=0;     /* variables to compute different factors from vectors */
     real tmp1=0;
     real tmp2=0;
-    real xtmp=0;
-    real ytmp=0;
-    real ztmp=0;
-    double ewald_error;
+    gmx_bool bFraction;
     
     /* Random number generator */
-    
     gmx_rng_t rng=NULL;
-    /*rng=gmx_rng_init(gmx_rng_make_seed());  */
+    int *numbers=NULL;
 
     /* Index variables for parallel work distribution */
     int startglobal,stopglobal;
     int startlocal, stoplocal;
     int x_per_core;
-    int nrsamples;
-    real xtot;    
+    int xtot;
 
-/* #define TAKETIME */
 #ifdef TAKETIME
     double t0=0.0;
     double t1=0.0;
-    double t2=0.0;
 #endif
 
-    rng=gmx_rng_init(cr->nodeid);
+    rng=gmx_rng_init(seed);
 
     clear_rvec(gridpx);
     clear_rvec(gridpxy);
@@ -511,7 +485,7 @@ static real estimate_reciprocal(
     xtot = stopglobal*2+1;
     if (PAR(cr))
     {
-        x_per_core = ceil(xtot / cr->nnodes);
+        x_per_core = ceil((real)xtot / (real)cr->nnodes);
         startlocal = startglobal + x_per_core*cr->nodeid;
         stoplocal = startlocal + x_per_core -1;
         if (stoplocal > stopglobal)
@@ -529,9 +503,11 @@ static real estimate_reciprocal(
 #endif
 */
 
+#ifdef GMX_MPI
 #ifdef TAKETIME
     if (MASTER(cr))
         t0 = MPI_Wtime();
+#endif
 #endif
     
     if (MASTER(cr)){
@@ -633,46 +609,61 @@ static real estimate_reciprocal(
         
     }
 
-/* 
-#ifdef GMX_MPI
-    MPI_Barrier(MPI_COMM_WORLD);
-#endif
-*/
-
     if (MASTER(cr))
         fprintf(stderr, "\n");
-    if (info->fracself>0)
+    
+    /* Use just a fraction of all charges to estimate the self energy error term? */
+    bFraction =  (info->fracself > 0.0) && (info->fracself < 1.0);
+
+    if (bFraction)
     {
-        nrsamples=ceil(info->fracself*nr);
+        /* Here xtot is the number of samples taken for the Monte Carlo calculation
+         * of the average of term IV of equation 35 in Wang2010. Round up to a
+         * number of samples that is divisible by the number of nodes */
+        x_per_core  = ceil(info->fracself * nr / (real)cr->nnodes);
+        xtot = x_per_core * cr->nnodes;
     }
     else
     {
-        nrsamples=nr;
+        /* In this case we use all nr particle positions */
+        xtot = nr;
+        x_per_core = ceil( (real)xtot / (real)cr->nnodes );
     }
-    
-    
-    xtot=nrsamples;
-
 
-    startglobal=0;
-    stopglobal=nr;
+    startlocal = x_per_core *  cr->nodeid;
+    stoplocal  = min(startlocal + x_per_core, xtot);  /* min needed if xtot == nr */
 
-    if(PAR(cr))
+    if (bFraction)
     {
-        x_per_core=ceil(xtot/cr->nnodes);
-        startlocal=startglobal+x_per_core*cr->nodeid;
-        stoplocal=startglobal+x_per_core*(cr->nodeid+1);
-        if (stoplocal>stopglobal)
-            stoplocal=stopglobal;
-    }
-    else
-    {
-        startlocal=startglobal;
-        stoplocal=stopglobal;
-        x_per_core=xtot;
-    }
+        /* Make shure we get identical results in serial and parallel. Therefore,
+         * take the sample indices from a single, global random number array that
+         * is constructed on the master node and that only depends on the seed */
+        snew(numbers, xtot);
+        if (MASTER(cr))
+        {
+            for (i=0; i<xtot; i++)
+            {
+                numbers[i] = floor(gmx_rng_uniform_real(rng) * nr );
+            }
+        }
+        /* Broadcast the random number array to the other nodes */
+        if (PAR(cr))
+        {
+            nblock_bc(cr,xtot,numbers);
+        }
 
+        if (bVerbose && MASTER(cr))
+        {
+            fprintf(stdout, "Using %d sample%s to approximate the self interaction error term",
+                    xtot, xtot==1?"":"s");
+            if (PAR(cr))
+                fprintf(stdout, " (%d sample%s per node)", x_per_core, x_per_core==1?"":"s");
+            fprintf(stdout, ".\n");
+        }
+    }
 
+    /* Return the number of positions used for the Monte Carlo algorithm */
+    *nsamples = xtot;
 
     for(i=startlocal;i<stoplocal;i++)
     {
@@ -680,14 +671,15 @@ static real estimate_reciprocal(
         e_rec3y=0;
         e_rec3z=0;
 
-        if (info->fracself<0) {
-            ci=i;
-        }else {
-            ci=floor(gmx_rng_uniform_real(rng) * nr );
-            if (ci==nr)
-            {
-                ci=nr-1;
-            }
+        if (bFraction)
+        {
+            /* Randomly pick a charge */
+            ci = numbers[i];
+        }
+        else
+        {
+            /* Use all charges */
+            ci = i;
         }
 
         /* for(nx=startlocal; nx<=stoplocal; nx++)*/
@@ -726,13 +718,12 @@ static real estimate_reciprocal(
         svmul(e_rec3z,info->recipbox[ZZ],tmpvec);
         rvec_inc(tmpvec2,tmpvec);
 
-        e_rec3 += q[ci]*q[ci]*q[ci]*q[ci]*norm2(tmpvec2) / ( nrsamples * M_PI * info->volume * M_PI * info->volume); 
+        e_rec3 += q[ci]*q[ci]*q[ci]*q[ci]*norm2(tmpvec2) / ( xtot * M_PI * info->volume * M_PI * info->volume);
         if (MASTER(cr)){
             fprintf(stderr, "\rCalculating reciprocal error part 2 ... %3.0f%%",
                     100.0*(i+1)/stoplocal);
 
         }
-       
     }
 
     if (MASTER(cr))
@@ -754,21 +745,6 @@ static real estimate_reciprocal(
                 cr->nodeid, startlocal, stoplocal, e_rec3);
     }
 #endif
-   
-
-/*
-#ifdef GMX_MPI
-    MPI_Barrier(MPI_COMM_WORLD);
-#endif
-  */ 
-
-#ifdef TAKETIME
-    if (MASTER(cr))
-    {
-        t2= MPI_Wtime() - t0;
-        fprintf(fp_out, "barrier   : %lf s\n", t2-t1);
-    }
-#endif
 
     if (PAR(cr))
     {
@@ -777,10 +753,6 @@ static real estimate_reciprocal(
         gmx_sum(1,&e_rec3,cr);
     }
     
-#ifdef TAKETIME
-    if (MASTER(cr))
-        fprintf(fp_out, "final reduce : %lf s\n", MPI_Wtime() - t0-t2);
-#endif
     /* e_rec1*=8.0 * q2_all / info->volume / info->volume / nr ;
        e_rec2*=  q2_all / M_PI / M_PI / info->volume / info->volume / nr ;
        e_rec3/= M_PI * M_PI * info->volume * info->volume * nr ; 
@@ -915,12 +887,11 @@ static void bcast_info(t_inputinfo *info, t_commrec *cr)
  * b) a total charge of zero.
  */
 static void estimate_PME_error(t_inputinfo *info, t_state *state, 
-        gmx_mtop_t *mtop, FILE *fp_out, t_commrec *cr)
+        gmx_mtop_t *mtop, FILE *fp_out, gmx_bool bVerbose, unsigned int seed,
+        t_commrec *cr)
 {
     rvec *x=NULL; /* The coordinates */
     real *q=NULL; /* The charges     */
-    real q2all=0.0;
-    real q2allnr=0.0;
     real  edir=0.0; /* real space error */
     real  erec=0.0; /* reciprocal space error */
     real  derr=0.0; /* difference of real and reciprocal space error */
@@ -928,6 +899,8 @@ static void estimate_PME_error(t_inputinfo *info, t_state *state,
     real  beta=0.0; /* splitting parameter beta */
     real  beta0=0.0; /* splitting parameter beta */
     int ncharges; /* The number of atoms with charges */
+    int nsamples; /* The number of samples used for the calculation of the
+                   * self-energy error term */
     int i=0;
     
     if (MASTER(cr))
@@ -960,7 +933,8 @@ static void estimate_PME_error(t_inputinfo *info, t_state *state,
     info->e_dir[0] = estimate_direct(info);
 
     /* Calculate reciprocal space error */
-    info->e_rec[0] = estimate_reciprocal(info, x, q, ncharges, fp_out, cr);
+    info->e_rec[0] = estimate_reciprocal(info, x, q, ncharges, fp_out, bVerbose,
+                                         seed, &nsamples, cr);
 
     if (PAR(cr))
         bcast_info(info, cr);
@@ -969,6 +943,7 @@ static void estimate_PME_error(t_inputinfo *info, t_state *state,
     {
         fprintf(fp_out, "Direct space error est. : %10.3e kJ/(mol*nm)\n", info->e_dir[0]);
         fprintf(fp_out, "Reciprocal sp. err. est.: %10.3e kJ/(mol*nm)\n", info->e_rec[0]);
+        fprintf(fp_out, "Self-energy error term was estimated using %d samples\n", nsamples);
         fflush(fp_out);
         fprintf(stderr, "Direct space error est. : %10.3e kJ/(mol*nm)\n", info->e_dir[0]);
         fprintf(stderr, "Reciprocal sp. err. est.: %10.3e kJ/(mol*nm)\n", info->e_rec[0]);
@@ -989,7 +964,8 @@ static void estimate_PME_error(t_inputinfo *info, t_state *state,
         else
             info->ewald_beta[0]-=0.1;
         info->e_dir[0] = estimate_direct(info);
-        info->e_rec[0] = estimate_reciprocal(info, x, q, ncharges, fp_out, cr);
+        info->e_rec[0] = estimate_reciprocal(info, x, q, ncharges, fp_out, bVerbose,
+                                             seed, &nsamples, cr);
 
         if (PAR(cr))
             bcast_info(info, cr);
@@ -1008,7 +984,8 @@ static void estimate_PME_error(t_inputinfo *info, t_state *state,
             derr0=derr;
 
             info->e_dir[0] = estimate_direct(info);
-            info->e_rec[0] = estimate_reciprocal(info, x, q, ncharges, fp_out, cr);
+            info->e_rec[0] = estimate_reciprocal(info, x, q, ncharges, fp_out, bVerbose,
+                                                 seed, &nsamples, cr);
 
             if (PAR(cr))
                 bcast_info(info, cr);
@@ -1047,29 +1024,23 @@ static void estimate_PME_error(t_inputinfo *info, t_state *state,
 
 }
 
-#define BENCHSTEPS (1000)
 
 int gmx_pme_error(int argc,char *argv[])
 {
     const char *desc[] = {
             "g_pme_error estimates the error of the electrostatic forces",
-            "if using the SPME algorithm. The flag [TT]-tune[tt] will determine",
+            "if using the sPME algorithm. The flag [TT]-tune[tt] will determine",
             "the splitting parameter such that the error is equally",
             "distributed over the real and reciprocal space part.",
-            "As a part of the error stems from self interaction of the particles "
-            "and is computationally very demanding a good a approximation is possible",
-            "if just a fraction of the particles is used to calculate the average",
-            "of this error by using the flag [TT]-self[tt].[PAR]",
+            "The part of the error that stems from self interaction of the particles "
+            "is computationally demanding. However, a good a approximation is to",
+            "just use a fraction of the particles for this term which can be",
+            "indicated by the flag [TT]-self[tt].[PAR]",
     };
 
-    int        repeats=2;
-    real       fs=0.0;             /* 0 indicates: not set by the user */
-
+    real        fs=0.0;             /* 0 indicates: not set by the user */
     real        user_beta=-1.0;
-    real        fracself=-1.0;
-    
-    
-    t_perf      **perfdata;
+    real        fracself=1.0;
     t_inputinfo info;
     t_state     state;     /* The state from the tpr input file */
     gmx_mtop_t  mtop;      /* The topology from the tpr input file */
@@ -1078,28 +1049,29 @@ int gmx_pme_error(int argc,char *argv[])
     t_commrec   *cr;
     unsigned long PCA_Flags;
     gmx_bool        bTUNE=FALSE;
+    gmx_bool    bVerbose=FALSE;
+    int         seed=0;
 
 
     static t_filenm fnm[] = {
-      /* g_tune_pme */
       { efTPX, "-s",     NULL,    ffREAD },
       { efOUT, "-o",    "error",  ffWRITE },
       { efTPX, "-so",   "tuned",  ffOPTWR }
     };
 
-
     output_env_t oenv=NULL;
 
     t_pargs pa[] = {
-      /***********************/
-      /* g_tune_pme options: */
-      /***********************/
         { "-beta",     FALSE, etREAL, {&user_beta},
             "If positive, overwrite ewald_beta from tpr file with this value" },
         { "-tune",     FALSE, etBOOL, {&bTUNE},
-            "If flag is set the splitting parameter will be tuned to distribute the error equally in real and rec. space" },
+            "Tune the splitting parameter such that the error is equally distributed between real and reciprocal space" },
         { "-self",     FALSE, etREAL, {&fracself},
-            "If positive, determine selfinteraction error just over this fraction (default=1.0)" }
+            "If between 0.0 and 1.0, determine self interaction error from just this fraction of the charged particles" },
+        { "-seed",     FALSE, etINT,  {&seed},
+          "Random number seed used for Monte Carlo algorithm when -self is set to a value between 0.0 and 1.0" },
+        { "-v",        FALSE, etBOOL, {&bVerbose},
+            "Be loud and noisy" }
     };
 
     
@@ -1107,6 +1079,10 @@ int gmx_pme_error(int argc,char *argv[])
     
     cr = init_par(&argc,&argv);
     
+#ifdef GMX_MPI
+    MPI_Barrier(MPI_COMM_WORLD);
+#endif
+
     if (MASTER(cr))
       CopyRight(stderr,argv[0]);
     
@@ -1162,13 +1138,17 @@ int gmx_pme_error(int argc,char *argv[])
     if (PAR(cr))
         bcast_info(&info, cr);
     
-    /* Get an error estimate of the input tpr file */
-    estimate_PME_error(&info, &state, &mtop, fp, cr);
+    /* Get an error estimate of the input tpr file and do some tuning if requested */
+    estimate_PME_error(&info, &state, &mtop, fp, bVerbose, seed, cr);
     
     if (MASTER(cr))
     {
-        ir->ewald_rtol=info.ewald_rtol[0];
-        write_tpx_state(opt2fn("-so",NFILE,fnm),ir,&state,&mtop);
+        /* Write out optimized tpr file if requested */
+        if ( opt2bSet("-so",NFILE,fnm) || bTUNE )
+        {
+            ir->ewald_rtol=info.ewald_rtol[0];
+            write_tpx_state(opt2fn("-so",NFILE,fnm),ir,&state,&mtop);
+        }
         please_cite(fp,"Wang2010");
         fclose(fp);
     }
index fee083580bab2bfe78ede097db4de888ad5c10dc..2da5f336ecda625687da11fd273dd85d8fbb8d3c 100644 (file)
@@ -454,11 +454,6 @@ static void write_pdb_bfac(const char *fname,const char *xname,
                 onedim = -1;
             }
         }
-        scale = 1.0/nfr_x;
-        for(i=0; i<isize; i++)
-        {
-            svmul(scale,x[index[i]],x[index[i]]);
-        }
         scale = 1.0/nfr_v;
         for(i=0; i<isize; i++)
         {
@@ -468,7 +463,7 @@ static void write_pdb_bfac(const char *fname,const char *xname,
         fp=xvgropen(xname,title,"Atom","",oenv);
         for(i=0; i<isize; i++)
         {
-            fprintf(fp,"%-5d  %10.3f  %10.3f  %10.3f\n",i,
+            fprintf(fp,"%-5d  %10.3f  %10.3f  %10.3f\n",1+i,
                     sum[index[i]][XX],sum[index[i]][YY],sum[index[i]][ZZ]);
         }
         ffclose(fp);
@@ -507,7 +502,7 @@ static void write_pdb_bfac(const char *fname,const char *xname,
         }
         
         printf("Maximum %s is %g on atom %d %s, res. %s %d\n",
-               title,sqrt(max)/nfr_v,maxi+1,*(atoms->atomname[maxi]),
+               title,sqrt(max),maxi+1,*(atoms->atomname[maxi]),
                *(atoms->resinfo[atoms->atom[maxi].resind].name),
                atoms->resinfo[atoms->atom[maxi].resind].nr);
         
@@ -613,9 +608,10 @@ int gmx_traj(int argc,char *argv[])
         "This implies [TT]-com[tt].[PAR]",
         "Options [TT]-cv[tt] and [TT]-cf[tt] write the average velocities",
         "and average forces as temperature factors to a pdb file with",
-        "the average coordinates. The temperature factors are scaled such",
-        "that the maximum is 10. The scaling can be changed with the option",
-        "[TT]-scale[tt]. To get the velocities or forces of one",
+        "the average coordinates or the coordinates at [TT]-ctime[tt].",
+        "The temperature factors are scaled such that the maximum is 10.",
+        "The scaling can be changed with the option [TT]-scale[tt].",
+        "To get the velocities or forces of one",
         "frame set both [TT]-b[tt] and [TT]-e[tt] to the time of",
         "desired frame. When averaging over frames you might need to use",
         "the [TT]-nojump[tt] option to obtain the correct average coordinates.",
@@ -629,7 +625,7 @@ int gmx_traj(int argc,char *argv[])
     static gmx_bool bMol=FALSE,bCom=FALSE,bPBC=TRUE,bNoJump=FALSE;
     static gmx_bool bX=TRUE,bY=TRUE,bZ=TRUE,bNorm=FALSE,bFP=FALSE;
     static int  ngroups=1;
-    static real scale=0,binwidth=1;
+    static real ctime=-1,scale=0,binwidth=1;
     t_pargs pa[] = {
         { "-com", FALSE, etBOOL, {&bCom},
           "Plot data for the com of each group" },
@@ -653,6 +649,8 @@ int gmx_traj(int argc,char *argv[])
           "Full precision output" },
         { "-bin", FALSE, etREAL, {&binwidth},
           "Binwidth for velocity histogram (nm/ps)" },
+        { "-ctime", FALSE, etREAL, {&ctime},
+          "Use frame at this time for x in -cv and -cf instead of the average x" },
         { "-scale", FALSE, etREAL, {&scale},
           "Scale factor for pdb output, 0 is autoscale" }
     };
@@ -666,7 +664,7 @@ int gmx_traj(int argc,char *argv[])
     t_trxframe fr,frout;
     int        flags,nvhisto=0,*vhisto=NULL;
     rvec       *xtop,*xp=NULL;
-    rvec       *sumxv=NULL,*sumv=NULL,*sumxf=NULL,*sumf=NULL;
+    rvec       *sumx=NULL,*sumv=NULL,*sumf=NULL;
     matrix     topbox;
     t_trxstatus *status;
     t_trxstatus *status_out=NULL;
@@ -902,14 +900,16 @@ int gmx_traj(int argc,char *argv[])
 
     read_first_frame(oenv,&status,ftp2fn(efTRX,NFILE,fnm),&fr,flags);
 
+    if (bCV || bCF)
+    {
+        snew(sumx,fr.natoms);
+    }
     if (bCV)
     {
-        snew(sumxv,fr.natoms);
         snew(sumv,fr.natoms);
     }
     if (bCF)
     {
-        snew(sumxf,fr.natoms);
         snew(sumf,fr.natoms);
     }
     nr_xfr = 0;
@@ -1008,46 +1008,39 @@ int gmx_traj(int argc,char *argv[])
             }
             fprintf(outekr,"\n");
         }
-        if (bCV)
+        if ((bCV || bCF) && fr.bX &&
+            (ctime < 0 || (fr.time >= ctime*0.999999 &&
+                           fr.time <= ctime*1.000001)))
         {
-            if (fr.bX)
-            {
-                for(i=0; i<fr.natoms; i++)
-                {
-                    rvec_inc(sumxv[i],fr.x[i]);
-                }
-                nr_xfr++;
-            }
-            if (fr.bV)
+            for(i=0; i<fr.natoms; i++)
             {
-                for(i=0; i<fr.natoms; i++)
-                    rvec_inc(sumv[i],fr.v[i]);
-                nr_vfr++;
+                rvec_inc(sumx[i],fr.x[i]);
             }
+            nr_xfr++;
         }
-        if (bCF)
+        if (bCV && fr.bV)
         {
-            if (fr.bX)
+            for(i=0; i<fr.natoms; i++)
             {
-                for(i=0; i<fr.natoms; i++)
-                {
-                    rvec_inc(sumxf[i],fr.x[i]);
-                }
-                nr_xfr++;
+                rvec_inc(sumv[i],fr.v[i]);
             }
-            if (fr.bF)
+            nr_vfr++;
+        }
+        if (bCF && fr.bF)
+        {
+            for(i=0; i<fr.natoms; i++)
             {
-                for(i=0; i<fr.natoms; i++)
-                {
-                    rvec_inc(sumf[i],fr.f[i]);
-                }
-                nr_ffr++;
+                rvec_inc(sumf[i],fr.f[i]);
             }
+            nr_ffr++;
         }
         
     } while(read_next_frame(oenv,status,&fr));
     
-    gmx_rmpbc_done(gpbc);
+    if (gpbc != NULL)
+    {
+        gmx_rmpbc_done(gpbc);
+    }
     
     /* clean up a bit */
     close_trj(status);
@@ -1066,24 +1059,37 @@ int gmx_traj(int argc,char *argv[])
         print_histo(opt2fn("-vd",NFILE,fnm),nvhisto,vhisto,binwidth,oenv);
     }
     
-    if ((bCV || bCF) && (nr_vfr>1 || nr_ffr>1) && !bNoJump)
+    if (bCV || bCF)
     {
-        fprintf(stderr,"WARNING: More than one frame was used for option -cv or -cf\n"
-                "If atoms jump across the box you should use the -nojump option\n");
+        if (nr_xfr > 1)
+        {
+            if (ePBC != epbcNONE && !bNoJump)
+            {
+                fprintf(stderr,"\nWARNING: More than one frame was used for option -cv or -cf\n"
+                        "If atoms jump across the box you should use the -nojump or -ctime option\n\n");
+            }
+            for(i=0; i<isize[0]; i++)
+            {
+                svmul(1.0/nr_xfr,sumx[index[0][i]],sumx[index[0][i]]);
+            }
+        }
+        else if (nr_xfr == 0)
+        {
+            fprintf(stderr,"\nWARNING: No coordinate frames found for option -cv or -cf\n\n");
+        }
     }
-    
     if (bCV)
     {
         write_pdb_bfac(opt2fn("-cv",NFILE,fnm),
                        opt2fn("-av",NFILE,fnm),"average velocity",&(top.atoms),
-                       ePBC,topbox,isize[0],index[0],nr_xfr,sumxv,
+                       ePBC,topbox,isize[0],index[0],nr_xfr,sumx,
                        nr_vfr,sumv,bDim,scale,oenv);
     }
     if (bCF)
     {
         write_pdb_bfac(opt2fn("-cf",NFILE,fnm),
                        opt2fn("-af",NFILE,fnm),"average force",&(top.atoms),
-                       ePBC,topbox,isize[0],index[0],nr_xfr,sumxf,
+                       ePBC,topbox,isize[0],index[0],nr_xfr,sumx,
                        nr_ffr,sumf,bDim,scale,oenv);
     }
 
index 4714d7c73fb90ee4d873d46fe98a09671238f975..12d747cdd8129702b8b57b3372c9a84ad007819e 100644 (file)
 #include <config.h>
 #endif
 
+
+#include <time.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+
+
 #include "statutil.h"
 #include "typedefs.h"
 #include "smalloc.h"