From c5cb103584f8046d87ec0b72417f51c57f2e32fc Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Tue, 12 Feb 2013 14:01:14 -0500 Subject: [PATCH] Code beautification with uncrustify Uses same unrustify config and version as release-4-6 branch. version: https://github.com/rolandschulz/uncrustify/tree/gromacs Final version and config is still under dicussion (I4ef0b69eed4). Final version will not change signficant from this. This commit allows to merge 4.6 into master. Command: uncrustify --replace -c admin/uncrustify.cfg `find src -not -name 'nb_kernel_Elec*' -not -path '*/external/*' -not -path '*src/gromacs/linearalgebra/gmx_blas/*' -not -path '*src/gromacs/linearalgebra/gmx_lapack/*' -not -path 'src/contrib/*' -not -path '*nb_kernel_adress_c*' -not -name 'parser.*' -not -name scanner.cpp -not -name scanner_flex.h \( -name '*.c' -o -name '*.cc' -o -name '*.h' -o -name '*.cpp' \) Change-Id: If3e0768cd09dafd23e38a7a3fff06e9e804891e1 --- admin/uncrustify.cfg | 1577 ++++ src/gromacs/analysisdata/abstractdata.cpp | 8 +- src/gromacs/analysisdata/abstractdata.h | 4 +- src/gromacs/analysisdata/analysisdata.cpp | 4 +- src/gromacs/analysisdata/analysisdata.h | 2 +- src/gromacs/analysisdata/arraydata.cpp | 12 +- src/gromacs/analysisdata/arraydata.h | 10 +- src/gromacs/analysisdata/dataframe.cpp | 8 +- src/gromacs/analysisdata/dataframe.h | 10 +- src/gromacs/analysisdata/datastorage.cpp | 18 +- src/gromacs/analysisdata/datastorage.h | 4 +- src/gromacs/analysisdata/modules/average.cpp | 4 +- src/gromacs/analysisdata/modules/average.h | 4 +- .../analysisdata/modules/displacement.cpp | 10 +- .../analysisdata/modules/displacement.h | 2 +- .../analysisdata/modules/histogram.cpp | 14 +- src/gromacs/analysisdata/modules/histogram.h | 12 +- src/gromacs/analysisdata/modules/plot.cpp | 34 +- src/gromacs/analysisdata/modules/plot.h | 8 +- .../analysisdata/tests/analysisdata.cpp | 20 +- src/gromacs/analysisdata/tests/arraydata.cpp | 4 +- src/gromacs/analysisdata/tests/average.cpp | 20 +- src/gromacs/analysisdata/tests/histogram.cpp | 44 +- src/gromacs/commandline/cmdlinehelpwriter.cpp | 42 +- .../commandline/cmdlinemodulemanager.cpp | 26 +- .../commandline/cmdlinemodulemanager.h | 2 +- src/gromacs/commandline/cmdlineparser.cpp | 6 +- .../commandline/tests/cmdlinehelpwriter.cpp | 102 +- .../tests/cmdlinemodulemanager.cpp | 24 +- .../commandline/tests/cmdlineparser.cpp | 4 +- src/gromacs/gmxlib/3dview.c | 453 +- src/gromacs/gmxlib/atomprop.c | 554 +- src/gromacs/gmxlib/bfunc.h | 56 - src/gromacs/gmxlib/bondfree.c | 5859 ++++++------ src/gromacs/gmxlib/calcgrid.c | 54 +- src/gromacs/gmxlib/calch.c | 415 +- src/gromacs/gmxlib/chargegroup.c | 199 +- src/gromacs/gmxlib/checkpoint.c | 1846 ++-- src/gromacs/gmxlib/cinvsqrtdata.c | 1189 ++- src/gromacs/gmxlib/confio.c | 2838 +++--- src/gromacs/gmxlib/copyrite.c | 1047 ++- src/gromacs/gmxlib/crecipdata.c | 1106 +-- src/gromacs/gmxlib/disre.c | 322 +- src/gromacs/gmxlib/dlb.h | 22 +- src/gromacs/gmxlib/do_fit.c | 419 +- src/gromacs/gmxlib/enxio.c | 854 +- src/gromacs/gmxlib/ewald_util.c | 734 +- src/gromacs/gmxlib/filenm.c | 592 +- src/gromacs/gmxlib/futil.c | 805 +- src/gromacs/gmxlib/gbutil.c | 450 +- src/gromacs/gmxlib/gmx_cpuid.c | 439 +- src/gromacs/gmxlib/gmx_cyclecounter.c | 138 +- src/gromacs/gmxlib/gmx_detect_hardware.c | 66 +- src/gromacs/gmxlib/gmx_fatal.c | 675 +- src/gromacs/gmxlib/gmx_omp.c | 10 +- src/gromacs/gmxlib/gmx_omp_nthreads.c | 56 +- src/gromacs/gmxlib/gmx_random.c | 306 +- src/gromacs/gmxlib/gmx_random_gausstable.h | 8198 ++++++++--------- src/gromacs/gmxlib/gmx_sort.c | 165 +- src/gromacs/gmxlib/gmx_system_xdr.c | 848 +- src/gromacs/gmxlib/gmx_thread_affinity.c | 46 +- src/gromacs/gmxlib/gmxcpp.c | 1172 +-- src/gromacs/gmxlib/gmxfio.c | 413 +- src/gromacs/gmxlib/gmxfio_asc.c | 368 +- src/gromacs/gmxlib/gmxfio_bin.c | 214 +- src/gromacs/gmxlib/gmxfio_int.h | 93 +- src/gromacs/gmxlib/gmxfio_rw.c | 619 +- src/gromacs/gmxlib/gmxfio_xdr.c | 410 +- .../gmxlib/gpu_utils/memtestG80_core.h | 136 +- src/gromacs/gmxlib/ifunc.c | 256 +- src/gromacs/gmxlib/index.c | 1622 ++-- src/gromacs/gmxlib/inputrec.c | 94 +- src/gromacs/gmxlib/invblock.c | 105 +- src/gromacs/gmxlib/invsqrt_test.c | 43 +- src/gromacs/gmxlib/libxdrf.c | 1791 ++-- src/gromacs/gmxlib/main.c | 500 +- src/gromacs/gmxlib/maths.c | 894 +- src/gromacs/gmxlib/matio.c | 1822 ++-- src/gromacs/gmxlib/md5.c | 302 +- src/gromacs/gmxlib/md_logging.c | 42 +- src/gromacs/gmxlib/minvert.h | 28 +- src/gromacs/gmxlib/mshift.c | 1642 ++-- src/gromacs/gmxlib/mtop_util.c | 544 +- src/gromacs/gmxlib/mvdata.c | 1184 +-- src/gromacs/gmxlib/names.c | 165 +- src/gromacs/gmxlib/network.c | 575 +- src/gromacs/gmxlib/nonbonded/nb_free_energy.c | 323 +- src/gromacs/gmxlib/nonbonded/nb_free_energy.h | 35 +- src/gromacs/gmxlib/nonbonded/nb_generic.c | 152 +- src/gromacs/gmxlib/nonbonded/nb_generic.h | 19 +- .../gmxlib/nonbonded/nb_generic_adress.c | 199 +- .../gmxlib/nonbonded/nb_generic_adress.h | 31 +- src/gromacs/gmxlib/nonbonded/nb_generic_cg.c | 555 +- src/gromacs/gmxlib/nonbonded/nb_generic_cg.h | 19 +- src/gromacs/gmxlib/nonbonded/nb_kernel.c | 90 +- src/gromacs/gmxlib/nonbonded/nb_kernel.h | 20 +- .../kernelutil_x86_avx_128_fma_double.h | 894 +- .../nb_kernel_avx_128_fma_double.c | 4 +- .../nb_kernel_avx_128_fma_double.h | 4 +- .../kernelutil_x86_avx_128_fma_single.h | 968 +- .../nb_kernel_avx_128_fma_single.c | 4 +- .../nb_kernel_avx_128_fma_single.h | 4 +- .../kernelutil_x86_avx_256_double.h | 1342 +-- .../nb_kernel_avx_256_double.c | 4 +- .../nb_kernel_avx_256_double.h | 4 +- .../kernelutil_x86_avx_256_single.h | 1962 ++-- .../nb_kernel_avx_256_single.c | 4 +- .../nb_kernel_avx_256_single.h | 4 +- .../nb_kernel_c/nb_kernel_allvsall.c | 364 +- .../nb_kernel_c/nb_kernel_allvsallgb.c | 456 +- .../nonbonded/nb_kernel_c/nb_kernel_c.c | 4 +- .../nonbonded/nb_kernel_c/nb_kernel_c.h | 4 +- .../kernelutil_x86_sse2_double.h | 966 +- .../nb_kernel_sse2_double.c | 4 +- .../nb_kernel_sse2_double.h | 4 +- .../kernelutil_x86_sse2_single.h | 988 +- .../nb_kernel_sse2_single.c | 4 +- .../nb_kernel_sse2_single.h | 4 +- .../kernelutil_x86_sse4_1_double.h | 906 +- .../nb_kernel_sse4_1_double.c | 4 +- .../nb_kernel_sse4_1_double.h | 4 +- .../kernelutil_x86_sse4_1_single.h | 1002 +- .../nb_kernel_sse4_1_single.c | 4 +- .../nb_kernel_sse4_1_single.h | 4 +- src/gromacs/gmxlib/nonbonded/nonbonded.c | 311 +- src/gromacs/gmxlib/nrama.c | 382 +- src/gromacs/gmxlib/nrjac.c | 309 +- src/gromacs/gmxlib/nrnb.c | 547 +- src/gromacs/gmxlib/oenv.cpp | 76 +- src/gromacs/gmxlib/orires.c | 482 +- src/gromacs/gmxlib/pargs.c | 616 +- src/gromacs/gmxlib/pbc.c | 1839 ++-- src/gromacs/gmxlib/pdbio.c | 1481 +-- src/gromacs/gmxlib/physics.c | 144 +- src/gromacs/gmxlib/physics_test.c | 23 +- src/gromacs/gmxlib/princ.c | 425 +- src/gromacs/gmxlib/rando.c | 79 +- src/gromacs/gmxlib/random.c | 260 +- src/gromacs/gmxlib/rbin.c | 267 +- src/gromacs/gmxlib/readinp.c | 784 +- src/gromacs/gmxlib/rmpbc.c | 115 +- src/gromacs/gmxlib/sfactor.c | 836 +- src/gromacs/gmxlib/shift_util.c | 109 +- src/gromacs/gmxlib/sighandler.c | 79 +- src/gromacs/gmxlib/smalloc.c | 409 +- src/gromacs/gmxlib/sortwater.c | 586 +- src/gromacs/gmxlib/splitter.c | 1858 ++-- .../gmxlib/statistics/gmx_statistics.c | 674 +- .../gmxlib/statistics/gmx_statistics_test.c | 243 +- src/gromacs/gmxlib/statistics/histogram.c | 14 +- src/gromacs/gmxlib/statutil.cpp | 715 +- src/gromacs/gmxlib/strdb.c | 310 +- src/gromacs/gmxlib/string2.c | 708 +- src/gromacs/gmxlib/symtab.c | 337 +- src/gromacs/gmxlib/tcontrol.c | 50 +- src/gromacs/gmxlib/thread_mpi/alltoall.c | 206 +- src/gromacs/gmxlib/thread_mpi/barrier.c | 72 +- src/gromacs/gmxlib/thread_mpi/bcast.c | 87 +- src/gromacs/gmxlib/thread_mpi/collective.c | 286 +- src/gromacs/gmxlib/thread_mpi/collective.h | 75 +- src/gromacs/gmxlib/thread_mpi/comm.c | 420 +- src/gromacs/gmxlib/thread_mpi/errhandler.c | 91 +- src/gromacs/gmxlib/thread_mpi/event.c | 72 +- src/gromacs/gmxlib/thread_mpi/gather.c | 184 +- src/gromacs/gmxlib/thread_mpi/group.c | 123 +- src/gromacs/gmxlib/thread_mpi/impl.h | 410 +- src/gromacs/gmxlib/thread_mpi/list.c | 82 +- src/gromacs/gmxlib/thread_mpi/lock.c | 56 +- src/gromacs/gmxlib/thread_mpi/numa_malloc.c | 263 +- src/gromacs/gmxlib/thread_mpi/once.c | 128 +- src/gromacs/gmxlib/thread_mpi/p2p.h | 62 +- src/gromacs/gmxlib/thread_mpi/p2p_buffer.c | 55 +- src/gromacs/gmxlib/thread_mpi/p2p_protocol.c | 820 +- src/gromacs/gmxlib/thread_mpi/p2p_send_recv.c | 205 +- src/gromacs/gmxlib/thread_mpi/p2p_wait.c | 282 +- src/gromacs/gmxlib/thread_mpi/profile.c | 228 +- src/gromacs/gmxlib/thread_mpi/profile.h | 172 +- src/gromacs/gmxlib/thread_mpi/pthreads.c | 404 +- src/gromacs/gmxlib/thread_mpi/pthreads.h | 63 +- src/gromacs/gmxlib/thread_mpi/reduce.c | 218 +- src/gromacs/gmxlib/thread_mpi/reduce_fast.c | 71 +- src/gromacs/gmxlib/thread_mpi/scan.c | 85 +- src/gromacs/gmxlib/thread_mpi/scatter.c | 209 +- src/gromacs/gmxlib/thread_mpi/settings.h | 90 +- .../gmxlib/thread_mpi/system_error.cpp | 57 +- src/gromacs/gmxlib/thread_mpi/tmpi_init.c | 391 +- src/gromacs/gmxlib/thread_mpi/tmpi_malloc.c | 60 +- src/gromacs/gmxlib/thread_mpi/tmpi_ops.h | 187 +- src/gromacs/gmxlib/thread_mpi/topology.c | 219 +- src/gromacs/gmxlib/thread_mpi/type.c | 173 +- src/gromacs/gmxlib/thread_mpi/winthreads.c | 716 +- src/gromacs/gmxlib/thread_mpi/winthreads.h | 87 +- src/gromacs/gmxlib/topsort.c | 224 +- src/gromacs/gmxlib/tpxio.c | 5603 ++++++----- src/gromacs/gmxlib/trajana/displacement.c | 10 +- src/gromacs/gmxlib/trnio.c | 429 +- src/gromacs/gmxlib/trxio.c | 1635 ++-- src/gromacs/gmxlib/txtdump.c | 2531 ++--- src/gromacs/gmxlib/typedefs.c | 1048 ++- src/gromacs/gmxlib/viewit.c | 162 +- src/gromacs/gmxlib/vmdio.c | 243 +- src/gromacs/gmxlib/vmdio.h | 16 +- src/gromacs/gmxlib/warninp.c | 124 +- src/gromacs/gmxlib/wgms.c | 93 +- src/gromacs/gmxlib/wman.cpp | 2402 ++--- src/gromacs/gmxlib/writeps.c | 428 +- src/gromacs/gmxlib/xdrd.c | 148 +- src/gromacs/gmxlib/xtcio.c | 343 +- src/gromacs/gmxlib/xvgr.c | 978 +- src/gromacs/gmxpreprocess/add_par.c | 374 +- src/gromacs/gmxpreprocess/add_par.h | 44 +- src/gromacs/gmxpreprocess/calc_verletbuf.c | 348 +- src/gromacs/gmxpreprocess/calc_verletbuf.h | 32 +- src/gromacs/gmxpreprocess/compute_io.c | 70 +- src/gromacs/gmxpreprocess/compute_io.h | 22 +- src/gromacs/gmxpreprocess/fflibutil.c | 170 +- src/gromacs/gmxpreprocess/fflibutil.h | 30 +- src/gromacs/gmxpreprocess/gen_ad.c | 1434 +-- src/gromacs/gmxpreprocess/gen_vsite.c | 3798 ++++---- src/gromacs/gmxpreprocess/gen_vsite.h | 30 +- src/gromacs/gmxpreprocess/genhydro.c | 1438 +-- src/gromacs/gmxpreprocess/genhydro.h | 45 +- src/gromacs/gmxpreprocess/gpp_atomtype.c | 884 +- src/gromacs/gmxpreprocess/gpp_bond_atomtype.c | 94 +- src/gromacs/gmxpreprocess/gpp_bond_atomtype.h | 32 +- src/gromacs/gmxpreprocess/h_db.c | 302 +- src/gromacs/gmxpreprocess/h_db.h | 32 +- src/gromacs/gmxpreprocess/hackblock.c | 452 +- src/gromacs/gmxpreprocess/pdb2top.c | 1776 ++-- src/gromacs/gmxpreprocess/pgutil.c | 132 +- src/gromacs/gmxpreprocess/pgutil.h | 26 +- src/gromacs/gmxpreprocess/readadress.c | 218 +- src/gromacs/gmxpreprocess/readir.c | 5736 ++++++------ src/gromacs/gmxpreprocess/readir.h | 136 +- src/gromacs/gmxpreprocess/readpull.c | 626 +- src/gromacs/gmxpreprocess/readrot.c | 272 +- src/gromacs/gmxpreprocess/resall.c | 806 +- src/gromacs/gmxpreprocess/ter_db.c | 771 +- src/gromacs/gmxpreprocess/ter_db.h | 28 +- src/gromacs/gmxpreprocess/topdirs.c | 664 +- src/gromacs/gmxpreprocess/topdirs.h | 24 +- src/gromacs/gmxpreprocess/topexcl.c | 486 +- src/gromacs/gmxpreprocess/topexcl.h | 38 +- src/gromacs/gmxpreprocess/topio.c | 2243 ++--- src/gromacs/gmxpreprocess/topio.h | 56 +- src/gromacs/gmxpreprocess/toppush.c | 4515 ++++----- src/gromacs/gmxpreprocess/toppush.h | 138 +- src/gromacs/gmxpreprocess/topshake.c | 338 +- src/gromacs/gmxpreprocess/topshake.h | 20 +- src/gromacs/gmxpreprocess/toputil.c | 782 +- src/gromacs/gmxpreprocess/vsite_parm.c | 2513 ++--- src/gromacs/gmxpreprocess/vsite_parm.h | 20 +- src/gromacs/legacyheaders/3dview.h | 49 +- src/gromacs/legacyheaders/atomprop.h | 30 +- src/gromacs/legacyheaders/bondf.h | 118 +- src/gromacs/legacyheaders/calcgrid.h | 20 +- src/gromacs/legacyheaders/calch.h | 24 +- src/gromacs/legacyheaders/calcmu.h | 24 +- src/gromacs/legacyheaders/chargegroup.h | 60 +- src/gromacs/legacyheaders/checkpoint.h | 38 +- src/gromacs/legacyheaders/confio.h | 84 +- src/gromacs/legacyheaders/constr.h | 198 +- src/gromacs/legacyheaders/copyrite.h | 46 +- src/gromacs/legacyheaders/coulomb.h | 58 +- src/gromacs/legacyheaders/disre.h | 34 +- src/gromacs/legacyheaders/do_fit.h | 54 +- src/gromacs/legacyheaders/domdec.h | 210 +- src/gromacs/legacyheaders/domdec_network.h | 52 +- src/gromacs/legacyheaders/ebin.h | 52 +- src/gromacs/legacyheaders/edsam.h | 42 +- src/gromacs/legacyheaders/enxio.h | 322 +- src/gromacs/legacyheaders/filenm.h | 78 +- src/gromacs/legacyheaders/force.h | 294 +- src/gromacs/legacyheaders/futil.h | 70 +- src/gromacs/legacyheaders/gbutil.h | 40 +- src/gromacs/legacyheaders/gen_ad.h | 18 +- src/gromacs/legacyheaders/genborn.h | 49 +- src/gromacs/legacyheaders/gmx_ana.h | 356 +- src/gromacs/legacyheaders/gmx_avx_double.h | 22 +- src/gromacs/legacyheaders/gmx_avx_single.h | 24 +- src/gromacs/legacyheaders/gmx_cpuid.h | 8 +- src/gromacs/legacyheaders/gmx_cyclecounter.h | 315 +- .../legacyheaders/gmx_detect_hardware.h | 6 +- src/gromacs/legacyheaders/gmx_fatal.h | 180 +- .../legacyheaders/gmx_fatal_collective.h | 28 +- src/gromacs/legacyheaders/gmx_fft.h | 98 +- src/gromacs/legacyheaders/gmx_ga2la.h | 82 +- src/gromacs/legacyheaders/gmx_hash.h | 68 +- .../gmx_math_x86_avx_128_fma_double.h | 1012 +- .../gmx_math_x86_avx_128_fma_single.h | 842 +- .../gmx_math_x86_avx_256_double.h | 3126 +++---- .../gmx_math_x86_avx_256_single.h | 2416 ++--- .../legacyheaders/gmx_math_x86_sse2_double.h | 1384 +-- .../legacyheaders/gmx_math_x86_sse2_single.h | 1070 +-- .../gmx_math_x86_sse4_1_double.h | 1392 +-- .../gmx_math_x86_sse4_1_single.h | 1084 +-- src/gromacs/legacyheaders/gmx_omp_nthreads.h | 6 +- .../legacyheaders/gmx_parallel_3dfft.h | 27 +- src/gromacs/legacyheaders/gmx_random.h | 81 +- src/gromacs/legacyheaders/gmx_simd_macros.h | 8 +- src/gromacs/legacyheaders/gmx_sort.h | 4 +- src/gromacs/legacyheaders/gmx_statistics.h | 102 +- src/gromacs/legacyheaders/gmx_system_xdr.h | 155 +- .../legacyheaders/gmx_thread_affinity.h | 10 +- src/gromacs/legacyheaders/gmx_wallcycle.h | 56 +- .../legacyheaders/gmx_x86_avx_128_fma.h | 74 +- src/gromacs/legacyheaders/gmx_x86_avx_256.h | 132 +- .../legacyheaders/gmx_x86_simd_double.h | 14 +- .../legacyheaders/gmx_x86_simd_single.h | 14 +- src/gromacs/legacyheaders/gmx_x86_sse2.h | 43 +- src/gromacs/legacyheaders/gmx_x86_sse4_1.h | 46 +- src/gromacs/legacyheaders/gmxcomplex.h | 118 +- src/gromacs/legacyheaders/gmxcpp.h | 88 +- src/gromacs/legacyheaders/gmxfio.h | 350 +- src/gromacs/legacyheaders/gpp_atomtype.h | 94 +- src/gromacs/legacyheaders/gpp_nextnb.h | 38 +- src/gromacs/legacyheaders/gpu_utils.h | 18 +- src/gromacs/legacyheaders/grompp.h | 254 +- src/gromacs/legacyheaders/gstat.h | 314 +- src/gromacs/legacyheaders/hackblock.h | 170 +- src/gromacs/legacyheaders/histogram.h | 4 +- src/gromacs/legacyheaders/index.h | 80 +- src/gromacs/legacyheaders/inputrec.h | 4 +- src/gromacs/legacyheaders/invblock.h | 22 +- src/gromacs/legacyheaders/macros.h | 39 +- src/gromacs/legacyheaders/main.h | 40 +- src/gromacs/legacyheaders/maths.h | 46 +- src/gromacs/legacyheaders/matio.h | 82 +- src/gromacs/legacyheaders/md5.h | 78 +- src/gromacs/legacyheaders/md_logging.h | 18 +- src/gromacs/legacyheaders/md_support.h | 64 +- src/gromacs/legacyheaders/mdatoms.h | 28 +- src/gromacs/legacyheaders/mdebin.h | 175 +- src/gromacs/legacyheaders/mdrun.h | 92 +- src/gromacs/legacyheaders/mshift.h | 42 +- src/gromacs/legacyheaders/mtop_util.h | 53 +- src/gromacs/legacyheaders/mvdata.h | 62 +- src/gromacs/legacyheaders/names.h | 110 +- .../legacyheaders/nbnxn_cuda_data_mgmt.h | 28 +- src/gromacs/legacyheaders/network.h | 54 +- src/gromacs/legacyheaders/nonbonded.h | 34 +- src/gromacs/legacyheaders/nrama.h | 60 +- src/gromacs/legacyheaders/nrjac.h | 22 +- src/gromacs/legacyheaders/nrnb.h | 38 +- src/gromacs/legacyheaders/ns.h | 70 +- src/gromacs/legacyheaders/nsgrid.h | 64 +- src/gromacs/legacyheaders/oenv.h | 38 +- src/gromacs/legacyheaders/orires.h | 42 +- src/gromacs/legacyheaders/partdec.h | 100 +- src/gromacs/legacyheaders/pbc.h | 354 +- src/gromacs/legacyheaders/pdb2top.h | 100 +- src/gromacs/legacyheaders/pdbio.h | 80 +- src/gromacs/legacyheaders/perf_est.h | 24 +- src/gromacs/legacyheaders/physics.h | 122 +- src/gromacs/legacyheaders/pmalloc_cuda.h | 2 - src/gromacs/legacyheaders/pme.h | 106 +- src/gromacs/legacyheaders/princ.h | 34 +- src/gromacs/legacyheaders/pull.h | 70 +- src/gromacs/legacyheaders/pull_rotation.h | 56 +- src/gromacs/legacyheaders/qmmm.h | 53 +- src/gromacs/legacyheaders/random.h | 28 +- src/gromacs/legacyheaders/rbin.h | 36 +- src/gromacs/legacyheaders/readinp.h | 158 +- src/gromacs/legacyheaders/resall.h | 34 +- src/gromacs/legacyheaders/rmpbc.h | 76 +- src/gromacs/legacyheaders/sfactor.h | 38 +- src/gromacs/legacyheaders/shellfc.h | 69 +- src/gromacs/legacyheaders/shift.h | 20 +- src/gromacs/legacyheaders/sighandler.h | 32 +- src/gromacs/legacyheaders/sim_util.h | 188 +- src/gromacs/legacyheaders/smalloc.h | 104 +- src/gromacs/legacyheaders/sortwater.h | 32 +- src/gromacs/legacyheaders/split.h | 162 +- src/gromacs/legacyheaders/splitter.h | 36 +- src/gromacs/legacyheaders/statutil.h | 136 +- src/gromacs/legacyheaders/strdb.h | 40 +- src/gromacs/legacyheaders/string2.h | 30 +- src/gromacs/legacyheaders/symtab.h | 114 +- src/gromacs/legacyheaders/sysstuff.h | 18 +- src/gromacs/legacyheaders/tables.h | 20 +- src/gromacs/legacyheaders/tgroup.h | 34 +- src/gromacs/legacyheaders/thread_mpi.h | 106 +- src/gromacs/legacyheaders/thread_mpi/atomic.h | 240 +- .../legacyheaders/thread_mpi/atomic/cycles.h | 7 +- .../legacyheaders/thread_mpi/atomic/gcc.h | 64 +- .../thread_mpi/atomic/gcc_ia64.h | 186 +- .../thread_mpi/atomic/gcc_intrinsics.h | 75 +- .../legacyheaders/thread_mpi/atomic/gcc_ppc.h | 145 +- .../thread_mpi/atomic/gcc_spinlock.h | 74 +- .../legacyheaders/thread_mpi/atomic/gcc_x86.h | 249 +- .../legacyheaders/thread_mpi/atomic/msvc.h | 77 +- .../thread_mpi/atomic/suncc-sparc.h | 79 +- .../legacyheaders/thread_mpi/atomic/xlc_ppc.h | 114 +- .../legacyheaders/thread_mpi/barrier.h | 98 +- .../legacyheaders/thread_mpi/collective.h | 96 +- src/gromacs/legacyheaders/thread_mpi/event.h | 121 +- src/gromacs/legacyheaders/thread_mpi/hwinfo.h | 65 +- src/gromacs/legacyheaders/thread_mpi/list.h | 86 +- src/gromacs/legacyheaders/thread_mpi/lock.h | 92 +- .../legacyheaders/thread_mpi/mpi_bindings.h | 97 +- src/gromacs/legacyheaders/thread_mpi/mutex.h | 145 +- .../legacyheaders/thread_mpi/numa_malloc.h | 113 +- .../legacyheaders/thread_mpi/system_error.h | 78 +- .../legacyheaders/thread_mpi/threads.h | 335 +- src/gromacs/legacyheaders/thread_mpi/tmpi.h | 636 +- .../legacyheaders/thread_mpi/visibility.h | 72 +- src/gromacs/legacyheaders/thread_mpi/wait.h | 81 +- src/gromacs/legacyheaders/tmpi.h | 124 +- src/gromacs/legacyheaders/topsort.h | 8 +- src/gromacs/legacyheaders/toputil.h | 34 +- src/gromacs/legacyheaders/tpxio.h | 108 +- src/gromacs/legacyheaders/trnio.h | 94 +- src/gromacs/legacyheaders/txtdump.h | 94 +- src/gromacs/legacyheaders/typedefs.h | 78 +- src/gromacs/legacyheaders/types/atoms.h | 98 +- src/gromacs/legacyheaders/types/block.h | 46 +- src/gromacs/legacyheaders/types/commrec.h | 394 +- src/gromacs/legacyheaders/types/constr.h | 16 +- src/gromacs/legacyheaders/types/energy.h | 22 +- src/gromacs/legacyheaders/types/enums.h | 194 +- src/gromacs/legacyheaders/types/fcdata.h | 118 +- src/gromacs/legacyheaders/types/filenm.h | 91 +- src/gromacs/legacyheaders/types/force_flags.h | 18 +- src/gromacs/legacyheaders/types/forcerec.h | 669 +- src/gromacs/legacyheaders/types/genborn.h | 131 +- src/gromacs/legacyheaders/types/globsig.h | 26 +- src/gromacs/legacyheaders/types/graph.h | 46 +- src/gromacs/legacyheaders/types/group.h | 79 +- src/gromacs/legacyheaders/types/hw_info.h | 28 +- src/gromacs/legacyheaders/types/idef.h | 448 +- src/gromacs/legacyheaders/types/ifunc.h | 64 +- src/gromacs/legacyheaders/types/inputrec.h | 676 +- .../legacyheaders/types/interaction_const.h | 6 +- src/gromacs/legacyheaders/types/ishift.h | 21 +- .../legacyheaders/types/iteratedconstraints.h | 28 +- src/gromacs/legacyheaders/types/matrix.h | 83 +- src/gromacs/legacyheaders/types/mdatom.h | 68 +- src/gromacs/legacyheaders/types/nb_verlet.h | 44 +- src/gromacs/legacyheaders/types/nblist.h | 22 +- .../types/nbnxn_cuda_types_ext.h | 6 +- .../legacyheaders/types/nbnxn_pairlist.h | 160 +- .../legacyheaders/types/nlistheuristics.h | 40 +- src/gromacs/legacyheaders/types/nrnb.h | 22 +- src/gromacs/legacyheaders/types/ns.h | 73 +- src/gromacs/legacyheaders/types/nsgrid.h | 66 +- src/gromacs/legacyheaders/types/oenv.h | 16 +- src/gromacs/legacyheaders/types/pbc.h | 42 +- src/gromacs/legacyheaders/types/qmmmrec.h | 126 +- src/gromacs/legacyheaders/types/shellfc.h | 16 +- src/gromacs/legacyheaders/types/simple.h | 107 +- src/gromacs/legacyheaders/types/state.h | 260 +- src/gromacs/legacyheaders/types/symtab.h | 26 +- src/gromacs/legacyheaders/types/topology.h | 111 +- src/gromacs/legacyheaders/types/trx.h | 90 +- src/gromacs/legacyheaders/update.h | 271 +- src/gromacs/legacyheaders/vcm.h | 56 +- src/gromacs/legacyheaders/vec.h | 1061 +-- src/gromacs/legacyheaders/viewit.h | 28 +- src/gromacs/legacyheaders/vsite.h | 107 +- src/gromacs/legacyheaders/warninp.h | 68 +- src/gromacs/legacyheaders/wgms.h | 24 +- src/gromacs/legacyheaders/wman.h | 46 +- src/gromacs/legacyheaders/writeps.h | 100 +- src/gromacs/legacyheaders/xdrf.h | 38 +- src/gromacs/legacyheaders/xtcio.h | 48 +- src/gromacs/legacyheaders/xvgr.h | 114 +- src/gromacs/linearalgebra/eigensolver.c | 408 +- src/gromacs/linearalgebra/eigensolver.h | 22 +- src/gromacs/linearalgebra/gmx_arpack.c | 7828 +++++++++------- src/gromacs/linearalgebra/gmx_arpack.h | 207 +- src/gromacs/linearalgebra/gmx_blas.h | 154 +- src/gromacs/linearalgebra/gmx_lapack.h | 954 +- src/gromacs/linearalgebra/matrix.c | 244 +- src/gromacs/linearalgebra/matrix.h | 28 +- src/gromacs/linearalgebra/mtxio.c | 153 +- src/gromacs/linearalgebra/mtxio.h | 19 +- src/gromacs/linearalgebra/sparsematrix.c | 229 +- src/gromacs/linearalgebra/sparsematrix.h | 70 +- src/gromacs/mdlib/adress.c | 409 +- src/gromacs/mdlib/adress.h | 24 +- src/gromacs/mdlib/calcmu.c | 47 +- src/gromacs/mdlib/calcvir.c | 380 +- src/gromacs/mdlib/clincs.c | 1131 +-- src/gromacs/mdlib/constr.c | 1598 ++-- src/gromacs/mdlib/coupling.c | 1701 ++-- src/gromacs/mdlib/csettle.c | 709 +- src/gromacs/mdlib/domdec.c | 5600 +++++------ src/gromacs/mdlib/domdec_box.c | 146 +- src/gromacs/mdlib/domdec_con.c | 746 +- src/gromacs/mdlib/domdec_network.c | 196 +- src/gromacs/mdlib/domdec_setup.c | 391 +- src/gromacs/mdlib/domdec_top.c | 1367 +-- src/gromacs/mdlib/ebin.c | 217 +- src/gromacs/mdlib/edsam.c | 1365 +-- src/gromacs/mdlib/ewald.c | 384 +- src/gromacs/mdlib/expanded.c | 801 +- src/gromacs/mdlib/fft5d.cpp | 1402 +-- src/gromacs/mdlib/fft5d.h | 77 +- src/gromacs/mdlib/force.c | 650 +- src/gromacs/mdlib/forcerec.c | 1928 ++-- src/gromacs/mdlib/genborn.c | 1647 ++-- src/gromacs/mdlib/genborn_allvsall.c | 971 +- src/gromacs/mdlib/genborn_allvsall.h | 9 +- .../mdlib/genborn_allvsall_sse2_double.c | 3075 +++---- .../mdlib/genborn_allvsall_sse2_double.h | 9 +- .../mdlib/genborn_allvsall_sse2_single.c | 4553 +++++---- .../mdlib/genborn_allvsall_sse2_single.h | 9 +- src/gromacs/mdlib/genborn_sse2_double.c | 1375 ++- src/gromacs/mdlib/genborn_sse2_double.h | 36 +- src/gromacs/mdlib/genborn_sse2_single.c | 2128 ++--- src/gromacs/mdlib/genborn_sse2_single.h | 30 +- src/gromacs/mdlib/gmx_fft.c | 220 +- src/gromacs/mdlib/gmx_fft_fftpack.c | 294 +- src/gromacs/mdlib/gmx_fft_fftw3.cpp | 330 +- src/gromacs/mdlib/gmx_fft_mkl.c | 472 +- src/gromacs/mdlib/gmx_parallel_3dfft.c | 168 +- src/gromacs/mdlib/gmx_wallcycle.c | 332 +- src/gromacs/mdlib/groupcoord.c | 236 +- src/gromacs/mdlib/groupcoord.h | 101 +- src/gromacs/mdlib/init.c | 220 +- src/gromacs/mdlib/iteratedconstraints.c | 148 +- src/gromacs/mdlib/md_support.c | 468 +- src/gromacs/mdlib/mdatom.c | 538 +- src/gromacs/mdlib/mdebin.c | 1017 +- src/gromacs/mdlib/mdebin_bar.c | 415 +- src/gromacs/mdlib/mdebin_bar.h | 155 +- src/gromacs/mdlib/minimize.c | 3821 ++++---- src/gromacs/mdlib/mvxvf.c | 295 +- src/gromacs/mdlib/nbnxn_atomdata.c | 946 +- src/gromacs/mdlib/nbnxn_atomdata.h | 64 +- src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda.h | 12 +- .../mdlib/nbnxn_cuda/nbnxn_cuda_types.h | 106 +- src/gromacs/mdlib/nbnxn_internal.h | 182 +- .../mdlib/nbnxn_kernels/nbnxn_kernel_common.c | 34 +- .../mdlib/nbnxn_kernels/nbnxn_kernel_common.h | 16 +- .../nbnxn_kernels/nbnxn_kernel_gpu_ref.c | 188 +- .../nbnxn_kernels/nbnxn_kernel_gpu_ref.h | 24 +- .../mdlib/nbnxn_kernels/nbnxn_kernel_ref.c | 56 +- .../mdlib/nbnxn_kernels/nbnxn_kernel_ref.h | 16 +- .../nbnxn_kernels/nbnxn_kernel_ref_inner.h | 288 +- .../nbnxn_kernels/nbnxn_kernel_ref_outer.h | 100 +- .../nbnxn_kernels/nbnxn_kernel_simd_2xnn.c | 98 +- .../nbnxn_kernels/nbnxn_kernel_simd_2xnn.h | 6 +- .../nbnxn_kernel_simd_2xnn_inner.h | 708 +- .../nbnxn_kernel_simd_2xnn_outer.h | 268 +- .../nbnxn_kernels/nbnxn_kernel_simd_4xn.c | 98 +- .../nbnxn_kernels/nbnxn_kernel_simd_4xn.h | 6 +- .../nbnxn_kernel_simd_4xn_inner.h | 1226 +-- .../nbnxn_kernel_simd_4xn_outer.h | 312 +- .../nbnxn_kernels/nbnxn_kernel_simd_utils.h | 642 +- .../nbnxn_kernels/nbnxn_kernel_x86_simd128.h | 6 +- .../nbnxn_kernels/nbnxn_kernel_x86_simd256.h | 6 +- src/gromacs/mdlib/nbnxn_search.c | 1964 ++-- src/gromacs/mdlib/nbnxn_search.h | 50 +- src/gromacs/mdlib/nbnxn_search_simd_2xnn.h | 98 +- src/gromacs/mdlib/nbnxn_search_simd_4xn.h | 174 +- src/gromacs/mdlib/nlistheuristics.c | 58 +- src/gromacs/mdlib/ns.c | 2282 ++--- src/gromacs/mdlib/nsgrid.c | 726 +- src/gromacs/mdlib/partdec.c | 1412 +-- src/gromacs/mdlib/perf_est.c | 299 +- src/gromacs/mdlib/pme.c | 2555 ++--- src/gromacs/mdlib/pme_pp.c | 582 +- src/gromacs/mdlib/pme_sse_single.h | 270 +- src/gromacs/mdlib/pull.c | 1370 +-- src/gromacs/mdlib/pull_rotation.c | 2341 ++--- src/gromacs/mdlib/pullutil.c | 798 +- src/gromacs/mdlib/qm_gamess.c | 395 +- src/gromacs/mdlib/qm_gaussian.c | 1878 ++-- src/gromacs/mdlib/qm_mopac.c | 293 +- src/gromacs/mdlib/qm_orca.c | 767 +- src/gromacs/mdlib/qmmm.c | 1875 ++-- src/gromacs/mdlib/rf_util.c | 456 +- src/gromacs/mdlib/shakef.c | 672 +- src/gromacs/mdlib/shellfc.c | 1999 ++-- src/gromacs/mdlib/sim_util.c | 1834 ++-- src/gromacs/mdlib/stat.c | 830 +- src/gromacs/mdlib/tables.c | 2370 ++--- src/gromacs/mdlib/tests/fft.cpp | 130 +- src/gromacs/mdlib/tgroup.c | 265 +- src/gromacs/mdlib/tpi.c | 805 +- src/gromacs/mdlib/update.c | 2180 ++--- src/gromacs/mdlib/vcm.c | 593 +- src/gromacs/mdlib/vsite.c | 2453 ++--- src/gromacs/mdlib/wall.c | 338 +- src/gromacs/mdlib/wnblist.c | 238 +- src/gromacs/onlinehelp/helpformat.cpp | 6 +- src/gromacs/onlinehelp/helpmanager.cpp | 14 +- src/gromacs/onlinehelp/helpmanager.h | 2 +- src/gromacs/onlinehelp/helptopic.cpp | 12 +- src/gromacs/onlinehelp/helptopic.h | 12 +- src/gromacs/onlinehelp/helpwritercontext.cpp | 8 +- src/gromacs/onlinehelp/tests/helpmanager.cpp | 22 +- src/gromacs/options/abstractoption.cpp | 4 +- src/gromacs/options/abstractoption.h | 4 +- src/gromacs/options/abstractoptionstorage.h | 2 +- src/gromacs/options/basicoptions.cpp | 14 +- src/gromacs/options/filenameoption.cpp | 12 +- src/gromacs/options/options.cpp | 2 +- src/gromacs/options/optionsassigner.cpp | 20 +- src/gromacs/options/optionstoragetemplate.h | 12 +- src/gromacs/options/optionsvisitor.cpp | 8 +- .../options/tests/abstractoptionstorage.cpp | 32 +- src/gromacs/options/tests/filenameoption.cpp | 26 +- src/gromacs/options/tests/option.cpp | 4 +- src/gromacs/options/tests/optionsassigner.cpp | 130 +- src/gromacs/options/tests/timeunitmanager.cpp | 18 +- src/gromacs/options/timeunitmanager.cpp | 6 +- src/gromacs/selection/centerofmass.cpp | 12 +- src/gromacs/selection/compiler.cpp | 138 +- src/gromacs/selection/evaluate.cpp | 126 +- src/gromacs/selection/evaluate.h | 68 +- src/gromacs/selection/indexutil.cpp | 60 +- src/gromacs/selection/keywords.h | 10 +- src/gromacs/selection/mempool.cpp | 6 +- src/gromacs/selection/nbsearch.cpp | 48 +- src/gromacs/selection/params.cpp | 66 +- src/gromacs/selection/parser_internal.h | 14 +- src/gromacs/selection/parsetree.cpp | 84 +- src/gromacs/selection/parsetree.h | 44 +- src/gromacs/selection/poscalc.cpp | 140 +- src/gromacs/selection/position.cpp | 36 +- src/gromacs/selection/scanner.h | 4 +- src/gromacs/selection/scanner_internal.cpp | 26 +- src/gromacs/selection/scanner_internal.h | 4 +- src/gromacs/selection/selection.cpp | 30 +- src/gromacs/selection/selection.h | 24 +- .../selection/selectioncollection-impl.h | 10 +- src/gromacs/selection/selectioncollection.cpp | 46 +- src/gromacs/selection/selectionoption.cpp | 6 +- .../selection/selectionoptionmanager.cpp | 56 +- .../selection/selectionoptionmanager.h | 4 +- .../selection/selectionoptionstorage.h | 2 +- src/gromacs/selection/selelem.cpp | 12 +- src/gromacs/selection/selelem.h | 6 +- src/gromacs/selection/selhelp.cpp | 92 +- src/gromacs/selection/selmethod.cpp | 8 +- src/gromacs/selection/selmethod.h | 4 +- src/gromacs/selection/selvalue.h | 2 +- src/gromacs/selection/sm_compare.cpp | 24 +- src/gromacs/selection/sm_distance.cpp | 4 +- src/gromacs/selection/sm_insolidangle.cpp | 65 +- src/gromacs/selection/sm_keywords.cpp | 52 +- src/gromacs/selection/sm_merge.cpp | 2 +- src/gromacs/selection/sm_permute.cpp | 6 +- src/gromacs/selection/sm_position.cpp | 26 +- src/gromacs/selection/sm_same.cpp | 39 +- src/gromacs/selection/sm_simple.cpp | 55 +- src/gromacs/selection/symrec.cpp | 42 +- src/gromacs/selection/symrec.h | 2 +- .../selection/tests/selectioncollection.cpp | 46 +- .../selection/tests/selectionoption.cpp | 76 +- .../trajectoryanalysis/analysismodule.cpp | 40 +- .../trajectoryanalysis/analysismodule.h | 18 +- .../analysissettings-impl.h | 6 +- .../trajectoryanalysis/cmdlinerunner.cpp | 18 +- src/gromacs/trajectoryanalysis/modules.cpp | 8 +- .../trajectoryanalysis/modules/angle.cpp | 68 +- .../trajectoryanalysis/modules/angle.h | 30 +- .../trajectoryanalysis/modules/distance.cpp | 14 +- .../trajectoryanalysis/modules/distance.h | 4 +- .../trajectoryanalysis/modules/select.cpp | 64 +- .../trajectoryanalysis/modules/select.h | 52 +- .../trajectoryanalysis/runnercommon.cpp | 64 +- src/gromacs/trajectoryanalysis/runnercommon.h | 2 +- .../trajectoryanalysis/tests/angle.cpp | 2 +- .../trajectoryanalysis/tests/moduletest.cpp | 20 +- .../trajectoryanalysis/tests/select.cpp | 2 +- .../tests/test_selection.cpp | 16 +- src/gromacs/utility/common.h | 4 +- src/gromacs/utility/errorcodes.cpp | 8 +- src/gromacs/utility/errorcodes.h | 2 +- src/gromacs/utility/errorformat.cpp | 10 +- src/gromacs/utility/errorformat.h | 2 +- src/gromacs/utility/exceptions.cpp | 24 +- src/gromacs/utility/exceptions.h | 6 +- src/gromacs/utility/file.cpp | 20 +- src/gromacs/utility/flags.h | 8 +- src/gromacs/utility/gmxassert.cpp | 2 +- src/gromacs/utility/gmxassert.h | 6 +- src/gromacs/utility/gmxregex.cpp | 14 +- src/gromacs/utility/gmxregex.h | 1 - src/gromacs/utility/messagestringcollector.h | 2 +- src/gromacs/utility/programinfo.cpp | 10 +- src/gromacs/utility/stringutil.cpp | 36 +- src/ngmx/Xstuff.h | 182 +- src/ngmx/buttons.c | 425 +- src/ngmx/buttons.h | 52 +- src/ngmx/dialogs.c | 656 +- src/ngmx/dialogs.h | 92 +- src/ngmx/fgrid.c | 643 +- src/ngmx/fgrid.h | 56 +- src/ngmx/filter.c | 240 +- src/ngmx/g_highway.c | 912 +- src/ngmx/g_logo.c | 39 +- src/ngmx/g_showcol.c | 431 +- src/ngmx/g_xrama.c | 561 +- src/ngmx/logo.c | 314 +- src/ngmx/logo.h | 34 +- src/ngmx/manager.c | 1105 ++- src/ngmx/manager.h | 174 +- src/ngmx/molps.c | 415 +- src/ngmx/molps.h | 22 +- src/ngmx/ngmx.c | 662 +- src/ngmx/nleg.c | 212 +- src/ngmx/nleg.h | 30 +- src/ngmx/nmol.c | 954 +- src/ngmx/nmol.h | 40 +- src/ngmx/popup.c | 341 +- src/ngmx/popup.h | 62 +- src/ngmx/pulldown.c | 220 +- src/ngmx/pulldown.h | 42 +- src/ngmx/test_ngmx_dialog.c | 52 +- src/ngmx/vbox.c | 35 +- src/ngmx/x11.c | 812 +- src/ngmx/x11.h | 92 +- src/ngmx/xdlg.c | 1163 ++- src/ngmx/xdlg.h | 80 +- src/ngmx/xdlghi.c | 631 +- src/ngmx/xdlghi.h | 46 +- src/ngmx/xdlgitem.c | 1112 ++- src/ngmx/xdlgitem.h | 130 +- src/ngmx/xmb.c | 266 +- src/ngmx/xmb.h | 22 +- src/ngmx/xstat.c | 318 +- src/ngmx/xutil.c | 411 +- src/ngmx/xutil.h | 58 +- src/programs/g_protonate/g_protonate.c | 313 +- src/programs/g_x2top/g_x2top.c | 996 +- src/programs/g_x2top/g_x2top.h | 44 +- src/programs/g_x2top/nm2type.c | 523 +- src/programs/gmx/legacymodules.cpp | 168 +- src/programs/gmxcheck/gmxcheck.c | 1366 +-- src/programs/gmxcheck/tpbcmp.c | 2195 +++-- src/programs/gmxcheck/tpbcmp.h | 28 +- src/programs/gmxdump/gmxdump.c | 787 +- src/programs/grompp/convparm.c | 998 +- src/programs/grompp/convparm.h | 24 +- src/programs/grompp/gpp_tomorse.h | 28 +- src/programs/grompp/grompp.c | 2661 +++--- src/programs/grompp/tomorse.c | 412 +- src/programs/main.cpp | 4 +- src/programs/mdrun/do_gct.c | 1469 +-- src/programs/mdrun/gctio.c | 923 +- src/programs/mdrun/genalg.c | 961 +- src/programs/mdrun/genalg.h | 66 +- src/programs/mdrun/ionize.c | 1514 +-- src/programs/mdrun/ionize.h | 28 +- src/programs/mdrun/md.c | 1519 +-- src/programs/mdrun/mdrun.c | 1367 +-- src/programs/mdrun/membed.c | 1120 +-- src/programs/mdrun/pme_loadbal.c | 298 +- src/programs/mdrun/pme_loadbal.h | 40 +- src/programs/mdrun/repl_ex.c | 1078 +-- src/programs/mdrun/repl_ex.h | 40 +- src/programs/mdrun/runner.c | 832 +- src/programs/mdrun/xmdrun.h | 160 +- src/programs/mdrun/xutils.c | 839 +- src/programs/pdb2gmx/hizzie.c | 509 +- src/programs/pdb2gmx/hizzie.h | 20 +- src/programs/pdb2gmx/pdb2gmx.c | 3317 +++---- src/programs/pdb2gmx/specbond.c | 570 +- src/programs/pdb2gmx/specbond.h | 20 +- src/programs/pdb2gmx/xlate.c | 124 +- src/programs/pdb2gmx/xlate.h | 24 +- src/programs/tpbconv/tpbconv.c | 1086 +-- src/testutils/cmdlinetest.cpp | 25 +- src/testutils/datatest.cpp | 16 +- src/testutils/datatest.h | 28 +- src/testutils/mock_datamodule.cpp | 66 +- src/testutils/mock_datamodule.h | 10 +- src/testutils/mock_helptopic.h | 4 +- src/testutils/refdata.cpp | 56 +- src/testutils/refdata.h | 2 +- src/testutils/stringtest.h | 4 +- src/testutils/testexceptions.h | 1 - src/testutils/testfilemanager.cpp | 4 +- src/testutils/tests/refdata.cpp | 56 +- src/tools/addconf.c | 1028 ++- src/tools/addconf.h | 26 +- src/tools/anadih.c | 1592 ++-- src/tools/autocorr.c | 1731 ++-- src/tools/binsearch.c | 167 +- src/tools/binsearch.h | 30 +- src/tools/calcpot.c | 503 +- src/tools/calcpot.h | 51 +- src/tools/cmat.c | 304 +- src/tools/cmat.h | 50 +- src/tools/correl.c | 274 +- src/tools/correl.h | 28 +- src/tools/dens_filter.c | 127 +- src/tools/dens_filter.h | 30 +- src/tools/dlist.c | 643 +- src/tools/edittop.c | 288 +- src/tools/eigio.c | 268 +- src/tools/eigio.h | 50 +- src/tools/expfit.c | 1121 +-- src/tools/fitahx.c | 212 +- src/tools/fitahx.h | 26 +- src/tools/g_membed.c | 13 +- src/tools/g_pme_error.c | 25 +- src/tools/g_tune_pme.c | 25 +- src/tools/geminate.c | 1572 ++-- src/tools/geminate.h | 142 +- src/tools/gmx_anadock.c | 569 +- src/tools/gmx_anaeig.c | 2400 ++--- src/tools/gmx_analyze.c | 1887 ++-- src/tools/gmx_angle.c | 745 +- src/tools/gmx_bar.c | 2143 ++--- src/tools/gmx_bond.c | 544 +- src/tools/gmx_bundle.c | 664 +- src/tools/gmx_chi.c | 2661 +++--- src/tools/gmx_cluster.c | 3001 +++--- src/tools/gmx_clustsize.c | 845 +- src/tools/gmx_confrms.c | 1308 +-- src/tools/gmx_covar.c | 1025 ++- src/tools/gmx_current.c | 1531 +-- src/tools/gmx_density.c | 845 +- src/tools/gmx_densmap.c | 801 +- src/tools/gmx_densorder.c | 930 +- src/tools/gmx_dielectric.c | 659 +- src/tools/gmx_dipoles.c | 1501 +-- src/tools/gmx_disre.c | 1514 +-- src/tools/gmx_dist.c | 514 +- src/tools/gmx_do_dssp.c | 1126 +-- src/tools/gmx_dos.c | 558 +- src/tools/gmx_dyecoupl.c | 248 +- src/tools/gmx_dyndom.c | 378 +- src/tools/gmx_editconf.c | 1341 +-- src/tools/gmx_eneconv.c | 1390 +-- src/tools/gmx_enemat.c | 882 +- src/tools/gmx_energy.c | 3914 ++++---- src/tools/gmx_filter.c | 506 +- src/tools/gmx_genbox.cpp | 1703 ++-- src/tools/gmx_genconf.c | 570 +- src/tools/gmx_genion.c | 1008 +- src/tools/gmx_genpr.c | 378 +- src/tools/gmx_gyrate.c | 559 +- src/tools/gmx_h2order.c | 504 +- src/tools/gmx_hbond.c | 4637 ++++++---- src/tools/gmx_helix.c | 589 +- src/tools/gmx_helixorient.c | 871 +- src/tools/gmx_hydorder.c | 728 +- src/tools/gmx_kinetics.c | 1724 ++-- src/tools/gmx_lie.c | 284 +- src/tools/gmx_make_edi.c | 1307 +-- src/tools/gmx_make_ndx.c | 2588 +++--- src/tools/gmx_mdmat.c | 584 +- src/tools/gmx_membed.c | 130 +- src/tools/gmx_mindist.c | 1280 +-- src/tools/gmx_mk_angndx.c | 433 +- src/tools/gmx_morph.c | 294 +- src/tools/gmx_msd.c | 1849 ++-- src/tools/gmx_nmeig.c | 840 +- src/tools/gmx_nmens.c | 398 +- src/tools/gmx_nmtraj.c | 508 +- src/tools/gmx_options.c | 134 +- src/tools/gmx_order.c | 1866 ++-- src/tools/gmx_pme_error.c | 1114 +-- src/tools/gmx_polystat.c | 809 +- src/tools/gmx_potential.c | 790 +- src/tools/gmx_principal.c | 198 +- src/tools/gmx_rama.c | 123 +- src/tools/gmx_rdf.c | 1509 +-- src/tools/gmx_rms.c | 1327 +-- src/tools/gmx_rmsdist.c | 1387 +-- src/tools/gmx_rmsf.c | 908 +- src/tools/gmx_rotacf.c | 336 +- src/tools/gmx_rotmat.c | 226 +- src/tools/gmx_saltbr.c | 476 +- src/tools/gmx_sans.c | 472 +- src/tools/gmx_sas.c | 1231 +-- src/tools/gmx_saxs.c | 50 +- src/tools/gmx_sgangle.c | 964 +- src/tools/gmx_sham.c | 1861 ++-- src/tools/gmx_sigeps.c | 244 +- src/tools/gmx_sorient.c | 765 +- src/tools/gmx_spatial.c | 701 +- src/tools/gmx_spol.c | 607 +- src/tools/gmx_tcaf.c | 761 +- src/tools/gmx_traj.c | 756 +- src/tools/gmx_trjcat.c | 718 +- src/tools/gmx_trjconv.c | 1859 ++-- src/tools/gmx_trjorder.c | 549 +- src/tools/gmx_tune_pme.c | 1253 +-- src/tools/gmx_vanhove.c | 711 +- src/tools/gmx_velacc.c | 321 +- src/tools/gmx_wham.cpp | 3416 ++++--- src/tools/gmx_wheel.c | 413 +- src/tools/gmx_xpm2ps.c | 2592 +++--- src/tools/hxprops.c | 929 +- src/tools/hxprops.h | 102 +- src/tools/interf.h | 24 +- src/tools/levenmar.c | 1035 ++- src/tools/nsc.c | 2005 ++-- src/tools/nsc.h | 116 +- src/tools/nsfactor.c | 376 +- src/tools/nsfactor.h | 50 +- src/tools/polynomials.c | 71 +- src/tools/powerspect.c | 170 +- src/tools/powerspect.h | 26 +- src/tools/pp2shift.c | 363 +- src/tools/pp2shift.h | 86 +- 903 files changed, 219874 insertions(+), 190833 deletions(-) create mode 100644 admin/uncrustify.cfg delete mode 100644 src/gromacs/gmxlib/bfunc.h diff --git a/admin/uncrustify.cfg b/admin/uncrustify.cfg new file mode 100644 index 0000000000..d89351a7e6 --- /dev/null +++ b/admin/uncrustify.cfg @@ -0,0 +1,1577 @@ +# Uncrustify 0.59 + +# +# General options +# + +# The type of line endings +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input +input_tab_size = 4 # number + +# The size of tabs in the output (only used if align_with_tabs=true) +output_tab_size = 4 # number + +# The ASCII value of the string escape char, usually 92 (\) or 94 (^). (Pawn) +string_escape_char = 92 # number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # number + +# Allow interpreting '>=' and '>>=' as part of a template in 'void f(list>=val);'. +# If true (default), 'assert(x<0 && y>=3)' will be broken. +# Improvements to template detection may make this option obsolete. +tok_split_gte = false # false/true + +# Control what to do with the UTF-8 BOM (recommend 'remove') +utf8_bom = ignore # ignore/add/remove/force + +# If the file contains bytes with values between 128 and 255, but is not UTF-8, then output as UTF-8 +utf8_byte = false # false/true + +# Force the output encoding to UTF-8 +utf8_force = false # false/true + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. +indent_columns = 4 # number + +# The continuation indent. If non-zero, this overrides the indent of '(' and '=' continuation indents. +# For FreeBSD, this is set to 4. Negative value is absolute and not increased for each ( level +indent_continue = 0 # number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs to brace level, align with spaces +# 2=indent and align with tabs, using spaces when not on a tabstop +indent_with_tabs = 0 # number + +# Comments that are not a brace level are indented with tabs on a tabstop. +# Requires indent_with_tabs=2. If false, will use spaces. +indent_cmt_with_tabs = false # false/true + +# Whether to indent strings broken by '\' so that they line up +indent_align_string = false # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True +indent_xml_string = 0 # number + +# Spaces to indent '{' from level +indent_brace = 0 # number + +# Whether braces are indented to the body level +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is true +indent_braces_no_func = true # false/true + +# Disabled indenting class braces if indent_braces is true +indent_braces_no_class = true # false/true + +# Disabled indenting struct braces if indent_braces is true +indent_braces_no_struct = true # false/true + +# Indent based on the size of the brace parent, i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Whether the 'namespace' body is indented +indent_namespace = false # false/true + +# The number of spaces to indent a namespace block +indent_namespace_level = 0 # number + +# If the body of the namespace is longer than this number, it won't be indented. +# Requires indent_namespace=true. Default=0 (no limit) +indent_namespace_limit = 0 # number + +# Whether the 'extern "C"' body is indented +indent_extern = false # false/true + +# Whether the 'class' body is indented +indent_class = true # false/true + +# Whether to indent the stuff after a leading class colon +indent_class_colon = true # false/true + +# Virtual indent from the ':' for member initializers. Default is 2 +indent_ctor_init_leading = 2 # number + +# Additional indenting for constructor initializer list +indent_ctor_init = 0 # number + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level +indent_else_if = false # false/true + +# Amount to indent variable declarations after a open brace. neg=relative, pos=absolute +indent_var_def_blk = 0 # number + +# Indent continued variable declarations instead of aligning. +indent_var_def_cont = false # false/true + +# True: force indentation of function definition to start in column 1 +# False: use the default behavior +indent_func_def_force_col1 = false # false/true + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren +indent_func_call_param = false # false/true + +# Same as indent_func_call_param, but for function defs +indent_func_def_param = false # false/true + +# Same as indent_func_call_param, but for function protos +indent_func_proto_param = false # false/true + +# Same as indent_func_call_param, but for class declarations +indent_func_class_param = false # false/true + +# Same as indent_func_call_param, but for class variable constructors +indent_func_ctor_var_param = false # false/true + +# Same as indent_func_call_param, but for templates +indent_template_param = false # false/true + +# Double the indent for indent_func_xxx_param options +indent_func_param_double = true # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier +indent_func_const = 0 # number + +# Indentation column for standalone 'throw' function decl/proto qualifier +indent_func_throw = 0 # number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 4 # number + +# Spaces to indent single line ('//') comments on lines before code +indent_sing_line_comments = 0 # number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 4 # number + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0 : absolute column where 1 is the leftmost column +# <=0 : subtract from brace indent +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon +indent_access_spec = 1 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0' +indent_access_spec_body = true # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended) +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # number + +# Controls the indent of a comma when inside a paren.If TRUE, aligns under the open paren +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If TRUE, aligns under the open paren +indent_bool_paren = false # false/true + +# If 'indent_bool_paren' is true, controls the indent of the first expression. If TRUE, aligns the first expression to the following ones +indent_first_bool_expr = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended) +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies +indent_preserve_sql = false # false/true + +# Align continued statements at the '='. Default=True +# If FALSE or the '=' is followed by a newline, the next line is indent one tab. +indent_align_assign = false # false/true + +# Indent OC blocks at brace level instead of usual rules. +indent_oc_block = false # false/true + +# Minimum indent for subsequent parameters +indent_oc_msg_colon = 0 # number + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +sp_arith = ignore # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc +sp_assign = add # ignore/add/remove/force + +# Add or remove space around '=' in C++11 lambda capture specifications. Overrides sp_assign +sp_cpp_lambda_assign = ignore # ignore/add/remove/force + +# Add or remove space after the capture specification in C++11 lambda. +sp_cpp_lambda_paren = ignore # ignore/add/remove/force + +# Add or remove space around assignment operator '=' in a prototype +sp_assign_default = add # ignore/add/remove/force + +# Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. +sp_before_assign = add # ignore/add/remove/force + +# Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. +sp_after_assign = add # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum +sp_enum_assign = add # ignore/add/remove/force + +# Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around preprocessor '##' concatenation operator. Default=Add +sp_pp_concat = add # ignore/add/remove/force + +# Add or remove space after preprocessor '#' stringify operator. Also affects the '#@' charizing operator. +sp_pp_stringify = ignore # ignore/add/remove/force + +# Add or remove space before preprocessor '#' stringify operator as in '#define x(y) L#y'. +sp_before_pp_stringify = ignore # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||' +sp_bool = add # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc +sp_compare = add # ignore/add/remove/force + +# Add or remove space inside '(' and ')' +sp_inside_paren = ignore # ignore/add/remove/force + +# Add or remove space between nested parens +sp_paren_paren = ignore # ignore/add/remove/force + +# Whether to balance spaces inside nested parens +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{' +sp_paren_brace = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' +sp_before_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space between pointer stars '*' +sp_between_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = ignore # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by an open paren (function types). +sp_ptr_star_paren = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&' +sp_before_byref = add # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = ignore # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = remove # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = ignore # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = ignore # ignore/add/remove/force + +# Add or remove space between type and word. Default=Force +sp_after_type = ignore # ignore/add/remove/force + +# Add or remove space before the paren in the D constructs 'template Foo(' and 'class Foo('. +sp_before_template_paren = ignore # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = ignore # ignore/add/remove/force + +# Add or remove space before '<>' +sp_before_angle = ignore # ignore/add/remove/force + +# Add or remove space inside '<' and '>' +sp_inside_angle = ignore # ignore/add/remove/force + +# Add or remove space after '<>' +sp_after_angle = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List();' +sp_angle_paren = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' +sp_angle_word = ignore # ignore/add/remove/force + +# Add or remove space between '>' and '>' in '>>' (template stuff C++/C# only). Default=Add +sp_angle_shift = add # ignore/add/remove/force + +# Permit removal of the space between '>>' in 'foo >' (C++11 only). Default=False +# sp_angle_shift cannot remove the space without this option. +sp_permit_cpp11_shift = false # false/true + +# Add or remove space before '(' of 'if', 'for', 'switch', and 'while' +sp_before_sparen = add # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')' +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space before if-condition ')'. Overrides sp_inside_sparen. +sp_inside_sparen_close = ignore # ignore/add/remove/force + +# Add or remove space before if-condition '('. Overrides sp_inside_sparen. +sp_inside_sparen_open = ignore # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while' +sp_after_sparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while' +sp_sparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between 'invariant' and '(' in the D language. +sp_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space after the ')' in 'invariant (C) c' in the D language. +sp_after_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while' +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';'. Default=Remove +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statement. +sp_before_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space after ';', except when followed by a comment. Default=Add +sp_after_semi = add # ignore/add/remove/force + +# Add or remove space after ';' in non-empty 'for' statements. Default=Force +sp_after_semi_for = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statement: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]') +sp_before_square = ignore # ignore/add/remove/force + +# Add or remove space before '[]' +sp_before_squares = ignore # ignore/add/remove/force + +# Add or remove space inside a non-empty '[' and ']' +sp_inside_square = ignore # ignore/add/remove/force + +# Add or remove space after ',' +sp_after_comma = add # ignore/add/remove/force + +# Add or remove space before ',' +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space between an open paren and comma: '(,' vs '( ,' +sp_paren_comma = force # ignore/add/remove/force + +# Add or remove space before the variadic '...' when preceded by a non-punctuator +sp_before_ellipsis = ignore # ignore/add/remove/force + +# Add or remove space after class ':' +sp_after_class_colon = add # ignore/add/remove/force + +# Add or remove space before class ':' +sp_before_class_colon = add # ignore/add/remove/force + +# Add or remove space before case ':'. Default=Remove +sp_before_case_colon = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign +sp_after_operator = remove # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++(' +sp_after_operator_sym = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, i.e. 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a' +sp_after_cast = ignore # ignore/add/remove/force + +# Add or remove spaces inside cast parens +sp_inside_paren_cast = ignore # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)' +sp_cpp_cast_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '(' +sp_sizeof_paren = ignore # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn) +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}' +sp_inside_braces_enum = ignore # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}' +sp_inside_braces_struct = ignore # ignore/add/remove/force + +# Add or remove space inside '{' and '}' +sp_inside_braces = ignore # ignore/add/remove/force + +# Add or remove space inside '{}' +sp_inside_braces_empty = ignore # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration +sp_func_proto_paren = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition +sp_func_def_paren = ignore # ignore/add/remove/force + +# Add or remove space inside empty function '()' +sp_inside_fparens = ignore # ignore/add/remove/force + +# Add or remove space inside function '(' and ')' +sp_inside_fparen = ignore # ignore/add/remove/force + +# Add or remove space inside the first parens in the function type: 'void (*x)(...)' +sp_inside_tparen = ignore # ignore/add/remove/force + +# Add or remove between the parens in the function type: 'void (*x)(...)' +sp_after_tparen_close = ignore # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = ignore # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function +sp_fparen_brace = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls +sp_func_call_paren = ignore # ignore/add/remove/force + +# Add or remove space between function name and '()' on function calls without parameters. +# If set to 'ignore' (the default), sp_func_call_paren is used. +sp_func_call_paren_empty = ignore # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren +sp_func_class_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'return' and '(' +sp_return_paren = ignore # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '(' +sp_attribute_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)' +sp_defined_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)' +sp_throw_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and anything other than '(' as in '@throw [...];' +sp_after_throw = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '(' in 'catch (something) { }' +# If set to ignore, sp_before_sparen is used. +sp_catch_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'version' and '(' in 'version (something) { }' (D language) +# If set to ignore, sp_before_sparen is used. +sp_version_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'scope' and '(' in 'scope (something) { }' (D language) +# If set to ignore, sp_before_sparen is used. +sp_scope_paren = ignore # ignore/add/remove/force + +# Add or remove space between macro and value +sp_macro = ignore # ignore/add/remove/force + +# Add or remove space between macro function ')' and value +sp_macro_func = ignore # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line +sp_else_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line +sp_brace_else = ignore # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line +sp_brace_typedef = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line +sp_catch_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line +sp_brace_catch = ignore # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line +sp_finally_brace = ignore # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line +sp_brace_finally = ignore # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line +sp_try_brace = ignore # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line +sp_getset_brace = ignore # ignore/add/remove/force + +# Add or remove space before the '::' operator +sp_before_dc = ignore # ignore/add/remove/force + +# Add or remove space after the '::' operator +sp_after_dc = ignore # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. Default=Remove +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. Default=Remove +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. Default=Remove +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators. Default=Remove +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. Default=Remove +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. Default=Remove +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'. Default=Remove +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line. Default=Add +sp_before_nl_cont = add # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;' +sp_after_oc_scope = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;' +sp_after_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;' +sp_before_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in immutable dictionary expression +# 'NSDictionary *test = @{@"foo" :@"bar"};' +sp_after_oc_dict_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in immutable dictionary expression +# 'NSDictionary *test = @{@"foo" :@"bar"};' +sp_before_oc_dict_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];' +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];' +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int)f: (int) x;' vs '-(int)f: (int)x;' +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space after the first (type) in message specs +# '-(int) f:(int)x;' vs '-(int)f:(int)x;' +sp_after_oc_return_type = ignore # ignore/add/remove/force + +# Add or remove space between '@selector' and '(' +# '@selector(msgName)' vs '@selector (msgName)' +# Also applies to @protocol() constructs +sp_after_oc_at_sel = ignore # ignore/add/remove/force + +# Add or remove space between '@selector(x)' and the following word +# '@selector(foo) a:' vs '@selector(foo)a:' +sp_after_oc_at_sel_parens = ignore # ignore/add/remove/force + +# Add or remove space inside '@selector' parens +# '@selector(foo)' vs '@selector( foo )' +# Also applies to @protocol() constructs +sp_inside_oc_at_sel_parens = ignore # ignore/add/remove/force + +# Add or remove space before a block pointer caret +# '^int (int arg){...}' vs. ' ^int (int arg){...}' +sp_before_oc_block_caret = ignore # ignore/add/remove/force + +# Add or remove space after a block pointer caret +# '^int (int arg){...}' vs. '^ int (int arg){...}' +sp_after_oc_block_caret = ignore # ignore/add/remove/force + +# Add or remove space between the receiver and selector in a message. +# '[receiver selector ...]' +sp_after_oc_msg_receiver = ignore # ignore/add/remove/force + +# Add or remove space after @property. +sp_after_oc_property = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f' +sp_cond_colon = add # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f' +sp_cond_question = add # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = ignore # ignore/add/remove/force + +# Control the space around the D '..' operator. +sp_range = ignore # ignore/add/remove/force + +# Control the spacing after ':' in 'for (TYPE VAR : EXPR)' (Java) +sp_after_for_colon = ignore # ignore/add/remove/force + +# Control the spacing before ':' in 'for (TYPE VAR : EXPR)' (Java) +sp_before_for_colon = ignore # ignore/add/remove/force + +# Control the spacing in 'extern (C)' (D) +sp_extern_paren = ignore # ignore/add/remove/force + +# Control the space after the opening of a C++ comment '// A' vs '//A' +sp_cmt_cpp_start = ignore # ignore/add/remove/force + +# Controls the spaces between #else or #endif and a trailing comment +sp_endif_cmt = ignore # ignore/add/remove/force + +# Controls the spaces after 'new', 'delete', and 'delete[]' +sp_after_new = ignore # ignore/add/remove/force + +# Controls the spaces before a trailing or embedded comment +sp_before_tr_emb_cmt = ignore # ignore/add/remove/force + +# Number of spaces before a trailing or embedded comment +sp_num_before_tr_emb_cmt = 0 # number + +# Control space between a Java annotation and the open paren. +sp_annotation_paren = ignore # ignore/add/remove/force + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs +align_keep_tabs = false # false/true + +# Whether to keep whitespace not required for alignment +align_keep_extra_space = true # false/true + +# Whether to use tabs for aligning +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning +align_on_tabstop = false # false/true + +# Whether to left-align numbers +align_number_left = false # false/true + +# Align variable definitions in prototypes and functions +align_func_params = true # false/true + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 2 # number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 2 # number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 2 # number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 20 # number + +# The gap for aligning variable definitions +align_var_def_gap = 0 # number + +# Whether to align the colon in struct bit fields +align_var_def_colon = false # false/true + +# Whether to align any attribute after the variable name +align_var_def_attribute = false # false/true + +# Whether to align inline struct/enum/union variable definitions +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 1 # number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 20 # number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 0 # number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 2 # number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # number + +# The gap for aligning struct/union member definitions +align_var_struct_gap = 0 # number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # number + +# The minimum space between the type and the synonym of a typedef +align_typedef_gap = 0 # number + +# The span for aligning single-line typedefs (0=don't align) +align_typedef_span = 0 # number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typedef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typedef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 3 # number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment +align_right_cmt_mix = true # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. This has to be > 0 to do anything. +align_right_cmt_gap = 0 # number + +# Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore) +align_right_cmt_at_col = 0 # number + +# The span for aligning function prototypes (0=don't align) +align_func_proto_span = 0 # number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # number + +# Align function protos on the 'operator' keyword instead of what follows +align_on_operator = false # false/true + +# Whether to mix aligning prototype and variable declarations. +# If true, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=true, uses align_func_proto_span +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = false # false/true + +# # Align macro functions and variables together +align_pp_define_together = false # false/true + +# The minimum space between label and value of a preprocessor define +align_pp_define_gap = 0 # number + +# The span for aligning on '#define' bodies (0=don't align) +align_pp_define_span = 0 # number + +# Align lines that start with '<<' with previous '<<'. Default=true +align_left_shift = false # false/true + +# Span for aligning parameters in an Obj-C message call on the ':' (0=don't align) +align_oc_msg_colon_span = 0 # number + +# If true, always align with the first parameter, even if it is too short. +align_oc_msg_colon_first = false # false/true + +# Aligning parameters in an Obj-C '+' or '-' declaration on the ':' +align_oc_decl_colon = false # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}' +nl_collapse_empty_body = false # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };' +nl_assign_leave_one_liners = true # false/true + +# Don't split one-line braced statements inside a class xx { } body +nl_class_leave_one_liners = true # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }' +nl_func_leave_one_liners = false # false/true + +# Don't split one-line if/else statements - 'if(a) b++;' +nl_if_leave_one_liners = false # false/true + +# Don't split one-line OC messages +nl_oc_msg_leave_one_liner = false # false/true + +# Add or remove newlines at the start of the file +nl_start_of_file = ignore # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force' +nl_start_of_file_min = 0 # number + +# Add or remove newline at the end of the file +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force') +nl_end_of_file_min = 1 # number + +# Add or remove newline between '=' and '{' +nl_assign_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only) +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']' +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of blank lines after a block of variable definitions at the top of a function body +# 0 = No change (default) +nl_func_var_def_blk = 0 # number + +# The number of newlines before a block of typedefs +# 0 = No change (default) +nl_typedef_blk_start = 0 # number + +# The number of newlines after a block of typedefs +# 0 = No change (default) +nl_typedef_blk_end = 0 # number + +# The maximum consecutive newlines within a block of typedefs +# 0 = No change (default) +nl_typedef_blk_in = 0 # number + +# The number of newlines before a block of variable definitions not at the top of a function body +# 0 = No change (default) +nl_var_def_blk_start = 0 # number + +# The number of newlines after a block of variable definitions not at the top of a function body +# 0 = No change (default) +nl_var_def_blk_end = 0 # number + +# The maximum consecutive newlines within a block of variable definitions +# 0 = No change (default) +nl_var_def_blk_in = 0 # number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { } +nl_fcall_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{' +nl_enum_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'struct and '{' +nl_struct_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'union' and '{' +nl_union_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'if' and '{' +nl_if_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'else' +nl_brace_else = add # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead +nl_elseif_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and '{' +nl_else_brace = add # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if' +nl_else_if = ignore # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally' +nl_brace_finally = ignore # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{' +nl_finally_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'try' and '{' +nl_try_brace = add # ignore/add/remove/force + +# Add or remove newline between get/set and '{' +nl_getset_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'for' and '{' +nl_for_brace = add # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{' +nl_catch_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch' +nl_brace_catch = add # ignore/add/remove/force + +# Add or remove newline between 'while' and '{' +nl_while_brace = add # ignore/add/remove/force + +# Add or remove newline between 'scope (x)' and '{' (D) +nl_scope_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'unittest' and '{' (D) +nl_unittest_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'version (x)' and '{' (D) +nl_version_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'using' and '{' +nl_using_brace = ignore # ignore/add/remove/force + +# Add or remove newline between two open or close braces. +# Due to general newline/brace handling, REMOVE may not work. +nl_brace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'do' and '{' +nl_do_brace = add # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement +nl_brace_while = add # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{' +nl_switch_brace = add # ignore/add/remove/force + +# Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. +# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch, and nl_catch_brace. +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = false # false/true + +# Whether to put a newline before 'case' statement +nl_before_case = false # false/true + +# Add or remove newline between ')' and 'throw' +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement +nl_after_case = false # false/true + +# Add or remove a newline between a case ':' and '{'. Overrides nl_after_case. +nl_case_colon_brace = add # ignore/add/remove/force + +# Newline between namespace and { +nl_namespace_brace = add # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{' +nl_class_brace = add # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization +nl_class_init_args = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a function definition +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name inside a class {} +# Uses nl_func_type_name or nl_func_proto_type_name if set to ignore. +nl_func_type_name_class = ignore # ignore/add/remove/force + +# Add or remove newline between function scope and name in a definition +# Controls the newline after '::' in 'void A::f() { }' +nl_func_scope_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype +nl_func_proto_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' +nl_func_paren = remove # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' in the definition +nl_func_def_paren = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function definition +nl_func_def_start = ignore # ignore/add/remove/force + +# Overrides nl_func_decl_start when there is only one parameter. +nl_func_decl_start_single = ignore # ignore/add/remove/force + +# Overrides nl_func_def_start when there is only one parameter. +nl_func_def_start_single = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function declaration +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function definition +nl_func_def_args = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function declaration +nl_func_decl_end = ignore # ignore/add/remove/force + +# Add or remove newline before the ')' in a function definition +nl_func_def_end = ignore # ignore/add/remove/force + +# Overrides nl_func_decl_end when there is only one parameter. +nl_func_decl_end_single = ignore # ignore/add/remove/force + +# Overrides nl_func_def_end when there is only one parameter. +nl_func_def_end_single = ignore # ignore/add/remove/force + +# Add or remove newline between '()' in a function declaration. +nl_func_decl_empty = ignore # ignore/add/remove/force + +# Add or remove newline between '()' in a function definition. +nl_func_def_empty = ignore # ignore/add/remove/force + +# Whether to put each OC message parameter on a separate line +# See nl_oc_msg_leave_one_liner +nl_oc_msg_args = false # false/true + +# Add or remove newline between function signature and '{' +nl_fdef_brace = add # ignore/add/remove/force + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements +nl_after_semicolon = false # false/true + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = true # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are true, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open with a non-empty body. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to put a newline after a virtual brace open with an empty body. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open_empty = false # false/true + +# Whether to put a newline after a brace close. +# Does not apply if followed by a necessary ';'. +nl_after_brace_close = false # false/true + +# Whether to put a newline after a virtual brace close. +# Would add a newline before return in: 'if (foo) a++; return;' +nl_after_vbrace_close = false # false/true + +# Control the newline between the close brace and 'b' in: 'struct { int a; } b;' +# Affects enums, unions, and structures. If set to ignore, uses nl_after_brace_close +nl_brace_struct_var = ignore # ignore/add/remove/force + +# Whether to alter newlines in '#define' macros +nl_define_macro = false # false/true + +# Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' +nl_squeeze_ifdef = false # false/true + +# Add or remove blank line before 'if' +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove blank line after 'if' statement +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove blank line before 'for' +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove blank line after 'for' statement +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove blank line before 'while' +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove blank line after 'while' statement +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove blank line before 'switch' +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove blank line after 'switch' statement +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove blank line before 'do' +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove blank line after 'do/while' statement +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/enum +nl_ds_struct_enum_cmt = false # false/true + +# Whether to double-space before the close brace of a struct/union/enum +# (lower priority than 'eat_blanks_before_close_brace') +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove a newline around a class colon. +# Related to pos_class_colon, nl_class_init_args, and pos_comma. +nl_class_colon = ignore # ignore/add/remove/force + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;' +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);' +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);' +nl_create_while_one_liner = false # false/true + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions +pos_arith = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of assignment in wrapped expressions. +# Do not affect '=' followed by '{' +pos_assign = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of boolean operators in wrapped expressions +pos_bool = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of comparison operators in wrapped expressions +pos_compare = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of conditional (b ? t : f) operators in wrapped expressions +pos_conditional = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of the comma in wrapped expressions +pos_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of the comma in the constructor initialization list +pos_class_comma = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of colons between constructor and member initialization +pos_class_colon = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 0 # number + +# Whether to fully split long 'for' statements at semi-colons +ls_for_split_full = false # false/true + +# Whether to fully split long function protos/calls at commas +ls_func_split_full = false # false/true + +# Whether to split lines as close to code_width as possible and ignore some groupings +ls_code_width = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines +nl_max = 0 # number + +# The number of newlines after a function prototype, if followed by another function prototype +nl_after_func_proto = 0 # number + +# The number of newlines after a function prototype, if not followed by another function prototype +nl_after_func_proto_group = 0 # number + +# The number of newlines after '}' of a multi-line function body +nl_after_func_body = 0 # number + +# The number of newlines after '}' of a multi-line function body in a class declaration +nl_after_func_body_class = 0 # number + +# The number of newlines after '}' of a single line function body +nl_after_func_body_one_liner = 0 # number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 0 # number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # number + +# Whether to force a newline after a multi-line comment. +nl_after_multiline_comment = false # false/true + +# The number of newlines after '}' or ';' of a struct/enum/union definition +nl_after_struct = 0 # number + +# The number of newlines after '}' or ';' of a class definition +nl_after_class = 0 # number + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 0 # number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# 0 = No change. +nl_after_access_spec = 0 # number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 0 # number + +# The number of newlines after a try-catch-finally block that isn't followed by a brace close. +# 0 = No change. +nl_after_try_catch_finally = 0 # number + +# The number of newlines before and after a property, indexer or event decl. +# 0 = No change. +nl_around_cs_property = 0 # number + +# The number of newlines between the get/set/add/remove handlers in C#. +# 0 = No change. +nl_between_get_set = 0 # number + +# Add or remove newline between C# property and the '{' +nl_property_brace = ignore # ignore/add/remove/force + +# Whether to remove blank lines after '{' +eat_blanks_after_open_brace = false # false/true + +# Whether to remove blank lines before '}' +eat_blanks_before_close_brace = false # false/true + +# How aggressively to remove extra newlines not in preproc. +# 0: No change +# 1: Remove most newlines not handled by other config +# 2: Remove all newlines and reformat completely by config +nl_remove_extra_newlines = 0 # number + +# Whether to put a blank line before 'return' statements, unless after an open brace. +nl_before_return = false # false/true + +# Whether to put a blank line after 'return' statements, unless followed by a close brace. +nl_after_return = false # false/true + +# Whether to put a newline after a Java annotation statement. +# Only affects annotations that are after a newline. +nl_after_annotation = ignore # ignore/add/remove/force + +# Controls the newline between two annotations. +nl_between_annotation = ignore # ignore/add/remove/force + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function definitions. (Pawn) +mod_full_brace_function = add # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = add # ignore/add/remove/force + +# Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if. +# If any must be braced, they are all braced. If all can be unbraced, then the braces are removed. +mod_full_brace_if_chain = false # false/true + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # number + +# Add or remove braces on single-line 'while' statement +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove braces on single-line 'using ()' statement +mod_full_brace_using = ignore # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement +mod_paren_on_return = ignore # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons +mod_remove_extra_semicolon = false # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # number + +# If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after +# the #endif, a comment will be added. +mod_add_long_ifdef_endif_comment = 0 # number + +# If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after +# the #else, a comment will be added. +mod_add_long_ifdef_else_comment = 0 # number + +# If TRUE, will sort consecutive single-line 'import' statements [Java, D] +mod_sort_import = false # false/true + +# If TRUE, will sort consecutive single-line 'using' statements [C#] +mod_sort_using = false # false/true + +# If TRUE, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If TRUE, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = false # false/true + +# Will add or remove the braces around a fully braced case statement. +# Will only remove the braces if there are no variable declarations in the block. +mod_case_brace = ignore # ignore/add/remove/force + +# If TRUE, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = false # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 0 # number + +# Set the comment reflow mode (default: 0) +# 0: no reflowing (apart from the line wrapping due to cmt_width) +# 1: no touching at all +# 2: full reflow +cmt_reflow_mode = 0 # number + +# If false, disable all multi-line comment changes, including cmt_width. keyword substitution, and leading chars. +# Default is true. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines +cmt_sp_before_star_cont = 0 # number + +# The number of spaces to insert after the star on subsequent comment lines +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True +cmt_multi_check_last = false # false/true + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitute $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. +# Will substitute $(filename) with the current file's name. +cmt_insert_file_footer = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceded with a C/C++ comment. +# Will substitute $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... } +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceded with a C/C++ comment. +# Will substitute $(class) with the class name. +cmt_insert_class_header = "" # string + +# The filename that contains text to insert before a Obj-C message specification if the method isn't preceeded with a C/C++ comment. +# Will substitute $(message) with the function name and $(javaparam) with the javadoc @param and @return stuff. +cmt_insert_oc_msg_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_oc_msg_header, cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 +pp_indent = ignore # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) +pp_indent_at_level = false # false/true + +# If pp_indent_at_level=false, specifies the number of columns to indent per level. Default=1. +pp_indent_count = 1 # number + +# Add or remove space after # based on pp_level of #if blocks +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space +pp_space_count = 0 # number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++ +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=true, sets the indent for #if, #else, and #endif when not at file-level +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif when not at file-level +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (true) or from column 1 (false) +pp_define_at_level = false # false/true + +# You can force a token to be a type with the 'type' option. +# Example: +# type myfoo1 myfoo2 +# +# You can create custom macro-based indentation using macro-open, +# macro-else and macro-close. +# Example: +# macro-open BEGIN_TEMPLATE_MESSAGE_MAP +# macro-open BEGIN_MESSAGE_MAP +# macro-close END_MESSAGE_MAP +# +# You can assign any keyword to any type with the set option. +# set func_call_user _ N_ +# +# The full syntax description of all custom definition config entries +# is shown below: +# +# define custom tokens as: +# - embed whitespace in token using '' escape character, or +# put token in quotes +# - these: ' " and ` are recognized as quote delimiters +# +# type token1 token2 token3 ... +# ^ optionally specify multiple tokens on a single line +# define def_token output_token +# ^ output_token is optional, then NULL is assumed +# macro-open token +# macro-close token +# macro-else token +# set id token1 token2 ... +# ^ optionally specify multiple tokens on a single line +# ^ id is one of the names in token_enum.h sans the CT_ prefix, +# e.g. PP_PRAGMA +# +# all tokens are separated by any mix of ',' commas, '=' equal signs +# and whitespace (space, tab) +# diff --git a/src/gromacs/analysisdata/abstractdata.cpp b/src/gromacs/analysisdata/abstractdata.cpp index d9c28126f4..c271e7296f 100644 --- a/src/gromacs/analysisdata/abstractdata.cpp +++ b/src/gromacs/analysisdata/abstractdata.cpp @@ -83,7 +83,7 @@ class AbstractAnalysisData::Impl * calls the notification functions in \p module as if the module had * been registered to the data object when the data was added. */ - void presentData(AbstractAnalysisData *data, + void presentData(AbstractAnalysisData *data, AnalysisDataModuleInterface *module); //! List of modules added to the data. @@ -113,7 +113,7 @@ AbstractAnalysisData::Impl::Impl() } void -AbstractAnalysisData::Impl::presentData(AbstractAnalysisData *data, +AbstractAnalysisData::Impl::presentData(AbstractAnalysisData *data, AnalysisDataModuleInterface *module) { module->dataStarted(data); @@ -310,7 +310,7 @@ AbstractAnalysisData::notifyFrameStart(const AnalysisDataFrameHeader &header) co "notifyFrameStart() called while inside a frame"); GMX_ASSERT(header.index() == impl_->nframes_, "Out of order frames"); - impl_->bInFrame_ = true; + impl_->bInFrame_ = true; impl_->currIndex_ = header.index(); Impl::ModuleList::const_iterator i; @@ -349,7 +349,7 @@ AbstractAnalysisData::notifyFrameFinish(const AnalysisDataFrameHeader &header) GMX_ASSERT(impl_->bInFrame_, "notifyFrameStart() not called"); GMX_ASSERT(header.index() == impl_->currIndex_, "Header does not correspond to current frame"); - impl_->bInFrame_ = false; + impl_->bInFrame_ = false; impl_->currIndex_ = -1; // Increment the counter before notifications to allow frame access from diff --git a/src/gromacs/analysisdata/abstractdata.h b/src/gromacs/analysisdata/abstractdata.h index 6c8ff7ee44..2ecba948b6 100644 --- a/src/gromacs/analysisdata/abstractdata.h +++ b/src/gromacs/analysisdata/abstractdata.h @@ -416,8 +416,8 @@ class AbstractAnalysisData class Impl; PrivateImplPointer impl_; - int columnCount_; - bool bMultiPoint_; + int columnCount_; + bool bMultiPoint_; /*! \brief * Needed to provide access to notification methods. diff --git a/src/gromacs/analysisdata/analysisdata.cpp b/src/gromacs/analysisdata/analysisdata.cpp index 162e83df0c..7314ff42d6 100644 --- a/src/gromacs/analysisdata/analysisdata.cpp +++ b/src/gromacs/analysisdata/analysisdata.cpp @@ -74,7 +74,7 @@ class AnalysisDataHandleImpl AnalysisDataStorageFrame *currentFrame_; }; -} // namespace internal +} // namespace internal /******************************************************************** * AnalysisData::Impl @@ -90,7 +90,7 @@ class AnalysisData::Impl public: //! Smart pointer type to manage a data handle implementation. typedef gmx_unique_ptr::type - HandlePointer; + HandlePointer; //! Shorthand for a list of data handles. typedef std::vector HandleList; diff --git a/src/gromacs/analysisdata/analysisdata.h b/src/gromacs/analysisdata/analysisdata.h index bdc3135423..6867de78ab 100644 --- a/src/gromacs/analysisdata/analysisdata.h +++ b/src/gromacs/analysisdata/analysisdata.h @@ -176,7 +176,7 @@ class AnalysisData : public AbstractAnalysisData namespace internal { class AnalysisDataHandleImpl; -} // namespace internal +} // namespace internal /*! \brief * Handle for inserting data into AnalysisData. diff --git a/src/gromacs/analysisdata/arraydata.cpp b/src/gromacs/analysisdata/arraydata.cpp index edf0e4b282..4833b355f0 100644 --- a/src/gromacs/analysisdata/arraydata.cpp +++ b/src/gromacs/analysisdata/arraydata.cpp @@ -66,8 +66,8 @@ AbstractAnalysisArrayData::tryGetDataFrameInternal(int index) const std::vector::const_iterator begin = value_.begin() + index * columnCount(); return AnalysisDataFrameRef( - AnalysisDataFrameHeader(index, xvalue(index), 0.0), - AnalysisDataValuesRef(begin, begin + columnCount())); + AnalysisDataFrameHeader(index, xvalue(index), 0.0), + AnalysisDataValuesRef(begin, begin + columnCount())); } @@ -117,7 +117,7 @@ AbstractAnalysisArrayData::setXAxis(real start, real step) { GMX_RELEASE_ASSERT(!bReady_, "X axis cannot be set after data is finished"); xstart_ = start; - xstep_ = step; + xstep_ = step; } @@ -138,8 +138,8 @@ AbstractAnalysisArrayData::valuesReady() AnalysisDataFrameHeader header(i, xvalue(i), 0); notifyFrameStart(header); notifyPointsAdd(AnalysisDataPointSetRef(header, 0, - AnalysisDataValuesRef(valueIter, - valueIter + columnCount()))); + AnalysisDataValuesRef(valueIter, + valueIter + columnCount()))); notifyFrameFinish(header); } notifyDataFinish(); @@ -148,7 +148,7 @@ AbstractAnalysisArrayData::valuesReady() void AbstractAnalysisArrayData::copyContents(const AbstractAnalysisArrayData *src, - AbstractAnalysisArrayData *dest) + AbstractAnalysisArrayData *dest) { GMX_RELEASE_ASSERT(src->isAllocated(), "Source data must not be empty"); GMX_RELEASE_ASSERT(!dest->isAllocated(), diff --git a/src/gromacs/analysisdata/arraydata.h b/src/gromacs/analysisdata/arraydata.h index 1c46fad609..5018720182 100644 --- a/src/gromacs/analysisdata/arraydata.h +++ b/src/gromacs/analysisdata/arraydata.h @@ -192,17 +192,17 @@ class AbstractAnalysisArrayData : public AbstractAnalysisData * \p dest should not have previous contents. */ static void copyContents(const AbstractAnalysisArrayData *src, - AbstractAnalysisArrayData *dest); + AbstractAnalysisArrayData *dest); private: virtual AnalysisDataFrameRef tryGetDataFrameInternal(int index) const; virtual bool requestStorageInternal(int nframes); - int rowCount_; + int rowCount_; std::vector value_; - real xstart_; - real xstep_; - bool bReady_; + real xstart_; + real xstep_; + bool bReady_; // Copy and assign disallowed by base. }; diff --git a/src/gromacs/analysisdata/dataframe.cpp b/src/gromacs/analysisdata/dataframe.cpp index 88fb15296a..d6f638e9ca 100644 --- a/src/gromacs/analysisdata/dataframe.cpp +++ b/src/gromacs/analysisdata/dataframe.cpp @@ -75,7 +75,7 @@ AnalysisDataPointSetRef::AnalysisDataPointSetRef( AnalysisDataPointSetRef::AnalysisDataPointSetRef( - const AnalysisDataFrameHeader &header, + const AnalysisDataFrameHeader &header, const std::vector &values) : header_(header), firstColumn_(0), values_(values.begin(), values.end()) { @@ -101,7 +101,7 @@ AnalysisDataPointSetRef::AnalysisDataPointSetRef( if (newFirstColumn > 0) { // Offset pointer if the first column is not the first in points. - begin += newFirstColumn; + begin += newFirstColumn; newFirstColumn = 0; } else @@ -144,14 +144,14 @@ AnalysisDataFrameRef::AnalysisDataFrameRef() AnalysisDataFrameRef::AnalysisDataFrameRef( const AnalysisDataFrameHeader &header, - const AnalysisDataValuesRef &values) + const AnalysisDataValuesRef &values) : header_(header), values_(values) { } AnalysisDataFrameRef::AnalysisDataFrameRef( - const AnalysisDataFrameHeader &header, + const AnalysisDataFrameHeader &header, const std::vector &values) : header_(header), values_(values.begin(), values.end()) { diff --git a/src/gromacs/analysisdata/dataframe.h b/src/gromacs/analysisdata/dataframe.h index 3cd87b29a7..7c06f0ef3d 100644 --- a/src/gromacs/analysisdata/dataframe.h +++ b/src/gromacs/analysisdata/dataframe.h @@ -294,8 +294,8 @@ class AnalysisDataPointSetRef * The first element in \p values should correspond to \p firstColumn. */ AnalysisDataPointSetRef(const AnalysisDataFrameHeader &header, - int firstColumn, - const AnalysisDataValuesRef &values); + int firstColumn, + const AnalysisDataValuesRef &values); /*! \brief * Constructs a point set reference from given values. * @@ -305,7 +305,7 @@ class AnalysisDataPointSetRef * The first element in \p values should correspond to the first * column. */ - AnalysisDataPointSetRef(const AnalysisDataFrameHeader &header, + AnalysisDataPointSetRef(const AnalysisDataFrameHeader &header, const std::vector &values); /*! \brief * Constructs a point set reference to a subset of columns. @@ -464,14 +464,14 @@ class AnalysisDataFrameRef * \param[in] values Values for each column. */ AnalysisDataFrameRef(const AnalysisDataFrameHeader &header, - const AnalysisDataValuesRef &values); + const AnalysisDataValuesRef &values); /*! \brief * Constructs a frame reference from given values. * * \param[in] header Header for the frame. * \param[in] values Values for each column. */ - AnalysisDataFrameRef(const AnalysisDataFrameHeader &header, + AnalysisDataFrameRef(const AnalysisDataFrameHeader &header, const std::vector &values); /*! \brief * Constructs a frame reference to a subset of columns. diff --git a/src/gromacs/analysisdata/datastorage.cpp b/src/gromacs/analysisdata/datastorage.cpp index a9ca1fd27e..708f06022c 100644 --- a/src/gromacs/analysisdata/datastorage.cpp +++ b/src/gromacs/analysisdata/datastorage.cpp @@ -318,13 +318,13 @@ AnalysisDataStorage::Impl::endStorageLocation() const void AnalysisDataStorage::Impl::extendBuffer(AnalysisDataStorage *storage, - size_t newSize) + size_t newSize) { frames_.reserve(newSize); while (frames_.size() < newSize) { frames_.push_back(StoredFrame( - new AnalysisDataStorageFrame(storage, columnCount(), nextIndex_))); + new AnalysisDataStorageFrame(storage, columnCount(), nextIndex_))); ++nextIndex_; } // The unused frame should not be included in the count. @@ -348,7 +348,7 @@ AnalysisDataStorage::Impl::rotateBuffer() } firstFrameLocation_ = nextFirst; StoredFrame &prevFrame = frames_[prevFirst]; - prevFrame.status = StoredFrame::eMissing; + prevFrame.status = StoredFrame::eMissing; prevFrame.frame->header_ = AnalysisDataFrameHeader(nextIndex_ + 1, 0.0, 0.0); prevFrame.frame->clearValues(); ++nextIndex_; @@ -376,7 +376,7 @@ AnalysisDataStorage::Impl::notifyNextFrames(size_t firstLocation) return; } } - size_t i = firstLocation; + size_t i = firstLocation; size_t end = endStorageLocation(); while (i != end) { @@ -425,7 +425,7 @@ AnalysisDataPointSetRef AnalysisDataStorageFrame::currentPoints() const { std::vector::const_iterator begin = values_.begin(); - std::vector::const_iterator end = values_.end(); + std::vector::const_iterator end = values_.end(); while (begin != end && !begin->isSet()) { ++begin; @@ -436,7 +436,7 @@ AnalysisDataStorageFrame::currentPoints() const } int firstColumn = (begin != end) ? begin - values_.begin() : 0; return AnalysisDataPointSetRef(header_, firstColumn, - AnalysisDataValuesRef(begin, end)); + AnalysisDataValuesRef(begin, end)); } @@ -578,7 +578,7 @@ AnalysisDataStorage::startFrame(const AnalysisDataFrameHeader &header) "startFrame() called twice for the same frame"); GMX_RELEASE_ASSERT(storedFrame->frame->frameIndex() == header.index(), "Inconsistent internal frame indexing"); - storedFrame->status = Impl::StoredFrame::eStarted; + storedFrame->status = Impl::StoredFrame::eStarted; storedFrame->frame->header_ = header; if (impl_->isMultipoint()) { @@ -598,7 +598,7 @@ AnalysisDataStorage::startFrame(int index, real x, real dx) AnalysisDataStorageFrame & AnalysisDataStorage::currentFrame(int index) { - int storageIndex = impl_->computeStorageLocation(index); + int storageIndex = impl_->computeStorageLocation(index); GMX_RELEASE_ASSERT(storageIndex >= 0, "Out of bounds frame index"); Impl::StoredFrame &storedFrame = impl_->frames_[storageIndex]; GMX_RELEASE_ASSERT(storedFrame.isStarted(), @@ -614,7 +614,7 @@ AnalysisDataStorage::currentFrame(int index) void AnalysisDataStorage::finishFrame(int index) { - int storageIndex = impl_->computeStorageLocation(index); + int storageIndex = impl_->computeStorageLocation(index); GMX_RELEASE_ASSERT(storageIndex >= 0, "Out of bounds frame index"); Impl::StoredFrame &storedFrame = impl_->frames_[storageIndex]; GMX_RELEASE_ASSERT(storedFrame.isStarted(), diff --git a/src/gromacs/analysisdata/datastorage.h b/src/gromacs/analysisdata/datastorage.h index 21c7789598..a652973970 100644 --- a/src/gromacs/analysisdata/datastorage.h +++ b/src/gromacs/analysisdata/datastorage.h @@ -195,9 +195,9 @@ class AnalysisDataStorageFrame void clearValues(); //! Storage object that contains this frame. - AnalysisDataStorage &storage_; + AnalysisDataStorage &storage_; //! Header for the frame. - AnalysisDataFrameHeader header_; + AnalysisDataFrameHeader header_; //! Values for the frame. std::vector values_; diff --git a/src/gromacs/analysisdata/modules/average.cpp b/src/gromacs/analysisdata/modules/average.cpp index 4b4658d915..e9ba25fa88 100644 --- a/src/gromacs/analysisdata/modules/average.cpp +++ b/src/gromacs/analysisdata/modules/average.cpp @@ -179,7 +179,7 @@ AnalysisDataFrameAverageModule::pointsAdded(const AnalysisDataPointSetRef &point if (points.present(i)) { const real y = points.y(i); - frame.value(0) += y; + frame.value(0) += y; impl_->sampleCount_ += 1; } } @@ -190,7 +190,7 @@ AnalysisDataFrameAverageModule::frameFinished(const AnalysisDataFrameHeader &hea { AnalysisDataStorageFrame &frame = impl_->storage_.currentFrame(header.index()); - const int samples = impl_->sampleCount_; + const int samples = impl_->sampleCount_; if (samples > 0) { frame.value(0) /= samples; diff --git a/src/gromacs/analysisdata/modules/average.h b/src/gromacs/analysisdata/modules/average.h index 910d10cf47..dff785083d 100644 --- a/src/gromacs/analysisdata/modules/average.h +++ b/src/gromacs/analysisdata/modules/average.h @@ -94,7 +94,7 @@ class AnalysisDataAverageModule : public AbstractAnalysisArrayData, //! Smart pointer to manage an AnalysisDataAverageModule object. typedef boost::shared_ptr - AnalysisDataAverageModulePointer; + AnalysisDataAverageModulePointer; /*! \brief * Data module for averaging of columns for each frame. @@ -136,7 +136,7 @@ class AnalysisDataFrameAverageModule : public AbstractAnalysisData, //! Smart pointer to manage an AnalysisDataFrameAverageModule object. typedef boost::shared_ptr - AnalysisDataFrameAverageModulePointer; + AnalysisDataFrameAverageModulePointer; } // namespace gmx diff --git a/src/gromacs/analysisdata/modules/displacement.cpp b/src/gromacs/analysisdata/modules/displacement.cpp index a27ecbde1b..d3014f0b02 100644 --- a/src/gromacs/analysisdata/modules/displacement.cpp +++ b/src/gromacs/analysisdata/modules/displacement.cpp @@ -82,11 +82,11 @@ class AnalysisDataDisplacementModule::Impl int ci; //! Maximum number of positions to store for a particle. - int max_store; + int max_store; //! The total number of positions ever stored (can be larger than \p max_store). - int nstored; + int nstored; //! Old values. - real *oldval; + real *oldval; //! The most recently calculated displacements. std::vector currValues_; @@ -222,7 +222,7 @@ AnalysisDataDisplacementModule::frameStarted(const AnalysisDataFrameHeader &head { _impl->p[_impl->ci + i].bPres = false; } -*/ + */ _impl->nstored++; _impl->bFirst = false; } @@ -283,7 +283,7 @@ AnalysisDataDisplacementModule::frameFinished(const AnalysisDataFrameHeader & /* for (int d = 0; d < _impl->ndim; ++d) { real displ = _impl->oldval[_impl->ci + j + d] - - _impl->oldval[i + j + d]; + - _impl->oldval[i + j + d]; dist2 += displ * displ; } _impl->currValues_.push_back(AnalysisDataValue(dist2)); diff --git a/src/gromacs/analysisdata/modules/displacement.h b/src/gromacs/analysisdata/modules/displacement.h index 10fd5f8de6..9abb1b8784 100644 --- a/src/gromacs/analysisdata/modules/displacement.h +++ b/src/gromacs/analysisdata/modules/displacement.h @@ -98,7 +98,7 @@ class AnalysisDataDisplacementModule : public AbstractAnalysisData, //! Smart pointer to manage an AnalysisDataDisplacementModule object. typedef boost::shared_ptr - AnalysisDataDisplacementModulePointer; + AnalysisDataDisplacementModulePointer; } // namespace gmx diff --git a/src/gromacs/analysisdata/modules/histogram.cpp b/src/gromacs/analysisdata/modules/histogram.cpp index f5d0f5cdd5..8feec89379 100644 --- a/src/gromacs/analysisdata/modules/histogram.cpp +++ b/src/gromacs/analysisdata/modules/histogram.cpp @@ -134,7 +134,7 @@ AnalysisHistogramSettings::AnalysisHistogramSettings( else { firstEdge_ = settings.min_; - lastEdge_ = settings.max_; + lastEdge_ = settings.max_; if (settings.binCount_ > 0) { binCount_ = settings.binCount_; @@ -223,7 +223,7 @@ StaticAverageHistogram::StaticAverageHistogram( { } -} // namespace +} // namespace /******************************************************************** @@ -274,9 +274,9 @@ AbstractAverageHistogram::resampleDoubleBinWidth(bool bIntegerBins) const } AverageHistogramPointer dest( - new StaticAverageHistogram( - histogramFromBins(xstart(), nbins, 2*xstep()) - .integerBins(bIntegerBins))); + new StaticAverageHistogram( + histogramFromBins(xstart(), nbins, 2*xstep()) + .integerBins(bIntegerBins))); dest->setColumnCount(columnCount()); dest->allocateValues(); @@ -490,7 +490,7 @@ class BasicHistogramImpl public: //! Smart pointer to manage an BasicAverageHistogramModule object. typedef boost::shared_ptr - BasicAverageHistogramModulePointer; + BasicAverageHistogramModulePointer; BasicHistogramImpl(); //! Creates an histogram impl with defined bin parameters. @@ -547,7 +547,7 @@ BasicHistogramImpl::initFrame(AnalysisDataStorageFrame *frame) } } -} // namespace internal +} // namespace internal /******************************************************************** diff --git a/src/gromacs/analysisdata/modules/histogram.h b/src/gromacs/analysisdata/modules/histogram.h index 99b24326d0..3cf4d428ad 100644 --- a/src/gromacs/analysisdata/modules/histogram.h +++ b/src/gromacs/analysisdata/modules/histogram.h @@ -179,7 +179,7 @@ inline AnalysisHistogramSettingsInitializer histogramFromBins(real start, int nbins, real binwidth) { return AnalysisHistogramSettingsInitializer() - .start(start).binCount(nbins).binWidth(binwidth); + .start(start).binCount(nbins).binWidth(binwidth); } @@ -237,13 +237,13 @@ namespace internal class BasicHistogramImpl; -} // namespace internal +} // namespace internal class AbstractAverageHistogram; //! Smart pointer to manage an AbstractAverageHistogram object. typedef gmx_unique_ptr::type - AverageHistogramPointer; + AverageHistogramPointer; /*! \brief * Base class for representing histograms averaged over frames. @@ -484,13 +484,13 @@ class AnalysisDataBinAverageModule : public AbstractAnalysisArrayData, //! Smart pointer to manage an AnalysisDataSimpleHistogramModule object. typedef boost::shared_ptr - AnalysisDataSimpleHistogramModulePointer; + AnalysisDataSimpleHistogramModulePointer; //! Smart pointer to manage an AnalysisDataWeightedHistogramModule object. typedef boost::shared_ptr - AnalysisDataWeightedHistogramModulePointer; + AnalysisDataWeightedHistogramModulePointer; //! Smart pointer to manage an AnalysisDataBinAverageModule object. typedef boost::shared_ptr - AnalysisDataBinAverageModulePointer; + AnalysisDataBinAverageModulePointer; } // namespace gmx diff --git a/src/gromacs/analysisdata/modules/plot.cpp b/src/gromacs/analysisdata/modules/plot.cpp index 17290ccac1..7b45c06256 100644 --- a/src/gromacs/analysisdata/modules/plot.cpp +++ b/src/gromacs/analysisdata/modules/plot.cpp @@ -110,20 +110,20 @@ class AbstractPlotModule::Impl void closeFile(); - AnalysisDataPlotSettings settings_; - std::string filename_; - FILE *fp_; - - bool bPlain_; - bool gOmitX_; - std::string title_; - std::string subtitle_; - std::string xlabel_; - std::string ylabel_; + AnalysisDataPlotSettings settings_; + std::string filename_; + FILE *fp_; + + bool bPlain_; + bool gOmitX_; + std::string title_; + std::string subtitle_; + std::string xlabel_; + std::string ylabel_; std::vector legend_; - char xformat_[15]; - char yformat_[15]; - real xscale_; + char xformat_[15]; + char yformat_[15]; + real xscale_; }; AbstractPlotModule::Impl::Impl(const AnalysisDataPlotSettings &settings) @@ -303,13 +303,13 @@ AbstractPlotModule::dataStarted(AbstractAnalysisData *data) } else { - time_unit_t time_unit + time_unit_t time_unit = static_cast(impl_->settings_.timeUnit() + 1); xvg_format_t xvg_format = (impl_->settings_.plotFormat() > 0 - ? static_cast(impl_->settings_.plotFormat()) - : exvgNONE); - output_env_t oenv; + ? static_cast(impl_->settings_.plotFormat()) + : exvgNONE); + output_env_t oenv; output_env_init(&oenv, 0, NULL, time_unit, FALSE, xvg_format, 0, 0); boost::shared_ptr oenvGuard(oenv, &output_env_done); impl_->fp_ = xvgropen(impl_->filename_.c_str(), impl_->title_.c_str(), diff --git a/src/gromacs/analysisdata/modules/plot.h b/src/gromacs/analysisdata/modules/plot.h index e8df738bda..0471ce67e6 100644 --- a/src/gromacs/analysisdata/modules/plot.h +++ b/src/gromacs/analysisdata/modules/plot.h @@ -108,8 +108,8 @@ class AnalysisDataPlotSettings private: const SelectionCollection *selections_; - TimeUnit timeUnit_; - int plotFormat_; + TimeUnit timeUnit_; + int plotFormat_; }; /*! \brief @@ -310,10 +310,10 @@ class AnalysisDataVectorPlotModule : public AbstractPlotModule //! Smart pointer to manage an AnalysisDataPlotModule object. typedef boost::shared_ptr - AnalysisDataPlotModulePointer; + AnalysisDataPlotModulePointer; //! Smart pointer to manage an AnalysisDataVectorPlotModule object. typedef boost::shared_ptr - AnalysisDataVectorPlotModulePointer; + AnalysisDataVectorPlotModulePointer; } // namespace gmx diff --git a/src/gromacs/analysisdata/tests/analysisdata.cpp b/src/gromacs/analysisdata/tests/analysisdata.cpp index a453e8af30..70f8545e1d 100644 --- a/src/gromacs/analysisdata/tests/analysisdata.cpp +++ b/src/gromacs/analysisdata/tests/analysisdata.cpp @@ -140,7 +140,7 @@ const real inputdata[] = { TEST_F(AnalysisDataTest, CallsModuleCorrectly) { gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); ASSERT_NO_THROW(addStaticCheckerModule(input, &data)); @@ -156,7 +156,7 @@ TEST_F(AnalysisDataTest, CallsModuleCorrectly) TEST_F(AnalysisDataTest, CallsColumnModuleCorrectly) { gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); ASSERT_NO_THROW(addStaticColumnCheckerModule(input, 0, 2, &data)); @@ -171,13 +171,13 @@ TEST_F(AnalysisDataTest, CallsColumnModuleCorrectly) TEST_F(AnalysisDataTest, CallsModuleCorrectlyWithOutOfOrderFrames) { gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); ASSERT_NO_THROW(addStaticCheckerModule(input, &data)); ASSERT_NO_THROW(addStaticColumnCheckerModule(input, 1, 2, &data)); - gmx::AnalysisDataHandle handle1; - gmx::AnalysisDataHandle handle2; + gmx::AnalysisDataHandle handle1; + gmx::AnalysisDataHandle handle2; gmx::AnalysisDataParallelOptions options(2); ASSERT_NO_THROW(handle1 = data.startData(options)); ASSERT_NO_THROW(handle2 = data.startData(options)); @@ -195,7 +195,7 @@ TEST_F(AnalysisDataTest, CallsModuleCorrectlyWithOutOfOrderFrames) TEST_F(AnalysisDataTest, FullStorageWorks) { gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); ASSERT_NO_THROW(addStaticStorageCheckerModule(input, -1, &data)); @@ -209,7 +209,7 @@ TEST_F(AnalysisDataTest, FullStorageWorks) TEST_F(AnalysisDataTest, CanAddModuleAfterStoredData) { gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); ASSERT_TRUE(data.requestStorage(-1)); @@ -224,7 +224,7 @@ TEST_F(AnalysisDataTest, CanAddModuleAfterStoredData) TEST_F(AnalysisDataTest, LimitedStorageWorks) { gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); ASSERT_NO_THROW(addStaticStorageCheckerModule(input, 1, &data)); @@ -245,7 +245,7 @@ const real multipointinputdata[] = { TEST_F(AnalysisDataTest, MultipointCallsModuleCorrectly) { gmx::test::AnalysisDataTestInput input(multipointinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); @@ -262,7 +262,7 @@ TEST_F(AnalysisDataTest, MultipointCallsModuleCorrectly) TEST_F(AnalysisDataTest, MultipointCallsColumnModuleCorrectly) { gmx::test::AnalysisDataTestInput input(multipointinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); diff --git a/src/gromacs/analysisdata/tests/arraydata.cpp b/src/gromacs/analysisdata/tests/arraydata.cpp index 728546dea6..96ae04f46c 100644 --- a/src/gromacs/analysisdata/tests/arraydata.cpp +++ b/src/gromacs/analysisdata/tests/arraydata.cpp @@ -68,7 +68,7 @@ const real inputdata[] = { TEST_F(AnalysisArrayDataTest, CallsModuleCorrectly) { gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisArrayData data; + gmx::AnalysisArrayData data; data.setXAxis(1.0, 1.0); setupArrayData(input, &data); @@ -80,7 +80,7 @@ TEST_F(AnalysisArrayDataTest, CallsModuleCorrectly) TEST_F(AnalysisArrayDataTest, StorageWorks) { gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisArrayData data; + gmx::AnalysisArrayData data; data.setXAxis(1.0, 1.0); setupArrayData(input, &data); diff --git a/src/gromacs/analysisdata/tests/average.cpp b/src/gromacs/analysisdata/tests/average.cpp index 5857be38c3..5f9110f5d3 100644 --- a/src/gromacs/analysisdata/tests/average.cpp +++ b/src/gromacs/analysisdata/tests/average.cpp @@ -64,10 +64,10 @@ const real inputdata[] = { const real mpinputdata[] = { // *INDENT-OFF* 1.0, 0.0, 1.0, 2.0, MPSTOP, - 1.0, 0.0, MPSTOP, - 2.0, END_OF_FRAME, + 1.0, 0.0, MPSTOP, + 2.0, END_OF_FRAME, 2.0, 1.0, 1.0, MPSTOP, - 2.0, END_OF_FRAME, + 2.0, END_OF_FRAME, 3.0, 2.0, 0.0, 0.0, END_OF_FRAME // *INDENT-ON* }; @@ -82,8 +82,8 @@ typedef gmx::test::AnalysisDataTestFixture AverageModuleTest; TEST_F(AverageModuleTest, BasicTest) { - gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::test::AnalysisDataTestInput input(inputdata); + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); gmx::AnalysisDataAverageModulePointer module( new gmx::AnalysisDataAverageModule); @@ -98,7 +98,7 @@ TEST_F(AverageModuleTest, BasicTest) TEST_F(AverageModuleTest, HandlesMultipointData) { gmx::test::AnalysisDataTestInput input(mpinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); gmx::AnalysisDataAverageModulePointer module( @@ -113,8 +113,8 @@ TEST_F(AverageModuleTest, HandlesMultipointData) TEST_F(AverageModuleTest, CanCustomizeXAxis) { - gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::test::AnalysisDataTestInput input(inputdata); + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); gmx::AnalysisDataAverageModulePointer module(new gmx::AnalysisDataAverageModule()); data.addModule(module); @@ -135,8 +135,8 @@ typedef gmx::test::AnalysisDataTestFixture FrameAverageModuleTest; TEST_F(FrameAverageModuleTest, BasicTest) { - gmx::test::AnalysisDataTestInput input(inputdata); - gmx::AnalysisData data; + gmx::test::AnalysisDataTestInput input(inputdata); + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); gmx::AnalysisDataFrameAverageModulePointer module( new gmx::AnalysisDataFrameAverageModule); diff --git a/src/gromacs/analysisdata/tests/histogram.cpp b/src/gromacs/analysisdata/tests/histogram.cpp index 97a1a494eb..75ef90aa5d 100644 --- a/src/gromacs/analysisdata/tests/histogram.cpp +++ b/src/gromacs/analysisdata/tests/histogram.cpp @@ -63,7 +63,7 @@ namespace TEST(AnalysisHistogramSettingsTest, InitializesFromBins) { gmx::AnalysisHistogramSettings settings( - gmx::histogramFromBins(1.0, 5, 0.5)); + gmx::histogramFromBins(1.0, 5, 0.5)); EXPECT_FLOAT_EQ(1.0, settings.firstEdge()); EXPECT_EQ(5, settings.binCount()); EXPECT_FLOAT_EQ(0.5, settings.binWidth()); @@ -74,7 +74,7 @@ TEST(AnalysisHistogramSettingsTest, InitializesFromBins) TEST(AnalysisHistogramSettingsTest, InitializesFromBinsWithIntegerBins) { gmx::AnalysisHistogramSettings settings( - gmx::histogramFromBins(1.0, 5, 0.5).integerBins()); + gmx::histogramFromBins(1.0, 5, 0.5).integerBins()); EXPECT_FLOAT_EQ(0.75, settings.firstEdge()); EXPECT_EQ(5, settings.binCount()); EXPECT_FLOAT_EQ(0.5, settings.binWidth()); @@ -85,7 +85,7 @@ TEST(AnalysisHistogramSettingsTest, InitializesFromBinsWithIntegerBins) TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithBinCount) { gmx::AnalysisHistogramSettings settings( - gmx::histogramFromRange(1.0, 4.0).binCount(6)); + gmx::histogramFromRange(1.0, 4.0).binCount(6)); EXPECT_FLOAT_EQ(1.0, settings.firstEdge()); EXPECT_FLOAT_EQ(4.0, settings.lastEdge()); EXPECT_EQ(6, settings.binCount()); @@ -96,7 +96,7 @@ TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithBinCount) TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithBinWidth) { gmx::AnalysisHistogramSettings settings( - gmx::histogramFromRange(1.0, 4.0).binWidth(0.5)); + gmx::histogramFromRange(1.0, 4.0).binWidth(0.5)); EXPECT_FLOAT_EQ(1.0, settings.firstEdge()); EXPECT_FLOAT_EQ(4.0, settings.lastEdge()); EXPECT_FLOAT_EQ(0.5, settings.binWidth()); @@ -107,7 +107,7 @@ TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithBinWidth) TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithBinCountAndIntegerBins) { gmx::AnalysisHistogramSettings settings( - gmx::histogramFromRange(1.0, 4.0).binCount(7).integerBins()); + gmx::histogramFromRange(1.0, 4.0).binCount(7).integerBins()); EXPECT_FLOAT_EQ(0.75, settings.firstEdge()); EXPECT_FLOAT_EQ(4.25, settings.lastEdge()); EXPECT_EQ(7, settings.binCount()); @@ -118,7 +118,7 @@ TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithBinCountAndIntegerBi TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithBinWidthAndIntegerBins) { gmx::AnalysisHistogramSettings settings( - gmx::histogramFromRange(1.0, 4.0).binWidth(0.5).integerBins()); + gmx::histogramFromRange(1.0, 4.0).binWidth(0.5).integerBins()); EXPECT_FLOAT_EQ(0.75, settings.firstEdge()); EXPECT_FLOAT_EQ(4.25, settings.lastEdge()); EXPECT_FLOAT_EQ(0.5, settings.binWidth()); @@ -129,7 +129,7 @@ TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithBinWidthAndIntegerBi TEST(AnalysisHistogramSettingsTest, InitializesFromRangeWithRoundedRange) { gmx::AnalysisHistogramSettings settings( - gmx::histogramFromRange(1.2, 3.8).binWidth(0.5).roundRange()); + gmx::histogramFromRange(1.2, 3.8).binWidth(0.5).roundRange()); EXPECT_FLOAT_EQ(1.0, settings.firstEdge()); EXPECT_FLOAT_EQ(4.0, settings.lastEdge()); EXPECT_FLOAT_EQ(0.5, settings.binWidth()); @@ -156,12 +156,12 @@ const real simpleinputdata[] = { TEST_F(SimpleHistogramModuleTest, ComputesCorrectly) { gmx::test::AnalysisDataTestInput input(simpleinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); gmx::AnalysisDataSimpleHistogramModulePointer module( - new gmx::AnalysisDataSimpleHistogramModule( - gmx::histogramFromRange(1.0, 3.0).binCount(4))); + new gmx::AnalysisDataSimpleHistogramModule( + gmx::histogramFromRange(1.0, 3.0).binCount(4))); data.addModule(module); ASSERT_NO_THROW(addStaticCheckerModule(input, &data)); @@ -177,7 +177,7 @@ TEST_F(SimpleHistogramModuleTest, ComputesCorrectly) TEST_F(SimpleHistogramModuleTest, ComputesCorrectlyWithAll) { gmx::test::AnalysisDataTestInput input(simpleinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); gmx::AnalysisDataSimpleHistogramModulePointer module( @@ -212,12 +212,12 @@ const real weightedinputdata[] = { TEST_F(WeightedHistogramModuleTest, ComputesCorrectly) { gmx::test::AnalysisDataTestInput input(weightedinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); gmx::AnalysisDataWeightedHistogramModulePointer module( - new gmx::AnalysisDataWeightedHistogramModule( - gmx::histogramFromRange(1.0, 3.0).binCount(4))); + new gmx::AnalysisDataWeightedHistogramModule( + gmx::histogramFromRange(1.0, 3.0).binCount(4))); data.addModule(module); ASSERT_NO_THROW(addStaticCheckerModule(input, &data)); @@ -233,7 +233,7 @@ TEST_F(WeightedHistogramModuleTest, ComputesCorrectly) TEST_F(WeightedHistogramModuleTest, ComputesCorrectlyWithAll) { gmx::test::AnalysisDataTestInput input(weightedinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); gmx::AnalysisDataWeightedHistogramModulePointer module( @@ -261,12 +261,12 @@ typedef gmx::test::AnalysisDataTestFixture BinAverageModuleTest; TEST_F(BinAverageModuleTest, ComputesCorrectly) { gmx::test::AnalysisDataTestInput input(weightedinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); gmx::AnalysisDataBinAverageModulePointer module( - new gmx::AnalysisDataBinAverageModule( - gmx::histogramFromRange(1.0, 3.0).binCount(4))); + new gmx::AnalysisDataBinAverageModule( + gmx::histogramFromRange(1.0, 3.0).binCount(4))); data.addModule(module); ASSERT_NO_THROW(addStaticCheckerModule(input, &data)); @@ -279,7 +279,7 @@ TEST_F(BinAverageModuleTest, ComputesCorrectly) TEST_F(BinAverageModuleTest, ComputesCorrectlyWithAll) { gmx::test::AnalysisDataTestInput input(weightedinputdata); - gmx::AnalysisData data; + gmx::AnalysisData data; data.setColumnCount(input.columnCount()); data.setMultipoint(true); gmx::AnalysisDataBinAverageModulePointer module( @@ -342,7 +342,7 @@ class MockAverageHistogram : public gmx::AbstractAverageHistogram TEST_F(AbstractAverageHistogramTest, ClonesCorrectly) { gmx::test::AnalysisDataTestInput input(averageinputdata); - MockAverageHistogram data( + MockAverageHistogram data( gmx::histogramFromBins(1.0, input.frameCount(), 0.5).integerBins()); setupArrayData(input, &data); @@ -360,7 +360,7 @@ TEST_F(AbstractAverageHistogramTest, ClonesCorrectly) TEST_F(AbstractAverageHistogramTest, ResamplesAtDoubleBinWidth) { gmx::test::AnalysisDataTestInput input(averageinputdata); - MockAverageHistogram data( + MockAverageHistogram data( gmx::histogramFromBins(1.0, input.frameCount(), 0.5).integerBins()); setupArrayData(input, &data); @@ -376,7 +376,7 @@ TEST_F(AbstractAverageHistogramTest, ResamplesAtDoubleBinWidth) TEST_F(AbstractAverageHistogramTest, ResamplesAtDoubleBinWidthWithIntegerBins) { gmx::test::AnalysisDataTestInput input(averageinputdata); - MockAverageHistogram data( + MockAverageHistogram data( gmx::histogramFromBins(1.0, input.frameCount(), 0.5).integerBins()); setupArrayData(input, &data); diff --git a/src/gromacs/commandline/cmdlinehelpwriter.cpp b/src/gromacs/commandline/cmdlinehelpwriter.cpp index a11ebe00f8..9bbbe86518 100644 --- a/src/gromacs/commandline/cmdlinehelpwriter.cpp +++ b/src/gromacs/commandline/cmdlinehelpwriter.cpp @@ -76,16 +76,16 @@ class OptionsFormatterInterface //! Formats the description text block for a section. virtual void formatDescription(const HelpWriterContext &context, - const Options §ion) = 0; + const Options §ion) = 0; //! Formats a single file option. - virtual void formatFileOption(const HelpWriterContext &context, + virtual void formatFileOption(const HelpWriterContext &context, const FileNameOptionInfo &option) = 0; //! Formats a single non-file, non-selection option. virtual void formatOption(const HelpWriterContext &context, - const OptionInfo &option) = 0; + const OptionInfo &option) = 0; //! Formats a single selection option. virtual void formatSelectionOption(const HelpWriterContext &context, - const OptionInfo &option) = 0; + const OptionInfo &option) = 0; }; /******************************************************************** @@ -123,7 +123,7 @@ class OptionsFilter : public OptionsVisitor * * Does not throw. */ - OptionsFilter(const HelpWriterContext &context, + OptionsFilter(const HelpWriterContext &context, OptionsFormatterInterface *formatter) : context_(context), formatter_(*formatter), filterType_(eSelectOtherOptions), bShowHidden_(false), @@ -244,19 +244,19 @@ class OptionsConsoleFormatter : public OptionsFormatterInterface explicit OptionsConsoleFormatter(const CommonFormatterData &common); virtual void formatDescription(const HelpWriterContext &context, - const Options §ion); - virtual void formatFileOption(const HelpWriterContext &context, + const Options §ion); + virtual void formatFileOption(const HelpWriterContext &context, const FileNameOptionInfo &option); virtual void formatOption(const HelpWriterContext &context, - const OptionInfo &option); + const OptionInfo &option); virtual void formatSelectionOption(const HelpWriterContext &context, - const OptionInfo &option); + const OptionInfo &option); private: const CommonFormatterData &common_; - TextTableFormatter fileOptionFormatter_; - TextTableFormatter genericOptionFormatter_; - TextTableFormatter selectionOptionFormatter_; + TextTableFormatter fileOptionFormatter_; + TextTableFormatter genericOptionFormatter_; + TextTableFormatter selectionOptionFormatter_; }; OptionsConsoleFormatter::OptionsConsoleFormatter(const CommonFormatterData &common) @@ -281,7 +281,7 @@ void OptionsConsoleFormatter::formatDescription( { if (!section.description().empty()) { - File &file = context.outputFile(); + File &file = context.outputFile(); const std::string &title = section.title(); if (!title.empty()) { @@ -295,9 +295,9 @@ void OptionsConsoleFormatter::formatDescription( void OptionsConsoleFormatter::formatFileOption( const HelpWriterContext &context, const FileNameOptionInfo &option) { - int firstShortValue = 0; // The first value after which the type fits. - int firstLongValue = -1; // First value that overlaps description column. - int lastLongValue = -1; // Last value like the above. + int firstShortValue = 0; // The first value after which the type fits. + int firstLongValue = -1; // First value that overlaps description column. + int lastLongValue = -1; // Last value like the above. // Get the values to write and check where text overflows the columns. fileOptionFormatter_.clear(); @@ -386,9 +386,9 @@ void OptionsConsoleFormatter::formatOption( const HelpWriterContext &context, const OptionInfo &option) { genericOptionFormatter_.clear(); - bool bIsBool = option.isType(); + bool bIsBool = option.isType(); std::string name(formatString("-%s%s", bIsBool ? "[no]" : "", - option.name().c_str())); + option.name().c_str())); genericOptionFormatter_.addColumnLine(0, name); genericOptionFormatter_.addColumnLine(1, option.type()); if (name.length() > 12U) @@ -406,7 +406,7 @@ void OptionsConsoleFormatter::formatOption( values.append(option.formatValue(i)); } genericOptionFormatter_.addColumnLine(2, values); - std::string description(context.substituteMarkup(option.description())); + std::string description(context.substituteMarkup(option.description())); const DoubleOptionInfo *doubleOption = option.toType(); if (doubleOption != NULL && doubleOption->isTime()) { @@ -446,7 +446,7 @@ void OptionsConsoleFormatter::formatSelectionOption( } } -} // namespace +} // namespace /******************************************************************** * CommandLineHelpWriter::Impl @@ -523,7 +523,7 @@ void CommandLineHelpWriter::writeHelp(const HelpWriterContext &context) // TODO: Implement once the situation with Redmine issue #969 is // more clear. GMX_THROW(NotImplementedError( - "Command-line help is not implemented for this output format")); + "Command-line help is not implemented for this output format")); } OptionsFilter filter(context, formatter.get()); filter.setShowHidden(impl_->bShowHidden_); diff --git a/src/gromacs/commandline/cmdlinemodulemanager.cpp b/src/gromacs/commandline/cmdlinemodulemanager.cpp index beab445543..bc0917a218 100644 --- a/src/gromacs/commandline/cmdlinemodulemanager.cpp +++ b/src/gromacs/commandline/cmdlinemodulemanager.cpp @@ -69,15 +69,15 @@ namespace struct RootHelpText { - static const char name[]; - static const char title[]; + static const char name[]; + static const char title[]; static const char *const text[]; }; // The first two are not used. -const char RootHelpText::name[] = ""; -const char RootHelpText::title[] = ""; -const char *const RootHelpText::text[] = { +const char RootHelpText::name[] = ""; +const char RootHelpText::title[] = ""; +const char *const RootHelpText::text[] = { "Usage: [PROGRAM] []", }; @@ -118,7 +118,7 @@ void RootHelpTopic::writeHelp(const HelpWriterContext &context) const // TODO: Implement once the situation with Redmine issue #969 is more // clear. GMX_THROW(NotImplementedError( - "Root help is not implemented for this output format")); + "Root help is not implemented for this output format")); } writeBasicHelpTopic(context, *this, helpText()); // TODO: If/when this list becomes long, it may be better to only print @@ -128,7 +128,7 @@ void RootHelpTopic::writeHelp(const HelpWriterContext &context) const context.writeTextBlock( "For additional help on a command, use '[PROGRAM] help '"); writeSubTopicList(context, - "\nAdditional help is available on the following topics:"); + "\nAdditional help is available on the following topics:"); context.writeTextBlock( "To access the help, use '[PROGRAM] help '."); } @@ -140,7 +140,7 @@ void RootHelpTopic::printModuleList(const HelpWriterContext &context) const // TODO: Implement once the situation with Redmine issue #969 is more // clear. GMX_THROW(NotImplementedError( - "Module list is not implemented for this output format")); + "Module list is not implemented for this output format")); } int maxNameLength = 0; CommandLineModuleMap::const_iterator module; @@ -153,7 +153,7 @@ void RootHelpTopic::printModuleList(const HelpWriterContext &context) const maxNameLength = nameLength; } } - File &file = context.outputFile(); + File &file = context.outputFile(); TextTableFormatter formatter; formatter.addColumn(NULL, maxNameLength + 1, false); formatter.addColumn(NULL, 72 - maxNameLength, true); @@ -162,7 +162,7 @@ void RootHelpTopic::printModuleList(const HelpWriterContext &context) const file.writeLine("Available commands:"); for (module = modules_.begin(); module != modules_.end(); ++module) { - const char *name = module->first.c_str(); + const char *name = module->first.c_str(); const char *description = module->second->shortDescription(); if (description != NULL) { @@ -216,7 +216,7 @@ void ModuleHelpTopic::writeHelp(const HelpWriterContext &context) const module_.writeHelp(context); } -} // namespace +} // namespace /******************************************************************** * CommandLineHelpModule @@ -281,7 +281,7 @@ int CommandLineHelpModule::run(int argc, char *argv[]) { HelpWriterContext context(&File::standardOutput(), eHelpOutputFormat_Console); - HelpManager helpManager(*rootTopic_, context); + HelpManager helpManager(*rootTopic_, context); try { for (int i = 1; i < argc; ++i) @@ -449,7 +449,7 @@ int CommandLineModuleManager::run(int argc, char *argv[]) impl_->helpModule_->printUsage(); return 2; } - module = impl_->findModuleByName(argv[1]); + module = impl_->findModuleByName(argv[1]); argOffset = 1; } if (module == impl_->modules_.end()) diff --git a/src/gromacs/commandline/cmdlinemodulemanager.h b/src/gromacs/commandline/cmdlinemodulemanager.h index d16f1bc9e3..43a9c82005 100644 --- a/src/gromacs/commandline/cmdlinemodulemanager.h +++ b/src/gromacs/commandline/cmdlinemodulemanager.h @@ -51,7 +51,7 @@ class ProgramInfo; //! Smart pointer type for managing a CommandLineModuleInterface. typedef gmx_unique_ptr::type - CommandLineModulePointer; + CommandLineModulePointer; /*! \brief * Implements a wrapper command-line interface for multiple modules. diff --git a/src/gromacs/commandline/cmdlineparser.cpp b/src/gromacs/commandline/cmdlineparser.cpp index f3fe596a34..b09e4ecc10 100644 --- a/src/gromacs/commandline/cmdlineparser.cpp +++ b/src/gromacs/commandline/cmdlineparser.cpp @@ -100,9 +100,9 @@ void CommandLineParser::parse(int *argc, char *argv[]) void CommandLineParser::parse(std::vector *commandLine) { ExceptionInitializer errors("Invalid command-line options"); - std::string currentContext; + std::string currentContext; // Start in the discard phase to skip options that can't be understood. - bool bDiscard = true; + bool bDiscard = true; impl_->assigner_.start(); std::vector::const_iterator arg; @@ -125,7 +125,7 @@ void CommandLineParser::parse(std::vector *commandLine) currentContext.clear(); } currentContext = "In command-line option " + *arg; - bDiscard = false; + bDiscard = false; try { const char *name = arg->c_str() + 1; diff --git a/src/gromacs/commandline/tests/cmdlinehelpwriter.cpp b/src/gromacs/commandline/tests/cmdlinehelpwriter.cpp index d6d0807e92..0e34bc7fa6 100644 --- a/src/gromacs/commandline/tests/cmdlinehelpwriter.cpp +++ b/src/gromacs/commandline/tests/cmdlinehelpwriter.cpp @@ -72,8 +72,8 @@ class CommandLineHelpWriterTest : public ::gmx::test::StringTestBase void CommandLineHelpWriterTest::checkHelp(gmx::CommandLineHelpWriter *writer) { - std::string filename = tempFiles_.getTemporaryFilePath("helptext.txt"); - gmx::File file(filename, "w"); + std::string filename = tempFiles_.getTemporaryFilePath("helptext.txt"); + gmx::File file(filename, "w"); gmx::HelpWriterContext context(&file, gmx::eHelpOutputFormat_Console); writer->writeHelp(context); file.close(); @@ -96,44 +96,44 @@ TEST_F(CommandLineHelpWriterTest, HandlesOptionTypes) Options options("test", "Short Description"); options.addOption(BooleanOption("bool").description("Boolean option") - .defaultValue(true)); + .defaultValue(true)); options.addOption(BooleanOption("hidden").description("Hidden option") - .hidden().defaultValue(true)); + .hidden().defaultValue(true)); options.addOption(IntegerOption("int").description("Integer option") - .defaultValue(2)); + .defaultValue(2)); ivec intvec = {1, 2, 3}; options.addOption(IntegerOption("ivec").description("Integer vector option") - .vector().store(intvec)); + .vector().store(intvec)); options.addOption(DoubleOption("double").description("Double option") - .defaultValue(2.5)); + .defaultValue(2.5)); dvec dblvec = {1.1, 2.3, 3.2}; options.addOption(DoubleOption("dvec").description("Double vector option") - .vector().store(dblvec)); + .vector().store(dblvec)); options.addOption(DoubleOption("time").description("Time option (%t)") - .timeValue().defaultValue(10.0)); + .timeValue().defaultValue(10.0)); options.addOption(StringOption("string").description("String option") - .defaultValue("test")); + .defaultValue("test")); const char * const enumValues[] = {"no", "opt1", "opt2", NULL}; options.addOption(StringOption("enum").description("Enum option") - .enumValue(enumValues).defaultEnumIndex(0)); + .enumValue(enumValues).defaultEnumIndex(0)); std::string filename; options.addOption(FileNameOption("f") - .description("Input file description") - .filetype(eftTrajectory).inputFile().required() - .defaultBasename("traj")); + .description("Input file description") + .filetype(eftTrajectory).inputFile().required() + .defaultBasename("traj")); options.addOption(FileNameOption("lib") - .description("Library file description") - .filetype(eftGenericData).inputFile().libraryFile() - .defaultBasename("libdata")); + .description("Library file description") + .filetype(eftGenericData).inputFile().libraryFile() + .defaultBasename("libdata")); options.addOption(FileNameOption("io") - .store(&filename) - .description("Input/Output file description") - .filetype(eftGenericData).inputOutputFile() - .defaultBasename("inout")); + .store(&filename) + .description("Input/Output file description") + .filetype(eftGenericData).inputOutputFile() + .defaultBasename("inout")); options.addOption(FileNameOption("o") - .description("Output file description") - .filetype(eftPlot).outputFile()); + .description("Output file description") + .filetype(eftPlot).outputFile()); options.addOption(SelectionFileOption("sf")); options.addOption(SelectionOption("sel").description("Selection option")); @@ -155,25 +155,25 @@ TEST_F(CommandLineHelpWriterTest, HandlesLongFileOptions) gmx::Options options(NULL, NULL); options.addOption(FileNameOption("f") - .description("File name option with a long value") - .filetype(eftTrajectory).inputFile().required() - .defaultBasename("path/to/long/trajectory/name")); + .description("File name option with a long value") + .filetype(eftTrajectory).inputFile().required() + .defaultBasename("path/to/long/trajectory/name")); options.addOption(FileNameOption("f2") - .description("File name option with a long value") - .filetype(eftTrajectory).inputFile().required() - .defaultBasename("path/to/long/trajectory")); + .description("File name option with a long value") + .filetype(eftTrajectory).inputFile().required() + .defaultBasename("path/to/long/trajectory")); options.addOption(FileNameOption("lib") - .description("File name option with a long value and type") - .filetype(eftTrajectory).inputFile().libraryFile() - .defaultBasename("path/to/long/trajectory/name")); + .description("File name option with a long value and type") + .filetype(eftTrajectory).inputFile().libraryFile() + .defaultBasename("path/to/long/trajectory/name")); options.addOption(FileNameOption("longfileopt") - .description("File name option with a long name") - .filetype(eftGenericData).inputFile() - .defaultBasename("deffile")); + .description("File name option with a long name") + .filetype(eftGenericData).inputFile() + .defaultBasename("deffile")); options.addOption(FileNameOption("longfileopt2") - .description("File name option with multiple long fields") - .filetype(eftGenericData).inputFile().libraryFile() - .defaultBasename("path/to/long/file/name")); + .description("File name option with multiple long fields") + .filetype(eftGenericData).inputFile().libraryFile() + .defaultBasename("path/to/long/file/name")); gmx::CommandLineHelpWriter writer(options); checkHelp(&writer); @@ -191,19 +191,19 @@ TEST_F(CommandLineHelpWriterTest, HandlesLongOptions) gmx::Options options(NULL, NULL); options.addOption(BooleanOption("longboolean") - .description("Boolean option with a long name") - .defaultValue(true)); + .description("Boolean option with a long name") + .defaultValue(true)); dvec dblvec = {1.135, 2.32, 3.2132}; options.addOption(DoubleOption("dvec").description("Double vector option") - .vector().store(dblvec)); + .vector().store(dblvec)); std::vector values; values.push_back("A very long string value that overflows even the description column"); values.push_back("Another very long string value that overflows even the description column"); options.addOption(StringOption("string") - .description("String option with very long values (may " - "be less relevant with selections having " - "their own option type)") - .storeVector(&values)); + .description("String option with very long values (may " + "be less relevant with selections having " + "their own option type)") + .storeVector(&values)); gmx::CommandLineHelpWriter writer(options); checkHelp(&writer); @@ -220,10 +220,10 @@ TEST_F(CommandLineHelpWriterTest, HandlesSelectionOptions) gmx::Options options(NULL, NULL); options.addOption(SelectionFileOption("sf")); options.addOption(SelectionOption("refsel").required() - .description("Reference selection option")); + .description("Reference selection option")); options.addOption(SelectionOption("sel").required().valueCount(2) - .description("Selection option")); - gmx::SelectionCollection selections; + .description("Selection option")); + gmx::SelectionCollection selections; gmx::SelectionOptionManager manager(&selections); setManagerForSelectionOptions(&options, &manager); options.finish(); @@ -256,11 +256,11 @@ TEST_F(CommandLineHelpWriterTest, HandlesMultipleSections) subSect2.setDescription("Description for subsection 2."); subSect3.setDescription("Description for subsection 3."); options.addOption(IntegerOption("main") - .description("Option in main section")); + .description("Option in main section")); subSect1.addOption(IntegerOption("sub1") - .description("Option in subsection 1")); + .description("Option in subsection 1")); subSect2.addOption(IntegerOption("sub2") - .description("Option in subsection 2")); + .description("Option in subsection 2")); CommandLineHelpWriter writer(options); writer.setShowDescriptions(true); diff --git a/src/gromacs/commandline/tests/cmdlinemodulemanager.cpp b/src/gromacs/commandline/tests/cmdlinemodulemanager.cpp index 658fc73397..dae61d4d18 100644 --- a/src/gromacs/commandline/tests/cmdlinemodulemanager.cpp +++ b/src/gromacs/commandline/tests/cmdlinemodulemanager.cpp @@ -96,7 +96,7 @@ class CommandLineModuleManagerTest : public ::testing::Test { public: void initManager(const CommandLine &args); - MockModule &addModule(const char *name, const char *description); + MockModule &addModule(const char *name, const char *description); MockHelpTopic &addHelpTopic(const char *name, const char *title); gmx::CommandLineModuleManager &manager() { return *manager_; } @@ -138,9 +138,9 @@ TEST_F(CommandLineModuleManagerTest, RunsModule) const char *const cmdline[] = { "g_test", "module", "-flag", "yes" }; - CommandLine args(CommandLine::create(cmdline)); + CommandLine args(CommandLine::create(cmdline)); initManager(args); - MockModule &mod1 = addModule("module", "First module"); + MockModule &mod1 = addModule("module", "First module"); addModule("other", "Second module"); using ::testing::_; using ::testing::Args; @@ -157,9 +157,9 @@ TEST_F(CommandLineModuleManagerTest, RunsModuleHelp) const char *const cmdline[] = { "g_test", "help", "module" }; - CommandLine args(CommandLine::create(cmdline)); + CommandLine args(CommandLine::create(cmdline)); initManager(args); - MockModule &mod1 = addModule("module", "First module"); + MockModule &mod1 = addModule("module", "First module"); addModule("other", "Second module"); using ::testing::_; EXPECT_CALL(mod1, writeHelp(_)); @@ -173,7 +173,7 @@ TEST_F(CommandLineModuleManagerTest, PrintsHelpOnTopic) const char *const cmdline[] = { "g_test", "help", "topic" }; - CommandLine args(CommandLine::create(cmdline)); + CommandLine args(CommandLine::create(cmdline)); initManager(args); addModule("module", "First module"); MockHelpTopic &topic = addHelpTopic("topic", "Test topic"); @@ -189,9 +189,9 @@ TEST_F(CommandLineModuleManagerTest, RunsModuleBasedOnBinaryName) const char *const cmdline[] = { "g_module", "-flag", "yes" }; - CommandLine args(CommandLine::create(cmdline)); + CommandLine args(CommandLine::create(cmdline)); initManager(args); - MockModule &mod1 = addModule("module", "First module"); + MockModule &mod1 = addModule("module", "First module"); addModule("other", "Second module"); using ::testing::_; using ::testing::Args; @@ -208,9 +208,9 @@ TEST_F(CommandLineModuleManagerTest, RunsModuleBasedOnBinaryNameWithPathAndSuffi const char *const cmdline[] = { "/usr/local/gromacs/bin/g_module" GMX_BINARY_SUFFIX ".exe", "-flag", "yes" }; - CommandLine args(CommandLine::create(cmdline)); + CommandLine args(CommandLine::create(cmdline)); initManager(args); - MockModule &mod1 = addModule("module", "First module"); + MockModule &mod1 = addModule("module", "First module"); addModule("other", "Second module"); using ::testing::_; using ::testing::Args; @@ -227,9 +227,9 @@ TEST_F(CommandLineModuleManagerTest, HandlesConflictingBinaryAndModuleNames) const char *const cmdline[] = { "g_test", "test", "-flag", "yes" }; - CommandLine args(CommandLine::create(cmdline)); + CommandLine args(CommandLine::create(cmdline)); initManager(args); - MockModule &mod1 = addModule("test", "Test module"); + MockModule &mod1 = addModule("test", "Test module"); addModule("other", "Second module"); using ::testing::_; using ::testing::Args; diff --git a/src/gromacs/commandline/tests/cmdlineparser.cpp b/src/gromacs/commandline/tests/cmdlineparser.cpp index 2d5a2fb864..c1b23592ab 100644 --- a/src/gromacs/commandline/tests/cmdlineparser.cpp +++ b/src/gromacs/commandline/tests/cmdlineparser.cpp @@ -82,7 +82,7 @@ TEST_F(CommandLineParserTest, HandlesSingleValues) const char *const cmdline[] = { "test", "-flag", "yes", "-mvi", "2", "-mvd", "2.7" }; - CommandLine args(CommandLine::create(cmdline)); + CommandLine args(CommandLine::create(cmdline)); ASSERT_NO_THROW(parser_.parse(&args.argc(), args.argv())); ASSERT_NO_THROW(options_.finish()); @@ -98,7 +98,7 @@ TEST_F(CommandLineParserTest, HandlesNegativeNumbers) const char *const cmdline[] = { "test", "-mvi", "1", "-2", "-mvd", "-2.7" }; - CommandLine args(CommandLine::create(cmdline)); + CommandLine args(CommandLine::create(cmdline)); ASSERT_NO_THROW(parser_.parse(&args.argc(), args.argv())); ASSERT_NO_THROW(options_.finish()); diff --git a/src/gromacs/gmxlib/3dview.c b/src/gromacs/gmxlib/3dview.c index de8dd068c5..32236ac27b 100644 --- a/src/gromacs/gmxlib/3dview.c +++ b/src/gromacs/gmxlib/3dview.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -47,272 +47,321 @@ #define N 4 -void m4_op(mat4 m,rvec x,vec4 v) +void m4_op(mat4 m, rvec x, vec4 v) { - int i; + int i; - for(i=0; (isc_x=sx; - view->sc_y=sy; + view->sc_x = sx; + view->sc_y = sy; } void calculate_view(t_3dview *view) { #define SMALL 1e-6 - mat4 To,Te,T1,T2,T3,T4,T5,N1,D1,D2,D3,D4,D5; - real dx,dy,dz,l,r; - - /* eye center */ - dx=view->eye[XX]; - dy=view->eye[YY]; - dz=view->eye[ZZ]; - l = sqrt(dx*dx+dy*dy+dz*dz); - r = sqrt(dx*dx+dy*dy); + mat4 To, Te, T1, T2, T3, T4, T5, N1, D1, D2, D3, D4, D5; + real dx, dy, dz, l, r; + + /* eye center */ + dx = view->eye[XX]; + dy = view->eye[YY]; + dz = view->eye[ZZ]; + l = sqrt(dx*dx+dy*dy+dz*dz); + r = sqrt(dx*dx+dy*dy); #ifdef DEBUG - print_v4(debug,"eye",N,view->eye); - printf("del: %10.5f%10.5f%10.5f l: %10.5f, r: %10.5f\n",dx,dy,dz,l,r); + print_v4(debug, "eye", N, view->eye); + printf("del: %10.5f%10.5f%10.5f l: %10.5f, r: %10.5f\n", dx, dy, dz, l, r); #endif - if (l < SMALL) - gmx_fatal(FARGS,"Error: Zero Length Vector - No View Specified"); - translate((real)(-view->origin[XX]), - (real)(-view->origin[YY]),(real)(-view->origin[ZZ]),To); - translate((real)(-view->eye[XX]), - (real)(-view->eye[YY]),(real)(-view->eye[ZZ]),Te); - - unity_m4(T2); - T2[YY][YY]=0, T2[YY][ZZ]=-1, T2[ZZ][YY]=1, T2[ZZ][ZZ]=0; - - unity_m4(T3); - if (r > 0) - T3[XX][XX]=-dy/r, T3[XX][ZZ]=dx/r, T3[ZZ][XX]=-dx/r, T3[ZZ][ZZ]=-dy/r; + if (l < SMALL) + { + gmx_fatal(FARGS, "Error: Zero Length Vector - No View Specified"); + } + translate((real)(-view->origin[XX]), + (real)(-view->origin[YY]), (real)(-view->origin[ZZ]), To); + translate((real)(-view->eye[XX]), + (real)(-view->eye[YY]), (real)(-view->eye[ZZ]), Te); + + unity_m4(T2); + T2[YY][YY] = 0, T2[YY][ZZ] = -1, T2[ZZ][YY] = 1, T2[ZZ][ZZ] = 0; + + unity_m4(T3); + if (r > 0) + { + T3[XX][XX] = -dy/r, T3[XX][ZZ] = dx/r, T3[ZZ][XX] = -dx/r, T3[ZZ][ZZ] = -dy/r; + } - unity_m4(T4); - T4[YY][YY]=r/l, T4[YY][ZZ]=dz/l, T4[ZZ][YY]=-dz/l, T4[ZZ][ZZ]=r/l; + unity_m4(T4); + T4[YY][YY] = r/l, T4[YY][ZZ] = dz/l, T4[ZZ][YY] = -dz/l, T4[ZZ][ZZ] = r/l; - unity_m4(T5); - T5[ZZ][ZZ]=-1; + unity_m4(T5); + T5[ZZ][ZZ] = -1; - unity_m4(N1); - /* N1[XX][XX]=4,N1[YY][YY]=4; */ + unity_m4(N1); + /* N1[XX][XX]=4,N1[YY][YY]=4; */ - mult_matrix(T1,To,view->Rot); - mult_matrix(D1,Te,T2); - mult_matrix(D2,T3,T4); - mult_matrix(D3,T5,N1); - mult_matrix(D4,T1,D1); - mult_matrix(D5,D2,D3); + mult_matrix(T1, To, view->Rot); + mult_matrix(D1, Te, T2); + mult_matrix(D2, T3, T4); + mult_matrix(D3, T5, N1); + mult_matrix(D4, T1, D1); + mult_matrix(D5, D2, D3); - mult_matrix(view->proj,D4,D5); + mult_matrix(view->proj, D4, D5); #ifdef DEBUG - print_m4(debug,"T1",T1); - print_m4(debug,"T2",T2); - print_m4(debug,"T3",T3); - print_m4(debug,"T4",T4); - print_m4(debug,"T5",T5); - print_m4(debug,"N1",N1); - print_m4(debug,"Rot",view->Rot); - print_m4(debug,"Proj",view->proj); + print_m4(debug, "T1", T1); + print_m4(debug, "T2", T2); + print_m4(debug, "T3", T3); + print_m4(debug, "T4", T4); + print_m4(debug, "T5", T5); + print_m4(debug, "N1", N1); + print_m4(debug, "Rot", view->Rot); + print_m4(debug, "Proj", view->proj); #endif } -gmx_bool zoom_3d(t_3dview *view,real fac) +gmx_bool zoom_3d(t_3dview *view, real fac) { - real dr; - real bm,dr1,dr2; - int i; - - dr2=0; - for(i=0; (ieye[i]; - dr2+=dr*dr; - } - dr1=sqrt(dr2); - if (fac < 1) { - bm=max(norm(view->box[XX]),max(norm(view->box[YY]),norm(view->box[ZZ]))); - if (dr1*fac < 1.1*bm) /* Don't come to close */ - return FALSE; - } - - for(i=0; (ieye[i]*=fac; - calculate_view(view); - return TRUE; + real dr; + real bm, dr1, dr2; + int i; + + dr2 = 0; + for (i = 0; (i < DIM); i++) + { + dr = view->eye[i]; + dr2 += dr*dr; + } + dr1 = sqrt(dr2); + if (fac < 1) + { + bm = max(norm(view->box[XX]), max(norm(view->box[YY]), norm(view->box[ZZ]))); + if (dr1*fac < 1.1*bm) /* Don't come to close */ + { + return FALSE; + } + } + + for (i = 0; (i < DIM); i++) + { + view->eye[i] *= fac; + } + calculate_view(view); + return TRUE; } void init_rotate_3d(t_3dview *view) { - real rot=DEG2RAD*15; - int i; - - for(i=0; (iRotP[i]); - rotate(i,(real)(-rot),view->RotM[i]); + real rot = DEG2RAD*15; + int i; + + for (i = 0; (i < DIM); i++) + { + rotate(i, rot, view->RotP[i]); + rotate(i, (real)(-rot), view->RotM[i]); #ifdef DEBUG - print_m4(debug,"RotP",view->RotP[i]); - print_m4(debug,"RotM",view->RotM[i]); + print_m4(debug, "RotP", view->RotP[i]); + print_m4(debug, "RotM", view->RotM[i]); #endif - } + } } - -void rotate_3d(t_3dview *view,int axis,gmx_bool bPositive) + +void rotate_3d(t_3dview *view, int axis, gmx_bool bPositive) { - int i,j; - mat4 m4; - - if (bPositive) - mult_matrix(m4,view->Rot,view->RotP[axis]); - else - mult_matrix(m4,view->Rot,view->RotM[axis]); - for(i=0; (iRot[i][j]=m4[i][j]; - - calculate_view(view); + int i, j; + mat4 m4; + + if (bPositive) + { + mult_matrix(m4, view->Rot, view->RotP[axis]); + } + else + { + mult_matrix(m4, view->Rot, view->RotM[axis]); + } + for (i = 0; (i < N); i++) + { + for (j = 0; (j < N); j++) + { + view->Rot[i][j] = m4[i][j]; + } + } + + calculate_view(view); } -void translate_view(t_3dview *view,int axis,gmx_bool bPositive) +void translate_view(t_3dview *view, int axis, gmx_bool bPositive) { #ifdef DEBUG - printf("Translate called\n"); + printf("Translate called\n"); #endif - if (bPositive) - view->origin[axis]+=view->box[axis][axis]/8; - else - view->origin[axis]-=view->box[axis][axis]/8; - calculate_view(view); + if (bPositive) + { + view->origin[axis] += view->box[axis][axis]/8; + } + else + { + view->origin[axis] -= view->box[axis][axis]/8; + } + calculate_view(view); } void reset_view(t_3dview *view) { - int i; + int i; #ifdef DEBUG - printf("Reset view called\n"); + printf("Reset view called\n"); #endif - set_scale(view,4.0,4.0); - clear_rvec(view->eye); - calc_box_center(view->ecenter,view->box,view->origin); - view->eye[ZZ]=3.0*max(view->box[XX][XX],view->box[YY][YY]); - zoom_3d(view,1.0); - view->eye[WW]=view->origin[WW]=0.0; - - /* Initiate the matrix */ - unity_m4(view->Rot); - calculate_view(view); - - init_rotate_3d(view); + set_scale(view, 4.0, 4.0); + clear_rvec(view->eye); + calc_box_center(view->ecenter, view->box, view->origin); + view->eye[ZZ] = 3.0*max(view->box[XX][XX], view->box[YY][YY]); + zoom_3d(view, 1.0); + view->eye[WW] = view->origin[WW] = 0.0; + + /* Initiate the matrix */ + unity_m4(view->Rot); + calculate_view(view); + + init_rotate_3d(view); } t_3dview *init_view(matrix box) { - t_3dview *view; - int i,j; - - snew(view,1); - - /* Copy parameters into variables */ - for(i=0; (ibox[i][j]=box[i][j]; + t_3dview *view; + int i, j; + + snew(view, 1); + + /* Copy parameters into variables */ + for (i = 0; (i < DIM); i++) + { + for (j = 0; (j < DIM); j++) + { + view->box[i][j] = box[i][j]; + } + } - view->ecenter = ecenterDEF; + view->ecenter = ecenterDEF; - reset_view(view); + reset_view(view); - return view; + return view; } - diff --git a/src/gromacs/gmxlib/atomprop.c b/src/gromacs/gmxlib/atomprop.c index ffcbdce9e2..9d8aa60f85 100644 --- a/src/gromacs/gmxlib/atomprop.c +++ b/src/gromacs/gmxlib/atomprop.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -51,311 +51,363 @@ #include "copyrite.h" typedef struct { - gmx_bool bSet; - int nprop,maxprop; - char *db; - double def; - char **atomnm; - char **resnm; - gmx_bool *bAvail; - real *value; + gmx_bool bSet; + int nprop, maxprop; + char *db; + double def; + char **atomnm; + char **resnm; + gmx_bool *bAvail; + real *value; } aprop_t; typedef struct gmx_atomprop { - gmx_bool bWarned; - aprop_t prop[epropNR]; - gmx_residuetype_t restype; + gmx_bool bWarned; + aprop_t prop[epropNR]; + gmx_residuetype_t restype; } gmx_atomprop; /* NOTFOUND should be smallest, others larger in increasing priority */ -enum { NOTFOUND=-4, WILDCARD, WILDPROT, PROTEIN }; +enum { + NOTFOUND = -4, WILDCARD, WILDPROT, PROTEIN +}; -/* return number of matching characters, +/* return number of matching characters, or NOTFOUND if not at least all characters in char *database match */ static int dbcmp_len(char *search, char *database) { - int i; - - i=0; - while(search[i] && database[i] && (search[i]==database[i]) ) - i++; - - if (database[i]) - i=NOTFOUND; - return i; + int i; + + i = 0; + while (search[i] && database[i] && (search[i] == database[i]) ) + { + i++; + } + + if (database[i]) + { + i = NOTFOUND; + } + return i; } -static int get_prop_index(aprop_t *ap,gmx_residuetype_t restype, - char *resnm,char *atomnm, - gmx_bool *bExact) +static int get_prop_index(aprop_t *ap, gmx_residuetype_t restype, + char *resnm, char *atomnm, + gmx_bool *bExact) { - int i,j=NOTFOUND; - long int alen,rlen; - long int malen,mrlen; - gmx_bool bProtein,bProtWild; - - bProtein = gmx_residuetype_is_protein(restype,resnm); - bProtWild = (strcmp(resnm,"AAA")==0); - malen = NOTFOUND; - mrlen = NOTFOUND; - for(i=0; (inprop); i++) { - rlen = dbcmp_len(resnm, ap->resnm[i]); - if (rlen == NOTFOUND) { - if ( (strcmp(ap->resnm[i],"*")==0) || - (strcmp(ap->resnm[i],"???")==0) ) - rlen=WILDCARD; - else if (strcmp(ap->resnm[i],"AAA")==0) - rlen=WILDPROT; + int i, j = NOTFOUND; + long int alen, rlen; + long int malen, mrlen; + gmx_bool bProtein, bProtWild; + + bProtein = gmx_residuetype_is_protein(restype, resnm); + bProtWild = (strcmp(resnm, "AAA") == 0); + malen = NOTFOUND; + mrlen = NOTFOUND; + for (i = 0; (i < ap->nprop); i++) + { + rlen = dbcmp_len(resnm, ap->resnm[i]); + if (rlen == NOTFOUND) + { + if ( (strcmp(ap->resnm[i], "*") == 0) || + (strcmp(ap->resnm[i], "???") == 0) ) + { + rlen = WILDCARD; + } + else if (strcmp(ap->resnm[i], "AAA") == 0) + { + rlen = WILDPROT; + } + } + alen = dbcmp_len(atomnm, ap->atomnm[i]); + if ( (alen > NOTFOUND) && (rlen > NOTFOUND)) + { + if ( ( (alen > malen) && (rlen >= mrlen)) || + ( (rlen > mrlen) && (alen >= malen) ) ) + { + malen = alen; + mrlen = rlen; + j = i; + } + } } - alen = dbcmp_len(atomnm, ap->atomnm[i]); - if ( (alen > NOTFOUND) && (rlen > NOTFOUND)) { - if ( ( (alen > malen) && (rlen >= mrlen)) || - ( (rlen > mrlen) && (alen >= malen) ) ) { - malen = alen; - mrlen = rlen; - j = i; - } + + *bExact = ((malen == (long int)strlen(atomnm)) && + ((mrlen == (long int)strlen(resnm)) || + ((mrlen == WILDPROT) && bProtWild) || + ((mrlen == WILDCARD) && !bProtein && !bProtWild))); + + if (debug) + { + fprintf(debug, "searching residue: %4s atom: %4s\n", resnm, atomnm); + if (j == NOTFOUND) + { + fprintf(debug, " not successful\n"); + } + else + { + fprintf(debug, " match: %4s %4s\n", ap->resnm[j], ap->atomnm[j]); + } } - } - - *bExact = ((malen == (long int)strlen(atomnm)) && - ((mrlen == (long int)strlen(resnm)) || - ((mrlen == WILDPROT) && bProtWild) || - ((mrlen == WILDCARD) && !bProtein && !bProtWild))); - - if (debug) { - fprintf(debug,"searching residue: %4s atom: %4s\n",resnm,atomnm); - if (j == NOTFOUND) - fprintf(debug," not successful\n"); - else - fprintf(debug," match: %4s %4s\n",ap->resnm[j],ap->atomnm[j]); - } - return j; + return j; } -static void add_prop(aprop_t *ap,gmx_residuetype_t restype, - char *resnm,char *atomnm, - real p,int line) +static void add_prop(aprop_t *ap, gmx_residuetype_t restype, + char *resnm, char *atomnm, + real p, int line) { - int i,j; - gmx_bool bExact; - - j = get_prop_index(ap,restype,resnm,atomnm,&bExact); - - if (!bExact) { - if (ap->nprop >= ap->maxprop) { - ap->maxprop += 10; - srenew(ap->resnm,ap->maxprop); - srenew(ap->atomnm,ap->maxprop); - srenew(ap->value,ap->maxprop); - srenew(ap->bAvail,ap->maxprop); - for(i=ap->nprop; (imaxprop); i++) { - ap->atomnm[i] = NULL; - ap->resnm[i] = NULL; - ap->value[i] = 0; - ap->bAvail[i] = FALSE; - } + int i, j; + gmx_bool bExact; + + j = get_prop_index(ap, restype, resnm, atomnm, &bExact); + + if (!bExact) + { + if (ap->nprop >= ap->maxprop) + { + ap->maxprop += 10; + srenew(ap->resnm, ap->maxprop); + srenew(ap->atomnm, ap->maxprop); + srenew(ap->value, ap->maxprop); + srenew(ap->bAvail, ap->maxprop); + for (i = ap->nprop; (i < ap->maxprop); i++) + { + ap->atomnm[i] = NULL; + ap->resnm[i] = NULL; + ap->value[i] = 0; + ap->bAvail[i] = FALSE; + } + } + ap->atomnm[ap->nprop] = strdup(atomnm); + ap->resnm[ap->nprop] = strdup(resnm); + j = ap->nprop; + ap->nprop++; + } + if (ap->bAvail[j]) + { + if (ap->value[j] == p) + { + fprintf(stderr, "Warning double identical entries for %s %s %g on line %d in file %s\n", + resnm, atomnm, p, line, ap->db); + } + else + { + fprintf(stderr, "Warning double different entries %s %s %g and %g on line %d in file %s\n" + "Using last entry (%g)\n", + resnm, atomnm, p, ap->value[j], line, ap->db, p); + ap->value[j] = p; + } } - ap->atomnm[ap->nprop] = strdup(atomnm); - ap->resnm[ap->nprop] = strdup(resnm); - j = ap->nprop; - ap->nprop++; - } - if (ap->bAvail[j]) { - if (ap->value[j] == p) - fprintf(stderr,"Warning double identical entries for %s %s %g on line %d in file %s\n", - resnm,atomnm,p,line,ap->db); - else { - fprintf(stderr,"Warning double different entries %s %s %g and %g on line %d in file %s\n" - "Using last entry (%g)\n", - resnm,atomnm,p,ap->value[j],line,ap->db,p); - ap->value[j] = p; + else + { + ap->bAvail[j] = TRUE; + ap->value[j] = p; } - } - else { - ap->bAvail[j] = TRUE; - ap->value[j] = p; - } } -static void read_prop(gmx_atomprop_t aps,int eprop,double factor) +static void read_prop(gmx_atomprop_t aps, int eprop, double factor) { - gmx_atomprop *ap2 = (gmx_atomprop*) aps; - FILE *fp; - char line[STRLEN],resnm[32],atomnm[32]; - double pp; - int line_no; - aprop_t *ap; - - ap = &ap2->prop[eprop]; - - fp = libopen(ap->db); - line_no = 0; - while(get_a_line(fp,line,STRLEN)) { - line_no++; - if (sscanf(line,"%s %s %lf",resnm,atomnm,&pp) == 3) { - pp *= factor; - add_prop(ap,aps->restype,resnm,atomnm,pp,line_no); + gmx_atomprop *ap2 = (gmx_atomprop*) aps; + FILE *fp; + char line[STRLEN], resnm[32], atomnm[32]; + double pp; + int line_no; + aprop_t *ap; + + ap = &ap2->prop[eprop]; + + fp = libopen(ap->db); + line_no = 0; + while (get_a_line(fp, line, STRLEN)) + { + line_no++; + if (sscanf(line, "%s %s %lf", resnm, atomnm, &pp) == 3) + { + pp *= factor; + add_prop(ap, aps->restype, resnm, atomnm, pp, line_no); + } + else + { + fprintf(stderr, "WARNING: Error in file %s at line %d ignored\n", + ap->db, line_no); + } } - else - fprintf(stderr,"WARNING: Error in file %s at line %d ignored\n", - ap->db,line_no); - } - - /* for libraries we can use the low-level close routines */ - ffclose(fp); - - ap->bSet = TRUE; + + /* for libraries we can use the low-level close routines */ + ffclose(fp); + + ap->bSet = TRUE; } -static void set_prop(gmx_atomprop_t aps,int eprop) +static void set_prop(gmx_atomprop_t aps, int eprop) { - gmx_atomprop *ap2 = (gmx_atomprop*) aps; - const char *fns[epropNR] = { "atommass.dat", "vdwradii.dat", "dgsolv.dat", "electroneg.dat", "elements.dat" }; - double fac[epropNR] = { 1.0, 1.0, 418.4, 1.0, 1.0 }; - double def[epropNR] = { 12.011, 0.14, 0.0, 2.2, -1 }; - aprop_t *ap; - - ap = &ap2->prop[eprop]; - if (!ap->bSet) { - ap->db = strdup(fns[eprop]); - ap->def = def[eprop]; - read_prop(aps,eprop,fac[eprop]); - - if (debug) - fprintf(debug,"Entries in %s: %d\n",ap->db,ap->nprop); - - if ( ( (!aps->bWarned) && (eprop == epropMass) ) || (eprop == epropVDW)) { - printf("\n" - "WARNING: Masses and atomic (Van der Waals) radii will be guessed\n" - " based on residue and atom names, since they could not be\n" - " definitively assigned from the information in your input\n" - " files. These guessed numbers might deviate from the mass\n" - " and radius of the atom type. Please check the output\n" - " files if necessary.\n\n"); - aps->bWarned = TRUE; + gmx_atomprop *ap2 = (gmx_atomprop*) aps; + const char *fns[epropNR] = { "atommass.dat", "vdwradii.dat", "dgsolv.dat", "electroneg.dat", "elements.dat" }; + double fac[epropNR] = { 1.0, 1.0, 418.4, 1.0, 1.0 }; + double def[epropNR] = { 12.011, 0.14, 0.0, 2.2, -1 }; + aprop_t *ap; + + ap = &ap2->prop[eprop]; + if (!ap->bSet) + { + ap->db = strdup(fns[eprop]); + ap->def = def[eprop]; + read_prop(aps, eprop, fac[eprop]); + + if (debug) + { + fprintf(debug, "Entries in %s: %d\n", ap->db, ap->nprop); + } + + if ( ( (!aps->bWarned) && (eprop == epropMass) ) || (eprop == epropVDW)) + { + printf("\n" + "WARNING: Masses and atomic (Van der Waals) radii will be guessed\n" + " based on residue and atom names, since they could not be\n" + " definitively assigned from the information in your input\n" + " files. These guessed numbers might deviate from the mass\n" + " and radius of the atom type. Please check the output\n" + " files if necessary.\n\n"); + aps->bWarned = TRUE; + } } - } } gmx_atomprop_t gmx_atomprop_init(void) { - gmx_atomprop *aps; - int p; + gmx_atomprop *aps; + int p; - snew(aps,1); + snew(aps, 1); - gmx_residuetype_init(&aps->restype); - aps->bWarned = FALSE; + gmx_residuetype_init(&aps->restype); + aps->bWarned = FALSE; - return (gmx_atomprop_t)aps; + return (gmx_atomprop_t)aps; } static void destroy_prop(aprop_t *ap) { - int i; - - if (ap->bSet) { - sfree(ap->db); - - for(i=0; inprop; i++) { - sfree(ap->atomnm[i]); - sfree(ap->resnm[i]); + int i; + + if (ap->bSet) + { + sfree(ap->db); + + for (i = 0; i < ap->nprop; i++) + { + sfree(ap->atomnm[i]); + sfree(ap->resnm[i]); + } + sfree(ap->atomnm); + sfree(ap->resnm); + sfree(ap->bAvail); + sfree(ap->value); } - sfree(ap->atomnm); - sfree(ap->resnm); - sfree(ap->bAvail); - sfree(ap->value); - } } void gmx_atomprop_destroy(gmx_atomprop_t aps) { - gmx_atomprop *ap = (gmx_atomprop*) aps; - int p; + gmx_atomprop *ap = (gmx_atomprop*) aps; + int p; - if (aps == NULL) { - printf("\nWARNING: gmx_atomprop_destroy called with a NULL pointer\n\n"); - return; - } + if (aps == NULL) + { + printf("\nWARNING: gmx_atomprop_destroy called with a NULL pointer\n\n"); + return; + } - for(p=0; pprop[p]); - } + for (p = 0; p < epropNR; p++) + { + destroy_prop(&ap->prop[p]); + } - gmx_residuetype_destroy(ap->restype); + gmx_residuetype_destroy(ap->restype); - sfree(ap); + sfree(ap); } gmx_bool gmx_atomprop_query(gmx_atomprop_t aps, - int eprop,const char *resnm,const char *atomnm, - real *value) + int eprop, const char *resnm, const char *atomnm, + real *value) { - gmx_atomprop *ap = (gmx_atomprop*) aps; - size_t i; - int j; + gmx_atomprop *ap = (gmx_atomprop*) aps; + size_t i; + int j; #define MAXQ 32 - char atomname[MAXQ],resname[MAXQ]; - gmx_bool bExact; + char atomname[MAXQ], resname[MAXQ]; + gmx_bool bExact; + + set_prop(aps, eprop); + if ((strlen(atomnm) > MAXQ-1) || (strlen(resnm) > MAXQ-1)) + { + if (debug) + { + fprintf(debug, "WARNING: will only compare first %d characters\n", + MAXQ-1); + } + } + if (isdigit(atomnm[0])) + { + /* put digit after atomname */ + for (i = 1; (i < min(MAXQ-1, strlen(atomnm))); i++) + { + atomname[i-1] = atomnm[i]; + } + atomname[i-1] = atomnm[0]; + atomname[i] = '\0'; + } + else + { + strncpy(atomname, atomnm, MAXQ-1); + } + strncpy(resname, resnm, MAXQ-1); - set_prop(aps,eprop); - if ((strlen(atomnm) > MAXQ-1) || (strlen(resnm) > MAXQ-1)) { - if (debug) - fprintf(debug,"WARNING: will only compare first %d characters\n", - MAXQ-1); - } - if (isdigit(atomnm[0])) { - /* put digit after atomname */ - for (i=1; (iprop[eprop]),ap->restype,resname, - atomname,&bExact); - - if (j >= 0) { - *value = ap->prop[eprop].value[j]; - return TRUE; - } - else { - *value = ap->prop[eprop].def; - return FALSE; - } + j = get_prop_index(&(ap->prop[eprop]), ap->restype, resname, + atomname, &bExact); + + if (j >= 0) + { + *value = ap->prop[eprop].value[j]; + return TRUE; + } + else + { + *value = ap->prop[eprop].def; + return FALSE; + } } -char *gmx_atomprop_element(gmx_atomprop_t aps,int atomnumber) +char *gmx_atomprop_element(gmx_atomprop_t aps, int atomnumber) { - gmx_atomprop *ap = (gmx_atomprop*) aps; - int i; - - set_prop(aps,epropElement); - for(i=0; (iprop[epropElement].nprop); i++) { - if (gmx_nint(ap->prop[epropElement].value[i]) == atomnumber) { - return ap->prop[epropElement].atomnm[i]; + gmx_atomprop *ap = (gmx_atomprop*) aps; + int i; + + set_prop(aps, epropElement); + for (i = 0; (i < ap->prop[epropElement].nprop); i++) + { + if (gmx_nint(ap->prop[epropElement].value[i]) == atomnumber) + { + return ap->prop[epropElement].atomnm[i]; + } } - } - return NULL; + return NULL; } -int gmx_atomprop_atomnumber(gmx_atomprop_t aps,const char *elem) +int gmx_atomprop_atomnumber(gmx_atomprop_t aps, const char *elem) { - gmx_atomprop *ap = (gmx_atomprop*) aps; - int i; - - set_prop(aps,epropElement); - for(i=0; (iprop[epropElement].nprop); i++) { - if (gmx_strcasecmp(ap->prop[epropElement].atomnm[i],elem) == 0) { - return gmx_nint(ap->prop[epropElement].value[i]); + gmx_atomprop *ap = (gmx_atomprop*) aps; + int i; + + set_prop(aps, epropElement); + for (i = 0; (i < ap->prop[epropElement].nprop); i++) + { + if (gmx_strcasecmp(ap->prop[epropElement].atomnm[i], elem) == 0) + { + return gmx_nint(ap->prop[epropElement].value[i]); + } } - } - return NOTSET; + return NOTSET; } diff --git a/src/gromacs/gmxlib/bfunc.h b/src/gromacs/gmxlib/bfunc.h deleted file mode 100644 index 02f03ca22b..0000000000 --- a/src/gromacs/gmxlib/bfunc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * This source code is part of - * - * G R O M A C S - * - * GROningen MAchine for Chemical Simulations - * - * VERSION 3.2.0 - * 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 - * - * And Hey: - * GROningen Mixture of Alchemy and Childrens' Stories - */ -/* - * bfunc.h - * - * Bcopy/Memcpy patch. - * -#ifdef HAVE_CONFIG_H -#include -#endif - -#if defined(SYSVBFUNC) -#include -#define BZERO(d,n) memset(d,0,n) -#define BCMP(s,d,n) memcmp(d,s,n) -#define BCOPY(s,d,n) memcpy(d,s,n) - -#else -#define BZERO(d,n) bzero(d,n) -#define BCMP(s,d,n) bcmp(s,d,n) -#define BCOPY(s,d,n) bcopy(s,d,n) - -#endif - diff --git a/src/gromacs/gmxlib/bondfree.c b/src/gromacs/gmxlib/bondfree.c index cd9741b949..b3bc55dddf 100644 --- a/src/gromacs/gmxlib/bondfree.c +++ b/src/gromacs/gmxlib/bondfree.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -63,48 +63,53 @@ /* Find a better place for this? */ const int cmap_coeff_matrix[] = { -1, 0, -3, 2, 0, 0, 0, 0, -3, 0, 9, -6, 2, 0, -6, 4 , -0, 0, 0, 0, 0, 0, 0, 0, 3, 0, -9, 6, -2, 0, 6, -4, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, -6, 0, 0, -6, 4 , -0, 0, 3, -2, 0, 0, 0, 0, 0, 0, -9, 6, 0, 0, 6, -4, -0, 0, 0, 0, 1, 0, -3, 2, -2, 0, 6, -4, 1, 0, -3, 2 , -0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 3, -2, 1, 0, -3, 2 , -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 2, 0, 0, 3, -2, -0, 0, 0, 0, 0, 0, 3, -2, 0, 0, -6, 4, 0, 0, 3, -2, -0, 1, -2, 1, 0, 0, 0, 0, 0, -3, 6, -3, 0, 2, -4, 2 , -0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -6, 3, 0, -2, 4, -2, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 3, 0, 0, 2, -2, -0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 3, -3, 0, 0, -2, 2 , -0, 0, 0, 0, 0, 1, -2, 1, 0, -2, 4, -2, 0, 1, -2, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 2, -1, 0, 1, -2, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 1, -0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 2, -2, 0, 0, -1, 1 + 1, 0, -3, 2, 0, 0, 0, 0, -3, 0, 9, -6, 2, 0, -6, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, -9, 6, -2, 0, 6, -4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, -6, 0, 0, -6, 4, + 0, 0, 3, -2, 0, 0, 0, 0, 0, 0, -9, 6, 0, 0, 6, -4, + 0, 0, 0, 0, 1, 0, -3, 2, -2, 0, 6, -4, 1, 0, -3, 2, + 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 3, -2, 1, 0, -3, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 2, 0, 0, 3, -2, + 0, 0, 0, 0, 0, 0, 3, -2, 0, 0, -6, 4, 0, 0, 3, -2, + 0, 1, -2, 1, 0, 0, 0, 0, 0, -3, 6, -3, 0, 2, -4, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -6, 3, 0, -2, 4, -2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 3, 0, 0, 2, -2, + 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 3, -3, 0, 0, -2, 2, + 0, 0, 0, 0, 0, 1, -2, 1, 0, -2, 4, -2, 0, 1, -2, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 2, -1, 0, 1, -2, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 1, + 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 2, -2, 0, 0, -1, 1 }; -int glatnr(int *global_atom_index,int i) +int glatnr(int *global_atom_index, int i) { int atnr; - if (global_atom_index == NULL) { + if (global_atom_index == NULL) + { atnr = i + 1; - } else { + } + else + { atnr = global_atom_index[i] + 1; } return atnr; } -static int pbc_rvec_sub(const t_pbc *pbc,const rvec xi,const rvec xj,rvec dx) +static int pbc_rvec_sub(const t_pbc *pbc, const rvec xi, const rvec xj, rvec dx) { - if (pbc) { - return pbc_dx_aiuc(pbc,xi,xj,dx); - } - else { - rvec_sub(xi,xj,dx); - return CENTRAL; - } + if (pbc) + { + return pbc_dx_aiuc(pbc, xi, xj, dx); + } + else + { + rvec_sub(xi, xj, dx); + return CENTRAL; + } } /* @@ -121,305 +126,327 @@ static int pbc_rvec_sub(const t_pbc *pbc,const rvec xi,const rvec xj,rvec dx) */ real morse_bonds(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) { - const real one=1.0; - const real two=2.0; - real dr,dr2,temp,omtemp,cbomtemp,fbond,vbond,fij,vtot; - real b0,be,cb,b0A,beA,cbA,b0B,beB,cbB,L1; - rvec dx; - int i,m,ki,type,ai,aj; - ivec dt; - - vtot = 0.0; - for(i=0; (i= bm2) - gmx_fatal(FARGS, - "r^2 (%f) >= bm^2 (%f) in FENE bond between atoms %d and %d", - dr2,bm2, - glatnr(global_atom_index,ai), - glatnr(global_atom_index,aj)); - - omdr2obm2 = one - dr2/bm2; - - vbond = -half*kb*bm2*log(omdr2obm2); - fbond = -kb/omdr2obm2; - - vtot += vbond; /* 35 */ - - if (g) { - ivec_sub(SHIFT_IVEC(g,ai),SHIFT_IVEC(g,aj),dt); - ki=IVEC2IS(dt); - } - for (m=0; (m= bm2) + { + gmx_fatal(FARGS, + "r^2 (%f) >= bm^2 (%f) in FENE bond between atoms %d and %d", + dr2, bm2, + glatnr(global_atom_index, ai), + glatnr(global_atom_index, aj)); + } + + omdr2obm2 = one - dr2/bm2; + + vbond = -half*kb*bm2*log(omdr2obm2); + fbond = -kb/omdr2obm2; + + vtot += vbond; /* 35 */ + + if (g) + { + ivec_sub(SHIFT_IVEC(g, ai), SHIFT_IVEC(g, aj), dt); + ki = IVEC2IS(dt); + } + for (m = 0; (m < DIM); m++) /* 15 */ + { + fij = fbond*dx[m]; + f[ai][m] += fij; + f[aj][m] -= fij; + fshift[ki][m] += fij; + fshift[CENTRAL][m] -= fij; + } + } /* 58 TOTAL */ + return vtot; } -real harmonic(real kA,real kB,real xA,real xB,real x,real lambda, - real *V,real *F) +real harmonic(real kA, real kB, real xA, real xB, real x, real lambda, + real *V, real *F) { - const real half=0.5; - real L1,kk,x0,dx,dx2; - real v,f,dvdlambda; - - L1 = 1.0-lambda; - kk = L1*kA+lambda*kB; - x0 = L1*xA+lambda*xB; + const real half = 0.5; + real L1, kk, x0, dx, dx2; + real v, f, dvdlambda; + + L1 = 1.0-lambda; + kk = L1*kA+lambda*kB; + x0 = L1*xA+lambda*xB; - dx = x-x0; - dx2 = dx*dx; + dx = x-x0; + dx2 = dx*dx; - f = -kk*dx; - v = half*kk*dx2; - dvdlambda = half*(kB-kA)*dx2 + (xA-xB)*kk*dx; + f = -kk*dx; + v = half*kk*dx2; + dvdlambda = half*(kB-kA)*dx2 + (xA-xB)*kk*dx; - *F = f; - *V = v; + *F = f; + *V = v; - return dvdlambda; + return dvdlambda; - /* That was 19 flops */ + /* That was 19 flops */ } real bonds(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) { - int i,m,ki,ai,aj,type; - real dr,dr2,fbond,vbond,fij,vtot; - rvec dx; - ivec dt; - - vtot = 0.0; - for(i=0; (ichargeA[aj])*ONE_4PI_EPS0/forceparams[type].polarize.alpha; - if (debug) - fprintf(debug,"POL: local ai = %d aj = %d ksh = %.3f\n",ai,aj,ksh); - - ki = pbc_rvec_sub(pbc,x[ai],x[aj],dx); /* 3 */ - dr2 = iprod(dx,dx); /* 5 */ - dr = dr2*gmx_invsqrt(dr2); /* 10 */ - - *dvdlambda += harmonic(ksh,ksh,0,0,dr,lambda,&vbond,&fbond); /* 19 */ - - if (dr2 == 0.0) - continue; - - vtot += vbond;/* 1*/ - fbond *= gmx_invsqrt(dr2); /* 6 */ - - if (g) { - ivec_sub(SHIFT_IVEC(g,ai),SHIFT_IVEC(g,aj),dt); - ki=IVEC2IS(dt); - } - for (m=0; (mchargeA[aj])*ONE_4PI_EPS0/forceparams[type].polarize.alpha; + if (debug) + { + fprintf(debug, "POL: local ai = %d aj = %d ksh = %.3f\n", ai, aj, ksh); + } + + ki = pbc_rvec_sub(pbc, x[ai], x[aj], dx); /* 3 */ + dr2 = iprod(dx, dx); /* 5 */ + dr = dr2*gmx_invsqrt(dr2); /* 10 */ + + *dvdlambda += harmonic(ksh, ksh, 0, 0, dr, lambda, &vbond, &fbond); /* 19 */ + + if (dr2 == 0.0) + { + continue; + } + + vtot += vbond; /* 1*/ + fbond *= gmx_invsqrt(dr2); /* 6 */ + + if (g) + { + ivec_sub(SHIFT_IVEC(g, ai), SHIFT_IVEC(g, aj), dt); + ki = IVEC2IS(dt); + } + for (m = 0; (m < DIM); m++) /* 15 */ + { + fij = fbond*dx[m]; + f[ai][m] += fij; + f[aj][m] -= fij; + fshift[ki][m] += fij; + fshift[CENTRAL][m] -= fij; + } + } /* 59 TOTAL */ + return vtot; } real anharm_polarize(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, int *global_atom_index) { - int i,m,ki,ai,aj,type; - real dr,dr2,fbond,vbond,fij,vtot,ksh,khyp,drcut,ddr,ddr3; - rvec dx; - ivec dt; - - vtot = 0.0; - for(i=0; (ichargeA[aj])*ONE_4PI_EPS0/forceparams[type].anharm_polarize.alpha; /* 7*/ - khyp = forceparams[type].anharm_polarize.khyp; - drcut = forceparams[type].anharm_polarize.drcut; - if (debug) - fprintf(debug,"POL: local ai = %d aj = %d ksh = %.3f\n",ai,aj,ksh); - - ki = pbc_rvec_sub(pbc,x[ai],x[aj],dx); /* 3 */ - dr2 = iprod(dx,dx); /* 5 */ - dr = dr2*gmx_invsqrt(dr2); /* 10 */ - - *dvdlambda += harmonic(ksh,ksh,0,0,dr,lambda,&vbond,&fbond); /* 19 */ - - if (dr2 == 0.0) - continue; - - if (dr > drcut) { - ddr = dr-drcut; - ddr3 = ddr*ddr*ddr; - vbond += khyp*ddr*ddr3; - fbond -= 4*khyp*ddr3; - } - fbond *= gmx_invsqrt(dr2); /* 6 */ - vtot += vbond;/* 1*/ - - if (g) { - ivec_sub(SHIFT_IVEC(g,ai),SHIFT_IVEC(g,aj),dt); - ki=IVEC2IS(dt); - } - for (m=0; (mchargeA[aj])*ONE_4PI_EPS0/forceparams[type].anharm_polarize.alpha; /* 7*/ + khyp = forceparams[type].anharm_polarize.khyp; + drcut = forceparams[type].anharm_polarize.drcut; + if (debug) + { + fprintf(debug, "POL: local ai = %d aj = %d ksh = %.3f\n", ai, aj, ksh); + } + + ki = pbc_rvec_sub(pbc, x[ai], x[aj], dx); /* 3 */ + dr2 = iprod(dx, dx); /* 5 */ + dr = dr2*gmx_invsqrt(dr2); /* 10 */ + + *dvdlambda += harmonic(ksh, ksh, 0, 0, dr, lambda, &vbond, &fbond); /* 19 */ + + if (dr2 == 0.0) + { + continue; + } + + if (dr > drcut) + { + ddr = dr-drcut; + ddr3 = ddr*ddr*ddr; + vbond += khyp*ddr*ddr3; + fbond -= 4*khyp*ddr3; + } + fbond *= gmx_invsqrt(dr2); /* 6 */ + vtot += vbond; /* 1*/ + + if (g) + { + ivec_sub(SHIFT_IVEC(g, ai), SHIFT_IVEC(g, aj), dt); + ki = IVEC2IS(dt); + } + for (m = 0; (m < DIM); m++) /* 15 */ + { + fij = fbond*dx[m]; + f[ai][m] += fij; + f[aj][m] -= fij; + fshift[ki][m] += fij; + fshift[CENTRAL][m] -= fij; + } + } /* 72 TOTAL */ + return vtot; } real water_pol(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) { - /* This routine implements anisotropic polarizibility for water, through - * a shell connected to a dummy with spring constant that differ in the - * three spatial dimensions in the molecular frame. - */ - int i,m,aO,aH1,aH2,aD,aS,type,type0; - rvec dOH1,dOH2,dHH,dOD,dDS,nW,kk,dx,kdx,proj; + /* This routine implements anisotropic polarizibility for water, through + * a shell connected to a dummy with spring constant that differ in the + * three spatial dimensions in the molecular frame. + */ + int i, m, aO, aH1, aH2, aD, aS, type, type0; + rvec dOH1, dOH2, dHH, dOD, dDS, nW, kk, dx, kdx, proj; #ifdef DEBUG - rvec df; + rvec df; #endif - real vtot,fij,r_HH,r_OD,r_nW,tx,ty,tz,qS; - - vtot = 0.0; - if (nbonds > 0) { - type0 = forceatoms[0]; - aS = forceatoms[5]; - qS = md->chargeA[aS]; - kk[XX] = sqr(qS)*ONE_4PI_EPS0/forceparams[type0].wpol.al_x; - kk[YY] = sqr(qS)*ONE_4PI_EPS0/forceparams[type0].wpol.al_y; - kk[ZZ] = sqr(qS)*ONE_4PI_EPS0/forceparams[type0].wpol.al_z; - r_HH = 1.0/forceparams[type0].wpol.rHH; - r_OD = 1.0/forceparams[type0].wpol.rOD; - if (debug) { - fprintf(debug,"WPOL: qS = %10.5f aS = %5d\n",qS,aS); - fprintf(debug,"WPOL: kk = %10.3f %10.3f %10.3f\n", - kk[XX],kk[YY],kk[ZZ]); - fprintf(debug,"WPOL: rOH = %10.3f rHH = %10.3f rOD = %10.3f\n", - forceparams[type0].wpol.rOH, - forceparams[type0].wpol.rHH, - forceparams[type0].wpol.rOD); - } - for(i=0; (i 0) + { + type0 = forceatoms[0]; + aS = forceatoms[5]; + qS = md->chargeA[aS]; + kk[XX] = sqr(qS)*ONE_4PI_EPS0/forceparams[type0].wpol.al_x; + kk[YY] = sqr(qS)*ONE_4PI_EPS0/forceparams[type0].wpol.al_y; + kk[ZZ] = sqr(qS)*ONE_4PI_EPS0/forceparams[type0].wpol.al_z; + r_HH = 1.0/forceparams[type0].wpol.rHH; + r_OD = 1.0/forceparams[type0].wpol.rOD; + if (debug) + { + fprintf(debug, "WPOL: qS = %10.5f aS = %5d\n", qS, aS); + fprintf(debug, "WPOL: kk = %10.3f %10.3f %10.3f\n", + kk[XX], kk[YY], kk[ZZ]); + fprintf(debug, "WPOL: rOH = %10.3f rHH = %10.3f rOD = %10.3f\n", + forceparams[type0].wpol.rOH, + forceparams[type0].wpol.rHH, + forceparams[type0].wpol.rOD); + } + for (i = 0; (i < nbonds); i += 6) + { + type = forceatoms[i]; + if (type != type0) + { + gmx_fatal(FARGS, "Sorry, type = %d, type0 = %d, file = %s, line = %d", + type, type0, __FILE__, __LINE__); + } + aO = forceatoms[i+1]; + aH1 = forceatoms[i+2]; + aH2 = forceatoms[i+3]; + aD = forceatoms[i+4]; + aS = forceatoms[i+5]; + + /* Compute vectors describing the water frame */ + rvec_sub(x[aH1], x[aO], dOH1); + rvec_sub(x[aH2], x[aO], dOH2); + rvec_sub(x[aH2], x[aH1], dHH); + rvec_sub(x[aD], x[aO], dOD); + rvec_sub(x[aS], x[aD], dDS); + cprod(dOH1, dOH2, nW); + + /* Compute inverse length of normal vector + * (this one could be precomputed, but I'm too lazy now) + */ + r_nW = gmx_invsqrt(iprod(nW, nW)); + /* This is for precision, but does not make a big difference, + * it can go later. + */ + r_OD = gmx_invsqrt(iprod(dOD, dOD)); + + /* Normalize the vectors in the water frame */ + svmul(r_nW, nW, nW); + svmul(r_HH, dHH, dHH); + svmul(r_OD, dOD, dOD); + + /* Compute displacement of shell along components of the vector */ + dx[ZZ] = iprod(dDS, dOD); + /* Compute projection on the XY plane: dDS - dx[ZZ]*dOD */ + for (m = 0; (m < DIM); m++) + { + proj[m] = dDS[m]-dx[ZZ]*dOD[m]; + } + + /*dx[XX] = iprod(dDS,nW); + dx[YY] = iprod(dDS,dHH);*/ + dx[XX] = iprod(proj, nW); + for (m = 0; (m < DIM); m++) + { + proj[m] -= dx[XX]*nW[m]; + } + dx[YY] = iprod(proj, dHH); + /*#define DEBUG*/ #ifdef DEBUG - if (debug) { - fprintf(debug,"WPOL: dx2=%10g dy2=%10g dz2=%10g sum=%10g dDS^2=%10g\n", - sqr(dx[XX]),sqr(dx[YY]),sqr(dx[ZZ]),iprod(dx,dx),iprod(dDS,dDS)); - fprintf(debug,"WPOL: dHH=(%10g,%10g,%10g)\n",dHH[XX],dHH[YY],dHH[ZZ]); - fprintf(debug,"WPOL: dOD=(%10g,%10g,%10g), 1/r_OD = %10g\n", - dOD[XX],dOD[YY],dOD[ZZ],1/r_OD); - fprintf(debug,"WPOL: nW =(%10g,%10g,%10g), 1/r_nW = %10g\n", - nW[XX],nW[YY],nW[ZZ],1/r_nW); - fprintf(debug,"WPOL: dx =%10g, dy =%10g, dz =%10g\n", - dx[XX],dx[YY],dx[ZZ]); - fprintf(debug,"WPOL: dDSx=%10g, dDSy=%10g, dDSz=%10g\n", - dDS[XX],dDS[YY],dDS[ZZ]); - } + if (debug) + { + fprintf(debug, "WPOL: dx2=%10g dy2=%10g dz2=%10g sum=%10g dDS^2=%10g\n", + sqr(dx[XX]), sqr(dx[YY]), sqr(dx[ZZ]), iprod(dx, dx), iprod(dDS, dDS)); + fprintf(debug, "WPOL: dHH=(%10g,%10g,%10g)\n", dHH[XX], dHH[YY], dHH[ZZ]); + fprintf(debug, "WPOL: dOD=(%10g,%10g,%10g), 1/r_OD = %10g\n", + dOD[XX], dOD[YY], dOD[ZZ], 1/r_OD); + fprintf(debug, "WPOL: nW =(%10g,%10g,%10g), 1/r_nW = %10g\n", + nW[XX], nW[YY], nW[ZZ], 1/r_nW); + fprintf(debug, "WPOL: dx =%10g, dy =%10g, dz =%10g\n", + dx[XX], dx[YY], dx[ZZ]); + fprintf(debug, "WPOL: dDSx=%10g, dDSy=%10g, dDSz=%10g\n", + dDS[XX], dDS[YY], dDS[ZZ]); + } #endif - /* Now compute the forces and energy */ - kdx[XX] = kk[XX]*dx[XX]; - kdx[YY] = kk[YY]*dx[YY]; - kdx[ZZ] = kk[ZZ]*dx[ZZ]; - vtot += iprod(dx,kdx); - for(m=0; (mchargeA[da1]; - q2 = md->chargeA[da2]; - a = forceparams[type].thole.a; - al1 = forceparams[type].thole.alpha1; - al2 = forceparams[type].thole.alpha2; - qq = q1*q2; - afac = a*pow(al1*al2,-1.0/6.0); - V += do_1_thole(x[a1], x[a2], f[a1], f[a2], pbc, qq,fshift,afac); - V += do_1_thole(x[da1],x[a2], f[da1],f[a2], pbc,-qq,fshift,afac); - V += do_1_thole(x[a1], x[da2],f[a1], f[da2],pbc,-qq,fshift,afac); - V += do_1_thole(x[da1],x[da2],f[da1],f[da2],pbc, qq,fshift,afac); - } - /* 290 flops */ - return V; + /* Interaction between two pairs of particles with opposite charge */ + int i, type, a1, da1, a2, da2; + real q1, q2, qq, a, al1, al2, afac; + real V = 0; + + for (i = 0; (i < nbonds); ) + { + type = forceatoms[i++]; + a1 = forceatoms[i++]; + da1 = forceatoms[i++]; + a2 = forceatoms[i++]; + da2 = forceatoms[i++]; + q1 = md->chargeA[da1]; + q2 = md->chargeA[da2]; + a = forceparams[type].thole.a; + al1 = forceparams[type].thole.alpha1; + al2 = forceparams[type].thole.alpha2; + qq = q1*q2; + afac = a*pow(al1*al2, -1.0/6.0); + V += do_1_thole(x[a1], x[a2], f[a1], f[a2], pbc, qq, fshift, afac); + V += do_1_thole(x[da1], x[a2], f[da1], f[a2], pbc, -qq, fshift, afac); + V += do_1_thole(x[a1], x[da2], f[a1], f[da2], pbc, -qq, fshift, afac); + V += do_1_thole(x[da1], x[da2], f[da1], f[da2], pbc, qq, fshift, afac); + } + /* 290 flops */ + return V; } -real bond_angle(const rvec xi,const rvec xj,const rvec xk,const t_pbc *pbc, - rvec r_ij,rvec r_kj,real *costh, - int *t1,int *t2) +real bond_angle(const rvec xi, const rvec xj, const rvec xk, const t_pbc *pbc, + rvec r_ij, rvec r_kj, real *costh, + int *t1, int *t2) /* Return value is the angle between the bonds i-j and j-k */ { - /* 41 FLOPS */ - real th; - - *t1 = pbc_rvec_sub(pbc,xi,xj,r_ij); /* 3 */ - *t2 = pbc_rvec_sub(pbc,xk,xj,r_kj); /* 3 */ - - *costh=cos_angle(r_ij,r_kj); /* 25 */ - th=acos(*costh); /* 10 */ - /* 41 TOTAL */ - return th; + /* 41 FLOPS */ + real th; + + *t1 = pbc_rvec_sub(pbc, xi, xj, r_ij); /* 3 */ + *t2 = pbc_rvec_sub(pbc, xk, xj, r_kj); /* 3 */ + + *costh = cos_angle(r_ij, r_kj); /* 25 */ + th = acos(*costh); /* 10 */ + /* 41 TOTAL */ + return th; } real angles(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, int *global_atom_index) { - int i,ai,aj,ak,t1,t2,type; - rvec r_ij,r_kj; - real cos_theta,cos_theta2,theta,dVdt,va,vtot; - ivec jt,dt_ij,dt_kj; + int i, ai, aj, ak, t1, t2, type; + rvec r_ij, r_kj; + real cos_theta, cos_theta2, theta, dVdt, va, vtot; + ivec jt, dt_ij, dt_kj; vtot = 0.0; - for(i=0; i toler) && (iprn > toler)) { - nrkj_1 = gmx_invsqrt(nrkj2); /* 10 */ - nrkj_2 = nrkj_1*nrkj_1; /* 1 */ - nrkj = nrkj2*nrkj_1; /* 1 */ - a = -ddphi*nrkj/iprm; /* 11 */ - svmul(a,m,f_i); /* 3 */ - b = ddphi*nrkj/iprn; /* 11 */ - svmul(b,n,f_l); /* 3 */ - p = iprod(r_ij,r_kj); /* 5 */ - p *= nrkj_2; /* 1 */ - q = iprod(r_kl,r_kj); /* 5 */ - q *= nrkj_2; /* 1 */ - svmul(p,f_i,uvec); /* 3 */ - svmul(q,f_l,vvec); /* 3 */ - rvec_sub(uvec,vvec,svec); /* 3 */ - rvec_sub(f_i,svec,f_j); /* 3 */ - rvec_add(f_l,svec,f_k); /* 3 */ - rvec_inc(f[i],f_i); /* 3 */ - rvec_dec(f[j],f_j); /* 3 */ - rvec_dec(f[k],f_k); /* 3 */ - rvec_inc(f[l],f_l); /* 3 */ - - if (g) { - copy_ivec(SHIFT_IVEC(g,j),jt); - ivec_sub(SHIFT_IVEC(g,i),jt,dt_ij); - ivec_sub(SHIFT_IVEC(g,k),jt,dt_kj); - ivec_sub(SHIFT_IVEC(g,l),jt,dt_lj); - t1=IVEC2IS(dt_ij); - t2=IVEC2IS(dt_kj); - t3=IVEC2IS(dt_lj); - } else if (pbc) { - t3 = pbc_rvec_sub(pbc,x[l],x[j],dx_jl); - } else { - t3 = CENTRAL; - } - - rvec_inc(fshift[t1],f_i); - rvec_dec(fshift[CENTRAL],f_j); - rvec_dec(fshift[t2],f_k); - rvec_inc(fshift[t3],f_l); - } - /* 112 TOTAL */ + /* 143 FLOPS */ + rvec f_i, f_j, f_k, f_l; + rvec uvec, vvec, svec, dx_jl; + real iprm, iprn, nrkj, nrkj2, nrkj_1, nrkj_2; + real a, b, p, q, toler; + ivec jt, dt_ij, dt_kj, dt_lj; + + iprm = iprod(m, m); /* 5 */ + iprn = iprod(n, n); /* 5 */ + nrkj2 = iprod(r_kj, r_kj); /* 5 */ + toler = nrkj2*GMX_REAL_EPS; + if ((iprm > toler) && (iprn > toler)) + { + nrkj_1 = gmx_invsqrt(nrkj2); /* 10 */ + nrkj_2 = nrkj_1*nrkj_1; /* 1 */ + nrkj = nrkj2*nrkj_1; /* 1 */ + a = -ddphi*nrkj/iprm; /* 11 */ + svmul(a, m, f_i); /* 3 */ + b = ddphi*nrkj/iprn; /* 11 */ + svmul(b, n, f_l); /* 3 */ + p = iprod(r_ij, r_kj); /* 5 */ + p *= nrkj_2; /* 1 */ + q = iprod(r_kl, r_kj); /* 5 */ + q *= nrkj_2; /* 1 */ + svmul(p, f_i, uvec); /* 3 */ + svmul(q, f_l, vvec); /* 3 */ + rvec_sub(uvec, vvec, svec); /* 3 */ + rvec_sub(f_i, svec, f_j); /* 3 */ + rvec_add(f_l, svec, f_k); /* 3 */ + rvec_inc(f[i], f_i); /* 3 */ + rvec_dec(f[j], f_j); /* 3 */ + rvec_dec(f[k], f_k); /* 3 */ + rvec_inc(f[l], f_l); /* 3 */ + + if (g) + { + copy_ivec(SHIFT_IVEC(g, j), jt); + ivec_sub(SHIFT_IVEC(g, i), jt, dt_ij); + ivec_sub(SHIFT_IVEC(g, k), jt, dt_kj); + ivec_sub(SHIFT_IVEC(g, l), jt, dt_lj); + t1 = IVEC2IS(dt_ij); + t2 = IVEC2IS(dt_kj); + t3 = IVEC2IS(dt_lj); + } + else if (pbc) + { + t3 = pbc_rvec_sub(pbc, x[l], x[j], dx_jl); + } + else + { + t3 = CENTRAL; + } + + rvec_inc(fshift[t1], f_i); + rvec_dec(fshift[CENTRAL], f_j); + rvec_dec(fshift[t2], f_k); + rvec_inc(fshift[t3], f_l); + } + /* 112 TOTAL */ } /* As do_dih_fup above, but without shift forces */ static void -do_dih_fup_noshiftf(int i,int j,int k,int l,real ddphi, - rvec r_ij,rvec r_kj,rvec r_kl, - rvec m,rvec n,rvec f[]) +do_dih_fup_noshiftf(int i, int j, int k, int l, real ddphi, + rvec r_ij, rvec r_kj, rvec r_kl, + rvec m, rvec n, rvec f[]) { - rvec f_i,f_j,f_k,f_l; - rvec uvec,vvec,svec,dx_jl; - real iprm,iprn,nrkj,nrkj2,nrkj_1,nrkj_2; - real a,b,p,q,toler; - ivec jt,dt_ij,dt_kj,dt_lj; - - iprm = iprod(m,m); /* 5 */ - iprn = iprod(n,n); /* 5 */ - nrkj2 = iprod(r_kj,r_kj); /* 5 */ - toler = nrkj2*GMX_REAL_EPS; - if ((iprm > toler) && (iprn > toler)) { - nrkj_1 = gmx_invsqrt(nrkj2); /* 10 */ - nrkj_2 = nrkj_1*nrkj_1; /* 1 */ - nrkj = nrkj2*nrkj_1; /* 1 */ - a = -ddphi*nrkj/iprm; /* 11 */ - svmul(a,m,f_i); /* 3 */ - b = ddphi*nrkj/iprn; /* 11 */ - svmul(b,n,f_l); /* 3 */ - p = iprod(r_ij,r_kj); /* 5 */ - p *= nrkj_2; /* 1 */ - q = iprod(r_kl,r_kj); /* 5 */ - q *= nrkj_2; /* 1 */ - svmul(p,f_i,uvec); /* 3 */ - svmul(q,f_l,vvec); /* 3 */ - rvec_sub(uvec,vvec,svec); /* 3 */ - rvec_sub(f_i,svec,f_j); /* 3 */ - rvec_add(f_l,svec,f_k); /* 3 */ - rvec_inc(f[i],f_i); /* 3 */ - rvec_dec(f[j],f_j); /* 3 */ - rvec_dec(f[k],f_k); /* 3 */ - rvec_inc(f[l],f_l); /* 3 */ - } + rvec f_i, f_j, f_k, f_l; + rvec uvec, vvec, svec, dx_jl; + real iprm, iprn, nrkj, nrkj2, nrkj_1, nrkj_2; + real a, b, p, q, toler; + ivec jt, dt_ij, dt_kj, dt_lj; + + iprm = iprod(m, m); /* 5 */ + iprn = iprod(n, n); /* 5 */ + nrkj2 = iprod(r_kj, r_kj); /* 5 */ + toler = nrkj2*GMX_REAL_EPS; + if ((iprm > toler) && (iprn > toler)) + { + nrkj_1 = gmx_invsqrt(nrkj2); /* 10 */ + nrkj_2 = nrkj_1*nrkj_1; /* 1 */ + nrkj = nrkj2*nrkj_1; /* 1 */ + a = -ddphi*nrkj/iprm; /* 11 */ + svmul(a, m, f_i); /* 3 */ + b = ddphi*nrkj/iprn; /* 11 */ + svmul(b, n, f_l); /* 3 */ + p = iprod(r_ij, r_kj); /* 5 */ + p *= nrkj_2; /* 1 */ + q = iprod(r_kl, r_kj); /* 5 */ + q *= nrkj_2; /* 1 */ + svmul(p, f_i, uvec); /* 3 */ + svmul(q, f_l, vvec); /* 3 */ + rvec_sub(uvec, vvec, svec); /* 3 */ + rvec_sub(f_i, svec, f_j); /* 3 */ + rvec_add(f_l, svec, f_k); /* 3 */ + rvec_inc(f[i], f_i); /* 3 */ + rvec_dec(f[j], f_j); /* 3 */ + rvec_dec(f[k], f_k); /* 3 */ + rvec_inc(f[l], f_l); /* 3 */ + } } /* As do_dih_fup_noshiftf above, but with pre-calculated pre-factors */ static void -do_dih_fup_noshiftf_precalc(int i,int j,int k,int l,real ddphi, - real nrkj_m2,real nrkj_n2, - real p,real q, - rvec m,rvec n,rvec f[]) +do_dih_fup_noshiftf_precalc(int i, int j, int k, int l, real ddphi, + real nrkj_m2, real nrkj_n2, + real p, real q, + rvec m, rvec n, rvec f[]) { - rvec f_i,f_j,f_k,f_l; - rvec uvec,vvec,svec,dx_jl; - real a,b,toler; - ivec jt,dt_ij,dt_kj,dt_lj; - + rvec f_i, f_j, f_k, f_l; + rvec uvec, vvec, svec, dx_jl; + real a, b, toler; + ivec jt, dt_ij, dt_kj, dt_lj; + a = -ddphi*nrkj_m2; - svmul(a,m,f_i); + svmul(a, m, f_i); b = ddphi*nrkj_n2; - svmul(b,n,f_l); - svmul(p,f_i,uvec); - svmul(q,f_l,vvec); - rvec_sub(uvec,vvec,svec); - rvec_sub(f_i,svec,f_j); - rvec_add(f_l,svec,f_k); - rvec_inc(f[i],f_i); - rvec_dec(f[j],f_j); - rvec_dec(f[k],f_k); - rvec_inc(f[l],f_l); + svmul(b, n, f_l); + svmul(p, f_i, uvec); + svmul(q, f_l, vvec); + rvec_sub(uvec, vvec, svec); + rvec_sub(f_i, svec, f_j); + rvec_add(f_l, svec, f_k); + rvec_inc(f[i], f_i); + rvec_dec(f[j], f_j); + rvec_dec(f[k], f_k); + rvec_inc(f[l], f_l); } -real dopdihs(real cpA,real cpB,real phiA,real phiB,int mult, - real phi,real lambda,real *V,real *F) +real dopdihs(real cpA, real cpB, real phiA, real phiB, int mult, + real phi, real lambda, real *V, real *F) { - real v,dvdlambda,mdphi,v1,sdphi,ddphi; - real L1 = 1.0 - lambda; - real ph0 = (L1*phiA + lambda*phiB)*DEG2RAD; - real dph0 = (phiB - phiA)*DEG2RAD; - real cp = L1*cpA + lambda*cpB; - - mdphi = mult*phi - ph0; - sdphi = sin(mdphi); - ddphi = -cp*mult*sdphi; - v1 = 1.0 + cos(mdphi); - v = cp*v1; - - dvdlambda = (cpB - cpA)*v1 + cp*dph0*sdphi; - - *V = v; - *F = ddphi; - - return dvdlambda; - - /* That was 40 flops */ + real v, dvdlambda, mdphi, v1, sdphi, ddphi; + real L1 = 1.0 - lambda; + real ph0 = (L1*phiA + lambda*phiB)*DEG2RAD; + real dph0 = (phiB - phiA)*DEG2RAD; + real cp = L1*cpA + lambda*cpB; + + mdphi = mult*phi - ph0; + sdphi = sin(mdphi); + ddphi = -cp*mult*sdphi; + v1 = 1.0 + cos(mdphi); + v = cp*v1; + + dvdlambda = (cpB - cpA)*v1 + cp*dph0*sdphi; + + *V = v; + *F = ddphi; + + return dvdlambda; + + /* That was 40 flops */ } static void -dopdihs_noener(real cpA,real cpB,real phiA,real phiB,int mult, - real phi,real lambda,real *F) +dopdihs_noener(real cpA, real cpB, real phiA, real phiB, int mult, + real phi, real lambda, real *F) { - real mdphi,sdphi,ddphi; - real L1 = 1.0 - lambda; - real ph0 = (L1*phiA + lambda*phiB)*DEG2RAD; - real cp = L1*cpA + lambda*cpB; - - mdphi = mult*phi - ph0; - sdphi = sin(mdphi); - ddphi = -cp*mult*sdphi; - - *F = ddphi; - - /* That was 20 flops */ + real mdphi, sdphi, ddphi; + real L1 = 1.0 - lambda; + real ph0 = (L1*phiA + lambda*phiB)*DEG2RAD; + real cp = L1*cpA + lambda*cpB; + + mdphi = mult*phi - ph0; + sdphi = sin(mdphi); + ddphi = -cp*mult*sdphi; + + *F = ddphi; + + /* That was 20 flops */ } static void -dopdihs_mdphi(real cpA,real cpB,real phiA,real phiB,int mult, - real phi,real lambda,real *cp,real *mdphi) +dopdihs_mdphi(real cpA, real cpB, real phiA, real phiB, int mult, + real phi, real lambda, real *cp, real *mdphi) { real L1 = 1.0 - lambda; real ph0 = (L1*phiA + lambda*phiB)*DEG2RAD; @@ -1510,75 +1602,76 @@ dopdihs_mdphi(real cpA,real cpB,real phiA,real phiB,int mult, *mdphi = mult*phi - ph0; } -static real dopdihs_min(real cpA,real cpB,real phiA,real phiB,int mult, - real phi,real lambda,real *V,real *F) - /* similar to dopdihs, except for a minus sign * - * and a different treatment of mult/phi0 */ +static real dopdihs_min(real cpA, real cpB, real phiA, real phiB, int mult, + real phi, real lambda, real *V, real *F) +/* similar to dopdihs, except for a minus sign * + * and a different treatment of mult/phi0 */ { - real v,dvdlambda,mdphi,v1,sdphi,ddphi; - real L1 = 1.0 - lambda; - real ph0 = (L1*phiA + lambda*phiB)*DEG2RAD; - real dph0 = (phiB - phiA)*DEG2RAD; - real cp = L1*cpA + lambda*cpB; - - mdphi = mult*(phi-ph0); - sdphi = sin(mdphi); - ddphi = cp*mult*sdphi; - v1 = 1.0-cos(mdphi); - v = cp*v1; - - dvdlambda = (cpB-cpA)*v1 + cp*dph0*sdphi; - - *V = v; - *F = ddphi; - - return dvdlambda; - - /* That was 40 flops */ + real v, dvdlambda, mdphi, v1, sdphi, ddphi; + real L1 = 1.0 - lambda; + real ph0 = (L1*phiA + lambda*phiB)*DEG2RAD; + real dph0 = (phiB - phiA)*DEG2RAD; + real cp = L1*cpA + lambda*cpB; + + mdphi = mult*(phi-ph0); + sdphi = sin(mdphi); + ddphi = cp*mult*sdphi; + v1 = 1.0-cos(mdphi); + v = cp*v1; + + dvdlambda = (cpB-cpA)*v1 + cp*dph0*sdphi; + + *V = v; + *F = ddphi; + + return dvdlambda; + + /* That was 40 flops */ } real pdihs(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) { - int i,type,ai,aj,ak,al; - int t1,t2,t3; - rvec r_ij,r_kj,r_kl,m,n; - real phi,sign,ddphi,vpd,vtot; - - vtot = 0.0; - - for(i=0; (ibox[m][m]; - posB *= pbc->box[m][m]; - for(d=m+1; dbox[d][m]; - posB += 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; - default: - gmx_fatal(FARGS, "No such scaling method implemented"); + 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 += pos0A[d]*pbc->box[d][m]; + posB += 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; + default: + gmx_fatal(FARGS, "No such scaling method implemented"); } } else @@ -1876,38 +1972,38 @@ static void posres_dx(const rvec x, const rvec pos0A, const rvec pos0B, if (pbc) { - pbc_dx(pbc,x,pos,dx); + pbc_dx(pbc, x, pos, dx); } else { - rvec_sub(x,pos,dx); + rvec_sub(x, pos, dx); } } /*! \brief Adds forces of flat-bottomed positions restraints to f[] * and fixes vir_diag. Returns the flat-bottomed potential. */ real fbposres(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec vir_diag, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec vir_diag, t_pbc *pbc, - int refcoord_scaling,int ePBC,rvec com) + int refcoord_scaling, int ePBC, rvec com) /* compute flat-bottomed positions restraints */ { - int i,ai,m,d,type,npbcdim=0,fbdim; + int i, ai, m, d, type, npbcdim = 0, fbdim; const t_iparams *pr; - real vtot,kk,v; - real ref=0,dr,dr2,rpot,rfb,rfb2,fact,invdr; - rvec com_sc,rdist,pos,dx,dpdl,fm; - gmx_bool bInvert; + real vtot, kk, v; + real ref = 0, dr, dr2, rpot, rfb, rfb2, fact, invdr; + rvec com_sc, rdist, pos, dx, dpdl, fm; + gmx_bool bInvert; npbcdim = ePBC2npbcdim(ePBC); if (refcoord_scaling == erscCOM) { clear_rvec(com_sc); - for(m=0; mbox[d][m]; } @@ -1915,83 +2011,84 @@ real fbposres(int nbonds, } vtot = 0.0; - for(i=0; (ifbposres.k; - rfb=pr->fbposres.r; - rfb2=sqr(rfb); + kk = pr->fbposres.k; + rfb = pr->fbposres.r; + rfb2 = sqr(rfb); /* with rfb<0, push particle out of the sphere/cylinder/layer */ - bInvert=FALSE; - if (rfb<0.){ - bInvert=TRUE; - rfb=-rfb; + bInvert = FALSE; + if (rfb < 0.) + { + bInvert = TRUE; + rfb = -rfb; } switch (pr->fbposres.geom) { - case efbposresSPHERE: - /* spherical flat-bottom posres */ - dr2=norm2(dx); - if ( dr2 > 0.0 && - ( (dr2 > rfb2 && bInvert==FALSE ) || (dr2 < rfb2 && bInvert==TRUE ) ) - ) - { - dr=sqrt(dr2); - v = 0.5*kk*sqr(dr - rfb); - fact = -kk*(dr-rfb)/dr; /* Force pointing to the center pos0 */ - svmul(fact,dx,fm); - } - break; - case efbposresCYLINDER: - /* cylidrical flat-bottom posres in x-y plane. fm[ZZ] = 0. */ - dr2=sqr(dx[XX])+sqr(dx[YY]); - if ( dr2 > 0.0 && - ( (dr2 > rfb2 && bInvert==FALSE ) || (dr2 < rfb2 && bInvert==TRUE ) ) - ) - { - dr=sqrt(dr2); - invdr=1./dr; - v = 0.5*kk*sqr(dr - rfb); - fm[XX] = -kk*(dr-rfb)*dx[XX]*invdr; /* Force pointing to the center */ - fm[YY] = -kk*(dr-rfb)*dx[YY]*invdr; - } - break; - case efbposresX: /* fbdim=XX */ - case efbposresY: /* fbdim=YY */ - case efbposresZ: /* fbdim=ZZ */ - /* 1D flat-bottom potential */ - fbdim = pr->fbposres.geom - efbposresX; - dr=dx[fbdim]; - if ( ( dr>rfb && bInvert==FALSE ) || ( 0 0.0 && + ( (dr2 > rfb2 && bInvert == FALSE ) || (dr2 < rfb2 && bInvert == TRUE ) ) + ) + { + dr = sqrt(dr2); + v = 0.5*kk*sqr(dr - rfb); + fact = -kk*(dr-rfb)/dr; /* Force pointing to the center pos0 */ + svmul(fact, dx, fm); + } + break; + case efbposresCYLINDER: + /* cylidrical flat-bottom posres in x-y plane. fm[ZZ] = 0. */ + dr2 = sqr(dx[XX])+sqr(dx[YY]); + if (dr2 > 0.0 && + ( (dr2 > rfb2 && bInvert == FALSE ) || (dr2 < rfb2 && bInvert == TRUE ) ) + ) + { + dr = sqrt(dr2); + invdr = 1./dr; + v = 0.5*kk*sqr(dr - rfb); + fm[XX] = -kk*(dr-rfb)*dx[XX]*invdr; /* Force pointing to the center */ + fm[YY] = -kk*(dr-rfb)*dx[YY]*invdr; + } + break; + case efbposresX: /* fbdim=XX */ + case efbposresY: /* fbdim=YY */ + case efbposresZ: /* fbdim=ZZ */ + /* 1D flat-bottom potential */ + fbdim = pr->fbposres.geom - efbposresX; + dr = dx[fbdim]; + if ( ( dr > rfb && bInvert == FALSE ) || ( 0 < dr && dr < rfb && bInvert == TRUE ) ) + { + v = 0.5*kk*sqr(dr - rfb); + fm[fbdim] = -kk*(dr - rfb); + } + else if ( (dr < (-rfb) && bInvert == FALSE ) || ( (-rfb) < dr && dr < 0 && bInvert == TRUE )) + { + v = 0.5*kk*sqr(dr + rfb); + fm[fbdim] = -kk*(dr + rfb); + } + break; } vtot += v; - for (m=0; (mbox[d][m]; comB_sc[m] += comB[d]*pbc->box[d][m]; @@ -2038,1351 +2136,1400 @@ real posres(int nbonds, } } - L1 = 1.0 - lambda; + L1 = 1.0 - lambda; + + vtot = 0.0; + for (i = 0; (i < nbonds); ) + { + type = forceatoms[i++]; + ai = forceatoms[i++]; + pr = &forceparams[type]; + + /* return dx, rdist, and dpdl */ + posres_dx(x[ai], forceparams[type].posres.pos0A, forceparams[type].posres.pos0B, + comA_sc, comB_sc, lambda, + pbc, refcoord_scaling, npbcdim, + dx, rdist, dpdl); + + for (m = 0; (m < DIM); m++) + { + kk = L1*pr->posres.fcA[m] + lambda*pr->posres.fcB[m]; + fm = -kk*dx[m]; + 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 */ + if (bForceValid) + { + f[ai][m] += fm; + vir_diag[m] -= 0.5*(dx[m] + rdist[m])*fm; + } + } + } + + return vtot; +} + +static real low_angres(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + gmx_bool bZAxis) +{ + int i, m, type, ai, aj, ak, al; + int t1, t2; + real phi, cos_phi, cos_phi2, vid, vtot, dVdphi; + rvec r_ij, r_kl, f_i, f_k = {0, 0, 0}; + real st, sth, nrij2, nrkl2, c, cij, ckl; + + ivec dt; + t2 = 0; /* avoid warning with gcc-3.3. It is never used uninitialized */ + + vtot = 0.0; + ak = al = 0; /* to avoid warnings */ + for (i = 0; i < nbonds; ) + { + type = forceatoms[i++]; + ai = forceatoms[i++]; + aj = forceatoms[i++]; + t1 = pbc_rvec_sub(pbc, x[aj], x[ai], r_ij); /* 3 */ + if (!bZAxis) + { + ak = forceatoms[i++]; + al = forceatoms[i++]; + t2 = pbc_rvec_sub(pbc, x[al], x[ak], r_kl); /* 3 */ + } + else + { + r_kl[XX] = 0; + r_kl[YY] = 0; + r_kl[ZZ] = 1; + } + + cos_phi = cos_angle(r_ij, r_kl); /* 25 */ + phi = acos(cos_phi); /* 10 */ + + *dvdlambda += dopdihs_min(forceparams[type].pdihs.cpA, + forceparams[type].pdihs.cpB, + forceparams[type].pdihs.phiA, + forceparams[type].pdihs.phiB, + forceparams[type].pdihs.mult, + phi, lambda, &vid, &dVdphi); /* 40 */ + + vtot += vid; + + cos_phi2 = sqr(cos_phi); /* 1 */ + if (cos_phi2 < 1) + { + st = -dVdphi*gmx_invsqrt(1 - cos_phi2); /* 12 */ + sth = st*cos_phi; /* 1 */ + nrij2 = iprod(r_ij, r_ij); /* 5 */ + nrkl2 = iprod(r_kl, r_kl); /* 5 */ + + c = st*gmx_invsqrt(nrij2*nrkl2); /* 11 */ + cij = sth/nrij2; /* 10 */ + ckl = sth/nrkl2; /* 10 */ + + for (m = 0; m < DIM; m++) /* 18+18 */ + { + f_i[m] = (c*r_kl[m]-cij*r_ij[m]); + f[ai][m] += f_i[m]; + f[aj][m] -= f_i[m]; + if (!bZAxis) + { + f_k[m] = (c*r_ij[m]-ckl*r_kl[m]); + f[ak][m] += f_k[m]; + f[al][m] -= f_k[m]; + } + } + + if (g) + { + ivec_sub(SHIFT_IVEC(g, ai), SHIFT_IVEC(g, aj), dt); + t1 = IVEC2IS(dt); + } + rvec_inc(fshift[t1], f_i); + rvec_dec(fshift[CENTRAL], f_i); + if (!bZAxis) + { + if (g) + { + ivec_sub(SHIFT_IVEC(g, ak), SHIFT_IVEC(g, al), dt); + t2 = IVEC2IS(dt); + } + rvec_inc(fshift[t2], f_k); + rvec_dec(fshift[CENTRAL], f_k); + } + } + } + + return vtot; /* 184 / 157 (bZAxis) total */ +} + +real angres(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) +{ + return low_angres(nbonds, forceatoms, forceparams, x, f, fshift, pbc, g, + lambda, dvdlambda, FALSE); +} + +real angresz(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) +{ + return low_angres(nbonds, forceatoms, forceparams, x, f, fshift, pbc, g, + lambda, dvdlambda, TRUE); +} + +real dihres(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) +{ + real vtot = 0; + int ai, aj, ak, al, i, k, type, t1, t2, t3; + real phi0A, phi0B, dphiA, dphiB, kfacA, kfacB, phi0, dphi, kfac; + real phi, ddphi, ddp, ddp2, dp, sign, d2r, fc, L1; + rvec r_ij, r_kj, r_kl, m, n; + + L1 = 1.0-lambda; + + d2r = DEG2RAD; + k = 0; + + for (i = 0; (i < nbonds); ) + { + type = forceatoms[i++]; + ai = forceatoms[i++]; + aj = forceatoms[i++]; + ak = forceatoms[i++]; + al = forceatoms[i++]; + + phi0A = forceparams[type].dihres.phiA*d2r; + dphiA = forceparams[type].dihres.dphiA*d2r; + kfacA = forceparams[type].dihres.kfacA; + + phi0B = forceparams[type].dihres.phiB*d2r; + dphiB = forceparams[type].dihres.dphiB*d2r; + kfacB = forceparams[type].dihres.kfacB; + + phi0 = L1*phi0A + lambda*phi0B; + dphi = L1*dphiA + lambda*dphiB; + kfac = L1*kfacA + lambda*kfacB; + + phi = dih_angle(x[ai], x[aj], x[ak], x[al], pbc, r_ij, r_kj, r_kl, m, n, + &sign, &t1, &t2, &t3); + /* 84 flops */ + + if (debug) + { + fprintf(debug, "dihres[%d]: %d %d %d %d : phi=%f, dphi=%f, kfac=%f\n", + k++, ai, aj, ak, al, phi0, dphi, kfac); + } + /* phi can jump if phi0 is close to Pi/-Pi, which will cause huge + * force changes if we just apply a normal harmonic. + * Instead, we first calculate phi-phi0 and take it modulo (-Pi,Pi). + * This means we will never have the periodicity problem, unless + * the dihedral is Pi away from phiO, which is very unlikely due to + * the potential. + */ + dp = phi-phi0; + make_dp_periodic(&dp); + + if (dp > dphi) + { + ddp = dp-dphi; + } + else if (dp < -dphi) + { + ddp = dp+dphi; + } + else + { + ddp = 0; + } + + if (ddp != 0.0) + { + ddp2 = ddp*ddp; + vtot += 0.5*kfac*ddp2; + ddphi = kfac*ddp; + + *dvdlambda += 0.5*(kfacB - kfacA)*ddp2; + /* lambda dependence from changing restraint distances */ + if (ddp > 0) + { + *dvdlambda -= kfac*ddp*((dphiB - dphiA)+(phi0B - phi0A)); + } + else if (ddp < 0) + { + *dvdlambda += kfac*ddp*((dphiB - dphiA)-(phi0B - phi0A)); + } + do_dih_fup(ai, aj, ak, al, ddphi, r_ij, r_kj, r_kl, m, n, + f, fshift, pbc, g, x, t1, t2, t3); /* 112 */ + } + } + return vtot; +} + + +real unimplemented(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) +{ + gmx_impl("*** you are using a not implemented function"); + + return 0.0; /* To make the compiler happy */ +} + +real rbdihs(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) +{ + const real c0 = 0.0, c1 = 1.0, c2 = 2.0, c3 = 3.0, c4 = 4.0, c5 = 5.0; + int type, ai, aj, ak, al, i, j; + int t1, t2, t3; + rvec r_ij, r_kj, r_kl, m, n; + real parmA[NR_RBDIHS]; + real parmB[NR_RBDIHS]; + real parm[NR_RBDIHS]; + real cos_phi, phi, rbp, rbpBA; + real v, sign, ddphi, sin_phi; + real cosfac, vtot; + real L1 = 1.0-lambda; + real dvdl_term = 0; + + vtot = 0.0; + for (i = 0; (i < nbonds); ) + { + type = forceatoms[i++]; + ai = forceatoms[i++]; + aj = forceatoms[i++]; + ak = forceatoms[i++]; + al = forceatoms[i++]; + + phi = dih_angle(x[ai], x[aj], x[ak], x[al], pbc, r_ij, r_kj, r_kl, m, n, + &sign, &t1, &t2, &t3); /* 84 */ + + /* Change to polymer convention */ + if (phi < c0) + { + phi += M_PI; + } + else + { + phi -= M_PI; /* 1 */ + + } + cos_phi = cos(phi); + /* Beware of accuracy loss, cannot use 1-sqrt(cos^2) ! */ + sin_phi = sin(phi); + + for (j = 0; (j < NR_RBDIHS); j++) + { + parmA[j] = forceparams[type].rbdihs.rbcA[j]; + parmB[j] = forceparams[type].rbdihs.rbcB[j]; + parm[j] = L1*parmA[j]+lambda*parmB[j]; + } + /* Calculate cosine powers */ + /* Calculate the energy */ + /* Calculate the derivative */ + + v = parm[0]; + dvdl_term += (parmB[0]-parmA[0]); + ddphi = c0; + cosfac = c1; + + rbp = parm[1]; + rbpBA = parmB[1]-parmA[1]; + ddphi += rbp*cosfac; + cosfac *= cos_phi; + v += cosfac*rbp; + dvdl_term += cosfac*rbpBA; + rbp = parm[2]; + rbpBA = parmB[2]-parmA[2]; + ddphi += c2*rbp*cosfac; + cosfac *= cos_phi; + v += cosfac*rbp; + dvdl_term += cosfac*rbpBA; + rbp = parm[3]; + rbpBA = parmB[3]-parmA[3]; + ddphi += c3*rbp*cosfac; + cosfac *= cos_phi; + v += cosfac*rbp; + dvdl_term += cosfac*rbpBA; + rbp = parm[4]; + rbpBA = parmB[4]-parmA[4]; + ddphi += c4*rbp*cosfac; + cosfac *= cos_phi; + v += cosfac*rbp; + dvdl_term += cosfac*rbpBA; + rbp = parm[5]; + rbpBA = parmB[5]-parmA[5]; + ddphi += c5*rbp*cosfac; + cosfac *= cos_phi; + v += cosfac*rbp; + dvdl_term += cosfac*rbpBA; + + ddphi = -ddphi*sin_phi; /* 11 */ + + do_dih_fup(ai, aj, ak, al, ddphi, r_ij, r_kj, r_kl, m, n, + f, fshift, pbc, g, x, t1, t2, t3); /* 112 */ + vtot += v; + } + *dvdlambda += dvdl_term; + + return vtot; +} + +int cmap_setup_grid_index(int ip, int grid_spacing, int *ipm1, int *ipp1, int *ipp2) +{ + int im1, ip1, ip2; + + if (ip < 0) + { + ip = ip + grid_spacing - 1; + } + else if (ip > grid_spacing) + { + ip = ip - grid_spacing - 1; + } + + im1 = ip - 1; + ip1 = ip + 1; + ip2 = ip + 2; + + if (ip == 0) + { + im1 = grid_spacing - 1; + } + else if (ip == grid_spacing-2) + { + ip2 = 0; + } + else if (ip == grid_spacing-1) + { + ip1 = 0; + ip2 = 1; + } + + *ipm1 = im1; + *ipp1 = ip1; + *ipp2 = ip2; + + return ip; + +} + +real cmap_dihs(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const gmx_cmap_t *cmap_grid, + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) +{ + int i, j, k, n, idx; + int ai, aj, ak, al, am; + int a1i, a1j, a1k, a1l, a2i, a2j, a2k, a2l; + int type, cmapA; + int t11, t21, t31, t12, t22, t32; + int iphi1, ip1m1, ip1p1, ip1p2; + int iphi2, ip2m1, ip2p1, ip2p2; + int l1, l2, l3, l4; + int pos1, pos2, pos3, pos4, tmp; + + real ty[4], ty1[4], ty2[4], ty12[4], tc[16], tx[16]; + real phi1, psi1, cos_phi1, sin_phi1, sign1, xphi1; + real phi2, psi2, cos_phi2, sin_phi2, sign2, xphi2; + real dx, xx, tt, tu, e, df1, df2, ddf1, ddf2, ddf12, vtot; + real ra21, rb21, rg21, rg1, rgr1, ra2r1, rb2r1, rabr1; + real ra22, rb22, rg22, rg2, rgr2, ra2r2, rb2r2, rabr2; + real fg1, hg1, fga1, hgb1, gaa1, gbb1; + real fg2, hg2, fga2, hgb2, gaa2, gbb2; + real fac; + + rvec r1_ij, r1_kj, r1_kl, m1, n1; + rvec r2_ij, r2_kj, r2_kl, m2, n2; + rvec f1_i, f1_j, f1_k, f1_l; + rvec f2_i, f2_j, f2_k, f2_l; + rvec a1, b1, a2, b2; + rvec f1, g1, h1, f2, g2, h2; + rvec dtf1, dtg1, dth1, dtf2, dtg2, dth2; + ivec jt1, dt1_ij, dt1_kj, dt1_lj; + ivec jt2, dt2_ij, dt2_kj, dt2_lj; + + const real *cmapd; + + int loop_index[4][4] = { + {0, 4, 8, 12}, + {1, 5, 9, 13}, + {2, 6, 10, 14}, + {3, 7, 11, 15} + }; + + /* Total CMAP energy */ + vtot = 0; + + for (n = 0; n < nbonds; ) + { + /* Five atoms are involved in the two torsions */ + type = forceatoms[n++]; + ai = forceatoms[n++]; + aj = forceatoms[n++]; + ak = forceatoms[n++]; + al = forceatoms[n++]; + am = forceatoms[n++]; + + /* Which CMAP type is this */ + cmapA = forceparams[type].cmap.cmapA; + cmapd = cmap_grid->cmapdata[cmapA].cmap; + + /* First torsion */ + a1i = ai; + a1j = aj; + a1k = ak; + a1l = al; + + phi1 = dih_angle(x[a1i], x[a1j], x[a1k], x[a1l], pbc, r1_ij, r1_kj, r1_kl, m1, n1, + &sign1, &t11, &t21, &t31); /* 84 */ + + cos_phi1 = cos(phi1); + + a1[0] = r1_ij[1]*r1_kj[2]-r1_ij[2]*r1_kj[1]; + a1[1] = r1_ij[2]*r1_kj[0]-r1_ij[0]*r1_kj[2]; + a1[2] = r1_ij[0]*r1_kj[1]-r1_ij[1]*r1_kj[0]; /* 9 */ + + b1[0] = r1_kl[1]*r1_kj[2]-r1_kl[2]*r1_kj[1]; + b1[1] = r1_kl[2]*r1_kj[0]-r1_kl[0]*r1_kj[2]; + b1[2] = r1_kl[0]*r1_kj[1]-r1_kl[1]*r1_kj[0]; /* 9 */ + + tmp = pbc_rvec_sub(pbc, x[a1l], x[a1k], h1); + + ra21 = iprod(a1, a1); /* 5 */ + rb21 = iprod(b1, b1); /* 5 */ + rg21 = iprod(r1_kj, r1_kj); /* 5 */ + rg1 = sqrt(rg21); + + rgr1 = 1.0/rg1; + ra2r1 = 1.0/ra21; + rb2r1 = 1.0/rb21; + rabr1 = sqrt(ra2r1*rb2r1); + + sin_phi1 = rg1 * rabr1 * iprod(a1, h1) * (-1); + + if (cos_phi1 < -0.5 || cos_phi1 > 0.5) + { + phi1 = asin(sin_phi1); + + if (cos_phi1 < 0) + { + if (phi1 > 0) + { + phi1 = M_PI - phi1; + } + else + { + phi1 = -M_PI - phi1; + } + } + } + else + { + phi1 = acos(cos_phi1); + + if (sin_phi1 < 0) + { + phi1 = -phi1; + } + } + + xphi1 = phi1 + M_PI; /* 1 */ + + /* Second torsion */ + a2i = aj; + a2j = ak; + a2k = al; + a2l = am; + + phi2 = dih_angle(x[a2i], x[a2j], x[a2k], x[a2l], pbc, r2_ij, r2_kj, r2_kl, m2, n2, + &sign2, &t12, &t22, &t32); /* 84 */ + + cos_phi2 = cos(phi2); + + a2[0] = r2_ij[1]*r2_kj[2]-r2_ij[2]*r2_kj[1]; + a2[1] = r2_ij[2]*r2_kj[0]-r2_ij[0]*r2_kj[2]; + a2[2] = r2_ij[0]*r2_kj[1]-r2_ij[1]*r2_kj[0]; /* 9 */ + + b2[0] = r2_kl[1]*r2_kj[2]-r2_kl[2]*r2_kj[1]; + b2[1] = r2_kl[2]*r2_kj[0]-r2_kl[0]*r2_kj[2]; + b2[2] = r2_kl[0]*r2_kj[1]-r2_kl[1]*r2_kj[0]; /* 9 */ + + tmp = pbc_rvec_sub(pbc, x[a2l], x[a2k], h2); + + ra22 = iprod(a2, a2); /* 5 */ + rb22 = iprod(b2, b2); /* 5 */ + rg22 = iprod(r2_kj, r2_kj); /* 5 */ + rg2 = sqrt(rg22); + + rgr2 = 1.0/rg2; + ra2r2 = 1.0/ra22; + rb2r2 = 1.0/rb22; + rabr2 = sqrt(ra2r2*rb2r2); + + sin_phi2 = rg2 * rabr2 * iprod(a2, h2) * (-1); + + if (cos_phi2 < -0.5 || cos_phi2 > 0.5) + { + phi2 = asin(sin_phi2); + + if (cos_phi2 < 0) + { + if (phi2 > 0) + { + phi2 = M_PI - phi2; + } + else + { + phi2 = -M_PI - phi2; + } + } + } + else + { + phi2 = acos(cos_phi2); + + if (sin_phi2 < 0) + { + phi2 = -phi2; + } + } + + xphi2 = phi2 + M_PI; /* 1 */ + + /* Range mangling */ + if (xphi1 < 0) + { + xphi1 = xphi1 + 2*M_PI; + } + else if (xphi1 >= 2*M_PI) + { + xphi1 = xphi1 - 2*M_PI; + } + + if (xphi2 < 0) + { + xphi2 = xphi2 + 2*M_PI; + } + else if (xphi2 >= 2*M_PI) + { + xphi2 = xphi2 - 2*M_PI; + } + + /* Number of grid points */ + dx = 2*M_PI / cmap_grid->grid_spacing; + + /* Where on the grid are we */ + iphi1 = (int)(xphi1/dx); + iphi2 = (int)(xphi2/dx); + + iphi1 = cmap_setup_grid_index(iphi1, cmap_grid->grid_spacing, &ip1m1, &ip1p1, &ip1p2); + iphi2 = cmap_setup_grid_index(iphi2, cmap_grid->grid_spacing, &ip2m1, &ip2p1, &ip2p2); + + pos1 = iphi1*cmap_grid->grid_spacing+iphi2; + pos2 = ip1p1*cmap_grid->grid_spacing+iphi2; + pos3 = ip1p1*cmap_grid->grid_spacing+ip2p1; + pos4 = iphi1*cmap_grid->grid_spacing+ip2p1; + + ty[0] = cmapd[pos1*4]; + ty[1] = cmapd[pos2*4]; + ty[2] = cmapd[pos3*4]; + ty[3] = cmapd[pos4*4]; + + ty1[0] = cmapd[pos1*4+1]; + ty1[1] = cmapd[pos2*4+1]; + ty1[2] = cmapd[pos3*4+1]; + ty1[3] = cmapd[pos4*4+1]; + + ty2[0] = cmapd[pos1*4+2]; + ty2[1] = cmapd[pos2*4+2]; + ty2[2] = cmapd[pos3*4+2]; + ty2[3] = cmapd[pos4*4+2]; + + ty12[0] = cmapd[pos1*4+3]; + ty12[1] = cmapd[pos2*4+3]; + ty12[2] = cmapd[pos3*4+3]; + ty12[3] = cmapd[pos4*4+3]; + + /* Switch to degrees */ + dx = 360.0 / cmap_grid->grid_spacing; + xphi1 = xphi1 * RAD2DEG; + xphi2 = xphi2 * RAD2DEG; + + for (i = 0; i < 4; i++) /* 16 */ + { + tx[i] = ty[i]; + tx[i+4] = ty1[i]*dx; + tx[i+8] = ty2[i]*dx; + tx[i+12] = ty12[i]*dx*dx; + } + + idx = 0; + for (i = 0; i < 4; i++) /* 1056 */ + { + for (j = 0; j < 4; j++) + { + xx = 0; + for (k = 0; k < 16; k++) + { + xx = xx + cmap_coeff_matrix[k*16+idx]*tx[k]; + } + + idx++; + tc[i*4+j] = xx; + } + } + + tt = (xphi1-iphi1*dx)/dx; + tu = (xphi2-iphi2*dx)/dx; + + e = 0; + df1 = 0; + df2 = 0; + ddf1 = 0; + ddf2 = 0; + ddf12 = 0; + + for (i = 3; i >= 0; i--) + { + l1 = loop_index[i][3]; + l2 = loop_index[i][2]; + l3 = loop_index[i][1]; + + e = tt * e + ((tc[i*4+3]*tu+tc[i*4+2])*tu + tc[i*4+1])*tu+tc[i*4]; + df1 = tu * df1 + (3.0*tc[l1]*tt+2.0*tc[l2])*tt+tc[l3]; + df2 = tt * df2 + (3.0*tc[i*4+3]*tu+2.0*tc[i*4+2])*tu+tc[i*4+1]; + ddf1 = tu * ddf1 + 2.0*3.0*tc[l1]*tt+2.0*tc[l2]; + ddf2 = tt * ddf2 + 2.0*3.0*tc[4*i+3]*tu+2.0*tc[4*i+2]; + } + + ddf12 = tc[5] + 2.0*tc[9]*tt + 3.0*tc[13]*tt*tt + 2.0*tu*(tc[6]+2.0*tc[10]*tt+3.0*tc[14]*tt*tt) + + 3.0*tu*tu*(tc[7]+2.0*tc[11]*tt+3.0*tc[15]*tt*tt); + + fac = RAD2DEG/dx; + df1 = df1 * fac; + df2 = df2 * fac; + ddf1 = ddf1 * fac * fac; + ddf2 = ddf2 * fac * fac; + ddf12 = ddf12 * fac * fac; + + /* CMAP energy */ + vtot += e; + + /* Do forces - first torsion */ + fg1 = iprod(r1_ij, r1_kj); + hg1 = iprod(r1_kl, r1_kj); + fga1 = fg1*ra2r1*rgr1; + hgb1 = hg1*rb2r1*rgr1; + gaa1 = -ra2r1*rg1; + gbb1 = rb2r1*rg1; + + for (i = 0; i < DIM; i++) + { + dtf1[i] = gaa1 * a1[i]; + dtg1[i] = fga1 * a1[i] - hgb1 * b1[i]; + dth1[i] = gbb1 * b1[i]; + + f1[i] = df1 * dtf1[i]; + g1[i] = df1 * dtg1[i]; + h1[i] = df1 * dth1[i]; + + f1_i[i] = f1[i]; + f1_j[i] = -f1[i] - g1[i]; + f1_k[i] = h1[i] + g1[i]; + f1_l[i] = -h1[i]; + + f[a1i][i] = f[a1i][i] + f1_i[i]; + f[a1j][i] = f[a1j][i] + f1_j[i]; /* - f1[i] - g1[i] */ + f[a1k][i] = f[a1k][i] + f1_k[i]; /* h1[i] + g1[i] */ + f[a1l][i] = f[a1l][i] + f1_l[i]; /* h1[i] */ + } + + /* Do forces - second torsion */ + fg2 = iprod(r2_ij, r2_kj); + hg2 = iprod(r2_kl, r2_kj); + fga2 = fg2*ra2r2*rgr2; + hgb2 = hg2*rb2r2*rgr2; + gaa2 = -ra2r2*rg2; + gbb2 = rb2r2*rg2; + + for (i = 0; i < DIM; i++) + { + dtf2[i] = gaa2 * a2[i]; + dtg2[i] = fga2 * a2[i] - hgb2 * b2[i]; + dth2[i] = gbb2 * b2[i]; + + f2[i] = df2 * dtf2[i]; + g2[i] = df2 * dtg2[i]; + h2[i] = df2 * dth2[i]; + + f2_i[i] = f2[i]; + f2_j[i] = -f2[i] - g2[i]; + f2_k[i] = h2[i] + g2[i]; + f2_l[i] = -h2[i]; + + f[a2i][i] = f[a2i][i] + f2_i[i]; /* f2[i] */ + f[a2j][i] = f[a2j][i] + f2_j[i]; /* - f2[i] - g2[i] */ + f[a2k][i] = f[a2k][i] + f2_k[i]; /* h2[i] + g2[i] */ + f[a2l][i] = f[a2l][i] + f2_l[i]; /* - h2[i] */ + } + + /* Shift forces */ + if (g) + { + copy_ivec(SHIFT_IVEC(g, a1j), jt1); + ivec_sub(SHIFT_IVEC(g, a1i), jt1, dt1_ij); + ivec_sub(SHIFT_IVEC(g, a1k), jt1, dt1_kj); + ivec_sub(SHIFT_IVEC(g, a1l), jt1, dt1_lj); + t11 = IVEC2IS(dt1_ij); + t21 = IVEC2IS(dt1_kj); + t31 = IVEC2IS(dt1_lj); + + copy_ivec(SHIFT_IVEC(g, a2j), jt2); + ivec_sub(SHIFT_IVEC(g, a2i), jt2, dt2_ij); + ivec_sub(SHIFT_IVEC(g, a2k), jt2, dt2_kj); + ivec_sub(SHIFT_IVEC(g, a2l), jt2, dt2_lj); + t12 = IVEC2IS(dt2_ij); + t22 = IVEC2IS(dt2_kj); + t32 = IVEC2IS(dt2_lj); + } + else if (pbc) + { + t31 = pbc_rvec_sub(pbc, x[a1l], x[a1j], h1); + t32 = pbc_rvec_sub(pbc, x[a2l], x[a2j], h2); + } + else + { + t31 = CENTRAL; + t32 = CENTRAL; + } + + rvec_inc(fshift[t11], f1_i); + rvec_inc(fshift[CENTRAL], f1_j); + rvec_inc(fshift[t21], f1_k); + rvec_inc(fshift[t31], f1_l); + + rvec_inc(fshift[t21], f2_i); + rvec_inc(fshift[CENTRAL], f2_j); + rvec_inc(fshift[t22], f2_k); + rvec_inc(fshift[t32], f2_l); + } + return vtot; +} + + + +/*********************************************************** + * + * G R O M O S 9 6 F U N C T I O N S + * + ***********************************************************/ +real g96harmonic(real kA, real kB, real xA, real xB, real x, real lambda, + real *V, real *F) +{ + const real half = 0.5; + real L1, kk, x0, dx, dx2; + real v, f, dvdlambda; + + L1 = 1.0-lambda; + kk = L1*kA+lambda*kB; + x0 = L1*xA+lambda*xB; + + dx = x-x0; + dx2 = dx*dx; + + f = -kk*dx; + v = half*kk*dx2; + dvdlambda = half*(kB-kA)*dx2 + (xA-xB)*kk*dx; + + *F = f; + *V = v; + + return dvdlambda; + + /* That was 21 flops */ +} + +real g96bonds(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) +{ + int i, m, ki, ai, aj, type; + real dr2, fbond, vbond, fij, vtot; + rvec dx; + ivec dt; vtot = 0.0; - for(i=0; (iposres.fcA[m] + lambda*pr->posres.fcB[m]; - fm = -kk*dx[m]; - 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]; + ki = pbc_rvec_sub(pbc, x[ai], x[aj], dx); /* 3 */ + dr2 = iprod(dx, dx); /* 5 */ - /* Here we correct for the pbc_dx which included rdist */ - if (bForceValid) { - f[ai][m] += fm; - vir_diag[m] -= 0.5*(dx[m] + rdist[m])*fm; - } + *dvdlambda += g96harmonic(forceparams[type].harmonic.krA, + forceparams[type].harmonic.krB, + forceparams[type].harmonic.rA, + forceparams[type].harmonic.rB, + dr2, lambda, &vbond, &fbond); + + vtot += 0.5*vbond; /* 1*/ +#ifdef DEBUG + if (debug) + { + fprintf(debug, "G96-BONDS: dr = %10g vbond = %10g fbond = %10g\n", + sqrt(dr2), vbond, fbond); } - } +#endif + if (g) + { + ivec_sub(SHIFT_IVEC(g, ai), SHIFT_IVEC(g, aj), dt); + ki = IVEC2IS(dt); + } + for (m = 0; (m < DIM); m++) /* 15 */ + { + fij = fbond*dx[m]; + f[ai][m] += fij; + f[aj][m] -= fij; + fshift[ki][m] += fij; + fshift[CENTRAL][m] -= fij; + } + } /* 44 TOTAL */ return vtot; } -static real low_angres(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - gmx_bool bZAxis) +real g96bond_angle(const rvec xi, const rvec xj, const rvec xk, const t_pbc *pbc, + rvec r_ij, rvec r_kj, + int *t1, int *t2) +/* Return value is the angle between the bonds i-j and j-k */ { - int i,m,type,ai,aj,ak,al; - int t1,t2; - real phi,cos_phi,cos_phi2,vid,vtot,dVdphi; - rvec r_ij,r_kl,f_i,f_k={0,0,0}; - real st,sth,nrij2,nrkl2,c,cij,ckl; - - ivec dt; - t2 = 0; /* avoid warning with gcc-3.3. It is never used uninitialized */ - - vtot = 0.0; - ak=al=0; /* to avoid warnings */ - for(i=0; i dphi) + /* Virial stuff */ + if (g) { - ddp = dp-dphi; + copy_ivec(SHIFT_IVEC(g, aj), jt); + + ivec_sub(SHIFT_IVEC(g, ai), jt, dt_ij); + ivec_sub(SHIFT_IVEC(g, ak), jt, dt_kj); + t1 = IVEC2IS(dt_ij); + t2 = IVEC2IS(dt_kj); } - else if (dp < -dphi) + rvec_inc(fshift[t1], f_i); + rvec_inc(fshift[CENTRAL], f_j); + rvec_inc(fshift[t2], f_k); /* 9 */ + /* 163 TOTAL */ + } + return vtot; +} + +real cross_bond_angle(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) +{ + /* Potential from Lawrence and Skimmer, Chem. Phys. Lett. 372 (2003) + * pp. 842-847 + */ + int i, ai, aj, ak, type, m, t1, t2, t3; + rvec r_ij, r_kj, r_ik; + real vtot, vrt, s1, s2, s3, r1, r2, r3, r1e, r2e, r3e, krt, k1, k2, k3; + rvec f_i, f_j, f_k; + ivec jt, dt_ij, dt_kj; + + vtot = 0.0; + for (i = 0; (i < nbonds); ) + { + type = forceatoms[i++]; + ai = forceatoms[i++]; + aj = forceatoms[i++]; + ak = forceatoms[i++]; + r1e = forceparams[type].cross_ba.r1e; + r2e = forceparams[type].cross_ba.r2e; + r3e = forceparams[type].cross_ba.r3e; + krt = forceparams[type].cross_ba.krt; + + /* Compute distance vectors ... */ + t1 = pbc_rvec_sub(pbc, x[ai], x[aj], r_ij); + t2 = pbc_rvec_sub(pbc, x[ak], x[aj], r_kj); + t3 = pbc_rvec_sub(pbc, x[ai], x[ak], r_ik); + + /* ... and their lengths */ + r1 = norm(r_ij); + r2 = norm(r_kj); + r3 = norm(r_ik); + + /* Deviations from ideality */ + s1 = r1-r1e; + s2 = r2-r2e; + s3 = r3-r3e; + + /* Energy (can be negative!) */ + vrt = krt*s3*(s1+s2); + vtot += vrt; + + /* Forces */ + k1 = -krt*(s3/r1); + k2 = -krt*(s3/r2); + k3 = -krt*(s1+s2)/r3; + for (m = 0; (m < DIM); m++) { - ddp = dp+dphi; + f_i[m] = k1*r_ij[m] + k3*r_ik[m]; + f_k[m] = k2*r_kj[m] - k3*r_ik[m]; + f_j[m] = -f_i[m] - f_k[m]; } - else + + for (m = 0; (m < DIM); m++) /* 12 */ { - ddp = 0; + f[ai][m] += f_i[m]; + f[aj][m] += f_j[m]; + f[ak][m] += f_k[m]; } - if (ddp != 0.0) + /* Virial stuff */ + if (g) { - ddp2 = ddp*ddp; - vtot += 0.5*kfac*ddp2; - ddphi = kfac*ddp; + copy_ivec(SHIFT_IVEC(g, aj), jt); - *dvdlambda += 0.5*(kfacB - kfacA)*ddp2; - /* lambda dependence from changing restraint distances */ - if (ddp > 0) - { - *dvdlambda -= kfac*ddp*((dphiB - dphiA)+(phi0B - phi0A)); - } - else if (ddp < 0) - { - *dvdlambda += kfac*ddp*((dphiB - dphiA)-(phi0B - phi0A)); - } - do_dih_fup(ai,aj,ak,al,ddphi,r_ij,r_kj,r_kl,m,n, - f,fshift,pbc,g,x,t1,t2,t3); /* 112 */ + ivec_sub(SHIFT_IVEC(g, ai), jt, dt_ij); + ivec_sub(SHIFT_IVEC(g, ak), jt, dt_kj); + t1 = IVEC2IS(dt_ij); + t2 = IVEC2IS(dt_kj); } + rvec_inc(fshift[t1], f_i); + rvec_inc(fshift[CENTRAL], f_j); + rvec_inc(fshift[t2], f_k); /* 9 */ + /* 163 TOTAL */ } return vtot; } - -real unimplemented(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) +static real bonded_tab(const char *type, int table_nr, + const bondedtable_t *table, real kA, real kB, real r, + real lambda, real *V, real *F) { - gmx_impl("*** you are using a not implemented function"); + real k, tabscale, *VFtab, rt, eps, eps2, Yt, Ft, Geps, Heps2, Fp, VV, FF; + int n0, nnn; + real v, f, dvdlambda; - return 0.0; /* To make the compiler happy */ -} + k = (1.0 - lambda)*kA + lambda*kB; -real rbdihs(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) -{ - const real c0=0.0,c1=1.0,c2=2.0,c3=3.0,c4=4.0,c5=5.0; - int type,ai,aj,ak,al,i,j; - int t1,t2,t3; - rvec r_ij,r_kj,r_kl,m,n; - real parmA[NR_RBDIHS]; - real parmB[NR_RBDIHS]; - real parm[NR_RBDIHS]; - real cos_phi,phi,rbp,rbpBA; - real v,sign,ddphi,sin_phi; - real cosfac,vtot; - real L1 = 1.0-lambda; - real dvdl_term=0; - - vtot = 0.0; - for(i=0; (iscale; + VFtab = table->data; -int cmap_setup_grid_index(int ip, int grid_spacing, int *ipm1, int *ipp1, int *ipp2) -{ - int im1, ip1, ip2; - - if(ip<0) - { - ip = ip + grid_spacing - 1; - } - else if(ip > grid_spacing) - { - ip = ip - grid_spacing - 1; - } - - im1 = ip - 1; - ip1 = ip + 1; - ip2 = ip + 2; - - if(ip == 0) - { - im1 = grid_spacing - 1; - } - else if(ip == grid_spacing-2) - { - ip2 = 0; - } - else if(ip == grid_spacing-1) - { - ip1 = 0; - ip2 = 1; - } - - *ipm1 = im1; - *ipp1 = ip1; - *ipp2 = ip2; - - return ip; - + rt = r*tabscale; + n0 = rt; + if (n0 >= table->n) + { + gmx_fatal(FARGS, "A tabulated %s interaction table number %d is out of the table range: r %f, between table indices %d and %d, table length %d", + type, table_nr, r, n0, n0+1, table->n); + } + eps = rt - n0; + eps2 = eps*eps; + nnn = 4*n0; + Yt = VFtab[nnn]; + Ft = VFtab[nnn+1]; + Geps = VFtab[nnn+2]*eps; + Heps2 = VFtab[nnn+3]*eps2; + Fp = Ft + Geps + Heps2; + VV = Yt + Fp*eps; + FF = Fp + Geps + 2.0*Heps2; + + *F = -k*FF*tabscale; + *V = k*VV; + dvdlambda = (kB - kA)*VV; + + return dvdlambda; + + /* That was 22 flops */ } -real cmap_dihs(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const gmx_cmap_t *cmap_grid, - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) +real tab_bonds(int nbonds, + const t_iatom forceatoms[], const t_iparams forceparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, + int *global_atom_index) { - int i,j,k,n,idx; - int ai,aj,ak,al,am; - int a1i,a1j,a1k,a1l,a2i,a2j,a2k,a2l; - int type,cmapA; - int t11,t21,t31,t12,t22,t32; - int iphi1,ip1m1,ip1p1,ip1p2; - int iphi2,ip2m1,ip2p1,ip2p2; - int l1,l2,l3,l4; - int pos1,pos2,pos3,pos4,tmp; - - real ty[4],ty1[4],ty2[4],ty12[4],tc[16],tx[16]; - real phi1,psi1,cos_phi1,sin_phi1,sign1,xphi1; - real phi2,psi2,cos_phi2,sin_phi2,sign2,xphi2; - real dx,xx,tt,tu,e,df1,df2,ddf1,ddf2,ddf12,vtot; - real ra21,rb21,rg21,rg1,rgr1,ra2r1,rb2r1,rabr1; - real ra22,rb22,rg22,rg2,rgr2,ra2r2,rb2r2,rabr2; - real fg1,hg1,fga1,hgb1,gaa1,gbb1; - real fg2,hg2,fga2,hgb2,gaa2,gbb2; - real fac; - - rvec r1_ij, r1_kj, r1_kl,m1,n1; - rvec r2_ij, r2_kj, r2_kl,m2,n2; - rvec f1_i,f1_j,f1_k,f1_l; - rvec f2_i,f2_j,f2_k,f2_l; - rvec a1,b1,a2,b2; - rvec f1,g1,h1,f2,g2,h2; - rvec dtf1,dtg1,dth1,dtf2,dtg2,dth2; - ivec jt1,dt1_ij,dt1_kj,dt1_lj; - ivec jt2,dt2_ij,dt2_kj,dt2_lj; - - const real *cmapd; + int i, m, ki, ai, aj, type, table; + real dr, dr2, fbond, vbond, fij, vtot; + rvec dx; + ivec dt; - int loop_index[4][4] = { - {0,4,8,12}, - {1,5,9,13}, - {2,6,10,14}, - {3,7,11,15} - }; - - /* Total CMAP energy */ - vtot = 0; - - for(n=0;ncmapdata[cmapA].cmap; + vtot = 0.0; + for (i = 0; (i < nbonds); ) + { + type = forceatoms[i++]; + ai = forceatoms[i++]; + aj = forceatoms[i++]; - /* First torsion */ - a1i = ai; - a1j = aj; - a1k = ak; - a1l = al; - - phi1 = dih_angle(x[a1i], x[a1j], x[a1k], x[a1l], pbc, r1_ij, r1_kj, r1_kl, m1, n1, - &sign1, &t11, &t21, &t31); /* 84 */ - - cos_phi1 = cos(phi1); - - a1[0] = r1_ij[1]*r1_kj[2]-r1_ij[2]*r1_kj[1]; - a1[1] = r1_ij[2]*r1_kj[0]-r1_ij[0]*r1_kj[2]; - a1[2] = r1_ij[0]*r1_kj[1]-r1_ij[1]*r1_kj[0]; /* 9 */ - - b1[0] = r1_kl[1]*r1_kj[2]-r1_kl[2]*r1_kj[1]; - b1[1] = r1_kl[2]*r1_kj[0]-r1_kl[0]*r1_kj[2]; - b1[2] = r1_kl[0]*r1_kj[1]-r1_kl[1]*r1_kj[0]; /* 9 */ - - tmp = pbc_rvec_sub(pbc,x[a1l],x[a1k],h1); - - ra21 = iprod(a1,a1); /* 5 */ - rb21 = iprod(b1,b1); /* 5 */ - rg21 = iprod(r1_kj,r1_kj); /* 5 */ - rg1 = sqrt(rg21); - - rgr1 = 1.0/rg1; - ra2r1 = 1.0/ra21; - rb2r1 = 1.0/rb21; - rabr1 = sqrt(ra2r1*rb2r1); - - sin_phi1 = rg1 * rabr1 * iprod(a1,h1) * (-1); - - if(cos_phi1 < -0.5 || cos_phi1 > 0.5) - { - phi1 = asin(sin_phi1); - - if(cos_phi1 < 0) - { - if(phi1 > 0) - { - phi1 = M_PI - phi1; - } - else - { - phi1 = -M_PI - phi1; - } - } - } - else - { - phi1 = acos(cos_phi1); - - if(sin_phi1 < 0) - { - phi1 = -phi1; - } - } - - xphi1 = phi1 + M_PI; /* 1 */ - - /* Second torsion */ - a2i = aj; - a2j = ak; - a2k = al; - a2l = am; - - phi2 = dih_angle(x[a2i], x[a2j], x[a2k], x[a2l], pbc, r2_ij, r2_kj, r2_kl, m2, n2, - &sign2, &t12, &t22, &t32); /* 84 */ - - cos_phi2 = cos(phi2); + ki = pbc_rvec_sub(pbc, x[ai], x[aj], dx); /* 3 */ + dr2 = iprod(dx, dx); /* 5 */ + dr = dr2*gmx_invsqrt(dr2); /* 10 */ - a2[0] = r2_ij[1]*r2_kj[2]-r2_ij[2]*r2_kj[1]; - a2[1] = r2_ij[2]*r2_kj[0]-r2_ij[0]*r2_kj[2]; - a2[2] = r2_ij[0]*r2_kj[1]-r2_ij[1]*r2_kj[0]; /* 9 */ - - b2[0] = r2_kl[1]*r2_kj[2]-r2_kl[2]*r2_kj[1]; - b2[1] = r2_kl[2]*r2_kj[0]-r2_kl[0]*r2_kj[2]; - b2[2] = r2_kl[0]*r2_kj[1]-r2_kl[1]*r2_kj[0]; /* 9 */ - - tmp = pbc_rvec_sub(pbc,x[a2l],x[a2k],h2); - - ra22 = iprod(a2,a2); /* 5 */ - rb22 = iprod(b2,b2); /* 5 */ - rg22 = iprod(r2_kj,r2_kj); /* 5 */ - rg2 = sqrt(rg22); - - rgr2 = 1.0/rg2; - ra2r2 = 1.0/ra22; - rb2r2 = 1.0/rb22; - rabr2 = sqrt(ra2r2*rb2r2); - - sin_phi2 = rg2 * rabr2 * iprod(a2,h2) * (-1); - - if(cos_phi2 < -0.5 || cos_phi2 > 0.5) - { - phi2 = asin(sin_phi2); - - if(cos_phi2 < 0) - { - if(phi2 > 0) - { - phi2 = M_PI - phi2; - } - else - { - phi2 = -M_PI - phi2; - } - } - } - else - { - phi2 = acos(cos_phi2); - - if(sin_phi2 < 0) - { - phi2 = -phi2; - } - } - - xphi2 = phi2 + M_PI; /* 1 */ - - /* Range mangling */ - if(xphi1<0) - { - xphi1 = xphi1 + 2*M_PI; - } - else if(xphi1>=2*M_PI) - { - xphi1 = xphi1 - 2*M_PI; - } - - if(xphi2<0) - { - xphi2 = xphi2 + 2*M_PI; - } - else if(xphi2>=2*M_PI) - { - xphi2 = xphi2 - 2*M_PI; - } - - /* Number of grid points */ - dx = 2*M_PI / cmap_grid->grid_spacing; - - /* Where on the grid are we */ - iphi1 = (int)(xphi1/dx); - iphi2 = (int)(xphi2/dx); - - iphi1 = cmap_setup_grid_index(iphi1, cmap_grid->grid_spacing, &ip1m1,&ip1p1,&ip1p2); - iphi2 = cmap_setup_grid_index(iphi2, cmap_grid->grid_spacing, &ip2m1,&ip2p1,&ip2p2); - - pos1 = iphi1*cmap_grid->grid_spacing+iphi2; - pos2 = ip1p1*cmap_grid->grid_spacing+iphi2; - pos3 = ip1p1*cmap_grid->grid_spacing+ip2p1; - pos4 = iphi1*cmap_grid->grid_spacing+ip2p1; - - ty[0] = cmapd[pos1*4]; - ty[1] = cmapd[pos2*4]; - ty[2] = cmapd[pos3*4]; - ty[3] = cmapd[pos4*4]; - - ty1[0] = cmapd[pos1*4+1]; - ty1[1] = cmapd[pos2*4+1]; - ty1[2] = cmapd[pos3*4+1]; - ty1[3] = cmapd[pos4*4+1]; - - ty2[0] = cmapd[pos1*4+2]; - ty2[1] = cmapd[pos2*4+2]; - ty2[2] = cmapd[pos3*4+2]; - ty2[3] = cmapd[pos4*4+2]; - - ty12[0] = cmapd[pos1*4+3]; - ty12[1] = cmapd[pos2*4+3]; - ty12[2] = cmapd[pos3*4+3]; - ty12[3] = cmapd[pos4*4+3]; - - /* Switch to degrees */ - dx = 360.0 / cmap_grid->grid_spacing; - xphi1 = xphi1 * RAD2DEG; - xphi2 = xphi2 * RAD2DEG; - - for(i=0;i<4;i++) /* 16 */ - { - tx[i] = ty[i]; - tx[i+4] = ty1[i]*dx; - tx[i+8] = ty2[i]*dx; - tx[i+12] = ty12[i]*dx*dx; - } - - idx=0; - for(i=0;i<4;i++) /* 1056 */ - { - for(j=0;j<4;j++) - { - xx = 0; - for(k=0;k<16;k++) - { - xx = xx + cmap_coeff_matrix[k*16+idx]*tx[k]; - } - - idx++; - tc[i*4+j]=xx; - } - } - - tt = (xphi1-iphi1*dx)/dx; - tu = (xphi2-iphi2*dx)/dx; - - e = 0; - df1 = 0; - df2 = 0; - ddf1 = 0; - ddf2 = 0; - ddf12 = 0; - - for(i=3;i>=0;i--) - { - l1 = loop_index[i][3]; - l2 = loop_index[i][2]; - l3 = loop_index[i][1]; - - e = tt * e + ((tc[i*4+3]*tu+tc[i*4+2])*tu + tc[i*4+1])*tu+tc[i*4]; - df1 = tu * df1 + (3.0*tc[l1]*tt+2.0*tc[l2])*tt+tc[l3]; - df2 = tt * df2 + (3.0*tc[i*4+3]*tu+2.0*tc[i*4+2])*tu+tc[i*4+1]; - ddf1 = tu * ddf1 + 2.0*3.0*tc[l1]*tt+2.0*tc[l2]; - ddf2 = tt * ddf2 + 2.0*3.0*tc[4*i+3]*tu+2.0*tc[4*i+2]; - } - - ddf12 = tc[5] + 2.0*tc[9]*tt + 3.0*tc[13]*tt*tt + 2.0*tu*(tc[6]+2.0*tc[10]*tt+3.0*tc[14]*tt*tt) + - 3.0*tu*tu*(tc[7]+2.0*tc[11]*tt+3.0*tc[15]*tt*tt); - - fac = RAD2DEG/dx; - df1 = df1 * fac; - df2 = df2 * fac; - ddf1 = ddf1 * fac * fac; - ddf2 = ddf2 * fac * fac; - ddf12 = ddf12 * fac * fac; - - /* CMAP energy */ - vtot += e; - - /* Do forces - first torsion */ - fg1 = iprod(r1_ij,r1_kj); - hg1 = iprod(r1_kl,r1_kj); - fga1 = fg1*ra2r1*rgr1; - hgb1 = hg1*rb2r1*rgr1; - gaa1 = -ra2r1*rg1; - gbb1 = rb2r1*rg1; - - for(i=0;ibondtab[table], + forceparams[type].tab.kA, + forceparams[type].tab.kB, + dr, lambda, &vbond, &fbond); /* 22 */ + if (dr2 == 0.0) + { + continue; + } -/*********************************************************** - * - * G R O M O S 9 6 F U N C T I O N S - * - ***********************************************************/ -real g96harmonic(real kA,real kB,real xA,real xB,real x,real lambda, - real *V,real *F) -{ - const real half=0.5; - real L1,kk,x0,dx,dx2; - real v,f,dvdlambda; - - L1 = 1.0-lambda; - kk = L1*kA+lambda*kB; - x0 = L1*xA+lambda*xB; - - dx = x-x0; - dx2 = dx*dx; - - f = -kk*dx; - v = half*kk*dx2; - dvdlambda = half*(kB-kA)*dx2 + (xA-xB)*kk*dx; - - *F = f; - *V = v; - - return dvdlambda; - - /* That was 21 flops */ -} -real g96bonds(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) -{ - int i,m,ki,ai,aj,type; - real dr2,fbond,vbond,fij,vtot; - rvec dx; - ivec dt; - - vtot = 0.0; - for(i=0; (iscale; - VFtab = table->data; - - rt = r*tabscale; - n0 = rt; - if (n0 >= table->n) { - gmx_fatal(FARGS,"A tabulated %s interaction table number %d is out of the table range: r %f, between table indices %d and %d, table length %d", - type,table_nr,r,n0,n0+1,table->n); - } - eps = rt - n0; - eps2 = eps*eps; - nnn = 4*n0; - Yt = VFtab[nnn]; - Ft = VFtab[nnn+1]; - Geps = VFtab[nnn+2]*eps; - Heps2 = VFtab[nnn+3]*eps2; - Fp = Ft + Geps + Heps2; - VV = Yt + Fp*eps; - FF = Fp + Geps + 2.0*Heps2; - - *F = -k*FF*tabscale; - *V = k*VV; - dvdlambda = (kB - kA)*VV; - - return dvdlambda; - - /* That was 22 flops */ -} + *dvdlambda += bonded_tab("angle", table, + &fcd->angletab[table], + forceparams[type].tab.kA, + forceparams[type].tab.kB, + theta, lambda, &va, &dVdt); /* 22 */ + vtot += va; -real tab_bonds(int nbonds, - const t_iatom forceatoms[],const t_iparams forceparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, - int *global_atom_index) -{ - int i,m,ki,ai,aj,type,table; - real dr,dr2,fbond,vbond,fij,vtot; - rvec dx; - ivec dt; - - vtot = 0.0; - for(i=0; (ibondtab[table], - forceparams[type].tab.kA, - forceparams[type].tab.kB, - dr,lambda,&vbond,&fbond); /* 22 */ - - if (dr2 == 0.0) - continue; - - - vtot += vbond;/* 1*/ - fbond *= gmx_invsqrt(dr2); /* 6 */ -#ifdef DEBUG - if (debug) - fprintf(debug,"TABBONDS: dr = %10g vbond = %10g fbond = %10g\n", - dr,vbond,fbond); -#endif - if (g) { - ivec_sub(SHIFT_IVEC(g,ai),SHIFT_IVEC(g,aj),dt); - ki=IVEC2IS(dt); - } - for (m=0; (mangletab[table], - forceparams[type].tab.kA, - forceparams[type].tab.kB, - theta,lambda,&va,&dVdt); /* 22 */ - vtot += va; - - cos_theta2 = sqr(cos_theta); /* 1 */ - if (cos_theta2 < 1) { - int m; - real snt,st,sth; - real cik,cii,ckk; - real nrkj2,nrij2; - rvec f_i,f_j,f_k; - - st = dVdt*gmx_invsqrt(1 - cos_theta2); /* 12 */ - sth = st*cos_theta; /* 1 */ + st = dVdt*gmx_invsqrt(1 - cos_theta2); /* 12 */ + sth = st*cos_theta; /* 1 */ #ifdef DEBUG - if (debug) - fprintf(debug,"ANGLES: theta = %10g vth = %10g dV/dtheta = %10g\n", - theta*RAD2DEG,va,dVdt); + if (debug) + { + fprintf(debug, "ANGLES: theta = %10g vth = %10g dV/dtheta = %10g\n", + theta*RAD2DEG, va, dVdt); + } #endif - nrkj2=iprod(r_kj,r_kj); /* 5 */ - nrij2=iprod(r_ij,r_ij); - - cik=st*gmx_invsqrt(nrkj2*nrij2); /* 12 */ - cii=sth/nrij2; /* 10 */ - ckk=sth/nrkj2; /* 10 */ - - for (m=0; (mdihtab[table], - forceparams[type].tab.kA, - forceparams[type].tab.kB, - phi+M_PI,lambda,&vpd,&ddphi); - - vtot += vpd; - do_dih_fup(ai,aj,ak,al,-ddphi,r_ij,r_kj,r_kl,m,n, - f,fshift,pbc,g,x,t1,t2,t3); /* 112 */ + int i, type, ai, aj, ak, al, table; + int t1, t2, t3; + rvec r_ij, r_kj, r_kl, m, n; + real phi, sign, ddphi, vpd, vtot; + + vtot = 0.0; + for (i = 0; (i < nbonds); ) + { + type = forceatoms[i++]; + ai = forceatoms[i++]; + aj = forceatoms[i++]; + ak = forceatoms[i++]; + al = forceatoms[i++]; + + phi = dih_angle(x[ai], x[aj], x[ak], x[al], pbc, r_ij, r_kj, r_kl, m, n, + &sign, &t1, &t2, &t3); /* 84 */ + + table = forceparams[type].tab.table; + + /* Hopefully phi+M_PI never results in values < 0 */ + *dvdlambda += bonded_tab("dihedral", table, + &fcd->dihtab[table], + forceparams[type].tab.kA, + forceparams[type].tab.kB, + phi+M_PI, lambda, &vpd, &ddphi); + + vtot += vpd; + do_dih_fup(ai, aj, ak, al, -ddphi, r_ij, r_kj, r_kl, m, n, + f, fshift, pbc, g, x, t1, t2, t3); /* 112 */ #ifdef DEBUG - fprintf(debug,"pdih: (%d,%d,%d,%d) phi=%g\n", - ai,aj,ak,al,phi); + fprintf(debug, "pdih: (%d,%d,%d,%d) phi=%g\n", + ai, aj, ak, al, phi); #endif - } /* 227 TOTAL */ + } /* 227 TOTAL */ - return vtot; + return vtot; } static unsigned calc_bonded_reduction_mask(const t_idef *idef, int shift, - int t,int nt) + int t, int nt) { unsigned mask; - int ftype,nb,nat1,nb0,nb1,i,a; + int ftype, nb, nat1, nb0, nb1, i, a; mask = 0; - for(ftype=0; ftypeil[ftype].iatoms[i+a]>>shift)); } @@ -3413,12 +3560,12 @@ calc_bonded_reduction_mask(const t_idef *idef, return mask; } -void init_bonded_thread_force_reduction(t_forcerec *fr, +void init_bonded_thread_force_reduction(t_forcerec *fr, const t_idef *idef) { #define MAX_BLOCK_BITS 32 int t; - int ctot,c,b; + int ctot, c, b; if (fr->nthreads <= 1) { @@ -3437,7 +3584,7 @@ void init_bonded_thread_force_reduction(t_forcerec *fr, } if (debug) { - fprintf(debug,"bonded force buffer block atom shift %d bits\n", + fprintf(debug, "bonded force buffer block atom shift %d bits\n", fr->red_ashift); } @@ -3445,93 +3592,93 @@ void init_bonded_thread_force_reduction(t_forcerec *fr, * contributes. Store this is a mask for each thread. */ #pragma omp parallel for num_threads(fr->nthreads) schedule(static) - for(t=1; tnthreads; t++) + for (t = 1; t < fr->nthreads; t++) { fr->f_t[t].red_mask = - calc_bonded_reduction_mask(idef,fr->red_ashift,t,fr->nthreads); + calc_bonded_reduction_mask(idef, fr->red_ashift, t, fr->nthreads); } /* Determine the maximum number of blocks we need to reduce over */ fr->red_nblock = 0; - ctot = 0; - for(t=0; tnthreads; t++) + ctot = 0; + for (t = 0; t < fr->nthreads; t++) { c = 0; - for(b=0; bf_t[t].red_mask & (1U<red_nblock = max(fr->red_nblock,b+1); + fr->red_nblock = max(fr->red_nblock, b+1); c++; } } if (debug) { - fprintf(debug,"thread %d flags %x count %d\n", - t,fr->f_t[t].red_mask,c); + fprintf(debug, "thread %d flags %x count %d\n", + t, fr->f_t[t].red_mask, c); } ctot += c; } if (debug) { - fprintf(debug,"Number of blocks to reduce: %d of size %d\n", - fr->red_nblock,1<red_ashift); - fprintf(debug,"Reduction density %.2f density/#thread %.2f\n", + fprintf(debug, "Number of blocks to reduce: %d of size %d\n", + fr->red_nblock, 1<red_ashift); + fprintf(debug, "Reduction density %.2f density/#thread %.2f\n", ctot*(1<red_ashift)/(double)fr->natoms_force, ctot*(1<red_ashift)/(double)(fr->natoms_force*fr->nthreads)); } } -static void zero_thread_forces(f_thread_t *f_t,int n, - int nblock,int blocksize) +static void zero_thread_forces(f_thread_t *f_t, int n, + int nblock, int blocksize) { - int b,a0,a1,a,i,j; + int b, a0, a1, a, i, j; if (n > f_t->f_nalloc) { f_t->f_nalloc = over_alloc_large(n); - srenew(f_t->f,f_t->f_nalloc); + srenew(f_t->f, f_t->f_nalloc); } if (f_t->red_mask != 0) { - for(b=0; bred_mask && (1U<f[a]); } } } } - for(i=0; ifshift[i]); } - for(i=0; iener[i] = 0; } - for(i=0; igrpp.nener; j++) + for (j = 0; j < f_t->grpp.nener; j++) { f_t->grpp.ener[i][j] = 0; } } - for(i=0; idvdl[i] = 0; } } -static void reduce_thread_force_buffer(int n,rvec *f, - int nthreads,f_thread_t *f_t, - int nblock,int block_size) +static void reduce_thread_force_buffer(int n, rvec *f, + int nthreads, f_thread_t *f_t, + int nblock, int block_size) { /* The max thread number is arbitrary, * we used a fixed number to avoid memory management. @@ -3542,7 +3689,7 @@ static void reduce_thread_force_buffer(int n,rvec *f, if (nthreads > MAX_BONDED_THREADS) { - gmx_fatal(FARGS,"Can not reduce bonded forces on more than %d threads", + gmx_fatal(FARGS, "Can not reduce bonded forces on more than %d threads", MAX_BONDED_THREADS); } @@ -3550,15 +3697,15 @@ static void reduce_thread_force_buffer(int n,rvec *f, * independently of nthreads. */ #pragma omp parallel for num_threads(nthreads) schedule(static) - for(b=0; b 0) { /* Reduce the bonded force buffer */ - reduce_thread_force_buffer(n,f,nthreads,f_t,nblock,block_size); + reduce_thread_force_buffer(n, f, nthreads, f_t, nblock, block_size); } /* When necessary, reduce energy and virial using one thread only */ if (bCalcEnerVir) { - int t,i,j; + int t, i, j; - for(i=0; iener[i][j] += f_t[t].grpp.ener[i][j]; } } } if (bDHDL) { - for(i=0; iil[ftype].nr/nat1; iatoms = idef->il[ftype].iatoms; @@ -3678,16 +3825,16 @@ static real calc_one_bond(FILE *fplog,int thread, if (!IS_LISTED_LJ_C(ftype)) { - if(ftype==F_CMAP) + if (ftype == F_CMAP) { - v = cmap_dihs(nbn,iatoms+nb0, - idef->iparams,&idef->cmap_grid, - (const rvec*)x,f,fshift, - pbc,g,lambda[efptFTYPE],&(dvdl[efptFTYPE]), - md,fcd,global_atom_index); + v = cmap_dihs(nbn, iatoms+nb0, + idef->iparams, &idef->cmap_grid, + (const rvec*)x, f, fshift, + pbc, g, lambda[efptFTYPE], &(dvdl[efptFTYPE]), + md, fcd, global_atom_index); } else if (ftype == F_PDIHS && - !bCalcEnerVir && fr->efep==efepNO) + !bCalcEnerVir && fr->efep == efepNO) { /* No energies, shift forces, dvdl */ #ifndef SSE_PROPER_DIHEDRALS @@ -3695,49 +3842,49 @@ static real calc_one_bond(FILE *fplog,int thread, #else pdihs_noener_sse #endif - (nbn,idef->il[ftype].iatoms+nb0, - idef->iparams, - (const rvec*)x,f, - pbc,g,lambda[efptFTYPE],md,fcd, - global_atom_index); + (nbn, idef->il[ftype].iatoms+nb0, + idef->iparams, + (const rvec*)x, f, + pbc, g, lambda[efptFTYPE], md, fcd, + global_atom_index); v = 0; } else { - v = interaction_function[ftype].ifunc(nbn,iatoms+nb0, + v = interaction_function[ftype].ifunc(nbn, iatoms+nb0, idef->iparams, - (const rvec*)x,f,fshift, - pbc,g,lambda[efptFTYPE],&(dvdl[efptFTYPE]), - md,fcd,global_atom_index); + (const rvec*)x, f, fshift, + pbc, g, lambda[efptFTYPE], &(dvdl[efptFTYPE]), + md, fcd, global_atom_index); } if (bPrintSepPot) { - fprintf(fplog," %-23s #%4d V %12.5e dVdl %12.5e\n", + fprintf(fplog, " %-23s #%4d V %12.5e dVdl %12.5e\n", interaction_function[ftype].longname, - nbonds/nat1,v,lambda[efptFTYPE]); + nbonds/nat1, v, lambda[efptFTYPE]); } } else { - v = do_nonbonded_listed(ftype,nbn,iatoms+nb0,idef->iparams,(const rvec*)x,f,fshift, - pbc,g,lambda,dvdl,md,fr,grpp,global_atom_index); + v = do_nonbonded_listed(ftype, nbn, iatoms+nb0, idef->iparams, (const rvec*)x, f, fshift, + pbc, g, lambda, dvdl, md, fr, grpp, global_atom_index); enerd->dvdl_nonlin[efptCOUL] += dvdl[efptCOUL]; - enerd->dvdl_nonlin[efptVDW] += dvdl[efptVDW]; - + enerd->dvdl_nonlin[efptVDW] += dvdl[efptVDW]; + if (bPrintSepPot) { - fprintf(fplog," %-5s + %-15s #%4d dVdl %12.5e\n", + fprintf(fplog, " %-5s + %-15s #%4d dVdl %12.5e\n", interaction_function[ftype].longname, - interaction_function[F_LJ14].longname,nbonds/nat1,dvdl[efptVDW]); - fprintf(fplog," %-5s + %-15s #%4d dVdl %12.5e\n", + interaction_function[F_LJ14].longname, nbonds/nat1, dvdl[efptVDW]); + fprintf(fplog, " %-5s + %-15s #%4d dVdl %12.5e\n", interaction_function[ftype].longname, - interaction_function[F_COUL14].longname,nbonds/nat1,dvdl[efptCOUL]); + interaction_function[F_COUL14].longname, nbonds/nat1, dvdl[efptCOUL]); } } if (ind != -1 && thread == 0) { - inc_nrnb(nrnb,ind,nbonds); + inc_nrnb(nrnb, ind, nbonds); } } @@ -3750,18 +3897,18 @@ static real calc_one_bond(FILE *fplog,int thread, different function, but for speed reasons, it needs to be made a separate function. TODO for 5.0 - figure out a way to reorganize to reduce duplication. -*/ + */ -static real calc_one_bond_foreign(FILE *fplog,int ftype, const t_idef *idef, +static real calc_one_bond_foreign(FILE *fplog, int ftype, const t_idef *idef, rvec x[], rvec f[], t_forcerec *fr, - const t_pbc *pbc,const t_graph *g, + const t_pbc *pbc, const t_graph *g, gmx_grppairener_t *grpp, t_nrnb *nrnb, real *lambda, real *dvdl, - const t_mdatoms *md,t_fcdata *fcd, + const t_mdatoms *md, t_fcdata *fcd, int *global_atom_index, gmx_bool bPrintSepPot) { - int ind,nat1,nbonds,efptFTYPE,nbonds_np; - real v=0; + int ind, nat1, nbonds, efptFTYPE, nbonds_np; + real v = 0; t_iatom *iatoms; if (IS_RESTRAINT_TYPE(ftype)) @@ -3773,13 +3920,13 @@ static real calc_one_bond_foreign(FILE *fplog,int ftype, const t_idef *idef, efptFTYPE = efptBONDED; } - if (ftypeF_GB14) + if (ftype < F_GB12 || ftype > F_GB14) { if (interaction_function[ftype].flags & IF_BOND && !(ftype == F_CONNBONDS || ftype == F_POSRES || ftype == F_FBPOSRES)) { - ind = interaction_function[ftype].nrnb_ind; - nat1 = interaction_function[ftype].nratoms+1; + ind = interaction_function[ftype].nrnb_ind; + nat1 = interaction_function[ftype].nratoms+1; nbonds_np = idef->il[ftype].nr_nonperturbed; nbonds = idef->il[ftype].nr - nbonds_np; iatoms = idef->il[ftype].iatoms + nbonds_np; @@ -3787,34 +3934,34 @@ static real calc_one_bond_foreign(FILE *fplog,int ftype, const t_idef *idef, { if (!IS_LISTED_LJ_C(ftype)) { - if(ftype==F_CMAP) + if (ftype == F_CMAP) { - v = cmap_dihs(nbonds,iatoms, - idef->iparams,&idef->cmap_grid, - (const rvec*)x,f,fr->fshift, - pbc,g,lambda[efptFTYPE],&(dvdl[efptFTYPE]),md,fcd, + v = cmap_dihs(nbonds, iatoms, + idef->iparams, &idef->cmap_grid, + (const rvec*)x, f, fr->fshift, + pbc, g, lambda[efptFTYPE], &(dvdl[efptFTYPE]), md, fcd, global_atom_index); } else { - v = interaction_function[ftype].ifunc(nbonds,iatoms, + v = interaction_function[ftype].ifunc(nbonds, iatoms, idef->iparams, - (const rvec*)x,f,fr->fshift, - pbc,g,lambda[efptFTYPE],&dvdl[efptFTYPE], - md,fcd,global_atom_index); + (const rvec*)x, f, fr->fshift, + pbc, g, lambda[efptFTYPE], &dvdl[efptFTYPE], + md, fcd, global_atom_index); } } else { - v = do_nonbonded_listed(ftype,nbonds,iatoms, + v = do_nonbonded_listed(ftype, nbonds, iatoms, idef->iparams, - (const rvec*)x,f,fr->fshift, - pbc,g,lambda,dvdl, - md,fr,grpp,global_atom_index); + (const rvec*)x, f, fr->fshift, + pbc, g, lambda, dvdl, + md, fr, grpp, global_atom_index); } if (ind != -1) { - inc_nrnb(nrnb,ind,nbonds/nat1); + inc_nrnb(nrnb, ind, nbonds/nat1); } } } @@ -3822,30 +3969,30 @@ static real calc_one_bond_foreign(FILE *fplog,int ftype, const t_idef *idef, return v; } -void calc_bonds(FILE *fplog,const gmx_multisim_t *ms, +void calc_bonds(FILE *fplog, const gmx_multisim_t *ms, const t_idef *idef, - rvec x[],history_t *hist, - rvec f[],t_forcerec *fr, - const t_pbc *pbc,const t_graph *g, - gmx_enerdata_t *enerd,t_nrnb *nrnb, + rvec x[], history_t *hist, + rvec f[], t_forcerec *fr, + const t_pbc *pbc, const t_graph *g, + gmx_enerdata_t *enerd, t_nrnb *nrnb, real *lambda, const t_mdatoms *md, - t_fcdata *fcd,int *global_atom_index, + t_fcdata *fcd, int *global_atom_index, t_atomtypes *atype, gmx_genborn_t *born, int force_flags, - gmx_bool bPrintSepPot,gmx_large_int_t step) + gmx_bool bPrintSepPot, gmx_large_int_t step) { - gmx_bool bCalcEnerVir; - int i; - real v,dvdl[efptNR],dvdl_dum[efptNR]; /* The dummy array is to have a place to store the dhdl at other values - of lambda, which will be thrown away in the end*/ + gmx_bool bCalcEnerVir; + int i; + real v, dvdl[efptNR], dvdl_dum[efptNR]; /* The dummy array is to have a place to store the dhdl at other values + of lambda, which will be thrown away in the end*/ const t_pbc *pbc_null; - char buf[22]; - int thread; + char buf[22]; + int thread; bCalcEnerVir = (force_flags & (GMX_FORCE_VIRIAL | GMX_FORCE_ENERGY)); - for (i=0;iil[F_ORIRES].nr) { enerd->term[F_ORIRESDEV] = - calc_orires_dev(ms,idef->il[F_ORIRES].nr, + calc_orires_dev(ms, idef->il[F_ORIRES].nr, idef->il[F_ORIRES].iatoms, - idef->iparams,md,(const rvec*)x, - pbc_null,fcd,hist); + idef->iparams, md, (const rvec*)x, + pbc_null, fcd, hist); } if (idef->il[F_DISRES].nr) { - calc_disres_R_6(ms,idef->il[F_DISRES].nr, + calc_disres_R_6(ms, idef->il[F_DISRES].nr, idef->il[F_DISRES].iatoms, - idef->iparams,(const rvec*)x,pbc_null, - fcd,hist); + idef->iparams, (const rvec*)x, pbc_null, + fcd, hist); } #pragma omp parallel for num_threads(fr->nthreads) schedule(static) - for(thread=0; threadnthreads; thread++) + for (thread = 0; thread < fr->nthreads; thread++) { - int ftype,nbonds,ind,nat1; - real *epot,v; + int ftype, nbonds, ind, nat1; + real *epot, v; /* thread stuff */ - rvec *ft,*fshift; - real *dvdlt; + rvec *ft, *fshift; + real *dvdlt; gmx_grppairener_t *grpp; - int nb0,nbn; + int nb0, nbn; if (thread == 0) { @@ -3908,8 +4055,8 @@ void calc_bonds(FILE *fplog,const gmx_multisim_t *ms, } else { - zero_thread_forces(&fr->f_t[thread],fr->natoms_force, - fr->red_nblock,1<red_ashift); + zero_thread_forces(&fr->f_t[thread], fr->natoms_force, + fr->red_nblock, 1<red_ashift); ft = fr->f_t[thread].f; fshift = fr->f_t[thread].fshift; @@ -3918,34 +4065,34 @@ void calc_bonds(FILE *fplog,const gmx_multisim_t *ms, dvdlt = fr->f_t[thread].dvdl; } /* Loop over all bonded force types to calculate the bonded forces */ - for(ftype=0; (ftypeil[ftype].nr > 0 && (interaction_function[ftype].flags & IF_BOND) && (ftype < F_GB12 || ftype > F_GB14) && !(ftype == F_CONNBONDS || ftype == F_POSRES)) { - v = calc_one_bond(fplog,thread,ftype,idef,x, - ft,fshift,fr,pbc_null,g,enerd,grpp, - nrnb,lambda,dvdlt, - md,fcd,bCalcEnerVir, - global_atom_index,bPrintSepPot); + v = calc_one_bond(fplog, thread, ftype, idef, x, + ft, fshift, fr, pbc_null, g, enerd, grpp, + nrnb, lambda, dvdlt, + md, fcd, bCalcEnerVir, + global_atom_index, bPrintSepPot); epot[ftype] += v; } } } if (fr->nthreads > 1) { - reduce_thread_forces(fr->natoms_force,f,fr->fshift, - enerd->term,&enerd->grpp,dvdl, - fr->nthreads,fr->f_t, - fr->red_nblock,1<red_ashift, + reduce_thread_forces(fr->natoms_force, f, fr->fshift, + enerd->term, &enerd->grpp, dvdl, + fr->nthreads, fr->f_t, + fr->red_nblock, 1<red_ashift, bCalcEnerVir, force_flags & GMX_FORCE_DHDL); } if (force_flags & GMX_FORCE_DHDL) { - for(i=0; idvdl_nonlin[i] += dvdl[i]; } @@ -3963,19 +4110,19 @@ void calc_bonds_lambda(FILE *fplog, const t_idef *idef, rvec x[], t_forcerec *fr, - const t_pbc *pbc,const t_graph *g, + const t_pbc *pbc, const t_graph *g, gmx_grppairener_t *grpp, real *epot, t_nrnb *nrnb, real *lambda, const t_mdatoms *md, t_fcdata *fcd, int *global_atom_index) { - int i,ftype,nbonds_np,nbonds,ind,nat; - real v,dr,dr2; - real dvdl_dum[efptNR]; - rvec *f,*fshift_orig; + int i, ftype, nbonds_np, nbonds, ind, nat; + real v, dr, dr2; + real dvdl_dum[efptNR]; + rvec *f, *fshift_orig; const t_pbc *pbc_null; - t_iatom *iatom_fe; + t_iatom *iatom_fe; if (fr->bMolPBC) { @@ -3986,17 +4133,17 @@ void calc_bonds_lambda(FILE *fplog, pbc_null = NULL; } - snew(f,fr->natoms_force); + snew(f, fr->natoms_force); /* We want to preserve the fshift array in forcerec */ fshift_orig = fr->fshift; - snew(fr->fshift,SHIFTS); + snew(fr->fshift, SHIFTS); /* Loop over all bonded force types to calculate the bonded forces */ - for(ftype=0; (ftype 0 ? "":" X",*ny > 0 ? "":" Y",*nz > 0 ? "":" Z"); + fprintf(fp, "Calculating fourier grid dimensions for%s%s%s\n", + *nx > 0 ? "" : " X", *ny > 0 ? "" : " Y", *nz > 0 ? "" : " Z"); } } - + max_spacing = 0; - for(d=0; d 2) - copy_rvec(xAI,xH3); - if (nh > 3) - copy_rvec(xAI,xH4); - - *l=(*l+1) % 6; + int m; + rvec kkk; + + /* This was copied from Gromos */ + for (m = 0; (m < DIM); m++) + { + xH1[m] = xAI[m]+matrix1[*l][m]; + xH2[m] = xAI[m]+matrix2[*l][m]; + } + if (nh > 2) + { + copy_rvec(xAI, xH3); + } + if (nh > 3) + { + copy_rvec(xAI, xH4); + } + + *l = (*l+1) % 6; } void calc_h_pos(int nht, rvec xa[], rvec xh[], int *l) @@ -108,159 +113,185 @@ void calc_h_pos(int nht, rvec xa[], rvec xh[], int *l) #define distOA 0.125 #define distOM 0.136 - rvec sa,sb,sij; - real s6,rij,ra,rb,xd; - int d; - - s6=0.5*sqrt(3.e0); + rvec sa, sb, sij; + real s6, rij, ra, rb, xd; + int d; - /* common work for constructing one, two or three dihedral hydrogens */ - switch (nht) { - case 2: - case 3: - case 4: - case 8: - case 9: - rij = 0.e0; - for(d=0; (dffparams.atnr; - snew(bLJ,ntype); - for(i=0; iffparams.iparams[i*ntype+j].lj.c6 != 0 || mtop->ffparams.iparams[i*ntype+j].lj.c12 != 0) @@ -81,29 +81,29 @@ void calc_chargegroup_radii(const gmx_mtop_t *mtop,rvec *x, } a_mol = 0; - for(mb=0; mbnmolblock; mb++) + for (mb = 0; mb < mtop->nmolblock; mb++) { molb = &mtop->molblock[mb]; molt = &mtop->moltype[molb->type]; cgs = &molt->cgs; atom = molt->atoms.atom; - for(m=0; mnmol; m++) + for (m = 0; m < molb->nmol; m++) { - for(cg=0; cgnr; cg++) + for (cg = 0; cg < cgs->nr; cg++) { a0 = cgs->index[cg]; a1 = cgs->index[cg+1]; if (a1 - a0 > 1) { clear_rvec(cen); - for(a=a0; a r2v2 && (bLJ[atom[a].type ] || bLJ[atom[a].typeB])) { @@ -145,126 +145,171 @@ void calc_chargegroup_radii(const gmx_mtop_t *mtop,rvec *x, *rcoul2 = sqrt(r2c2); } -void calc_cgcm(FILE *fplog,int cg0,int cg1,t_block *cgs, - rvec pos[],rvec cg_cm[]) +void calc_cgcm(FILE *fplog, int cg0, int cg1, t_block *cgs, + rvec pos[], rvec cg_cm[]) { - int icg,k,k0,k1,d; - rvec cg; - real nrcg,inv_ncg; + int icg, k, k0, k1, d; + rvec cg; + real nrcg, inv_ncg; atom_id *cgindex; #ifdef DEBUG - fprintf(fplog,"Calculating centre of geometry for charge groups %d to %d\n", - cg0,cg1); + fprintf(fplog, "Calculating centre of geometry for charge groups %d to %d\n", + cg0, cg1); #endif cgindex = cgs->index; /* Compute the center of geometry for all charge groups */ - for(icg=cg0; (icgindex; if (ePBC == epbcXY) + { npbcdim = 2; + } else + { npbcdim = 3; + } bTric = TRICLINIC(box); - for(icg=cg0; (icg=0; d--) { - while(cg_cm[icg][d] < 0) { - for(e=d; e>=0; e--) { + if (bTric) + { + for (d = npbcdim-1; d >= 0; d--) + { + while (cg_cm[icg][d] < 0) + { + for (e = d; e >= 0; e--) + { cg_cm[icg][e] += box[d][e]; - for(k=k0; (k= box[d][d]) { - for(e=d; e>=0; e--) { + while (cg_cm[icg][d] >= box[d][d]) + { + for (e = d; e >= 0; e--) + { cg_cm[icg][e] -= box[d][e]; - for(k=k0; (k= box[d][d]) { + while (cg_cm[icg][d] >= box[d][d]) + { cg_cm[icg][d] -= box[d][d]; - for(k=k0; (k= box[d][d])) - gmx_fatal(FARGS,"cg_cm[%d] = %15f %15f %15f\n" + { + gmx_fatal(FARGS, "cg_cm[%d] = %15f %15f %15f\n" "box = %15f %15f %15f\n", - icg,cg_cm[icg][XX],cg_cm[icg][YY],cg_cm[icg][ZZ], - box[XX][XX],box[YY][YY],box[ZZ][ZZ]); + icg, cg_cm[icg][XX], cg_cm[icg][YY], cg_cm[icg][ZZ], + box[XX][XX], box[YY][YY], box[ZZ][ZZ]); + } } #endif } diff --git a/src/gromacs/gmxlib/checkpoint.c b/src/gromacs/gmxlib/checkpoint.c index 704310a81a..0e8876c0a7 100644 --- a/src/gromacs/gmxlib/checkpoint.c +++ b/src/gromacs/gmxlib/checkpoint.c @@ -1,6 +1,6 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This file is part of Gromacs Copyright (c) 1991-2008 * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen. * @@ -11,13 +11,13 @@ * * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org - * + * * And Hey: * Gnomes, ROck Monsters And Chili Sauce */ -/* The source code in this file should be thread-safe. - Please keep it that way. */ +/* The source code in this file should be thread-safe. + Please keep it that way. */ #ifdef HAVE_CONFIG_H @@ -67,7 +67,7 @@ /* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */ char * -gmx_ctime_r(const time_t *clock,char *buf, int n); +gmx_ctime_r(const time_t *clock, char *buf, int n); #define CPT_MAGIC1 171817 @@ -89,7 +89,7 @@ gmx_ctime_r(const time_t *clock,char *buf, int n); static const int cpt_version = 15; -const char *est_names[estNR]= +const char *est_names[estNR] = { "FE-lambda", "box", "box-rel", "box-v", "pres_prev", @@ -97,44 +97,50 @@ const char *est_names[estNR]= "x", "v", "SDx", "CGp", "LD-rng", "LD-rng-i", "disre_initf", "disre_rm3tav", "orire_initf", "orire_Dtav", - "svir_prev", "nosehoover-vxi", "v_eta", "vol0", "nhpres_xi", "nhpres_vxi", "fvir_prev","fep_state", "MC-rng", "MC-rng-i" + "svir_prev", "nosehoover-vxi", "v_eta", "vol0", "nhpres_xi", "nhpres_vxi", "fvir_prev", "fep_state", "MC-rng", "MC-rng-i" }; -enum { eeksEKIN_N, eeksEKINH, eeksDEKINDL, eeksMVCOS, eeksEKINF, eeksEKINO, eeksEKINSCALEF, eeksEKINSCALEH, eeksVSCALE, eeksEKINTOTAL, eeksNR }; +enum { + eeksEKIN_N, eeksEKINH, eeksDEKINDL, eeksMVCOS, eeksEKINF, eeksEKINO, eeksEKINSCALEF, eeksEKINSCALEH, eeksVSCALE, eeksEKINTOTAL, eeksNR +}; -const char *eeks_names[eeksNR]= +const char *eeks_names[eeksNR] = { "Ekin_n", "Ekinh", "dEkindlambda", "mv_cos", - "Ekinf", "Ekinh_old", "EkinScaleF_NHC", "EkinScaleH_NHC","Vscale_NHC","Ekin_Total" + "Ekinf", "Ekinh_old", "EkinScaleF_NHC", "EkinScaleH_NHC", "Vscale_NHC", "Ekin_Total" }; -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_STARTLAMBDA, - eenhNR }; +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_STARTLAMBDA, + eenhNR +}; -const char *eenh_names[eenhNR]= +const char *eenh_names[eenhNR] = { "energy_n", "energy_aver", "energy_sum", "energy_nsum", "energy_sum_sim", "energy_nsum_sim", - "energy_nsteps", "energy_nsteps_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" }; /* free energy history variables -- need to be preserved over checkpoint */ -enum { edfhBEQUIL,edfhNATLAMBDA,edfhWLHISTO,edfhWLDELTA,edfhSUMWEIGHTS,edfhSUMDG,edfhSUMMINVAR,edfhSUMVAR, - edfhACCUMP,edfhACCUMM,edfhACCUMP2,edfhACCUMM2,edfhTIJ,edfhTIJEMP,edfhNR }; +enum { + edfhBEQUIL, edfhNATLAMBDA, edfhWLHISTO, edfhWLDELTA, edfhSUMWEIGHTS, edfhSUMDG, edfhSUMMINVAR, edfhSUMVAR, + edfhACCUMP, edfhACCUMM, edfhACCUMP2, edfhACCUMM2, edfhTIJ, edfhTIJEMP, edfhNR +}; /* free energy history variable names */ -const char *edfh_names[edfhNR]= +const char *edfh_names[edfhNR] = { - "bEquilibrated","N_at_state", "Wang-Landau_Histogram", "Wang-Landau-delta", "Weights", "Free Energies", "minvar","variance", + "bEquilibrated", "N_at_state", "Wang-Landau_Histogram", "Wang-Landau-delta", "Weights", "Free Energies", "minvar", "variance", "accumulated_plus", "accumulated_minus", "accumulated_plus_2", "accumulated_minus_2", "Tij", "Tij_empirical" }; @@ -148,39 +154,43 @@ gmx_wintruncate(const char *filename, __int64 size) #else FILE *fp; int rc; - - fp=fopen(filename,"rb+"); - - if(fp==NULL) + + fp = fopen(filename, "rb+"); + + if (fp == NULL) { return -1; } - + return _chsize_s( fileno(fp), size); #endif } #endif -enum { ecprREAL, ecprRVEC, ecprMATRIX }; +enum { + ecprREAL, ecprRVEC, ecprMATRIX +}; -enum { cptpEST, cptpEEKS, cptpEENH, cptpEDFH }; +enum { + cptpEST, cptpEEKS, cptpEENH, cptpEDFH +}; /* enums for the different components of checkpoint variables, replacing the hard coded ones. cptpEST - state variables. cptpEEKS - Kinetic energy state variables. cptpEENH - Energy history state variables. cptpEDFH - free energy history variables. -*/ + */ -static const char *st_names(int cptp,int ecpt) +static const char *st_names(int cptp, int ecpt) { switch (cptp) { - case cptpEST: return est_names [ecpt]; break; - case cptpEEKS: return eeks_names[ecpt]; break; - case cptpEENH: return eenh_names[ecpt]; break; - case cptpEDFH: return edfh_names[ecpt]; break; + case cptpEST: return est_names [ecpt]; break; + case cptpEEKS: return eeks_names[ecpt]; break; + case cptpEENH: return eenh_names[ecpt]; break; + case cptpEDFH: return edfh_names[ecpt]; break; } return NULL; @@ -188,69 +198,69 @@ static const char *st_names(int cptp,int ecpt) static void cp_warning(FILE *fp) { - fprintf(fp,"\nWARNING: Checkpoint file is corrupted or truncated\n\n"); + fprintf(fp, "\nWARNING: Checkpoint file is corrupted or truncated\n\n"); } static void cp_error() { - gmx_fatal(FARGS,"Checkpoint file corrupted/truncated, or maybe you are out of disk space?"); + gmx_fatal(FARGS, "Checkpoint file corrupted/truncated, or maybe you are out of disk space?"); } -static void do_cpt_string_err(XDR *xd,gmx_bool bRead,const char *desc,char **s,FILE *list) +static void do_cpt_string_err(XDR *xd, gmx_bool bRead, const char *desc, char **s, FILE *list) { - bool_t res=0; - + bool_t res = 0; + if (bRead) { - snew(*s,CPTSTRLEN); + snew(*s, CPTSTRLEN); } - res = xdr_string(xd,s,CPTSTRLEN); + res = xdr_string(xd, s, CPTSTRLEN); if (res == 0) { cp_error(); } if (list) { - fprintf(list,"%s = %s\n",desc,*s); + fprintf(list, "%s = %s\n", desc, *s); sfree(*s); } } -static int do_cpt_int(XDR *xd,const char *desc,int *i,FILE *list) +static int do_cpt_int(XDR *xd, const char *desc, int *i, FILE *list) { - bool_t res=0; - - res = xdr_int(xd,i); + bool_t res = 0; + + res = xdr_int(xd, i); if (res == 0) { return -1; } if (list) { - fprintf(list,"%s = %d\n",desc,*i); + fprintf(list, "%s = %d\n", desc, *i); } return 0; } -static int do_cpt_u_chars(XDR *xd,const char *desc,int n,unsigned char *i,FILE *list) +static int do_cpt_u_chars(XDR *xd, const char *desc, int n, unsigned char *i, FILE *list) { - bool_t res=1; - int j; + bool_t res = 1; + int j; if (list) { - fprintf(list,"%s = ",desc); + fprintf(list, "%s = ", desc); } - for (j=0; j= 0, nval is used; on read this should match the passed value. * If nval n<0, *nptr is used; on read the value is stored in nptr */ -static int do_cpte_reals_low(XDR *xd,int cptp,int ecpt,int sflags, - int nval,int *nptr,real **v, - FILE *list,int erealtype) +static int do_cpte_reals_low(XDR *xd, int cptp, int ecpt, int sflags, + int nval, int *nptr, real **v, + FILE *list, int erealtype) { - bool_t res=0; + bool_t res = 0; #ifndef GMX_DOUBLE - int dtc=xdr_datatype_float; + int dtc = xdr_datatype_float; #else - int dtc=xdr_datatype_double; + int dtc = xdr_datatype_double; #endif - real *vp,*va=NULL; + real *vp, *va = NULL; float *vf; double *vd; - int nf,dt,i; - + int nf, dt, i; + if (list == NULL) { if (nval >= 0) @@ -358,14 +368,14 @@ static int do_cpte_reals_low(XDR *xd,int cptp,int ecpt,int sflags, } else { - if (nptr == NULL) - { - gmx_incons("*ntpr=NULL in do_cpte_reals_low"); - } - nf = *nptr; + if (nptr == NULL) + { + gmx_incons("*ntpr=NULL in do_cpte_reals_low"); + } + nf = *nptr; } } - res = xdr_int(xd,&nf); + res = xdr_int(xd, &nf); if (res == 0) { return -1; @@ -376,7 +386,7 @@ static int do_cpte_reals_low(XDR *xd,int cptp,int ecpt,int sflags, { if (nf != nval) { - gmx_fatal(FARGS,"Count mismatch for state entry %s, code count is %d, file count is %d\n",st_names(cptp,ecpt),nval,nf); + gmx_fatal(FARGS, "Count mismatch for state entry %s, code count is %d, file count is %d\n", st_names(cptp, ecpt), nval, nf); } } else @@ -384,28 +394,28 @@ static int do_cpte_reals_low(XDR *xd,int cptp,int ecpt,int sflags, *nptr = nf; } } - dt = dtc; - res = xdr_int(xd,&dt); + dt = dtc; + res = xdr_int(xd, &dt); if (res == 0) { return -1; } if (dt != dtc) { - fprintf(stderr,"Precision mismatch for state entry %s, code precision is %s, file precision is %s\n", - st_names(cptp,ecpt),xdr_datatype_names[dtc], + fprintf(stderr, "Precision mismatch for state entry %s, code precision is %s, file precision is %s\n", + st_names(cptp, ecpt), xdr_datatype_names[dtc], xdr_datatype_names[dt]); } if (list || !(sflags & (1< cpt_version) { - gmx_fatal(FARGS,"Attempting to read a checkpoint file of version %d with code of version %d\n",*file_version,cpt_version); + gmx_fatal(FARGS, "Attempting to read a checkpoint file of version %d with code of version %d\n", *file_version, cpt_version); } if (*file_version >= 13) { - do_cpt_int_err(xd,"GROMACS double precision",double_prec,list); + do_cpt_int_err(xd, "GROMACS double precision", double_prec, list); } else { @@ -849,17 +859,17 @@ static void do_cpt_header(XDR *xd,gmx_bool bRead,int *file_version, } if (*file_version >= 12) { - do_cpt_string_err(xd,bRead,"generating host" ,&fhost,list); + do_cpt_string_err(xd, bRead, "generating host", &fhost, list); if (list == NULL) { sfree(fhost); } } - do_cpt_int_err(xd,"#atoms" ,natoms ,list); - do_cpt_int_err(xd,"#T-coupling groups",ngtc ,list); - if (*file_version >= 10) + do_cpt_int_err(xd, "#atoms", natoms, list); + do_cpt_int_err(xd, "#T-coupling groups", ngtc, list); + if (*file_version >= 10) { - do_cpt_int_err(xd,"#Nose-Hoover T-chains",nhchainlength,list); + do_cpt_int_err(xd, "#Nose-Hoover T-chains", nhchainlength, list); } else { @@ -867,7 +877,7 @@ static void do_cpt_header(XDR *xd,gmx_bool bRead,int *file_version, } if (*file_version >= 11) { - do_cpt_int_err(xd,"#Nose-Hoover T-chains for barostat ",nnhpres,list); + do_cpt_int_err(xd, "#Nose-Hoover T-chains for barostat ", nnhpres, list); } else { @@ -875,61 +885,63 @@ static void do_cpt_header(XDR *xd,gmx_bool bRead,int *file_version, } if (*file_version >= 14) { - do_cpt_int_err(xd,"# of total lambda states ",nlambda,list); + do_cpt_int_err(xd, "# of total lambda states ", nlambda, list); } else { *nlambda = 0; } - do_cpt_int_err(xd,"integrator" ,eIntegrator,list); - if (*file_version >= 3) - { - do_cpt_int_err(xd,"simulation part #", simulation_part,list); - } - else - { - *simulation_part = 1; - } + do_cpt_int_err(xd, "integrator", eIntegrator, list); + if (*file_version >= 3) + { + do_cpt_int_err(xd, "simulation part #", simulation_part, list); + } + else + { + *simulation_part = 1; + } if (*file_version >= 5) { - do_cpt_step_err(xd,"step" ,step ,list); + do_cpt_step_err(xd, "step", step, list); } else { - do_cpt_int_err(xd,"step" ,&idum ,list); + do_cpt_int_err(xd, "step", &idum, list); *step = idum; } - do_cpt_double_err(xd,"t" ,t ,list); - do_cpt_int_err(xd,"#PP-nodes" ,nnodes ,list); + do_cpt_double_err(xd, "t", t, list); + do_cpt_int_err(xd, "#PP-nodes", nnodes, list); idum = 1; - do_cpt_int_err(xd,"dd_nc[x]",dd_nc ? &(dd_nc[0]) : &idum,list); - do_cpt_int_err(xd,"dd_nc[y]",dd_nc ? &(dd_nc[1]) : &idum,list); - do_cpt_int_err(xd,"dd_nc[z]",dd_nc ? &(dd_nc[2]) : &idum,list); - do_cpt_int_err(xd,"#PME-only nodes",npme,list); - do_cpt_int_err(xd,"state flags",flags_state,list); - if (*file_version >= 4) + do_cpt_int_err(xd, "dd_nc[x]", dd_nc ? &(dd_nc[0]) : &idum, list); + do_cpt_int_err(xd, "dd_nc[y]", dd_nc ? &(dd_nc[1]) : &idum, list); + do_cpt_int_err(xd, "dd_nc[z]", dd_nc ? &(dd_nc[2]) : &idum, list); + do_cpt_int_err(xd, "#PME-only nodes", npme, list); + do_cpt_int_err(xd, "state flags", flags_state, list); + if (*file_version >= 4) { - do_cpt_int_err(xd,"ekin data flags",flags_eks,list); - do_cpt_int_err(xd,"energy history flags",flags_enh,list); + do_cpt_int_err(xd, "ekin data flags", flags_eks, list); + do_cpt_int_err(xd, "energy history flags", flags_enh, list); } else { - *flags_eks = 0; + *flags_eks = 0; *flags_enh = (*flags_state >> (estORIRE_DTAV+1)); *flags_state = (*flags_state & ~((1<<(estORIRE_DTAV+1)) | (1<<(estORIRE_DTAV+2)) | (1<<(estORIRE_DTAV+3)))); } - if (*file_version >= 14) + if (*file_version >= 14) + { + do_cpt_int_err(xd, "df history flags", flags_dfh, list); + } + else { - do_cpt_int_err(xd,"df history flags",flags_dfh,list); - } else { *flags_dfh = 0; } if (*file_version >= 15) { - do_cpt_int_err(xd,"ED data sets",nED,list); + do_cpt_int_err(xd, "ED data sets", nED, list); } else { @@ -937,15 +949,15 @@ static void do_cpt_header(XDR *xd,gmx_bool bRead,int *file_version, } } -static int do_cpt_footer(XDR *xd,gmx_bool bRead,int file_version) +static int do_cpt_footer(XDR *xd, gmx_bool bRead, int file_version) { - bool_t res=0; - int magic; - + bool_t res = 0; + int magic; + if (file_version >= 2) { magic = CPT_MAGIC2; - res = xdr_int(xd,&magic); + res = xdr_int(xd, &magic); if (res == 0) { cp_error(); @@ -959,19 +971,19 @@ static int do_cpt_footer(XDR *xd,gmx_bool bRead,int file_version) return 0; } -static int do_cpt_state(XDR *xd,gmx_bool bRead, - int fflags,t_state *state, - gmx_bool bReadRNG,FILE *list) +static int do_cpt_state(XDR *xd, gmx_bool bRead, + int fflags, t_state *state, + gmx_bool bReadRNG, FILE *list) { - int sflags; - int **rng_p,**rngi_p; - int i; - int ret; - int nnht,nnhtp; + int sflags; + int **rng_p, **rngi_p; + int i; + int ret; + int nnht, nnhtp; ret = 0; - - nnht = state->nhchainlength*state->ngtc; + + nnht = state->nhchainlength*state->ngtc; nnhtp = state->nhchainlength*state->nnhpres; if (bReadRNG) @@ -988,50 +1000,50 @@ static int do_cpt_state(XDR *xd,gmx_bool bRead, /* We want the MC_RNG the same across all the notes for now -- lambda MC is global */ sflags = state->flags; - for(i=0; (ilambda),list); break; - case estFEPSTATE: ret = do_cpte_int (xd,cptpEST,i,sflags,&state->fep_state,list); break; - case estBOX: ret = do_cpte_matrix(xd,cptpEST,i,sflags,state->box,list); break; - case estBOX_REL: ret = do_cpte_matrix(xd,cptpEST,i,sflags,state->box_rel,list); break; - case estBOXV: ret = do_cpte_matrix(xd,cptpEST,i,sflags,state->boxv,list); break; - case estPRES_PREV: ret = do_cpte_matrix(xd,cptpEST,i,sflags,state->pres_prev,list); break; - case estSVIR_PREV: ret = do_cpte_matrix(xd,cptpEST,i,sflags,state->svir_prev,list); break; - case estFVIR_PREV: ret = do_cpte_matrix(xd,cptpEST,i,sflags,state->fvir_prev,list); break; - case estNH_XI: ret = do_cpte_doubles(xd,cptpEST,i,sflags,nnht,&state->nosehoover_xi,list); break; - case estNH_VXI: ret = do_cpte_doubles(xd,cptpEST,i,sflags,nnht,&state->nosehoover_vxi,list); break; - case estNHPRES_XI: ret = do_cpte_doubles(xd,cptpEST,i,sflags,nnhtp,&state->nhpres_xi,list); break; - case estNHPRES_VXI: ret = do_cpte_doubles(xd,cptpEST,i,sflags,nnhtp,&state->nhpres_vxi,list); break; - case estTC_INT: ret = do_cpte_doubles(xd,cptpEST,i,sflags,state->ngtc,&state->therm_integral,list); break; - case estVETA: ret = do_cpte_real(xd,cptpEST,i,sflags,&state->veta,list); break; - case estVOL0: ret = do_cpte_real(xd,cptpEST,i,sflags,&state->vol0,list); break; - case estX: ret = do_cpte_rvecs(xd,cptpEST,i,sflags,state->natoms,&state->x,list); break; - case estV: ret = do_cpte_rvecs(xd,cptpEST,i,sflags,state->natoms,&state->v,list); break; - case estSDX: ret = do_cpte_rvecs(xd,cptpEST,i,sflags,state->natoms,&state->sd_X,list); break; - case estLD_RNG: ret = do_cpte_ints(xd,cptpEST,i,sflags,state->nrng,rng_p,list); break; - case estLD_RNGI: ret = do_cpte_ints(xd,cptpEST,i,sflags,state->nrngi,rngi_p,list); break; - case estMC_RNG: ret = do_cpte_ints(xd,cptpEST,i,sflags,state->nmcrng,(int **)&state->mc_rng,list); break; - case estMC_RNGI: ret = do_cpte_ints(xd,cptpEST,i,sflags,1,&state->mc_rngi,list); break; - case estDISRE_INITF: ret = do_cpte_real (xd,cptpEST,i,sflags,&state->hist.disre_initf,list); break; - case estDISRE_RM3TAV: ret = do_cpte_reals(xd,cptpEST,i,sflags,state->hist.ndisrepairs,&state->hist.disre_rm3tav,list); break; - case estORIRE_INITF: ret = do_cpte_real (xd,cptpEST,i,sflags,&state->hist.orire_initf,list); break; - case estORIRE_DTAV: ret = do_cpte_reals(xd,cptpEST,i,sflags,state->hist.norire_Dtav,&state->hist.orire_Dtav,list); break; - default: - gmx_fatal(FARGS,"Unknown state entry %d\n" - "You are probably reading a new checkpoint file with old code",i); + case estLAMBDA: ret = do_cpte_reals(xd, cptpEST, i, sflags, efptNR, &(state->lambda), list); break; + case estFEPSTATE: ret = do_cpte_int (xd, cptpEST, i, sflags, &state->fep_state, list); break; + case estBOX: ret = do_cpte_matrix(xd, cptpEST, i, sflags, state->box, list); break; + case estBOX_REL: ret = do_cpte_matrix(xd, cptpEST, i, sflags, state->box_rel, list); break; + case estBOXV: ret = do_cpte_matrix(xd, cptpEST, i, sflags, state->boxv, list); break; + case estPRES_PREV: ret = do_cpte_matrix(xd, cptpEST, i, sflags, state->pres_prev, list); break; + case estSVIR_PREV: ret = do_cpte_matrix(xd, cptpEST, i, sflags, state->svir_prev, list); break; + case estFVIR_PREV: ret = do_cpte_matrix(xd, cptpEST, i, sflags, state->fvir_prev, list); break; + case estNH_XI: ret = do_cpte_doubles(xd, cptpEST, i, sflags, nnht, &state->nosehoover_xi, list); break; + case estNH_VXI: ret = do_cpte_doubles(xd, cptpEST, i, sflags, nnht, &state->nosehoover_vxi, list); break; + case estNHPRES_XI: ret = do_cpte_doubles(xd, cptpEST, i, sflags, nnhtp, &state->nhpres_xi, list); break; + case estNHPRES_VXI: ret = do_cpte_doubles(xd, cptpEST, i, sflags, nnhtp, &state->nhpres_vxi, list); break; + case estTC_INT: ret = do_cpte_doubles(xd, cptpEST, i, sflags, state->ngtc, &state->therm_integral, list); break; + case estVETA: ret = do_cpte_real(xd, cptpEST, i, sflags, &state->veta, list); break; + case estVOL0: ret = do_cpte_real(xd, cptpEST, i, sflags, &state->vol0, list); break; + case estX: ret = do_cpte_rvecs(xd, cptpEST, i, sflags, state->natoms, &state->x, list); break; + case estV: ret = do_cpte_rvecs(xd, cptpEST, i, sflags, state->natoms, &state->v, list); break; + case estSDX: ret = do_cpte_rvecs(xd, cptpEST, i, sflags, state->natoms, &state->sd_X, list); break; + case estLD_RNG: ret = do_cpte_ints(xd, cptpEST, i, sflags, state->nrng, rng_p, list); break; + case estLD_RNGI: ret = do_cpte_ints(xd, cptpEST, i, sflags, state->nrngi, rngi_p, list); break; + case estMC_RNG: ret = do_cpte_ints(xd, cptpEST, i, sflags, state->nmcrng, (int **)&state->mc_rng, list); break; + case estMC_RNGI: ret = do_cpte_ints(xd, cptpEST, i, sflags, 1, &state->mc_rngi, list); break; + case estDISRE_INITF: ret = do_cpte_real (xd, cptpEST, i, sflags, &state->hist.disre_initf, list); break; + case estDISRE_RM3TAV: ret = do_cpte_reals(xd, cptpEST, i, sflags, state->hist.ndisrepairs, &state->hist.disre_rm3tav, list); break; + case estORIRE_INITF: ret = do_cpte_real (xd, cptpEST, i, sflags, &state->hist.orire_initf, list); break; + case estORIRE_DTAV: ret = do_cpte_reals(xd, cptpEST, i, sflags, state->hist.norire_Dtav, &state->hist.orire_Dtav, list); break; + default: + gmx_fatal(FARGS, "Unknown state entry %d\n" + "You are probably reading a new checkpoint file with old code", i); } } } - + return ret; } -static int do_cpt_ekinstate(XDR *xd,gmx_bool bRead, - int fflags,ekinstate_t *ekins, +static int do_cpt_ekinstate(XDR *xd, gmx_bool bRead, + int fflags, ekinstate_t *ekins, FILE *list) { int i; @@ -1039,36 +1051,36 @@ static int do_cpt_ekinstate(XDR *xd,gmx_bool bRead, ret = 0; - for(i=0; (iekin_n,list); break; - case eeksEKINH : ret = do_cpte_matrices(xd,cptpEEKS,i,fflags,ekins->ekin_n,&ekins->ekinh,list); break; - case eeksEKINF: ret = do_cpte_matrices(xd,cptpEEKS,i,fflags,ekins->ekin_n,&ekins->ekinf,list); break; - case eeksEKINO: ret = do_cpte_matrices(xd,cptpEEKS,i,fflags,ekins->ekin_n,&ekins->ekinh_old,list); break; - case eeksEKINTOTAL: ret = do_cpte_matrix(xd,cptpEEKS,i,fflags,ekins->ekin_total,list); break; - case eeksEKINSCALEF: ret = do_cpte_doubles(xd,cptpEEKS,i,fflags,ekins->ekin_n,&ekins->ekinscalef_nhc,list); break; - case eeksVSCALE: ret = do_cpte_doubles(xd,1,cptpEEKS,fflags,ekins->ekin_n,&ekins->vscale_nhc,list); break; - case eeksEKINSCALEH: ret = do_cpte_doubles(xd,1,cptpEEKS,fflags,ekins->ekin_n,&ekins->ekinscaleh_nhc,list); break; - case eeksDEKINDL : ret = do_cpte_real(xd,1,cptpEEKS,fflags,&ekins->dekindl,list); break; - case eeksMVCOS: ret = do_cpte_real(xd,1,cptpEEKS,fflags,&ekins->mvcos,list); break; - default: - gmx_fatal(FARGS,"Unknown ekin data state entry %d\n" - "You are probably reading a new checkpoint file with old code",i); + + case eeksEKIN_N: ret = do_cpte_int(xd, cptpEEKS, i, fflags, &ekins->ekin_n, list); break; + case eeksEKINH: ret = do_cpte_matrices(xd, cptpEEKS, i, fflags, ekins->ekin_n, &ekins->ekinh, list); break; + case eeksEKINF: ret = do_cpte_matrices(xd, cptpEEKS, i, fflags, ekins->ekin_n, &ekins->ekinf, list); break; + case eeksEKINO: ret = do_cpte_matrices(xd, cptpEEKS, i, fflags, ekins->ekin_n, &ekins->ekinh_old, list); break; + case eeksEKINTOTAL: ret = do_cpte_matrix(xd, cptpEEKS, i, fflags, ekins->ekin_total, list); break; + case eeksEKINSCALEF: ret = do_cpte_doubles(xd, cptpEEKS, i, fflags, ekins->ekin_n, &ekins->ekinscalef_nhc, list); break; + case eeksVSCALE: ret = do_cpte_doubles(xd, 1, cptpEEKS, fflags, ekins->ekin_n, &ekins->vscale_nhc, list); break; + case eeksEKINSCALEH: ret = do_cpte_doubles(xd, 1, cptpEEKS, fflags, ekins->ekin_n, &ekins->ekinscaleh_nhc, list); break; + case eeksDEKINDL: ret = do_cpte_real(xd, 1, cptpEEKS, fflags, &ekins->dekindl, list); break; + case eeksMVCOS: ret = do_cpte_real(xd, 1, cptpEEKS, fflags, &ekins->mvcos, list); break; + default: + gmx_fatal(FARGS, "Unknown ekin data state entry %d\n" + "You are probably reading a new checkpoint file with old code", i); } } } - + return ret; } -static int do_cpt_enerhist(XDR *xd,gmx_bool bRead, - int fflags,energyhistory_t *enerhist, +static int do_cpt_enerhist(XDR *xd, gmx_bool bRead, + int fflags, energyhistory_t *enerhist, FILE *list) { int i; @@ -1087,52 +1099,52 @@ static int do_cpt_enerhist(XDR *xd,gmx_bool bRead, if (fflags & (1<< eenhENERGY_DELTA_H_NN) ) { - snew(enerhist->dht,1); - enerhist->dht->ndh = NULL; - enerhist->dht->dh = NULL; - enerhist->dht->start_lambda_set=FALSE; + snew(enerhist->dht, 1); + enerhist->dht->ndh = NULL; + enerhist->dht->dh = NULL; + enerhist->dht->start_lambda_set = FALSE; } } - for(i=0; (inener,list); break; - case eenhENERGY_AVER: ret = do_cpte_doubles(xd,cptpEENH,i,fflags,enerhist->nener,&enerhist->ener_ave,list); break; - case eenhENERGY_SUM: ret = do_cpte_doubles(xd,cptpEENH,i,fflags,enerhist->nener,&enerhist->ener_sum,list); break; - case eenhENERGY_NSUM: do_cpt_step_err(xd,eenh_names[i],&enerhist->nsum,list); break; - case eenhENERGY_SUM_SIM: ret = do_cpte_doubles(xd,cptpEENH,i,fflags,enerhist->nener,&enerhist->ener_sum_sim,list); break; - case eenhENERGY_NSUM_SIM: do_cpt_step_err(xd,eenh_names[i],&enerhist->nsum_sim,list); break; - case eenhENERGY_NSTEPS: do_cpt_step_err(xd,eenh_names[i],&enerhist->nsteps,list); break; - case eenhENERGY_NSTEPS_SIM: do_cpt_step_err(xd,eenh_names[i],&enerhist->nsteps_sim,list); break; - case eenhENERGY_DELTA_H_NN: do_cpt_int_err(xd,eenh_names[i], &(enerhist->dht->nndh), list); - if (bRead) /* now allocate memory for it */ - { - snew(enerhist->dht->dh, enerhist->dht->nndh); - snew(enerhist->dht->ndh, enerhist->dht->nndh); - for(j=0;jdht->nndh;j++) + case eenhENERGY_N: ret = do_cpte_int(xd, cptpEENH, i, fflags, &enerhist->nener, list); break; + case eenhENERGY_AVER: ret = do_cpte_doubles(xd, cptpEENH, i, fflags, enerhist->nener, &enerhist->ener_ave, list); break; + case eenhENERGY_SUM: ret = do_cpte_doubles(xd, cptpEENH, i, fflags, enerhist->nener, &enerhist->ener_sum, list); break; + case eenhENERGY_NSUM: do_cpt_step_err(xd, eenh_names[i], &enerhist->nsum, list); break; + case eenhENERGY_SUM_SIM: ret = do_cpte_doubles(xd, cptpEENH, i, fflags, enerhist->nener, &enerhist->ener_sum_sim, list); break; + case eenhENERGY_NSUM_SIM: do_cpt_step_err(xd, eenh_names[i], &enerhist->nsum_sim, list); break; + case eenhENERGY_NSTEPS: do_cpt_step_err(xd, eenh_names[i], &enerhist->nsteps, list); break; + case eenhENERGY_NSTEPS_SIM: do_cpt_step_err(xd, eenh_names[i], &enerhist->nsteps_sim, list); break; + case eenhENERGY_DELTA_H_NN: do_cpt_int_err(xd, eenh_names[i], &(enerhist->dht->nndh), list); + if (bRead) /* now allocate memory for it */ { - enerhist->dht->ndh[j] = 0; - enerhist->dht->dh[j] = NULL; + snew(enerhist->dht->dh, enerhist->dht->nndh); + snew(enerhist->dht->ndh, enerhist->dht->nndh); + for (j = 0; j < enerhist->dht->nndh; j++) + { + enerhist->dht->ndh[j] = 0; + enerhist->dht->dh[j] = NULL; + } } - } - break; - case eenhENERGY_DELTA_H_LIST: - for(j=0;jdht->nndh;j++) - { - ret=do_cpte_n_reals(xd, cptpEENH, i, fflags, &enerhist->dht->ndh[j], &(enerhist->dht->dh[j]), list); - } - break; - case eenhENERGY_DELTA_H_STARTTIME: - ret=do_cpte_double(xd, cptpEENH, i, fflags, &(enerhist->dht->start_time), list); break; - case eenhENERGY_DELTA_H_STARTLAMBDA: - ret=do_cpte_double(xd, cptpEENH, i, fflags, &(enerhist->dht->start_lambda), list); break; - default: - gmx_fatal(FARGS,"Unknown energy history entry %d\n" - "You are probably reading a new checkpoint file with old code",i); + break; + case eenhENERGY_DELTA_H_LIST: + for (j = 0; j < enerhist->dht->nndh; j++) + { + ret = do_cpte_n_reals(xd, cptpEENH, i, fflags, &enerhist->dht->ndh[j], &(enerhist->dht->dh[j]), list); + } + break; + case eenhENERGY_DELTA_H_STARTTIME: + ret = do_cpte_double(xd, cptpEENH, i, fflags, &(enerhist->dht->start_time), list); break; + case eenhENERGY_DELTA_H_STARTLAMBDA: + ret = do_cpte_double(xd, cptpEENH, i, fflags, &(enerhist->dht->start_lambda), list); break; + default: + gmx_fatal(FARGS, "Unknown energy history entry %d\n" + "You are probably reading a new checkpoint file with old code", i); } } } @@ -1140,64 +1152,64 @@ static int do_cpt_enerhist(XDR *xd,gmx_bool bRead, if ((fflags & (1<ener_sum_sim,enerhist->nener); - for(i=0; inener; i++) + srenew(enerhist->ener_sum_sim, enerhist->nener); + for (i = 0; i < enerhist->nener; i++) { enerhist->ener_sum_sim[i] = enerhist->ener_sum[i]; } fflags |= (1<nsteps = enerhist->nsum; - fflags |= (1<nsteps_sim = enerhist->nsum_sim; - fflags |= (1<nlambda; - ret = 0; + ret = 0; - for(i=0; (ibEquil,list); break; - case edfhNATLAMBDA: ret = do_cpte_ints(xd,cptpEDFH,i,fflags,nlambda,&dfhist->n_at_lam,list); break; - case edfhWLHISTO: ret = do_cpte_reals(xd,cptpEDFH,i,fflags,nlambda,&dfhist->wl_histo,list); break; - case edfhWLDELTA: ret = do_cpte_real(xd,cptpEDFH,i,fflags,&dfhist->wl_delta,list); break; - case edfhSUMWEIGHTS: ret = do_cpte_reals(xd,cptpEDFH,i,fflags,nlambda,&dfhist->sum_weights,list); break; - case edfhSUMDG: ret = do_cpte_reals(xd,cptpEDFH,i,fflags,nlambda,&dfhist->sum_dg,list); break; - case edfhSUMMINVAR: ret = do_cpte_reals(xd,cptpEDFH,i,fflags,nlambda,&dfhist->sum_minvar,list); break; - case edfhSUMVAR: ret = do_cpte_reals(xd,cptpEDFH,i,fflags,nlambda,&dfhist->sum_variance,list); break; - case edfhACCUMP: ret = do_cpte_nmatrix(xd,cptpEDFH,i,fflags,nlambda,dfhist->accum_p,list); break; - case edfhACCUMM: ret = do_cpte_nmatrix(xd,cptpEDFH,i,fflags,nlambda,dfhist->accum_m,list); break; - case edfhACCUMP2: ret = do_cpte_nmatrix(xd,cptpEDFH,i,fflags,nlambda,dfhist->accum_p2,list); break; - case edfhACCUMM2: ret = do_cpte_nmatrix(xd,cptpEDFH,i,fflags,nlambda,dfhist->accum_m2,list); break; - case edfhTIJ: ret = do_cpte_nmatrix(xd,cptpEDFH,i,fflags,nlambda,dfhist->Tij,list); break; - case edfhTIJEMP: ret = do_cpte_nmatrix(xd,cptpEDFH,i,fflags,nlambda,dfhist->Tij_empirical,list); break; - - default: - gmx_fatal(FARGS,"Unknown df history entry %d\n" - "You are probably reading a new checkpoint file with old code",i); + case edfhBEQUIL: ret = do_cpte_int(xd, cptpEDFH, i, fflags, &dfhist->bEquil, list); break; + case edfhNATLAMBDA: ret = do_cpte_ints(xd, cptpEDFH, i, fflags, nlambda, &dfhist->n_at_lam, list); break; + case edfhWLHISTO: ret = do_cpte_reals(xd, cptpEDFH, i, fflags, nlambda, &dfhist->wl_histo, list); break; + case edfhWLDELTA: ret = do_cpte_real(xd, cptpEDFH, i, fflags, &dfhist->wl_delta, list); break; + case edfhSUMWEIGHTS: ret = do_cpte_reals(xd, cptpEDFH, i, fflags, nlambda, &dfhist->sum_weights, list); break; + case edfhSUMDG: ret = do_cpte_reals(xd, cptpEDFH, i, fflags, nlambda, &dfhist->sum_dg, list); break; + case edfhSUMMINVAR: ret = do_cpte_reals(xd, cptpEDFH, i, fflags, nlambda, &dfhist->sum_minvar, list); break; + case edfhSUMVAR: ret = do_cpte_reals(xd, cptpEDFH, i, fflags, nlambda, &dfhist->sum_variance, list); break; + case edfhACCUMP: ret = do_cpte_nmatrix(xd, cptpEDFH, i, fflags, nlambda, dfhist->accum_p, list); break; + case edfhACCUMM: ret = do_cpte_nmatrix(xd, cptpEDFH, i, fflags, nlambda, dfhist->accum_m, list); break; + case edfhACCUMP2: ret = do_cpte_nmatrix(xd, cptpEDFH, i, fflags, nlambda, dfhist->accum_p2, list); break; + case edfhACCUMM2: ret = do_cpte_nmatrix(xd, cptpEDFH, i, fflags, nlambda, dfhist->accum_m2, list); break; + case edfhTIJ: ret = do_cpte_nmatrix(xd, cptpEDFH, i, fflags, nlambda, dfhist->Tij, list); break; + case edfhTIJEMP: ret = do_cpte_nmatrix(xd, cptpEDFH, i, fflags, nlambda, dfhist->Tij_empirical, list); break; + + default: + gmx_fatal(FARGS, "Unknown df history entry %d\n" + "You are probably reading a new checkpoint file with old code", i); } } } @@ -1209,11 +1221,11 @@ static int do_cpt_df_hist(XDR *xd,gmx_bool bRead,int fflags,df_history_t *dfhist /* This function stores the last whole configuration of the reference and * average structure in the .cpt file */ -static int do_cpt_EDstate(XDR *xd,gmx_bool bRead, - edsamstate_t *EDstate, FILE *list) +static int do_cpt_EDstate(XDR *xd, gmx_bool bRead, + edsamstate_t *EDstate, FILE *list) { - int i,j; - int ret=0; + int i, j; + int ret = 0; char buf[STRLEN]; @@ -1228,18 +1240,18 @@ static int do_cpt_EDstate(XDR *xd,gmx_bool bRead, * so we have to allocate memory first. */ if (bRead) { - snew(EDstate->nref , EDstate->nED); + snew(EDstate->nref, EDstate->nED); snew(EDstate->old_sref, EDstate->nED); - snew(EDstate->nav , EDstate->nED); - snew(EDstate->old_sav , EDstate->nED); + snew(EDstate->nav, EDstate->nED); + snew(EDstate->old_sav, EDstate->nED); } /* Read/write the last whole conformation of SREF and SAV for each ED dataset (usually only one) */ - for (i=0; i< EDstate->nED; i++) + for (i = 0; i < EDstate->nED; i++) { /* Reference structure SREF */ sprintf(buf, "ED%d # of atoms in reference structure", i+1); - do_cpt_int_err(xd, buf, &EDstate->nref[i],list); + do_cpt_int_err(xd, buf, &EDstate->nref[i], list); sprintf(buf, "ED%d x_ref", i+1); if (bRead) { @@ -1253,7 +1265,7 @@ static int do_cpt_EDstate(XDR *xd,gmx_bool bRead, /* Average structure SAV */ sprintf(buf, "ED%d # of atoms in average structure", i+1); - do_cpt_int_err(xd, buf, &EDstate->nav[i] ,list); + do_cpt_int_err(xd, buf, &EDstate->nav[i], list); sprintf(buf, "ED%d x_av", i+1); if (bRead) { @@ -1270,46 +1282,46 @@ static int do_cpt_EDstate(XDR *xd,gmx_bool bRead, } -static int do_cpt_files(XDR *xd, gmx_bool bRead, - gmx_file_position_t **p_outputfiles, int *nfiles, +static int do_cpt_files(XDR *xd, gmx_bool bRead, + gmx_file_position_t **p_outputfiles, int *nfiles, FILE *list, int file_version) { - int i,j; - gmx_off_t offset; - gmx_off_t mask = 0xFFFFFFFFL; - int offset_high,offset_low; - char *buf; + int i, j; + gmx_off_t offset; + gmx_off_t mask = 0xFFFFFFFFL; + int offset_high, offset_low; + char *buf; gmx_file_position_t *outputfiles; - if (do_cpt_int(xd,"number of output files",nfiles,list) != 0) + if (do_cpt_int(xd, "number of output files", nfiles, list) != 0) { return -1; } - if(bRead) + if (bRead) { - snew(*p_outputfiles,*nfiles); + snew(*p_outputfiles, *nfiles); } outputfiles = *p_outputfiles; - for(i=0;i<*nfiles;i++) + for (i = 0; i < *nfiles; i++) { /* 64-bit XDR numbers are not portable, so it is stored as separate high/low fractions */ - if(bRead) + if (bRead) { - do_cpt_string_err(xd,bRead,"output filename",&buf,list); - strncpy(outputfiles[i].filename,buf,CPTSTRLEN-1); - if(list==NULL) + do_cpt_string_err(xd, bRead, "output filename", &buf, list); + strncpy(outputfiles[i].filename, buf, CPTSTRLEN-1); + if (list == NULL) { - sfree(buf); + sfree(buf); } - if (do_cpt_int(xd,"file_offset_high",&offset_high,list) != 0) + if (do_cpt_int(xd, "file_offset_high", &offset_high, list) != 0) { return -1; } - if (do_cpt_int(xd,"file_offset_low",&offset_low,list) != 0) + if (do_cpt_int(xd, "file_offset_low", &offset_low, list) != 0) { return -1; } @@ -1322,7 +1334,7 @@ static int do_cpt_files(XDR *xd, gmx_bool bRead, else { buf = outputfiles[i].filename; - do_cpt_string_err(xd,bRead,"output filename",&buf,list); + do_cpt_string_err(xd, bRead, "output filename", &buf, list); /* writing */ offset = outputfiles[i].offset; if (offset == -1) @@ -1340,28 +1352,28 @@ static int do_cpt_files(XDR *xd, gmx_bool bRead, offset_high = 0; #endif } - if (do_cpt_int(xd,"file_offset_high",&offset_high,list) != 0) + if (do_cpt_int(xd, "file_offset_high", &offset_high, list) != 0) { return -1; } - if (do_cpt_int(xd,"file_offset_low",&offset_low,list) != 0) + if (do_cpt_int(xd, "file_offset_low", &offset_low, list) != 0) { return -1; } } if (file_version >= 8) { - if (do_cpt_int(xd,"file_checksum_size",&(outputfiles[i].chksum_size), + if (do_cpt_int(xd, "file_checksum_size", &(outputfiles[i].chksum_size), list) != 0) { return -1; } - if (do_cpt_u_chars(xd,"file_checksum",16,outputfiles[i].chksum,list) != 0) + if (do_cpt_u_chars(xd, "file_checksum", 16, outputfiles[i].chksum, list) != 0) { return -1; } - } - else + } + else { outputfiles[i].chksum_size = -1; } @@ -1370,31 +1382,31 @@ static int do_cpt_files(XDR *xd, gmx_bool bRead, } -void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep, - FILE *fplog,t_commrec *cr, - int eIntegrator,int simulation_part, +void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep, + FILE *fplog, t_commrec *cr, + int eIntegrator, int simulation_part, gmx_bool bExpanded, int elamstats, - gmx_large_int_t step,double t,t_state *state) + gmx_large_int_t step, double t, t_state *state) { - t_fileio *fp; - int file_version; - char *version; - char *btime; - char *buser; - char *bhost; - int double_prec; - char *fprog; - char *fntemp; /* the temporary checkpoint file name */ - time_t now; - char timebuf[STRLEN]; - int nppnodes,npmenodes,flag_64bit; - char buf[1024],suffix[5+STEPSTRSIZE],sbuf[STEPSTRSIZE]; + t_fileio *fp; + int file_version; + char *version; + char *btime; + char *buser; + char *bhost; + int double_prec; + char *fprog; + char *fntemp; /* the temporary checkpoint file name */ + time_t now; + char timebuf[STRLEN]; + int nppnodes, npmenodes, flag_64bit; + char buf[1024], suffix[5+STEPSTRSIZE], sbuf[STEPSTRSIZE]; gmx_file_position_t *outputfiles; - int noutputfiles; - char *ftime; - int flags_eks,flags_enh,flags_dfh,i; - t_fileio *ret; - + int noutputfiles; + char *ftime; + int flags_eks, flags_enh, flags_dfh, i; + t_fileio *ret; + if (PAR(cr)) { if (DOMAINDECOMP(cr)) @@ -1416,31 +1428,31 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep, /* make the new temporary filename */ snew(fntemp, strlen(fn)+5+STEPSTRSIZE); - strcpy(fntemp,fn); + strcpy(fntemp, fn); fntemp[strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1] = '\0'; - sprintf(suffix,"_%s%s","step",gmx_step_str(step,sbuf)); - strcat(fntemp,suffix); - strcat(fntemp,fn+strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1); - + sprintf(suffix, "_%s%s", "step", gmx_step_str(step, sbuf)); + strcat(fntemp, suffix); + strcat(fntemp, fn+strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1); + time(&now); - gmx_ctime_r(&now,timebuf,STRLEN); + gmx_ctime_r(&now, timebuf, STRLEN); if (fplog) - { - fprintf(fplog,"Writing checkpoint, step %s at %s\n\n", - gmx_step_str(step,buf),timebuf); + { + fprintf(fplog, "Writing checkpoint, step %s at %s\n\n", + gmx_step_str(step, buf), timebuf); } - + /* Get offsets for open files */ gmx_fio_get_output_file_positions(&outputfiles, &noutputfiles); - fp = gmx_fio_open(fntemp,"w"); - + fp = gmx_fio_open(fntemp, "w"); + if (state->ekinstate.bUpToDate) { flags_eks = - ((1<enerhist.dht) { flags_enh |= ( (1<< eenhENERGY_DELTA_H_NN) | - (1<< eenhENERGY_DELTA_H_LIST) | + (1<< eenhENERGY_DELTA_H_LIST) | (1<< eenhENERGY_DELTA_H_STARTTIME) | (1<< eenhENERGY_DELTA_H_STARTLAMBDA) ); } @@ -1484,10 +1496,12 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep, flags_dfh |= ((1<dd->nc : NULL,&npmenodes, - &state->natoms,&state->ngtc,&state->nnhpres, - &state->nhchainlength,&(state->dfhist.nlambda),&state->flags,&flags_eks,&flags_enh,&flags_dfh, + + do_cpt_header(gmx_fio_getxdr(fp), FALSE, &file_version, + &version, &btime, &buser, &bhost, &double_prec, &fprog, &ftime, + &eIntegrator, &simulation_part, &step, &t, &nppnodes, + DOMAINDECOMP(cr) ? cr->dd->nc : NULL, &npmenodes, + &state->natoms, &state->ngtc, &state->nnhpres, + &state->nhchainlength, &(state->dfhist.nlambda), &state->flags, &flags_eks, &flags_enh, &flags_dfh, &state->edsamstate.nED, NULL); - + sfree(version); sfree(btime); sfree(buser); sfree(bhost); sfree(fprog); - if((do_cpt_state(gmx_fio_getxdr(fp),FALSE,state->flags,state,TRUE,NULL) < 0) || - (do_cpt_ekinstate(gmx_fio_getxdr(fp),FALSE,flags_eks,&state->ekinstate,NULL) < 0)|| - (do_cpt_enerhist(gmx_fio_getxdr(fp),FALSE,flags_enh,&state->enerhist,NULL) < 0) || - (do_cpt_df_hist(gmx_fio_getxdr(fp),FALSE,flags_dfh,&state->dfhist,NULL) < 0) || - (do_cpt_EDstate(gmx_fio_getxdr(fp),FALSE,&state->edsamstate,NULL) < 0) || - (do_cpt_files(gmx_fio_getxdr(fp),FALSE,&outputfiles,&noutputfiles,NULL, - file_version) < 0)) + if ((do_cpt_state(gmx_fio_getxdr(fp), FALSE, state->flags, state, TRUE, NULL) < 0) || + (do_cpt_ekinstate(gmx_fio_getxdr(fp), FALSE, flags_eks, &state->ekinstate, NULL) < 0) || + (do_cpt_enerhist(gmx_fio_getxdr(fp), FALSE, flags_enh, &state->enerhist, NULL) < 0) || + (do_cpt_df_hist(gmx_fio_getxdr(fp), FALSE, flags_dfh, &state->dfhist, NULL) < 0) || + (do_cpt_EDstate(gmx_fio_getxdr(fp), FALSE, &state->edsamstate, NULL) < 0) || + (do_cpt_files(gmx_fio_getxdr(fp), FALSE, &outputfiles, &noutputfiles, NULL, + file_version) < 0)) { gmx_file("Cannot read/write checkpoint; corrupt file, or maybe you are out of disk space?"); } - do_cpt_footer(gmx_fio_getxdr(fp),FALSE,file_version); + do_cpt_footer(gmx_fio_getxdr(fp), FALSE, file_version); - /* we really, REALLY, want to make sure to physically write the checkpoint, + /* we really, REALLY, want to make sure to physically write the checkpoint, and all the files it depends on, out to disk. Because we've opened the checkpoint with gmx_fio_open(), it's in our list of open files. */ - ret=gmx_fio_all_output_fsync(); + ret = gmx_fio_all_output_fsync(); if (ret) { @@ -1544,7 +1558,7 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep, "Cannot fsync '%s'; maybe you are out of disk space?", gmx_fio_getname(ret)); - if (getenv(GMX_IGNORE_FSYNC_FAILURE_ENV)==NULL) + if (getenv(GMX_IGNORE_FSYNC_FAILURE_ENV) == NULL) { gmx_file(buf); } @@ -1554,7 +1568,7 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep, } } - if( gmx_fio_close(fp) != 0) + if (gmx_fio_close(fp) != 0) { gmx_file("Cannot read/write checkpoint; corrupt file, or maybe you are out of disk space?"); } @@ -1566,10 +1580,10 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep, if (gmx_fexist(fn)) { /* Rename the previous checkpoint file */ - strcpy(buf,fn); + strcpy(buf, fn); buf[strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1] = '\0'; - strcat(buf,"_prev"); - strcat(buf,fn+strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1); + strcat(buf, "_prev"); + strcat(buf, fn+strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1); #ifndef GMX_FAHCORE /* we copy here so that if something goes wrong between now and * the rename below, there's always a state.cpt. @@ -1577,7 +1591,7 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep, * this copying should be unneccesary. */ gmx_file_copy(fn, buf, FALSE); - /* We don't really care if this fails: + /* We don't really care if this fails: * there's already a new checkpoint. */ #else @@ -1594,27 +1608,28 @@ void write_checkpoint(const char *fn,gmx_bool bNumberAndKeep, sfree(fntemp); #ifdef GMX_FAHCORE - /*code for alternate checkpointing scheme. moved from top of loop over - steps */ + /*code for alternate checkpointing scheme. moved from top of loop over + steps */ fcRequestCheckPoint(); - if ( fcCheckPointParallel( cr->nodeid, NULL,0) == 0 ) { - gmx_fatal( 3,__FILE__,__LINE__, "Checkpoint error on step %d\n", step ); + if (fcCheckPointParallel( cr->nodeid, NULL, 0) == 0) + { + gmx_fatal( 3, __FILE__, __LINE__, "Checkpoint error on step %d\n", step ); } #endif /* end GMX_FAHCORE block */ } -static void print_flag_mismatch(FILE *fplog,int sflags,int fflags) +static void print_flag_mismatch(FILE *fplog, int sflags, int fflags) { int i; - - fprintf(fplog,"\nState entry mismatch between the simulation and the checkpoint file\n"); - fprintf(fplog,"Entries which are not present in the checkpoint file will not be updated\n"); - fprintf(fplog," %24s %11s %11s\n","","simulation","checkpoint"); - for(i=0; innodes ,npp_f+npme_f ,&mm); + + check_string(fplog, "Version", VERSION, version, &mm); + check_string(fplog, "Build time", BUILD_TIME, btime, &mm); + check_string(fplog, "Build user", BUILD_USER, buser, &mm); + check_string(fplog, "Build host", BUILD_HOST, bhost, &mm); + check_int (fplog, "Double prec.", GMX_CPT_BUILD_DP, double_prec, &mm); + check_string(fplog, "Program name", Program(), fprog, &mm); + + check_int (fplog, "#nodes", cr->nnodes, npp_f+npme_f, &mm); if (bPartDecomp) { dd_nc[XX] = 1; @@ -1679,7 +1694,7 @@ static void check_match(FILE *fplog, } if (cr->nnodes > 1) { - check_int (fplog,"#PME-nodes" ,cr->npmenodes,npme_f ,&mm); + check_int (fplog, "#PME-nodes", cr->npmenodes, npme_f, &mm); npp = cr->nnodes; if (cr->npmenodes >= 0) @@ -1688,70 +1703,70 @@ static void check_match(FILE *fplog, } if (npp == npp_f) { - check_int (fplog,"#DD-cells[x]",dd_nc[XX] ,dd_nc_f[XX],&mm); - check_int (fplog,"#DD-cells[y]",dd_nc[YY] ,dd_nc_f[YY],&mm); - check_int (fplog,"#DD-cells[z]",dd_nc[ZZ] ,dd_nc_f[ZZ],&mm); + check_int (fplog, "#DD-cells[x]", dd_nc[XX], dd_nc_f[XX], &mm); + check_int (fplog, "#DD-cells[y]", dd_nc[YY], dd_nc_f[YY], &mm); + check_int (fplog, "#DD-cells[z]", dd_nc[ZZ], dd_nc_f[ZZ], &mm); } } - + if (mm) { - fprintf(stderr, - "Gromacs binary or parallel settings not identical to previous run.\n" - "Continuation is exact, but is not guaranteed to be binary identical%s.\n\n", - fplog ? ",\n see the log file for details" : ""); - + fprintf(stderr, + "Gromacs binary or parallel settings not identical to previous run.\n" + "Continuation is exact, but is not guaranteed to be binary identical%s.\n\n", + fplog ? ",\n see the log file for details" : ""); + if (fplog) { - fprintf(fplog, - "Gromacs binary or parallel settings not identical to previous run.\n" - "Continuation is exact, but is not guaranteed to be binary identical.\n\n"); - } + fprintf(fplog, + "Gromacs binary or parallel settings not identical to previous run.\n" + "Continuation is exact, but is not guaranteed to be binary identical.\n\n"); + } } } -static void read_checkpoint(const char *fn,FILE **pfplog, - t_commrec *cr,gmx_bool bPartDecomp,ivec dd_nc, - int eIntegrator, int *init_fep_state, gmx_large_int_t *step,double *t, - t_state *state,gmx_bool *bReadRNG,gmx_bool *bReadEkin, +static void read_checkpoint(const char *fn, FILE **pfplog, + t_commrec *cr, gmx_bool bPartDecomp, ivec dd_nc, + int eIntegrator, int *init_fep_state, gmx_large_int_t *step, double *t, + t_state *state, gmx_bool *bReadRNG, gmx_bool *bReadEkin, int *simulation_part, - gmx_bool bAppendOutputFiles,gmx_bool bForceAppend) + gmx_bool bAppendOutputFiles, gmx_bool bForceAppend) { - t_fileio *fp; - int i,j,rc; - int file_version; - char *version,*btime,*buser,*bhost,*fprog,*ftime; - int double_prec; - char filename[STRLEN],buf[STEPSTRSIZE]; - int nppnodes,eIntegrator_f,nppnodes_f,npmenodes_f; - ivec dd_nc_f; - int natoms,ngtc,nnhpres,nhchainlength,nlambda,fflags,flags_eks,flags_enh,flags_dfh; - int d; - int ret; + t_fileio *fp; + int i, j, rc; + int file_version; + char *version, *btime, *buser, *bhost, *fprog, *ftime; + int double_prec; + char filename[STRLEN], buf[STEPSTRSIZE]; + int nppnodes, eIntegrator_f, nppnodes_f, npmenodes_f; + ivec dd_nc_f; + int natoms, ngtc, nnhpres, nhchainlength, nlambda, fflags, flags_eks, flags_enh, flags_dfh; + int d; + int ret; gmx_file_position_t *outputfiles; - int nfiles; - t_fileio *chksum_file; - FILE* fplog = *pfplog; - unsigned char digest[16]; + int nfiles; + t_fileio *chksum_file; + FILE * fplog = *pfplog; + unsigned char digest[16]; #ifndef GMX_NATIVE_WINDOWS - struct flock fl; /* don't initialize here: the struct order is OS - dependent! */ + struct flock fl; /* don't initialize here: the struct order is OS + dependent! */ #endif - const char *int_warn= - "WARNING: The checkpoint file was generated with integrator %s,\n" - " while the simulation uses integrator %s\n\n"; - const char *sd_note= + const char *int_warn = + "WARNING: The checkpoint file was generated with integrator %s,\n" + " while the simulation uses integrator %s\n\n"; + const char *sd_note = "NOTE: The checkpoint file was for %d nodes doing SD or BD,\n" " while the simulation uses %d SD or BD nodes,\n" " continuation will be exact, except for the random state\n\n"; - + #ifndef GMX_NATIVE_WINDOWS - fl.l_type=F_WRLCK; - fl.l_whence=SEEK_SET; - fl.l_start=0; - fl.l_len=0; - fl.l_pid=0; + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_pid = 0; #endif if (PARTDECOMP(cr)) @@ -1759,93 +1774,93 @@ static void read_checkpoint(const char *fn,FILE **pfplog, gmx_fatal(FARGS, "read_checkpoint not (yet) supported with particle decomposition"); } - - fp = gmx_fio_open(fn,"r"); - do_cpt_header(gmx_fio_getxdr(fp),TRUE,&file_version, - &version,&btime,&buser,&bhost,&double_prec,&fprog,&ftime, - &eIntegrator_f,simulation_part,step,t, - &nppnodes_f,dd_nc_f,&npmenodes_f, - &natoms,&ngtc,&nnhpres,&nhchainlength,&nlambda, - &fflags,&flags_eks,&flags_enh,&flags_dfh, - &state->edsamstate.nED,NULL); + + fp = gmx_fio_open(fn, "r"); + do_cpt_header(gmx_fio_getxdr(fp), TRUE, &file_version, + &version, &btime, &buser, &bhost, &double_prec, &fprog, &ftime, + &eIntegrator_f, simulation_part, step, t, + &nppnodes_f, dd_nc_f, &npmenodes_f, + &natoms, &ngtc, &nnhpres, &nhchainlength, &nlambda, + &fflags, &flags_eks, &flags_enh, &flags_dfh, + &state->edsamstate.nED, NULL); if (bAppendOutputFiles && file_version >= 13 && double_prec != GMX_CPT_BUILD_DP) { - gmx_fatal(FARGS,"Output file appending requested, but the code and checkpoint file precision (single/double) don't match"); + gmx_fatal(FARGS, "Output file appending requested, but the code and checkpoint file precision (single/double) don't match"); } - + if (cr == NULL || MASTER(cr)) { - fprintf(stderr,"\nReading checkpoint file %s generated: %s\n\n", - fn,ftime); + fprintf(stderr, "\nReading checkpoint file %s generated: %s\n\n", + fn, ftime); } - - /* This will not be written if we do appending, since fplog is still NULL then */ + + /* This will not be written if we do appending, since fplog is still NULL then */ if (fplog) { - fprintf(fplog,"\n"); - fprintf(fplog,"Reading checkpoint file %s\n",fn); - fprintf(fplog," file generated by: %s\n",fprog); - fprintf(fplog," file generated at: %s\n",ftime); - fprintf(fplog," GROMACS build time: %s\n",btime); - fprintf(fplog," GROMACS build user: %s\n",buser); - fprintf(fplog," GROMACS build host: %s\n",bhost); - fprintf(fplog," GROMACS double prec.: %d\n",double_prec); - fprintf(fplog," simulation part #: %d\n",*simulation_part); - fprintf(fplog," step: %s\n",gmx_step_str(*step,buf)); - fprintf(fplog," time: %f\n",*t); - fprintf(fplog,"\n"); - } - + fprintf(fplog, "\n"); + fprintf(fplog, "Reading checkpoint file %s\n", fn); + fprintf(fplog, " file generated by: %s\n", fprog); + fprintf(fplog, " file generated at: %s\n", ftime); + fprintf(fplog, " GROMACS build time: %s\n", btime); + fprintf(fplog, " GROMACS build user: %s\n", buser); + fprintf(fplog, " GROMACS build host: %s\n", bhost); + fprintf(fplog, " GROMACS double prec.: %d\n", double_prec); + fprintf(fplog, " simulation part #: %d\n", *simulation_part); + fprintf(fplog, " step: %s\n", gmx_step_str(*step, buf)); + fprintf(fplog, " time: %f\n", *t); + fprintf(fplog, "\n"); + } + if (natoms != state->natoms) { - gmx_fatal(FARGS,"Checkpoint file is for a system of %d atoms, while the current system consists of %d atoms",natoms,state->natoms); + gmx_fatal(FARGS, "Checkpoint file is for a system of %d atoms, while the current system consists of %d atoms", natoms, state->natoms); } if (ngtc != state->ngtc) { - gmx_fatal(FARGS,"Checkpoint file is for a system of %d T-coupling groups, while the current system consists of %d T-coupling groups",ngtc,state->ngtc); + gmx_fatal(FARGS, "Checkpoint file is for a system of %d T-coupling groups, while the current system consists of %d T-coupling groups", ngtc, state->ngtc); } if (nnhpres != state->nnhpres) { - gmx_fatal(FARGS,"Checkpoint file is for a system of %d NH-pressure-coupling variables, while the current system consists of %d NH-pressure-coupling variables",nnhpres,state->nnhpres); + gmx_fatal(FARGS, "Checkpoint file is for a system of %d NH-pressure-coupling variables, while the current system consists of %d NH-pressure-coupling variables", nnhpres, state->nnhpres); } if (nlambda != state->dfhist.nlambda) { - gmx_fatal(FARGS,"Checkpoint file is for a system with %d lambda states, while the current system consists of %d lambda states",nlambda,state->dfhist.nlambda); + gmx_fatal(FARGS, "Checkpoint file is for a system with %d lambda states, while the current system consists of %d lambda states", nlambda, state->dfhist.nlambda); } - init_gtc_state(state,state->ngtc,state->nnhpres,nhchainlength); /* need to keep this here to keep the tpr format working */ + init_gtc_state(state, state->ngtc, state->nnhpres, nhchainlength); /* need to keep this here to keep the tpr format working */ /* write over whatever was read; we use the number of Nose-Hoover chains from the checkpoint */ - + if (eIntegrator_f != eIntegrator) { if (MASTER(cr)) { - fprintf(stderr,int_warn,EI(eIntegrator_f),EI(eIntegrator)); + fprintf(stderr, int_warn, EI(eIntegrator_f), EI(eIntegrator)); + } + if (bAppendOutputFiles) + { + gmx_fatal(FARGS, + "Output file appending requested, but input/checkpoint integrators do not match.\n" + "Stopping the run to prevent you from ruining all your data...\n" + "If you _really_ know what you are doing, try with the -noappend option.\n"); } - if(bAppendOutputFiles) - { - gmx_fatal(FARGS, - "Output file appending requested, but input/checkpoint integrators do not match.\n" - "Stopping the run to prevent you from ruining all your data...\n" - "If you _really_ know what you are doing, try with the -noappend option.\n"); - } if (fplog) { - fprintf(fplog,int_warn,EI(eIntegrator_f),EI(eIntegrator)); + fprintf(fplog, int_warn, EI(eIntegrator_f), EI(eIntegrator)); } } if (!PAR(cr)) { - nppnodes = 1; + nppnodes = 1; cr->npmenodes = 0; } else if (bPartDecomp) { - nppnodes = cr->nnodes; + nppnodes = cr->nnodes; cr->npmenodes = 0; } else if (cr->nnodes == nppnodes_f + npmenodes_f) @@ -1857,7 +1872,7 @@ static void read_checkpoint(const char *fn,FILE **pfplog, nppnodes = cr->nnodes - cr->npmenodes; if (nppnodes == nppnodes_f) { - for(d=0; dnrng = nppnodes*gmx_rng_n(); state->nrngi = nppnodes; } - + *bReadRNG = TRUE; if (fflags != state->flags) { - + if (MASTER(cr)) { - if(bAppendOutputFiles) - { - gmx_fatal(FARGS, - "Output file appending requested, but input and checkpoint states are not identical.\n" - "Stopping the run to prevent you from ruining all your data...\n" - "You can try with the -noappend option, and get more info in the log file.\n"); - } - + if (bAppendOutputFiles) + { + gmx_fatal(FARGS, + "Output file appending requested, but input and checkpoint states are not identical.\n" + "Stopping the run to prevent you from ruining all your data...\n" + "You can try with the -noappend option, and get more info in the log file.\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"); + 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 { @@ -1906,11 +1921,11 @@ static void read_checkpoint(const char *fn,FILE **pfplog, " see the log file for details\n\n"); } } - - if(fplog) - { - print_flag_mismatch(fplog,state->flags,fflags); - } + + if (fplog) + { + print_flag_mismatch(fplog, state->flags, fflags); + } } else { @@ -1920,43 +1935,43 @@ static void read_checkpoint(const char *fn,FILE **pfplog, *bReadRNG = FALSE; if (MASTER(cr)) { - fprintf(stderr,sd_note,nppnodes_f,nppnodes); + fprintf(stderr, sd_note, nppnodes_f, nppnodes); } if (fplog) { - fprintf(fplog ,sd_note,nppnodes_f,nppnodes); + fprintf(fplog, sd_note, nppnodes_f, nppnodes); } } if (MASTER(cr)) { - check_match(fplog,version,btime,buser,bhost,double_prec,fprog, - cr,bPartDecomp,nppnodes_f,npmenodes_f,dd_nc,dd_nc_f); + check_match(fplog, version, btime, buser, bhost, double_prec, fprog, + cr, bPartDecomp, nppnodes_f, npmenodes_f, dd_nc, dd_nc_f); } } - ret = do_cpt_state(gmx_fio_getxdr(fp),TRUE,fflags,state,*bReadRNG,NULL); + ret = do_cpt_state(gmx_fio_getxdr(fp), TRUE, fflags, state, *bReadRNG, NULL); *init_fep_state = state->fep_state; /* there should be a better way to do this than setting it here. Investigate for 5.0. */ if (ret) { cp_error(); } - ret = do_cpt_ekinstate(gmx_fio_getxdr(fp),TRUE, - flags_eks,&state->ekinstate,NULL); + ret = do_cpt_ekinstate(gmx_fio_getxdr(fp), TRUE, + flags_eks, &state->ekinstate, NULL); if (ret) { cp_error(); } *bReadEkin = ((flags_eks & (1<enerhist,NULL); + + ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE, + flags_enh, &state->enerhist, NULL); if (ret) { cp_error(); } - ret = do_cpt_EDstate(gmx_fio_getxdr(fp),TRUE,&state->edsamstate,NULL); + ret = do_cpt_EDstate(gmx_fio_getxdr(fp), TRUE, &state->edsamstate, NULL); if (ret) { cp_error(); @@ -1964,80 +1979,80 @@ static void read_checkpoint(const char *fn,FILE **pfplog, if (file_version < 6) { - const char *warn="Reading checkpoint file in old format, assuming that the run that generated this file started at step 0, if this is not the case the averages stored in the energy file will be incorrect."; + const char *warn = "Reading checkpoint file in old format, assuming that the run that generated this file started at step 0, if this is not the case the averages stored in the energy file will be incorrect."; - fprintf(stderr,"\nWARNING: %s\n\n",warn); + fprintf(stderr, "\nWARNING: %s\n\n", warn); if (fplog) { - fprintf(fplog,"\nWARNING: %s\n\n",warn); + fprintf(fplog, "\nWARNING: %s\n\n", warn); } state->enerhist.nsum = *step; state->enerhist.nsum_sim = *step; } - ret = do_cpt_df_hist(gmx_fio_getxdr(fp),TRUE, - flags_dfh,&state->dfhist,NULL); + ret = do_cpt_df_hist(gmx_fio_getxdr(fp), TRUE, + flags_dfh, &state->dfhist, NULL); + if (ret) + { + cp_error(); + } + + ret = do_cpt_files(gmx_fio_getxdr(fp), TRUE, &outputfiles, &nfiles, NULL, file_version); if (ret) { cp_error(); } - ret = do_cpt_files(gmx_fio_getxdr(fp),TRUE,&outputfiles,&nfiles,NULL,file_version); - if (ret) - { - cp_error(); - } - - ret = do_cpt_footer(gmx_fio_getxdr(fp),TRUE,file_version); + ret = do_cpt_footer(gmx_fio_getxdr(fp), TRUE, file_version); if (ret) { cp_error(); } - if( gmx_fio_close(fp) != 0) - { + if (gmx_fio_close(fp) != 0) + { gmx_file("Cannot read/write checkpoint; corrupt file, or maybe you are out of disk space?"); - } - + } + sfree(fprog); sfree(ftime); sfree(btime); sfree(buser); sfree(bhost); - - /* If the user wants to append to output files, + + /* If the user wants to append to output files, * we use the file pointer positions of the output files stored * in the checkpoint file and truncate the files such that any frames * written after the checkpoint time are removed. * All files are md5sum checked such that we can be sure that * we do not truncate other (maybe imprortant) files. - */ + */ if (bAppendOutputFiles) { - if (fn2ftp(outputfiles[0].filename)!=efLOG) + if (fn2ftp(outputfiles[0].filename) != efLOG) { - /* make sure first file is log file so that it is OK to use it for + /* make sure first file is log file so that it is OK to use it for * locking */ - gmx_fatal(FARGS,"The first output file should always be the log " + gmx_fatal(FARGS, "The first output file should always be the log " "file but instead is: %s. Cannot do appending because of this condition.", outputfiles[0].filename); } - for(i=0;ieI,&(ir->fepvals->init_fep_state),&step,&t,state,bReadRNG,bReadEkin, - &ir->simulation_part,bAppend,bForceAppend); - } - if (PAR(cr)) { - gmx_bcast(sizeof(cr->npmenodes),&cr->npmenodes,cr); - gmx_bcast(DIM*sizeof(dd_nc[0]),dd_nc,cr); - gmx_bcast(sizeof(step),&step,cr); - gmx_bcast(sizeof(*bReadRNG),bReadRNG,cr); - gmx_bcast(sizeof(*bReadEkin),bReadEkin,cr); + double t; + + if (SIMMASTER(cr)) + { + /* Read the state from the checkpoint file */ + read_checkpoint(fn, fplog, + cr, bPartDecomp, dd_nc, + ir->eI, &(ir->fepvals->init_fep_state), &step, &t, state, bReadRNG, bReadEkin, + &ir->simulation_part, bAppend, bForceAppend); + } + if (PAR(cr)) + { + gmx_bcast(sizeof(cr->npmenodes), &cr->npmenodes, cr); + gmx_bcast(DIM*sizeof(dd_nc[0]), dd_nc, cr); + gmx_bcast(sizeof(step), &step, cr); + gmx_bcast(sizeof(*bReadRNG), bReadRNG, cr); + gmx_bcast(sizeof(*bReadEkin), bReadEkin, cr); } ir->bContinuation = TRUE; if (ir->nsteps >= 0) @@ -2175,77 +2192,77 @@ void load_checkpoint(const char *fn,FILE **fplog, ir->nsteps += ir->init_step - step; } ir->init_step = step; - ir->simulation_part += 1; + ir->simulation_part += 1; } -static void read_checkpoint_data(t_fileio *fp,int *simulation_part, - gmx_large_int_t *step,double *t,t_state *state, +static void read_checkpoint_data(t_fileio *fp, int *simulation_part, + gmx_large_int_t *step, double *t, t_state *state, gmx_bool bReadRNG, - int *nfiles,gmx_file_position_t **outputfiles) + int *nfiles, gmx_file_position_t **outputfiles) { - int file_version; - char *version,*btime,*buser,*bhost,*fprog,*ftime; - int double_prec; - int eIntegrator; - int nppnodes,npme; - ivec dd_nc; - int flags_eks,flags_enh,flags_dfh; - int nfiles_loc; - gmx_file_position_t *files_loc=NULL; - int ret; - - do_cpt_header(gmx_fio_getxdr(fp),TRUE,&file_version, - &version,&btime,&buser,&bhost,&double_prec,&fprog,&ftime, - &eIntegrator,simulation_part,step,t,&nppnodes,dd_nc,&npme, - &state->natoms,&state->ngtc,&state->nnhpres,&state->nhchainlength, - &(state->dfhist.nlambda),&state->flags,&flags_eks,&flags_enh,&flags_dfh, - &state->edsamstate.nED,NULL); + int file_version; + char *version, *btime, *buser, *bhost, *fprog, *ftime; + int double_prec; + int eIntegrator; + int nppnodes, npme; + ivec dd_nc; + int flags_eks, flags_enh, flags_dfh; + int nfiles_loc; + gmx_file_position_t *files_loc = NULL; + int ret; + + do_cpt_header(gmx_fio_getxdr(fp), TRUE, &file_version, + &version, &btime, &buser, &bhost, &double_prec, &fprog, &ftime, + &eIntegrator, simulation_part, step, t, &nppnodes, dd_nc, &npme, + &state->natoms, &state->ngtc, &state->nnhpres, &state->nhchainlength, + &(state->dfhist.nlambda), &state->flags, &flags_eks, &flags_enh, &flags_dfh, + &state->edsamstate.nED, NULL); ret = - do_cpt_state(gmx_fio_getxdr(fp),TRUE,state->flags,state,bReadRNG,NULL); + do_cpt_state(gmx_fio_getxdr(fp), TRUE, state->flags, state, bReadRNG, NULL); if (ret) { cp_error(); } - ret = do_cpt_ekinstate(gmx_fio_getxdr(fp),TRUE, - flags_eks,&state->ekinstate,NULL); + ret = do_cpt_ekinstate(gmx_fio_getxdr(fp), TRUE, + flags_eks, &state->ekinstate, NULL); if (ret) { cp_error(); } - ret = do_cpt_enerhist(gmx_fio_getxdr(fp),TRUE, - flags_enh,&state->enerhist,NULL); + ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE, + flags_enh, &state->enerhist, NULL); if (ret) { cp_error(); } - ret = do_cpt_df_hist(gmx_fio_getxdr(fp),TRUE, - flags_dfh,&state->dfhist,NULL); + ret = do_cpt_df_hist(gmx_fio_getxdr(fp), TRUE, + flags_dfh, &state->dfhist, NULL); if (ret) { cp_error(); } - ret = do_cpt_EDstate(gmx_fio_getxdr(fp),TRUE,&state->edsamstate,NULL); + ret = do_cpt_EDstate(gmx_fio_getxdr(fp), TRUE, &state->edsamstate, NULL); if (ret) { cp_error(); } - ret = do_cpt_files(gmx_fio_getxdr(fp),TRUE, + ret = do_cpt_files(gmx_fio_getxdr(fp), TRUE, outputfiles != NULL ? outputfiles : &files_loc, outputfiles != NULL ? nfiles : &nfiles_loc, - NULL,file_version); + NULL, file_version); if (files_loc != NULL) { sfree(files_loc); } - + if (ret) { cp_error(); } - - ret = do_cpt_footer(gmx_fio_getxdr(fp),TRUE,file_version); + + ret = do_cpt_footer(gmx_fio_getxdr(fp), TRUE, file_version); if (ret) { cp_error(); @@ -2258,43 +2275,43 @@ static void read_checkpoint_data(t_fileio *fp,int *simulation_part, sfree(bhost); } -void -read_checkpoint_state(const char *fn,int *simulation_part, - gmx_large_int_t *step,double *t,t_state *state) +void +read_checkpoint_state(const char *fn, int *simulation_part, + gmx_large_int_t *step, double *t, t_state *state) { t_fileio *fp; - - fp = gmx_fio_open(fn,"r"); - read_checkpoint_data(fp,simulation_part,step,t,state,FALSE,NULL,NULL); - if( gmx_fio_close(fp) != 0) - { + + fp = gmx_fio_open(fn, "r"); + read_checkpoint_data(fp, simulation_part, step, t, state, FALSE, NULL, NULL); + if (gmx_fio_close(fp) != 0) + { gmx_file("Cannot read/write checkpoint; corrupt file, or maybe you are out of disk space?"); - } + } } -void read_checkpoint_trxframe(t_fileio *fp,t_trxframe *fr) +void read_checkpoint_trxframe(t_fileio *fp, t_trxframe *fr) { - t_state state; - int simulation_part; + t_state state; + int simulation_part; gmx_large_int_t step; - double t; - - init_state(&state,0,0,0,0,0); - - read_checkpoint_data(fp,&simulation_part,&step,&t,&state,FALSE,NULL,NULL); - + double t; + + init_state(&state, 0, 0, 0, 0, 0); + + read_checkpoint_data(fp, &simulation_part, &step, &t, &state, FALSE, NULL, NULL); + fr->natoms = state.natoms; fr->bTitle = FALSE; fr->bStep = TRUE; fr->step = gmx_large_int_to_int(step, - "conversion of checkpoint to trajectory"); - fr->bTime = TRUE; - fr->time = t; - fr->bLambda = TRUE; - fr->lambda = state.lambda[efptFEP]; + "conversion of checkpoint to trajectory"); + fr->bTime = TRUE; + fr->time = t; + fr->bLambda = TRUE; + fr->lambda = state.lambda[efptFEP]; fr->fep_state = state.fep_state; - fr->bAtoms = FALSE; - fr->bX = (state.flags & (1<bAtoms = FALSE; + fr->bX = (state.flags & (1<bX) { fr->x = state.x; @@ -2310,88 +2327,88 @@ void read_checkpoint_trxframe(t_fileio *fp,t_trxframe *fr) fr->bBox = (state.flags & (1<bBox) { - copy_mat(state.box,fr->box); + copy_mat(state.box, fr->box); } done_state(&state); } -void list_checkpoint(const char *fn,FILE *out) +void list_checkpoint(const char *fn, FILE *out) { - t_fileio *fp; - int file_version; - char *version,*btime,*buser,*bhost,*fprog,*ftime; - int double_prec; - int eIntegrator,simulation_part,nppnodes,npme; - gmx_large_int_t step; - double t; - ivec dd_nc; - t_state state; - int flags_eks,flags_enh,flags_dfh; - int indent; - int i,j; - int ret; + t_fileio *fp; + int file_version; + char *version, *btime, *buser, *bhost, *fprog, *ftime; + int double_prec; + int eIntegrator, simulation_part, nppnodes, npme; + gmx_large_int_t step; + double t; + ivec dd_nc; + t_state state; + int flags_eks, flags_enh, flags_dfh; + int indent; + int i, j; + int ret; gmx_file_position_t *outputfiles; - int nfiles; - - init_state(&state,-1,-1,-1,-1,0); - - fp = gmx_fio_open(fn,"r"); - do_cpt_header(gmx_fio_getxdr(fp),TRUE,&file_version, - &version,&btime,&buser,&bhost,&double_prec,&fprog,&ftime, - &eIntegrator,&simulation_part,&step,&t,&nppnodes,dd_nc,&npme, - &state.natoms,&state.ngtc,&state.nnhpres,&state.nhchainlength, - &(state.dfhist.nlambda),&state.flags, - &flags_eks,&flags_enh,&flags_dfh,&state.edsamstate.nED,out); - ret = do_cpt_state(gmx_fio_getxdr(fp),TRUE,state.flags,&state,TRUE,out); + int nfiles; + + init_state(&state, -1, -1, -1, -1, 0); + + fp = gmx_fio_open(fn, "r"); + do_cpt_header(gmx_fio_getxdr(fp), TRUE, &file_version, + &version, &btime, &buser, &bhost, &double_prec, &fprog, &ftime, + &eIntegrator, &simulation_part, &step, &t, &nppnodes, dd_nc, &npme, + &state.natoms, &state.ngtc, &state.nnhpres, &state.nhchainlength, + &(state.dfhist.nlambda), &state.flags, + &flags_eks, &flags_enh, &flags_dfh, &state.edsamstate.nED, out); + ret = do_cpt_state(gmx_fio_getxdr(fp), TRUE, state.flags, &state, TRUE, out); if (ret) { cp_error(); } - ret = do_cpt_ekinstate(gmx_fio_getxdr(fp),TRUE, - flags_eks,&state.ekinstate,out); + ret = do_cpt_ekinstate(gmx_fio_getxdr(fp), TRUE, + flags_eks, &state.ekinstate, out); if (ret) { cp_error(); } - ret = do_cpt_enerhist(gmx_fio_getxdr(fp),TRUE, - flags_enh,&state.enerhist,out); + ret = do_cpt_enerhist(gmx_fio_getxdr(fp), TRUE, + flags_enh, &state.enerhist, out); if (ret == 0) { - init_df_history(&state.dfhist,state.dfhist.nlambda,0); /* reinitialize state with correct sizes */ - ret = do_cpt_df_hist(gmx_fio_getxdr(fp),TRUE, - flags_dfh,&state.dfhist,out); + init_df_history(&state.dfhist, state.dfhist.nlambda, 0); /* reinitialize state with correct sizes */ + ret = do_cpt_df_hist(gmx_fio_getxdr(fp), TRUE, + flags_dfh, &state.dfhist, out); } if (ret == 0) { - ret = do_cpt_EDstate(gmx_fio_getxdr(fp),TRUE,&state.edsamstate,out); + ret = do_cpt_EDstate(gmx_fio_getxdr(fp), TRUE, &state.edsamstate, out); } if (ret == 0) { - do_cpt_files(gmx_fio_getxdr(fp),TRUE,&outputfiles,&nfiles,out,file_version); - } - + do_cpt_files(gmx_fio_getxdr(fp), TRUE, &outputfiles, &nfiles, out, file_version); + } + if (ret == 0) { - ret = do_cpt_footer(gmx_fio_getxdr(fp),TRUE,file_version); + ret = do_cpt_footer(gmx_fio_getxdr(fp), TRUE, file_version); } - + if (ret) { cp_warning(out); } - if( gmx_fio_close(fp) != 0) - { + if (gmx_fio_close(fp) != 0) + { gmx_file("Cannot read/write checkpoint; corrupt file, or maybe you are out of disk space?"); - } - + } + done_state(&state); } -static gmx_bool exist_output_file(const char *fnm_cp,int nfile,const t_filenm fnm[]) +static gmx_bool exist_output_file(const char *fnm_cp, int nfile, const t_filenm fnm[]) { int i; @@ -2400,45 +2417,46 @@ static gmx_bool exist_output_file(const char *fnm_cp,int nfile,const t_filenm fn */ i = 0; while (i < nfile && - !(is_output(&fnm[i]) && strcmp(fnm_cp,fnm[i].fns[0]) == 0)) + !(is_output(&fnm[i]) && strcmp(fnm_cp, fnm[i].fns[0]) == 0)) { i++; } - + return (i < nfile && gmx_fexist(fnm_cp)); } /* This routine cannot print tons of data, since it is called before the log file is opened. */ gmx_bool read_checkpoint_simulation_part(const char *filename, int *simulation_part, - gmx_large_int_t *cpt_step,t_commrec *cr, - gmx_bool bAppendReq, - int nfile,const t_filenm fnm[], - const char *part_suffix,gmx_bool *bAddPart) + gmx_large_int_t *cpt_step, t_commrec *cr, + gmx_bool bAppendReq, + int nfile, const t_filenm fnm[], + const char *part_suffix, gmx_bool *bAddPart) { - t_fileio *fp; - gmx_large_int_t step=0; - double t; - t_state state; - int nfiles; + t_fileio *fp; + gmx_large_int_t step = 0; + double t; + t_state state; + int nfiles; gmx_file_position_t *outputfiles; - int nexist,f; - gmx_bool bAppend; - char *fn,suf_up[STRLEN]; + int nexist, f; + gmx_bool bAppend; + char *fn, suf_up[STRLEN]; bAppend = FALSE; - if (SIMMASTER(cr)) { - if(!gmx_fexist(filename) || (!(fp = gmx_fio_open(filename,"r")) )) + if (SIMMASTER(cr)) + { + if (!gmx_fexist(filename) || (!(fp = gmx_fio_open(filename, "r")) )) { *simulation_part = 0; } - else + else { - init_state(&state,0,0,0,0,0); + init_state(&state, 0, 0, 0, 0, 0); - read_checkpoint_data(fp,simulation_part,&step,&t,&state,FALSE, - &nfiles,&outputfiles); - if( gmx_fio_close(fp) != 0) + read_checkpoint_data(fp, simulation_part, &step, &t, &state, FALSE, + &nfiles, &outputfiles); + if (gmx_fio_close(fp) != 0) { gmx_file("Cannot read/write checkpoint; corrupt file, or maybe you are out of disk space?"); } @@ -2447,9 +2465,9 @@ gmx_bool read_checkpoint_simulation_part(const char *filename, int *simulation_p if (bAppendReq) { nexist = 0; - for(f=0; f 0 && bAppendReq) { - gmx_bcast(sizeof(bAppend),&bAppend,cr); - gmx_bcast(sizeof(*bAddPart),bAddPart,cr); + gmx_bcast(sizeof(bAppend), &bAppend, cr); + gmx_bcast(sizeof(*bAddPart), bAddPart, cr); } } if (NULL != cpt_step) diff --git a/src/gromacs/gmxlib/cinvsqrtdata.c b/src/gromacs/gmxlib/cinvsqrtdata.c index 405fa477c9..e4bccbbb1f 100644 --- a/src/gromacs/gmxlib/cinvsqrtdata.c +++ b/src/gromacs/gmxlib/cinvsqrtdata.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -38,597 +38,597 @@ #endif -struct gmx_invsqrtdata +struct gmx_invsqrtdata { - unsigned int exptab[256]; /*!< Exponential lookup table */ - unsigned int fracttab[4096]; /*!< Mantissa lookup table */ + unsigned int exptab[256]; /*!< Exponential lookup table */ + unsigned int fracttab[4096]; /*!< Mantissa lookup table */ }; -struct gmx_invsqrtdata -F77_FUNC(gmxinvsqrtdata,GMXINVSQRTDATA) = -{ +struct gmx_invsqrtdata +F77_FUNC(gmxinvsqrtdata, GMXINVSQRTDATA) = +{ /* data for exponent table - 256 floats */ - { - 0x5f000000,0x5e800000,0x5e800000,0x5e000000, - 0x5e000000,0x5d800000,0x5d800000,0x5d000000, - 0x5d000000,0x5c800000,0x5c800000,0x5c000000, - 0x5c000000,0x5b800000,0x5b800000,0x5b000000, - 0x5b000000,0x5a800000,0x5a800000,0x5a000000, - 0x5a000000,0x59800000,0x59800000,0x59000000, - 0x59000000,0x58800000,0x58800000,0x58000000, - 0x58000000,0x57800000,0x57800000,0x57000000, - 0x57000000,0x56800000,0x56800000,0x56000000, - 0x56000000,0x55800000,0x55800000,0x55000000, - 0x55000000,0x54800000,0x54800000,0x54000000, - 0x54000000,0x53800000,0x53800000,0x53000000, - 0x53000000,0x52800000,0x52800000,0x52000000, - 0x52000000,0x51800000,0x51800000,0x51000000, - 0x51000000,0x50800000,0x50800000,0x50000000, - 0x50000000,0x4f800000,0x4f800000,0x4f000000, - 0x4f000000,0x4e800000,0x4e800000,0x4e000000, - 0x4e000000,0x4d800000,0x4d800000,0x4d000000, - 0x4d000000,0x4c800000,0x4c800000,0x4c000000, - 0x4c000000,0x4b800000,0x4b800000,0x4b000000, - 0x4b000000,0x4a800000,0x4a800000,0x4a000000, - 0x4a000000,0x49800000,0x49800000,0x49000000, - 0x49000000,0x48800000,0x48800000,0x48000000, - 0x48000000,0x47800000,0x47800000,0x47000000, - 0x47000000,0x46800000,0x46800000,0x46000000, - 0x46000000,0x45800000,0x45800000,0x45000000, - 0x45000000,0x44800000,0x44800000,0x44000000, - 0x44000000,0x43800000,0x43800000,0x43000000, - 0x43000000,0x42800000,0x42800000,0x42000000, - 0x42000000,0x41800000,0x41800000,0x41000000, - 0x41000000,0x40800000,0x40800000,0x40000000, - 0x40000000,0x3f800000,0x3f800000,0x3f000000, - 0x3f000000,0x3e800000,0x3e800000,0x3e000000, - 0x3e000000,0x3d800000,0x3d800000,0x3d000000, - 0x3d000000,0x3c800000,0x3c800000,0x3c000000, - 0x3c000000,0x3b800000,0x3b800000,0x3b000000, - 0x3b000000,0x3a800000,0x3a800000,0x3a000000, - 0x3a000000,0x39800000,0x39800000,0x39000000, - 0x39000000,0x38800000,0x38800000,0x38000000, - 0x38000000,0x37800000,0x37800000,0x37000000, - 0x37000000,0x36800000,0x36800000,0x36000000, - 0x36000000,0x35800000,0x35800000,0x35000000, - 0x35000000,0x34800000,0x34800000,0x34000000, - 0x34000000,0x33800000,0x33800000,0x33000000, - 0x33000000,0x32800000,0x32800000,0x32000000, - 0x32000000,0x31800000,0x31800000,0x31000000, - 0x31000000,0x30800000,0x30800000,0x30000000, - 0x30000000,0x2f800000,0x2f800000,0x2f000000, - 0x2f000000,0x2e800000,0x2e800000,0x2e000000, - 0x2e000000,0x2d800000,0x2d800000,0x2d000000, - 0x2d000000,0x2c800000,0x2c800000,0x2c000000, - 0x2c000000,0x2b800000,0x2b800000,0x2b000000, - 0x2b000000,0x2a800000,0x2a800000,0x2a000000, - 0x2a000000,0x29800000,0x29800000,0x29000000, - 0x29000000,0x28800000,0x28800000,0x28000000, - 0x28000000,0x27800000,0x27800000,0x27000000, - 0x27000000,0x26800000,0x26800000,0x26000000, - 0x26000000,0x25800000,0x25800000,0x25000000, - 0x25000000,0x24800000,0x24800000,0x24000000, - 0x24000000,0x23800000,0x23800000,0x23000000, - 0x23000000,0x22800000,0x22800000,0x22000000, - 0x22000000,0x21800000,0x21800000,0x21000000, - 0x21000000,0x20800000,0x20800000,0x20000000, - 0x20000000,0x1f800000,0x1f800000,0x1f000000 - } , + { + 0x5f000000, 0x5e800000, 0x5e800000, 0x5e000000, + 0x5e000000, 0x5d800000, 0x5d800000, 0x5d000000, + 0x5d000000, 0x5c800000, 0x5c800000, 0x5c000000, + 0x5c000000, 0x5b800000, 0x5b800000, 0x5b000000, + 0x5b000000, 0x5a800000, 0x5a800000, 0x5a000000, + 0x5a000000, 0x59800000, 0x59800000, 0x59000000, + 0x59000000, 0x58800000, 0x58800000, 0x58000000, + 0x58000000, 0x57800000, 0x57800000, 0x57000000, + 0x57000000, 0x56800000, 0x56800000, 0x56000000, + 0x56000000, 0x55800000, 0x55800000, 0x55000000, + 0x55000000, 0x54800000, 0x54800000, 0x54000000, + 0x54000000, 0x53800000, 0x53800000, 0x53000000, + 0x53000000, 0x52800000, 0x52800000, 0x52000000, + 0x52000000, 0x51800000, 0x51800000, 0x51000000, + 0x51000000, 0x50800000, 0x50800000, 0x50000000, + 0x50000000, 0x4f800000, 0x4f800000, 0x4f000000, + 0x4f000000, 0x4e800000, 0x4e800000, 0x4e000000, + 0x4e000000, 0x4d800000, 0x4d800000, 0x4d000000, + 0x4d000000, 0x4c800000, 0x4c800000, 0x4c000000, + 0x4c000000, 0x4b800000, 0x4b800000, 0x4b000000, + 0x4b000000, 0x4a800000, 0x4a800000, 0x4a000000, + 0x4a000000, 0x49800000, 0x49800000, 0x49000000, + 0x49000000, 0x48800000, 0x48800000, 0x48000000, + 0x48000000, 0x47800000, 0x47800000, 0x47000000, + 0x47000000, 0x46800000, 0x46800000, 0x46000000, + 0x46000000, 0x45800000, 0x45800000, 0x45000000, + 0x45000000, 0x44800000, 0x44800000, 0x44000000, + 0x44000000, 0x43800000, 0x43800000, 0x43000000, + 0x43000000, 0x42800000, 0x42800000, 0x42000000, + 0x42000000, 0x41800000, 0x41800000, 0x41000000, + 0x41000000, 0x40800000, 0x40800000, 0x40000000, + 0x40000000, 0x3f800000, 0x3f800000, 0x3f000000, + 0x3f000000, 0x3e800000, 0x3e800000, 0x3e000000, + 0x3e000000, 0x3d800000, 0x3d800000, 0x3d000000, + 0x3d000000, 0x3c800000, 0x3c800000, 0x3c000000, + 0x3c000000, 0x3b800000, 0x3b800000, 0x3b000000, + 0x3b000000, 0x3a800000, 0x3a800000, 0x3a000000, + 0x3a000000, 0x39800000, 0x39800000, 0x39000000, + 0x39000000, 0x38800000, 0x38800000, 0x38000000, + 0x38000000, 0x37800000, 0x37800000, 0x37000000, + 0x37000000, 0x36800000, 0x36800000, 0x36000000, + 0x36000000, 0x35800000, 0x35800000, 0x35000000, + 0x35000000, 0x34800000, 0x34800000, 0x34000000, + 0x34000000, 0x33800000, 0x33800000, 0x33000000, + 0x33000000, 0x32800000, 0x32800000, 0x32000000, + 0x32000000, 0x31800000, 0x31800000, 0x31000000, + 0x31000000, 0x30800000, 0x30800000, 0x30000000, + 0x30000000, 0x2f800000, 0x2f800000, 0x2f000000, + 0x2f000000, 0x2e800000, 0x2e800000, 0x2e000000, + 0x2e000000, 0x2d800000, 0x2d800000, 0x2d000000, + 0x2d000000, 0x2c800000, 0x2c800000, 0x2c000000, + 0x2c000000, 0x2b800000, 0x2b800000, 0x2b000000, + 0x2b000000, 0x2a800000, 0x2a800000, 0x2a000000, + 0x2a000000, 0x29800000, 0x29800000, 0x29000000, + 0x29000000, 0x28800000, 0x28800000, 0x28000000, + 0x28000000, 0x27800000, 0x27800000, 0x27000000, + 0x27000000, 0x26800000, 0x26800000, 0x26000000, + 0x26000000, 0x25800000, 0x25800000, 0x25000000, + 0x25000000, 0x24800000, 0x24800000, 0x24000000, + 0x24000000, 0x23800000, 0x23800000, 0x23000000, + 0x23000000, 0x22800000, 0x22800000, 0x22000000, + 0x22000000, 0x21800000, 0x21800000, 0x21000000, + 0x21000000, 0x20800000, 0x20800000, 0x20000000, + 0x20000000, 0x1f800000, 0x1f800000, 0x1f000000 + }, /* data for fraction table - 4096 floats */ { - 0x3504f3,0x34f9a4,0x34ee57,0x34e30c,0x34d7c3,0x34cc7c,0x34c137,0x34b5f5, - 0x34aab4,0x349f76,0x34943a,0x348900,0x347dc7,0x347291,0x34675e,0x345c2c, - 0x3450fc,0x3445ce,0x343aa3,0x342f79,0x342452,0x34192c,0x340e09,0x3402e8, - 0x33f7c9,0x33ecac,0x33e191,0x33d678,0x33cb61,0x33c04c,0x33b539,0x33aa28, - 0x339f19,0x33940d,0x338902,0x337df9,0x3372f3,0x3367ee,0x335cec,0x3351eb, - 0x3346ed,0x333bf0,0x3330f6,0x3325fd,0x331b07,0x331013,0x330520,0x32fa30, - 0x32ef41,0x32e455,0x32d96b,0x32ce82,0x32c39c,0x32b8b7,0x32add5,0x32a2f5, - 0x329816,0x328d3a,0x32825f,0x327787,0x326cb0,0x3261dc,0x325709,0x324c38, - 0x32416a,0x32369d,0x322bd2,0x32210a,0x321643,0x320b7e,0x3200bb,0x31f5fa, - 0x31eb3b,0x31e07e,0x31d5c3,0x31cb0a,0x31c053,0x31b59d,0x31aaea,0x31a038, - 0x319589,0x318adb,0x318030,0x317586,0x316ade,0x316038,0x315594,0x314af2, - 0x314052,0x3135b4,0x312b18,0x31207d,0x3115e5,0x310b4e,0x3100b9,0x30f627, - 0x30eb96,0x30e107,0x30d67a,0x30cbee,0x30c165,0x30b6dd,0x30ac58,0x30a1d4, - 0x309752,0x308cd2,0x308254,0x3077d8,0x306d5e,0x3062e5,0x30586e,0x304dfa, - 0x304387,0x303916,0x302ea7,0x302439,0x3019ce,0x300f64,0x3004fc,0x2ffa96, - 0x2ff032,0x2fe5d0,0x2fdb6f,0x2fd111,0x2fc6b4,0x2fbc59,0x2fb200,0x2fa7a9, - 0x2f9d53,0x2f9300,0x2f88ae,0x2f7e5e,0x2f7410,0x2f69c3,0x2f5f79,0x2f5530, - 0x2f4ae9,0x2f40a4,0x2f3661,0x2f2c1f,0x2f21df,0x2f17a1,0x2f0d65,0x2f032b, - 0x2ef8f2,0x2eeebc,0x2ee487,0x2eda53,0x2ed022,0x2ec5f2,0x2ebbc5,0x2eb199, - 0x2ea76e,0x2e9d46,0x2e931f,0x2e88fa,0x2e7ed7,0x2e74b5,0x2e6a96,0x2e6078, - 0x2e565c,0x2e4c41,0x2e4229,0x2e3812,0x2e2dfd,0x2e23e9,0x2e19d8,0x2e0fc8, - 0x2e05ba,0x2dfbad,0x2df1a3,0x2de79a,0x2ddd93,0x2dd38d,0x2dc989,0x2dbf87, - 0x2db587,0x2dab89,0x2da18c,0x2d9791,0x2d8d97,0x2d83a0,0x2d79aa,0x2d6fb6, - 0x2d65c3,0x2d5bd2,0x2d51e3,0x2d47f6,0x2d3e0a,0x2d3420,0x2d2a38,0x2d2051, - 0x2d166c,0x2d0c89,0x2d02a8,0x2cf8c8,0x2ceeea,0x2ce50d,0x2cdb33,0x2cd15a, - 0x2cc782,0x2cbdad,0x2cb3d9,0x2caa06,0x2ca036,0x2c9667,0x2c8c99,0x2c82ce, - 0x2c7904,0x2c6f3b,0x2c6575,0x2c5bb0,0x2c51ed,0x2c482b,0x2c3e6b,0x2c34ad, - 0x2c2af0,0x2c2135,0x2c177b,0x2c0dc4,0x2c040e,0x2bfa59,0x2bf0a6,0x2be6f5, - 0x2bdd46,0x2bd398,0x2bc9eb,0x2bc041,0x2bb698,0x2bacf0,0x2ba34b,0x2b99a6, - 0x2b9004,0x2b8663,0x2b7cc4,0x2b7326,0x2b698a,0x2b5ff0,0x2b5657,0x2b4cc0, - 0x2b432a,0x2b3996,0x2b3004,0x2b2673,0x2b1ce4,0x2b1357,0x2b09cb,0x2b0040, - 0x2af6b7,0x2aed30,0x2ae3ab,0x2ada27,0x2ad0a4,0x2ac724,0x2abda4,0x2ab427, - 0x2aaaab,0x2aa130,0x2a97b7,0x2a8e40,0x2a84ca,0x2a7b56,0x2a71e3,0x2a6872, - 0x2a5f03,0x2a5595,0x2a4c29,0x2a42be,0x2a3955,0x2a2fed,0x2a2687,0x2a1d23, - 0x2a13c0,0x2a0a5e,0x2a00fe,0x29f7a0,0x29ee43,0x29e4e8,0x29db8e,0x29d236, - 0x29c8e0,0x29bf8b,0x29b637,0x29ace5,0x29a395,0x299a46,0x2990f8,0x2987ad, - 0x297e62,0x297519,0x296bd2,0x29628c,0x295948,0x295005,0x2946c4,0x293d85, - 0x293446,0x292b0a,0x2921cf,0x291895,0x290f5d,0x290626,0x28fcf1,0x28f3be, - 0x28ea8c,0x28e15b,0x28d82c,0x28cefe,0x28c5d2,0x28bca8,0x28b37f,0x28aa57, - 0x28a131,0x28980c,0x288ee9,0x2885c7,0x287ca7,0x287389,0x286a6b,0x286150, - 0x285835,0x284f1c,0x284605,0x283cef,0x2833db,0x282ac8,0x2821b7,0x2818a7, - 0x280f98,0x28068b,0x27fd80,0x27f475,0x27eb6d,0x27e266,0x27d960,0x27d05c, - 0x27c759,0x27be57,0x27b557,0x27ac59,0x27a35c,0x279a60,0x279166,0x27886d, - 0x277f76,0x277680,0x276d8c,0x276499,0x275ba7,0x2752b7,0x2749c9,0x2740db, - 0x2737f0,0x272f05,0x27261c,0x271d35,0x27144f,0x270b6a,0x270287,0x26f9a5, - 0x26f0c4,0x26e7e5,0x26df08,0x26d62c,0x26cd51,0x26c477,0x26bba0,0x26b2c9, - 0x26a9f4,0x26a120,0x26984e,0x268f7d,0x2686ad,0x267ddf,0x267512,0x266c47, - 0x26637d,0x265ab4,0x2651ed,0x264927,0x264063,0x2637a0,0x262ede,0x26261e, - 0x261d5f,0x2614a2,0x260be6,0x26032b,0x25fa72,0x25f1ba,0x25e903,0x25e04e, - 0x25d79a,0x25cee7,0x25c636,0x25bd87,0x25b4d8,0x25ac2b,0x25a37f,0x259ad5, - 0x25922c,0x258985,0x2580de,0x257839,0x256f96,0x2566f4,0x255e53,0x2555b3, - 0x254d15,0x254479,0x253bdd,0x253343,0x252aaa,0x252213,0x25197d,0x2510e8, - 0x250855,0x24ffc3,0x24f732,0x24eea3,0x24e615,0x24dd88,0x24d4fc,0x24cc72, - 0x24c3ea,0x24bb62,0x24b2dc,0x24aa57,0x24a1d4,0x249952,0x2490d1,0x248852, - 0x247fd3,0x247756,0x246edb,0x246661,0x245de8,0x245570,0x244cfa,0x244485, - 0x243c11,0x24339f,0x242b2e,0x2422be,0x241a4f,0x2411e2,0x240976,0x24010c, - 0x23f8a2,0x23f03a,0x23e7d4,0x23df6e,0x23d70a,0x23cea7,0x23c646,0x23bde6, - 0x23b587,0x23ad29,0x23a4cc,0x239c71,0x239417,0x238bbf,0x238368,0x237b12, - 0x2372bd,0x236a69,0x236217,0x2359c6,0x235177,0x234928,0x2340db,0x23388f, - 0x233045,0x2327fb,0x231fb3,0x23176c,0x230f27,0x2306e2,0x22fe9f,0x22f65e, - 0x22ee1d,0x22e5de,0x22dda0,0x22d563,0x22cd28,0x22c4ed,0x22bcb4,0x22b47c, - 0x22ac46,0x22a411,0x229bdd,0x2293aa,0x228b78,0x228348,0x227b19,0x2272eb, - 0x226abe,0x226293,0x225a69,0x225240,0x224a18,0x2241f2,0x2239cc,0x2231a8, - 0x222985,0x222164,0x221944,0x221124,0x220907,0x2200ea,0x21f8ce,0x21f0b4, - 0x21e89b,0x21e083,0x21d86d,0x21d057,0x21c843,0x21c030,0x21b81e,0x21b00e, - 0x21a7fe,0x219ff0,0x2197e3,0x218fd8,0x2187cd,0x217fc4,0x2177bc,0x216fb5, - 0x2167af,0x215faa,0x2157a7,0x214fa5,0x2147a4,0x213fa4,0x2137a5,0x212fa8, - 0x2127ac,0x211fb1,0x2117b7,0x210fbe,0x2107c7,0x20ffd0,0x20f7db,0x20efe7, - 0x20e7f5,0x20e003,0x20d813,0x20d023,0x20c835,0x20c048,0x20b85d,0x20b072, - 0x20a889,0x20a0a1,0x2098ba,0x2090d4,0x2088ef,0x20810b,0x207929,0x207148, - 0x206968,0x206189,0x2059ab,0x2051cf,0x2049f3,0x204219,0x203a40,0x203268, - 0x202a91,0x2022bb,0x201ae7,0x201313,0x200b41,0x200370,0x1ffba0,0x1ff3d1, - 0x1fec04,0x1fe437,0x1fdc6c,0x1fd4a2,0x1fccd9,0x1fc511,0x1fbd4a,0x1fb584, - 0x1fadc0,0x1fa5fc,0x1f9e3a,0x1f9679,0x1f8eb9,0x1f86fa,0x1f7f3c,0x1f777f, - 0x1f6fc4,0x1f680a,0x1f6050,0x1f5898,0x1f50e1,0x1f492b,0x1f4176,0x1f39c3, - 0x1f3210,0x1f2a5f,0x1f22af,0x1f1aff,0x1f1351,0x1f0ba4,0x1f03f8,0x1efc4e, - 0x1ef4a4,0x1eecfb,0x1ee554,0x1eddae,0x1ed608,0x1ece64,0x1ec6c1,0x1ebf1f, - 0x1eb77f,0x1eafdf,0x1ea840,0x1ea0a3,0x1e9906,0x1e916b,0x1e89d1,0x1e8238, - 0x1e7aa0,0x1e7309,0x1e6b73,0x1e63de,0x1e5c4a,0x1e54b8,0x1e4d26,0x1e4596, - 0x1e3e06,0x1e3678,0x1e2eeb,0x1e275f,0x1e1fd4,0x1e184a,0x1e10c1,0x1e0939, - 0x1e01b3,0x1dfa2d,0x1df2a8,0x1deb25,0x1de3a2,0x1ddc21,0x1dd4a1,0x1dcd22, - 0x1dc5a3,0x1dbe26,0x1db6aa,0x1daf2f,0x1da7b6,0x1da03d,0x1d98c5,0x1d914e, - 0x1d89d9,0x1d8264,0x1d7af1,0x1d737e,0x1d6c0d,0x1d649c,0x1d5d2d,0x1d55bf, - 0x1d4e52,0x1d46e5,0x1d3f7a,0x1d3810,0x1d30a7,0x1d293f,0x1d21d8,0x1d1a73, - 0x1d130e,0x1d0baa,0x1d0447,0x1cfce6,0x1cf585,0x1cee25,0x1ce6c7,0x1cdf69, - 0x1cd80d,0x1cd0b1,0x1cc957,0x1cc1fe,0x1cbaa5,0x1cb34e,0x1cabf8,0x1ca4a2, - 0x1c9d4e,0x1c95fb,0x1c8ea9,0x1c8758,0x1c8008,0x1c78b8,0x1c716a,0x1c6a1d, - 0x1c62d1,0x1c5b86,0x1c543c,0x1c4cf3,0x1c45ab,0x1c3e65,0x1c371f,0x1c2fda, - 0x1c2896,0x1c2153,0x1c1a11,0x1c12d0,0x1c0b90,0x1c0452,0x1bfd14,0x1bf5d7, - 0x1bee9b,0x1be760,0x1be027,0x1bd8ee,0x1bd1b6,0x1bca7f,0x1bc349,0x1bbc15, - 0x1bb4e1,0x1badae,0x1ba67c,0x1b9f4c,0x1b981c,0x1b90ed,0x1b89bf,0x1b8292, - 0x1b7b67,0x1b743c,0x1b6d12,0x1b65e9,0x1b5ec1,0x1b579a,0x1b5074,0x1b4950, - 0x1b422c,0x1b3b09,0x1b33e7,0x1b2cc6,0x1b25a6,0x1b1e87,0x1b1769,0x1b104c, - 0x1b0930,0x1b0215,0x1afafb,0x1af3e2,0x1aecc9,0x1ae5b2,0x1ade9c,0x1ad787, - 0x1ad073,0x1ac95f,0x1ac24d,0x1abb3c,0x1ab42b,0x1aad1c,0x1aa60d,0x1a9f00, - 0x1a97f3,0x1a90e8,0x1a89dd,0x1a82d4,0x1a7bcb,0x1a74c3,0x1a6dbd,0x1a66b7, - 0x1a5fb2,0x1a58ae,0x1a51ab,0x1a4aa9,0x1a43a8,0x1a3ca8,0x1a35a9,0x1a2eab, - 0x1a27ae,0x1a20b1,0x1a19b6,0x1a12bc,0x1a0bc2,0x1a04ca,0x19fdd2,0x19f6dc, - 0x19efe6,0x19e8f2,0x19e1fe,0x19db0b,0x19d419,0x19cd28,0x19c638,0x19bf49, - 0x19b85b,0x19b16e,0x19aa82,0x19a396,0x199cac,0x1995c3,0x198eda,0x1987f3, - 0x19810c,0x197a26,0x197342,0x196c5e,0x19657b,0x195e99,0x1957b8,0x1950d8, - 0x1949f8,0x19431a,0x193c3d,0x193560,0x192e85,0x1927aa,0x1920d1,0x1919f8, - 0x191320,0x190c49,0x190573,0x18fe9e,0x18f7ca,0x18f0f7,0x18ea24,0x18e353, - 0x18dc82,0x18d5b3,0x18cee4,0x18c816,0x18c149,0x18ba7d,0x18b3b2,0x18ace8, - 0x18a61f,0x189f56,0x18988f,0x1891c8,0x188b03,0x18843e,0x187d7a,0x1876b7, - 0x186ff5,0x186934,0x186274,0x185bb4,0x1854f6,0x184e38,0x18477c,0x1840c0, - 0x183a05,0x18334b,0x182c92,0x1825da,0x181f23,0x18186c,0x1811b7,0x180b02, - 0x18044e,0x17fd9b,0x17f6e9,0x17f038,0x17e988,0x17e2d9,0x17dc2a,0x17d57d, - 0x17ced0,0x17c824,0x17c179,0x17bacf,0x17b426,0x17ad7e,0x17a6d6,0x17a030, - 0x17998a,0x1792e5,0x178c41,0x17859e,0x177efc,0x17785b,0x1771ba,0x176b1b, - 0x17647c,0x175dde,0x175741,0x1750a5,0x174a0a,0x17436f,0x173cd6,0x17363d, - 0x172fa5,0x17290f,0x172278,0x171be3,0x17154f,0x170ebb,0x170829,0x170197, - 0x16fb06,0x16f476,0x16ede7,0x16e759,0x16e0cb,0x16da3e,0x16d3b3,0x16cd28, - 0x16c69e,0x16c014,0x16b98c,0x16b305,0x16ac7e,0x16a5f8,0x169f73,0x1698ef, - 0x16926c,0x168be9,0x168568,0x167ee7,0x167867,0x1671e8,0x166b6a,0x1664ec, - 0x165e70,0x1657f4,0x165179,0x164aff,0x164486,0x163e0d,0x163796,0x16311f, - 0x162aa9,0x162434,0x161dc0,0x16174d,0x1610da,0x160a68,0x1603f8,0x15fd88, - 0x15f718,0x15f0aa,0x15ea3c,0x15e3d0,0x15dd64,0x15d6f9,0x15d08e,0x15ca25, - 0x15c3bc,0x15bd55,0x15b6ee,0x15b087,0x15aa22,0x15a3be,0x159d5a,0x1596f7, - 0x159095,0x158a34,0x1583d3,0x157d74,0x157715,0x1570b7,0x156a5a,0x1563fd, - 0x155da2,0x155747,0x1550ed,0x154a94,0x15443c,0x153de4,0x15378e,0x153138, - 0x152ae3,0x15248e,0x151e3b,0x1517e8,0x151197,0x150b45,0x1504f5,0x14fea6, - 0x14f857,0x14f209,0x14ebbc,0x14e570,0x14df25,0x14d8da,0x14d290,0x14cc47, - 0x14c5ff,0x14bfb7,0x14b971,0x14b32b,0x14ace6,0x14a6a1,0x14a05e,0x149a1b, - 0x1493d9,0x148d98,0x148758,0x148118,0x147ada,0x14749c,0x146e5f,0x146822, - 0x1461e7,0x145bac,0x145572,0x144f38,0x144900,0x1442c8,0x143c91,0x14365b, - 0x143026,0x1429f1,0x1423be,0x141d8b,0x141758,0x141127,0x140af6,0x1404c6, - 0x13fe97,0x13f869,0x13f23b,0x13ec0f,0x13e5e3,0x13dfb7,0x13d98d,0x13d363, - 0x13cd3a,0x13c712,0x13c0eb,0x13bac4,0x13b49e,0x13ae79,0x13a855,0x13a231, - 0x139c0e,0x1395ec,0x138fcb,0x1389ab,0x13838b,0x137d6c,0x13774e,0x137130, - 0x136b13,0x1364f8,0x135edc,0x1358c2,0x1352a8,0x134c8f,0x134677,0x134060, - 0x133a49,0x133433,0x132e1e,0x13280a,0x1321f6,0x131be3,0x1315d1,0x130fc0, - 0x1309af,0x13039f,0x12fd90,0x12f782,0x12f174,0x12eb67,0x12e55b,0x12df50, - 0x12d945,0x12d33b,0x12cd32,0x12c72a,0x12c122,0x12bb1b,0x12b515,0x12af10, - 0x12a90b,0x12a307,0x129d04,0x129702,0x129100,0x128aff,0x1284ff,0x127eff, - 0x127900,0x127302,0x126d05,0x126708,0x12610d,0x125b11,0x125517,0x124f1d, - 0x124925,0x12432c,0x123d35,0x12373e,0x123148,0x122b53,0x12255e,0x121f6b, - 0x121978,0x121385,0x120d94,0x1207a3,0x1201b3,0x11fbc3,0x11f5d4,0x11efe6, - 0x11e9f9,0x11e40d,0x11de21,0x11d836,0x11d24b,0x11cc62,0x11c679,0x11c090, - 0x11baa9,0x11b4c2,0x11aedc,0x11a8f7,0x11a312,0x119d2e,0x11974b,0x119168, - 0x118b87,0x1185a6,0x117fc5,0x1179e5,0x117407,0x116e28,0x11684b,0x11626e, - 0x115c92,0x1156b6,0x1150dc,0x114b02,0x114529,0x113f50,0x113978,0x1133a1, - 0x112dca,0x1127f5,0x112220,0x111c4b,0x111678,0x1110a5,0x110ad3,0x110501, - 0x10ff30,0x10f960,0x10f391,0x10edc2,0x10e7f4,0x10e226,0x10dc5a,0x10d68e, - 0x10d0c3,0x10caf8,0x10c52e,0x10bf65,0x10b99c,0x10b3d5,0x10ae0e,0x10a847, - 0x10a281,0x109cbc,0x1096f8,0x109134,0x108b72,0x1085af,0x107fee,0x107a2d, - 0x10746d,0x106ead,0x1068ee,0x106330,0x105d73,0x1057b6,0x1051fa,0x104c3e, - 0x104684,0x1040ca,0x103b10,0x103558,0x102fa0,0x1029e8,0x102432,0x101e7c, - 0x1018c6,0x101312,0x100d5e,0x1007ab,0x1001f8,0xffc46,0xff695,0xff0e4, - 0xfeb35,0xfe585,0xfdfd7,0xfda29,0xfd47c,0xfcecf,0xfc923,0xfc378, - 0xfbdce,0xfb824,0xfb27b,0xfacd2,0xfa72a,0xfa183,0xf9bdd,0xf9637, - 0xf9092,0xf8aed,0xf854a,0xf7fa6,0xf7a04,0xf7462,0xf6ec1,0xf6920, - 0xf6381,0xf5de1,0xf5843,0xf52a5,0xf4d08,0xf476b,0xf41cf,0xf3c34, - 0xf369a,0xf3100,0xf2b66,0xf25ce,0xf2036,0xf1a9f,0xf1508,0xf0f72, - 0xf09dd,0xf0448,0xefeb4,0xef921,0xef38e,0xeedfc,0xee86b,0xee2da, - 0xedd4a,0xed7ba,0xed22b,0xecc9d,0xec710,0xec183,0xebbf7,0xeb66b, - 0xeb0e0,0xeab56,0xea5cc,0xea043,0xe9abb,0xe9533,0xe8fac,0xe8a26, - 0xe84a0,0xe7f1b,0xe7996,0xe7413,0xe6e8f,0xe690d,0xe638b,0xe5e0a, - 0xe5889,0xe5309,0xe4d8a,0xe480b,0xe428d,0xe3d0f,0xe3792,0xe3216, - 0xe2c9b,0xe2720,0xe21a5,0xe1c2c,0xe16b3,0xe113a,0xe0bc3,0xe064c, - 0xe00d5,0xdfb5f,0xdf5ea,0xdf075,0xdeb01,0xde58e,0xde01b,0xddaa9, - 0xdd538,0xdcfc7,0xdca57,0xdc4e7,0xdbf78,0xdba0a,0xdb49c,0xdaf2f, - 0xda9c2,0xda457,0xd9eeb,0xd9981,0xd9417,0xd8ead,0xd8945,0xd83dc, - 0xd7e75,0xd790e,0xd73a8,0xd6e42,0xd68dd,0xd6379,0xd5e15,0xd58b2, - 0xd534f,0xd4ded,0xd488c,0xd432b,0xd3dcb,0xd386c,0xd330d,0xd2dae, - 0xd2851,0xd22f4,0xd1d97,0xd183b,0xd12e0,0xd0d86,0xd082c,0xd02d2, - 0xcfd79,0xcf821,0xcf2ca,0xced73,0xce81c,0xce2c7,0xcdd72,0xcd81d, - 0xcd2c9,0xccd76,0xcc823,0xcc2d1,0xcbd7f,0xcb82f,0xcb2de,0xcad8f, - 0xca83f,0xca2f1,0xc9da3,0xc9856,0xc9309,0xc8dbd,0xc8871,0xc8326, - 0xc7ddc,0xc7892,0xc7349,0xc6e01,0xc68b9,0xc6372,0xc5e2b,0xc58e5, - 0xc539f,0xc4e5a,0xc4916,0xc43d2,0xc3e8f,0xc394c,0xc340a,0xc2ec9, - 0xc2988,0xc2448,0xc1f08,0xc19c9,0xc148b,0xc0f4d,0xc0a10,0xc04d3, - 0xbff97,0xbfa5b,0xbf521,0xbefe6,0xbeaad,0xbe573,0xbe03b,0xbdb03, - 0xbd5cb,0xbd095,0xbcb5e,0xbc629,0xbc0f4,0xbbbbf,0xbb68b,0xbb158, - 0xbac25,0xba6f3,0xba1c1,0xb9c90,0xb9760,0xb9230,0xb8d01,0xb87d2, - 0xb82a4,0xb7d76,0xb7849,0xb731d,0xb6df1,0xb68c6,0xb639b,0xb5e71, - 0xb5948,0xb541f,0xb4ef6,0xb49cf,0xb44a7,0xb3f81,0xb3a5b,0xb3535, - 0xb3010,0xb2aec,0xb25c8,0xb20a5,0xb1b82,0xb1660,0xb113e,0xb0c1d, - 0xb06fd,0xb01dd,0xafcbe,0xaf79f,0xaf281,0xaed64,0xae847,0xae32a, - 0xade0e,0xad8f3,0xad3d8,0xacebe,0xac9a4,0xac48b,0xabf73,0xaba5b, - 0xab544,0xab02d,0xaab17,0xaa601,0xaa0ec,0xa9bd7,0xa96c3,0xa91b0, - 0xa8c9d,0xa878a,0xa8279,0xa7d67,0xa7857,0xa7347,0xa6e37,0xa6928, - 0xa641a,0xa5f0c,0xa59fe,0xa54f2,0xa4fe5,0xa4ada,0xa45ce,0xa40c4, - 0xa3bba,0xa36b0,0xa31a7,0xa2c9f,0xa2797,0xa2290,0xa1d89,0xa1883, - 0xa137d,0xa0e78,0xa0974,0xa0470,0x9ff6c,0x9fa69,0x9f567,0x9f065, - 0x9eb64,0x9e663,0x9e163,0x9dc63,0x9d764,0x9d266,0x9cd68,0x9c86a, - 0x9c36d,0x9be71,0x9b975,0x9b47a,0x9af7f,0x9aa85,0x9a58b,0x9a092, - 0x99b9a,0x996a1,0x991aa,0x98cb3,0x987bd,0x982c7,0x97dd1,0x978dc, - 0x973e8,0x96ef4,0x96a01,0x9650e,0x9601c,0x95b2b,0x9563a,0x95149, - 0x94c59,0x94769,0x9427a,0x93d8c,0x9389e,0x933b1,0x92ec4,0x929d8, - 0x924ec,0x92001,0x91b16,0x9162c,0x91142,0x90c59,0x90770,0x90288, - 0x8fda1,0x8f8ba,0x8f3d3,0x8eeed,0x8ea08,0x8e523,0x8e03e,0x8db5b, - 0x8d677,0x8d194,0x8ccb2,0x8c7d0,0x8c2ef,0x8be0e,0x8b92e,0x8b44e, - 0x8af6f,0x8aa91,0x8a5b2,0x8a0d5,0x89bf8,0x8971b,0x8923f,0x88d64, - 0x88889,0x883ae,0x87ed4,0x879fb,0x87522,0x87049,0x86b71,0x8669a, - 0x861c3,0x85ced,0x85817,0x85341,0x84e6d,0x84998,0x844c5,0x83ff1, - 0x83b1e,0x8364c,0x8317a,0x82ca9,0x827d8,0x82308,0x81e39,0x81969, - 0x8149b,0x80fcd,0x80aff,0x80632,0x80165,0x7fc99,0x7f7cd,0x7f302, - 0x7ee37,0x7e96d,0x7e4a4,0x7dfdb,0x7db12,0x7d64a,0x7d182,0x7ccbb, - 0x7c7f5,0x7c32f,0x7be69,0x7b9a4,0x7b4df,0x7b01b,0x7ab58,0x7a695, - 0x7a1d2,0x79d10,0x7984f,0x7938e,0x78ecd,0x78a0d,0x7854d,0x7808e, - 0x77bd0,0x77712,0x77254,0x76d97,0x768da,0x7641e,0x75f63,0x75aa8, - 0x755ed,0x75133,0x74c79,0x747c0,0x74308,0x73e50,0x73998,0x734e1, - 0x7302a,0x72b74,0x726be,0x72209,0x71d55,0x718a0,0x713ed,0x70f3a, - 0x70a87,0x705d5,0x70123,0x6fc72,0x6f7c1,0x6f311,0x6ee61,0x6e9b2, - 0x6e503,0x6e055,0x6dba7,0x6d6f9,0x6d24d,0x6cda0,0x6c8f4,0x6c449, - 0x6bf9e,0x6baf4,0x6b64a,0x6b1a0,0x6acf7,0x6a84f,0x6a3a7,0x69eff, - 0x69a58,0x695b2,0x6910c,0x68c66,0x687c1,0x6831d,0x67e78,0x679d5, - 0x67532,0x6708f,0x66bed,0x6674b,0x662aa,0x65e09,0x65969,0x654c9, - 0x65029,0x64b8a,0x646ec,0x6424e,0x63db1,0x63914,0x63477,0x62fdb, - 0x62b40,0x626a5,0x6220a,0x61d70,0x618d6,0x6143d,0x60fa4,0x60b0c, - 0x60674,0x601dd,0x5fd46,0x5f8b0,0x5f41a,0x5ef85,0x5eaf0,0x5e65b, - 0x5e1c7,0x5dd34,0x5d8a1,0x5d40e,0x5cf7c,0x5caea,0x5c659,0x5c1c9, - 0x5bd38,0x5b8a9,0x5b419,0x5af8a,0x5aafc,0x5a66e,0x5a1e1,0x59d54, - 0x598c7,0x5943b,0x58fb0,0x58b24,0x5869a,0x58210,0x57d86,0x578fd, - 0x57474,0x56feb,0x56b64,0x566dc,0x56255,0x55dcf,0x55949,0x554c3, - 0x5503e,0x54bb9,0x54735,0x542b1,0x53e2e,0x539ab,0x53529,0x530a7, - 0x52c25,0x527a4,0x52324,0x51ea4,0x51a24,0x515a5,0x51126,0x50ca8, - 0x5082a,0x503ad,0x4ff30,0x4fab4,0x4f638,0x4f1bc,0x4ed41,0x4e8c6, - 0x4e44c,0x4dfd3,0x4db59,0x4d6e0,0x4d268,0x4cdf0,0x4c979,0x4c502, - 0x4c08b,0x4bc15,0x4b79f,0x4b32a,0x4aeb5,0x4aa41,0x4a5cd,0x4a15a, - 0x49ce7,0x49874,0x49402,0x48f91,0x48b1f,0x486af,0x4823e,0x47dce, - 0x4795f,0x474f0,0x47082,0x46c14,0x467a6,0x46339,0x45ecc,0x45a60, - 0x455f4,0x45189,0x44d1e,0x448b3,0x44449,0x43fdf,0x43b76,0x4370d, - 0x432a5,0x42e3d,0x429d6,0x4256f,0x42108,0x41ca2,0x4183c,0x413d7, - 0x40f72,0x40b0e,0x406aa,0x40247,0x3fde4,0x3f981,0x3f51f,0x3f0bd, - 0x3ec5c,0x3e7fb,0x3e39b,0x3df3b,0x3dadb,0x3d67c,0x3d21d,0x3cdbf, - 0x3c961,0x3c504,0x3c0a7,0x3bc4a,0x3b7ee,0x3b393,0x3af37,0x3aadd, - 0x3a682,0x3a228,0x39dcf,0x39976,0x3951d,0x390c5,0x38c6d,0x38816, - 0x383bf,0x37f69,0x37b13,0x376bd,0x37268,0x36e13,0x369bf,0x3656b, - 0x36117,0x35cc4,0x35872,0x3541f,0x34fce,0x34b7c,0x3472b,0x342db, - 0x33e8b,0x33a3b,0x335ec,0x3319d,0x32d4f,0x32901,0x324b3,0x32066, - 0x31c1a,0x317cd,0x31381,0x30f36,0x30aeb,0x306a1,0x30256,0x2fe0d, - 0x2f9c3,0x2f57a,0x2f132,0x2ecea,0x2e8a2,0x2e45b,0x2e014,0x2dbce, - 0x2d788,0x2d343,0x2cefd,0x2cab9,0x2c675,0x2c231,0x2bded,0x2b9aa, - 0x2b568,0x2b125,0x2ace4,0x2a8a2,0x2a461,0x2a021,0x29be1,0x297a1, - 0x29362,0x28f23,0x28ae4,0x286a6,0x28269,0x27e2c,0x279ef,0x275b2, - 0x27176,0x26d3b,0x26900,0x264c5,0x2608b,0x25c51,0x25817,0x253de, - 0x24fa6,0x24b6d,0x24735,0x242fe,0x23ec7,0x23a90,0x2365a,0x23224, - 0x22def,0x229ba,0x22585,0x22151,0x21d1d,0x218ea,0x214b7,0x21084, - 0x20c52,0x20821,0x203ef,0x1ffbe,0x1fb8e,0x1f75e,0x1f32e,0x1eeff, - 0x1ead0,0x1e6a1,0x1e273,0x1de45,0x1da18,0x1d5eb,0x1d1bf,0x1cd93, - 0x1c967,0x1c53c,0x1c111,0x1bce6,0x1b8bc,0x1b493,0x1b069,0x1ac40, - 0x1a818,0x1a3f0,0x19fc8,0x19ba1,0x1977a,0x19354,0x18f2d,0x18b08, - 0x186e2,0x182be,0x17e99,0x17a75,0x17651,0x1722e,0x16e0b,0x169e9, - 0x165c6,0x161a5,0x15d83,0x15963,0x15542,0x15122,0x14d02,0x148e3, - 0x144c4,0x140a5,0x13c87,0x13869,0x1344c,0x1302f,0x12c12,0x127f6, - 0x123da,0x11fbf,0x11ba4,0x11789,0x1136f,0x10f55,0x10b3c,0x10723, - 0x1030a,0xfef2,0xfada,0xf6c2,0xf2ab,0xee95,0xea7e,0xe668, - 0xe253,0xde3e,0xda29,0xd614,0xd200,0xcded,0xc9da,0xc5c7, - 0xc1b4,0xbda2,0xb990,0xb57f,0xb16e,0xad5e,0xa94e,0xa53e, - 0xa12e,0x9d1f,0x9911,0x9503,0x90f5,0x8ce7,0x88da,0x84ce, - 0x80c1,0x7cb5,0x78aa,0x749f,0x7094,0x6c89,0x687f,0x6476, - 0x606d,0x5c64,0x585b,0x5453,0x504b,0x4c44,0x483d,0x4436, - 0x4030,0x3c2a,0x3825,0x3420,0x301b,0x2c17,0x2813,0x240f, - 0x200c,0x1c09,0x1807,0x1405,0x1003,0xc02,0x801,0x400, - 0x7fffff,0x7ff001,0x7fe006,0x7fd00d,0x7fc018,0x7fb025,0x7fa036,0x7f9049, - 0x7f8060,0x7f7079,0x7f6095,0x7f50b5,0x7f40d7,0x7f30fc,0x7f2124,0x7f114f, - 0x7f017e,0x7ef1af,0x7ee1e2,0x7ed219,0x7ec253,0x7eb290,0x7ea2d0,0x7e9312, - 0x7e8358,0x7e73a0,0x7e63eb,0x7e543a,0x7e448b,0x7e34df,0x7e2536,0x7e1590, - 0x7e05ec,0x7df64c,0x7de6ae,0x7dd714,0x7dc77c,0x7db7e7,0x7da855,0x7d98c6, - 0x7d893a,0x7d79b0,0x7d6a2a,0x7d5aa6,0x7d4b25,0x7d3ba7,0x7d2c2c,0x7d1cb3, - 0x7d0d3e,0x7cfdcb,0x7cee5b,0x7cdeee,0x7ccf84,0x7cc01d,0x7cb0b8,0x7ca156, - 0x7c91f7,0x7c829b,0x7c7342,0x7c63eb,0x7c5497,0x7c4546,0x7c35f8,0x7c26ad, - 0x7c1764,0x7c081e,0x7bf8db,0x7be99b,0x7bda5d,0x7bcb23,0x7bbbeb,0x7bacb5, - 0x7b9d83,0x7b8e53,0x7b7f26,0x7b6ffc,0x7b60d4,0x7b51b0,0x7b428e,0x7b336e, - 0x7b2452,0x7b1538,0x7b0621,0x7af70c,0x7ae7fb,0x7ad8ec,0x7ac9e0,0x7abad6, - 0x7aabcf,0x7a9ccb,0x7a8dca,0x7a7ecb,0x7a6fcf,0x7a60d5,0x7a51df,0x7a42eb, - 0x7a33f9,0x7a250b,0x7a161f,0x7a0735,0x79f84f,0x79e96b,0x79da89,0x79cbab, - 0x79bccf,0x79adf5,0x799f1f,0x79904a,0x798179,0x7972aa,0x7963de,0x795515, - 0x79464e,0x793789,0x7928c8,0x791a09,0x790b4c,0x78fc92,0x78eddb,0x78df27, - 0x78d075,0x78c1c5,0x78b319,0x78a46e,0x7895c7,0x788722,0x78787f,0x7869e0, - 0x785b42,0x784ca8,0x783e10,0x782f7a,0x7820e7,0x781257,0x7803c9,0x77f53e, - 0x77e6b5,0x77d82f,0x77c9ab,0x77bb2a,0x77acac,0x779e30,0x778fb6,0x77813f, - 0x7772cb,0x776459,0x7755ea,0x77477d,0x773913,0x772aab,0x771c46,0x770de3, - 0x76ff83,0x76f125,0x76e2ca,0x76d472,0x76c61b,0x76b7c8,0x76a977,0x769b28, - 0x768cdc,0x767e92,0x76704b,0x766206,0x7653c4,0x764584,0x763747,0x76290c, - 0x761ad3,0x760c9d,0x75fe6a,0x75f039,0x75e20a,0x75d3de,0x75c5b5,0x75b78e, - 0x75a969,0x759b46,0x758d27,0x757f09,0x7570ee,0x7562d6,0x7554bf,0x7546ac, - 0x75389a,0x752a8c,0x751c7f,0x750e75,0x75006d,0x74f268,0x74e465,0x74d665, - 0x74c867,0x74ba6b,0x74ac72,0x749e7b,0x749087,0x748295,0x7474a5,0x7466b8, - 0x7458cd,0x744ae4,0x743cfe,0x742f1a,0x742139,0x74135a,0x74057d,0x73f7a3, - 0x73e9cb,0x73dbf5,0x73ce22,0x73c051,0x73b282,0x73a4b6,0x7396ec,0x738925, - 0x737b60,0x736d9d,0x735fdc,0x73521e,0x734462,0x7336a9,0x7328f1,0x731b3c, - 0x730d8a,0x72ffd9,0x72f22c,0x72e480,0x72d6d7,0x72c92f,0x72bb8b,0x72ade8, - 0x72a048,0x7292aa,0x72850f,0x727775,0x7269de,0x725c4a,0x724eb7,0x724127, - 0x723399,0x72260e,0x721884,0x720afd,0x71fd79,0x71eff6,0x71e276,0x71d4f8, - 0x71c77c,0x71ba02,0x71ac8b,0x719f16,0x7191a3,0x718433,0x7176c5,0x716959, - 0x715bef,0x714e87,0x714122,0x7133bf,0x71265e,0x711900,0x710ba3,0x70fe49, - 0x70f0f1,0x70e39b,0x70d648,0x70c8f6,0x70bba7,0x70ae5a,0x70a110,0x7093c7, - 0x708681,0x70793d,0x706bfb,0x705ebb,0x70517d,0x704442,0x703709,0x7029d2, - 0x701c9d,0x700f6a,0x70023a,0x6ff50c,0x6fe7e0,0x6fdab6,0x6fcd8e,0x6fc068, - 0x6fb345,0x6fa624,0x6f9904,0x6f8be7,0x6f7ecd,0x6f71b4,0x6f649d,0x6f5789, - 0x6f4a77,0x6f3d67,0x6f3059,0x6f234d,0x6f1643,0x6f093c,0x6efc36,0x6eef33, - 0x6ee232,0x6ed533,0x6ec836,0x6ebb3b,0x6eae42,0x6ea14c,0x6e9457,0x6e8765, - 0x6e7a74,0x6e6d86,0x6e609a,0x6e53b0,0x6e46c8,0x6e39e3,0x6e2cff,0x6e201d, - 0x6e133e,0x6e0661,0x6df985,0x6decac,0x6ddfd5,0x6dd300,0x6dc62d,0x6db95c, - 0x6dac8d,0x6d9fc0,0x6d92f5,0x6d862d,0x6d7966,0x6d6ca2,0x6d5fdf,0x6d531f, - 0x6d4660,0x6d39a4,0x6d2cea,0x6d2032,0x6d137c,0x6d06c7,0x6cfa15,0x6ced65, - 0x6ce0b7,0x6cd40b,0x6cc761,0x6cbab9,0x6cae14,0x6ca170,0x6c94ce,0x6c882e, - 0x6c7b90,0x6c6ef5,0x6c625b,0x6c55c3,0x6c492d,0x6c3c9a,0x6c3008,0x6c2378, - 0x6c16ea,0x6c0a5f,0x6bfdd5,0x6bf14d,0x6be4c8,0x6bd844,0x6bcbc2,0x6bbf42, - 0x6bb2c5,0x6ba649,0x6b99cf,0x6b8d57,0x6b80e2,0x6b746e,0x6b67fc,0x6b5b8c, - 0x6b4f1e,0x6b42b2,0x6b3648,0x6b29e0,0x6b1d7a,0x6b1116,0x6b04b4,0x6af854, - 0x6aebf5,0x6adf99,0x6ad33f,0x6ac6e6,0x6aba90,0x6aae3b,0x6aa1e9,0x6a9598, - 0x6a8949,0x6a7cfd,0x6a70b2,0x6a6469,0x6a5822,0x6a4bdd,0x6a3f9a,0x6a3359, - 0x6a271a,0x6a1adc,0x6a0ea1,0x6a0267,0x69f630,0x69e9fa,0x69ddc6,0x69d195, - 0x69c565,0x69b937,0x69ad0b,0x69a0e0,0x6994b8,0x698892,0x697c6d,0x69704a, - 0x69642a,0x69580b,0x694bee,0x693fd3,0x6933ba,0x6927a2,0x691b8d,0x690f79, - 0x690368,0x68f758,0x68eb4a,0x68df3e,0x68d334,0x68c72b,0x68bb25,0x68af20, - 0x68a31d,0x68971d,0x688b1d,0x687f20,0x687325,0x68672c,0x685b34,0x684f3e, - 0x68434a,0x683758,0x682b68,0x681f7a,0x68138d,0x6807a2,0x67fbb9,0x67efd2, - 0x67e3ed,0x67d80a,0x67cc28,0x67c048,0x67b46a,0x67a88e,0x679cb4,0x6790dc, - 0x678505,0x677930,0x676d5d,0x67618c,0x6755bd,0x6749ef,0x673e23,0x673259, - 0x672691,0x671acb,0x670f06,0x670343,0x66f782,0x66ebc3,0x66e006,0x66d44a, - 0x66c891,0x66bcd8,0x66b122,0x66a56e,0x6699bb,0x668e0a,0x66825b,0x6676ae, - 0x666b02,0x665f58,0x6653b0,0x66480a,0x663c66,0x6630c3,0x662522,0x661983, - 0x660de5,0x66024a,0x65f6b0,0x65eb17,0x65df81,0x65d3ec,0x65c859,0x65bcc8, - 0x65b139,0x65a5ab,0x659a1f,0x658e95,0x65830d,0x657786,0x656c01,0x65607e, - 0x6554fc,0x65497c,0x653dfe,0x653282,0x652707,0x651b8e,0x651017,0x6504a2, - 0x64f92e,0x64edbc,0x64e24c,0x64d6dd,0x64cb70,0x64c005,0x64b49c,0x64a934, - 0x649dce,0x64926a,0x648707,0x647ba6,0x647047,0x6464ea,0x64598e,0x644e34, - 0x6442db,0x643784,0x642c2f,0x6420dc,0x64158a,0x640a3a,0x63feec,0x63f39f, - 0x63e854,0x63dd0b,0x63d1c3,0x63c67d,0x63bb39,0x63aff7,0x63a4b6,0x639976, - 0x638e39,0x6382fd,0x6377c3,0x636c8a,0x636153,0x63561e,0x634aea,0x633fb8, - 0x633488,0x632959,0x631e2c,0x631301,0x6307d7,0x62fcaf,0x62f189,0x62e664, - 0x62db41,0x62d01f,0x62c500,0x62b9e1,0x62aec5,0x62a3aa,0x629890,0x628d79, - 0x628263,0x62774e,0x626c3b,0x62612a,0x62561b,0x624b0d,0x624000,0x6234f6, - 0x6229ed,0x621ee5,0x6213df,0x6208db,0x61fdd8,0x61f2d7,0x61e7d8,0x61dcda, - 0x61d1de,0x61c6e3,0x61bbea,0x61b0f3,0x61a5fd,0x619b09,0x619016,0x618525, - 0x617a36,0x616f48,0x61645b,0x615971,0x614e88,0x6143a0,0x6138ba,0x612dd6, - 0x6122f3,0x611812,0x610d32,0x610254,0x60f778,0x60ec9d,0x60e1c4,0x60d6ec, - 0x60cc16,0x60c141,0x60b66e,0x60ab9c,0x60a0cc,0x6095fe,0x608b31,0x608066, - 0x60759c,0x606ad4,0x60600e,0x605549,0x604a85,0x603fc3,0x603503,0x602a44, - 0x601f87,0x6014cb,0x600a11,0x5fff58,0x5ff4a1,0x5fe9eb,0x5fdf37,0x5fd485, - 0x5fc9d4,0x5fbf24,0x5fb476,0x5fa9ca,0x5f9f1f,0x5f9476,0x5f89ce,0x5f7f28, - 0x5f7483,0x5f69df,0x5f5f3e,0x5f549d,0x5f49ff,0x5f3f62,0x5f34c6,0x5f2a2c, - 0x5f1f93,0x5f14fc,0x5f0a66,0x5effd2,0x5ef53f,0x5eeaae,0x5ee01f,0x5ed591, - 0x5ecb04,0x5ec079,0x5eb5ef,0x5eab67,0x5ea0e0,0x5e965b,0x5e8bd8,0x5e8155, - 0x5e76d5,0x5e6c55,0x5e61d8,0x5e575c,0x5e4ce1,0x5e4268,0x5e37f0,0x5e2d79, - 0x5e2305,0x5e1891,0x5e0e1f,0x5e03af,0x5df940,0x5deed3,0x5de467,0x5dd9fc, - 0x5dcf93,0x5dc52b,0x5dbac5,0x5db061,0x5da5fd,0x5d9b9c,0x5d913b,0x5d86dc, - 0x5d7c7f,0x5d7223,0x5d67c9,0x5d5d70,0x5d5318,0x5d48c2,0x5d3e6d,0x5d341a, - 0x5d29c8,0x5d1f78,0x5d1529,0x5d0adc,0x5d0090,0x5cf645,0x5cebfc,0x5ce1b4, - 0x5cd76e,0x5ccd29,0x5cc2e6,0x5cb8a4,0x5cae63,0x5ca424,0x5c99e6,0x5c8faa, - 0x5c856f,0x5c7b36,0x5c70fe,0x5c66c7,0x5c5c92,0x5c525e,0x5c482c,0x5c3dfb, - 0x5c33cc,0x5c299d,0x5c1f71,0x5c1546,0x5c0b1c,0x5c00f3,0x5bf6cc,0x5beca7, - 0x5be282,0x5bd85f,0x5bce3e,0x5bc41e,0x5bb9ff,0x5bafe2,0x5ba5c6,0x5b9bac, - 0x5b9193,0x5b877b,0x5b7d65,0x5b7350,0x5b693d,0x5b5f2a,0x5b551a,0x5b4b0a, - 0x5b40fd,0x5b36f0,0x5b2ce5,0x5b22db,0x5b18d3,0x5b0ecc,0x5b04c6,0x5afac2, - 0x5af0bf,0x5ae6bd,0x5adcbd,0x5ad2be,0x5ac8c1,0x5abec5,0x5ab4ca,0x5aaad1, - 0x5aa0d9,0x5a96e2,0x5a8ced,0x5a82f9,0x5a7906,0x5a6f15,0x5a6525,0x5a5b37, - 0x5a514a,0x5a475e,0x5a3d74,0x5a338b,0x5a29a3,0x5a1fbd,0x5a15d8,0x5a0bf4, - 0x5a0212,0x59f831,0x59ee51,0x59e473,0x59da96,0x59d0ba,0x59c6e0,0x59bd07, - 0x59b330,0x59a959,0x599f84,0x5995b1,0x598bde,0x59820e,0x59783e,0x596e70, - 0x5964a3,0x595ad7,0x59510d,0x594744,0x593d7c,0x5933b6,0x5929f1,0x59202d, - 0x59166b,0x590caa,0x5902ea,0x58f92b,0x58ef6e,0x58e5b3,0x58dbf8,0x58d23f, - 0x58c887,0x58bed0,0x58b51b,0x58ab67,0x58a1b4,0x589803,0x588e53,0x5884a4, - 0x587af7,0x58714b,0x5867a0,0x585df6,0x58544e,0x584aa7,0x584101,0x58375d, - 0x582dba,0x582418,0x581a77,0x5810d8,0x58073a,0x57fd9d,0x57f402,0x57ea68, - 0x57e0cf,0x57d737,0x57cda1,0x57c40c,0x57ba78,0x57b0e6,0x57a754,0x579dc5, - 0x579436,0x578aa9,0x57811c,0x577792,0x576e08,0x576480,0x575af9,0x575173, - 0x5747ee,0x573e6b,0x5734e9,0x572b68,0x5721e9,0x57186b,0x570eee,0x570572, - 0x56fbf8,0x56f27e,0x56e906,0x56df90,0x56d61a,0x56cca6,0x56c333,0x56b9c1, - 0x56b051,0x56a6e2,0x569d74,0x569407,0x568a9b,0x568131,0x5677c8,0x566e60, - 0x5664fa,0x565b95,0x565231,0x5648ce,0x563f6c,0x56360c,0x562cad,0x56234f, - 0x5619f2,0x561097,0x56073c,0x55fde3,0x55f48c,0x55eb35,0x55e1e0,0x55d88c, - 0x55cf39,0x55c5e7,0x55bc97,0x55b347,0x55a9f9,0x55a0ad,0x559761,0x558e17, - 0x5584cd,0x557b86,0x55723f,0x5568f9,0x555fb5,0x555672,0x554d30,0x5543ef, - 0x553ab0,0x553171,0x552834,0x551ef8,0x5515be,0x550c84,0x55034c,0x54fa15, - 0x54f0df,0x54e7aa,0x54de77,0x54d544,0x54cc13,0x54c2e3,0x54b9b4,0x54b087, - 0x54a75a,0x549e2f,0x549505,0x548bdc,0x5482b5,0x54798e,0x547069,0x546745, - 0x545e22,0x545500,0x544be0,0x5442c0,0x5439a2,0x543085,0x542769,0x541e4f, - 0x541535,0x540c1d,0x540306,0x53f9f0,0x53f0db,0x53e7c7,0x53deb5,0x53d5a3, - 0x53cc93,0x53c384,0x53ba76,0x53b169,0x53a85e,0x539f54,0x53964a,0x538d42, - 0x53843b,0x537b36,0x537231,0x53692e,0x53602b,0x53572a,0x534e2a,0x53452b, - 0x533c2e,0x533331,0x532a36,0x53213b,0x531842,0x530f4a,0x530654,0x52fd5e, - 0x52f469,0x52eb76,0x52e284,0x52d993,0x52d0a3,0x52c7b4,0x52bec6,0x52b5d9, - 0x52acee,0x52a404,0x529b1b,0x529233,0x52894c,0x528066,0x527781,0x526e9e, - 0x5265bb,0x525cda,0x5253fa,0x524b1b,0x52423d,0x523960,0x523084,0x5227aa, - 0x521ed0,0x5215f8,0x520d21,0x52044b,0x51fb76,0x51f2a2,0x51e9cf,0x51e0fe, - 0x51d82d,0x51cf5e,0x51c68f,0x51bdc2,0x51b4f6,0x51ac2b,0x51a361,0x519a98, - 0x5191d1,0x51890a,0x518045,0x517780,0x516ebd,0x5165fb,0x515d3a,0x51547a, - 0x514bbb,0x5142fd,0x513a41,0x513185,0x5128cb,0x512011,0x511759,0x510ea2, - 0x5105ec,0x50fd36,0x50f483,0x50ebd0,0x50e31e,0x50da6d,0x50d1be,0x50c90f, - 0x50c062,0x50b7b5,0x50af0a,0x50a660,0x509db7,0x50950f,0x508c68,0x5083c2, - 0x507b1d,0x507279,0x5069d7,0x506135,0x505894,0x504ff5,0x504757,0x503eb9, - 0x50361d,0x502d82,0x5024e8,0x501c4f,0x5013b7,0x500b20,0x50028a,0x4ff9f5, - 0x4ff162,0x4fe8cf,0x4fe03d,0x4fd7ad,0x4fcf1d,0x4fc68f,0x4fbe01,0x4fb575, - 0x4facea,0x4fa460,0x4f9bd7,0x4f934e,0x4f8ac7,0x4f8241,0x4f79bc,0x4f7139, - 0x4f68b6,0x4f6034,0x4f57b3,0x4f4f33,0x4f46b5,0x4f3e37,0x4f35bb,0x4f2d3f, - 0x4f24c5,0x4f1c4b,0x4f13d3,0x4f0b5b,0x4f02e5,0x4efa70,0x4ef1fb,0x4ee988, - 0x4ee116,0x4ed8a5,0x4ed035,0x4ec7c6,0x4ebf58,0x4eb6ea,0x4eae7e,0x4ea613, - 0x4e9daa,0x4e9541,0x4e8cd9,0x4e8472,0x4e7c0c,0x4e73a7,0x4e6b43,0x4e62e1, - 0x4e5a7f,0x4e521e,0x4e49be,0x4e4160,0x4e3902,0x4e30a5,0x4e284a,0x4e1fef, - 0x4e1796,0x4e0f3d,0x4e06e5,0x4dfe8f,0x4df639,0x4dede5,0x4de591,0x4ddd3f, - 0x4dd4ed,0x4dcc9d,0x4dc44d,0x4dbbff,0x4db3b1,0x4dab65,0x4da319,0x4d9acf, - 0x4d9285,0x4d8a3d,0x4d81f5,0x4d79af,0x4d7169,0x4d6925,0x4d60e2,0x4d589f, - 0x4d505e,0x4d481d,0x4d3fde,0x4d379f,0x4d2f62,0x4d2725,0x4d1eea,0x4d16af, - 0x4d0e76,0x4d063d,0x4cfe05,0x4cf5cf,0x4ced99,0x4ce565,0x4cdd31,0x4cd4fe, - 0x4ccccd,0x4cc49c,0x4cbc6c,0x4cb43e,0x4cac10,0x4ca3e3,0x4c9bb8,0x4c938d, - 0x4c8b63,0x4c833a,0x4c7b12,0x4c72eb,0x4c6ac6,0x4c62a1,0x4c5a7d,0x4c525a, - 0x4c4a38,0x4c4217,0x4c39f7,0x4c31d7,0x4c29b9,0x4c219c,0x4c1980,0x4c1165, - 0x4c094b,0x4c0131,0x4bf919,0x4bf102,0x4be8eb,0x4be0d6,0x4bd8c1,0x4bd0ae, - 0x4bc89b,0x4bc089,0x4bb879,0x4bb069,0x4ba85a,0x4ba04d,0x4b9840,0x4b9034, - 0x4b8829,0x4b801f,0x4b7816,0x4b700e,0x4b6807,0x4b6001,0x4b57fc,0x4b4ff7, - 0x4b47f4,0x4b3ff2,0x4b37f0,0x4b2ff0,0x4b27f0,0x4b1ff2,0x4b17f4,0x4b0ff7, - 0x4b07fc,0x4b0001,0x4af807,0x4af00e,0x4ae816,0x4ae01f,0x4ad829,0x4ad034, - 0x4ac83f,0x4ac04c,0x4ab85a,0x4ab068,0x4aa878,0x4aa088,0x4a989a,0x4a90ac, - 0x4a88bf,0x4a80d3,0x4a78e8,0x4a70fe,0x4a6915,0x4a612d,0x4a5946,0x4a5160, - 0x4a497a,0x4a4196,0x4a39b2,0x4a31d0,0x4a29ee,0x4a220d,0x4a1a2d,0x4a124f, - 0x4a0a71,0x4a0294,0x49fab7,0x49f2dc,0x49eb02,0x49e328,0x49db50,0x49d378, - 0x49cba2,0x49c3cc,0x49bbf7,0x49b423,0x49ac50,0x49a47e,0x499cad,0x4994dd, - 0x498d0d,0x49853f,0x497d71,0x4975a5,0x496dd9,0x49660e,0x495e44,0x49567b, - 0x494eb3,0x4946ec,0x493f25,0x493760,0x492f9b,0x4927d8,0x492015,0x491853, - 0x491092,0x4908d2,0x490113,0x48f955,0x48f198,0x48e9db,0x48e21f,0x48da65, - 0x48d2ab,0x48caf2,0x48c33a,0x48bb83,0x48b3cd,0x48ac18,0x48a463,0x489cb0, - 0x4894fd,0x488d4b,0x48859a,0x487dea,0x48763b,0x486e8d,0x4866df,0x485f33, - 0x485787,0x484fdd,0x484833,0x48408a,0x4838e2,0x48313b,0x482994,0x4821ef, - 0x481a4a,0x4812a6,0x480b04,0x480362,0x47fbc1,0x47f420,0x47ec81,0x47e4e3, - 0x47dd45,0x47d5a8,0x47ce0c,0x47c672,0x47bed7,0x47b73e,0x47afa6,0x47a80e, - 0x47a078,0x4798e2,0x47914d,0x4789b9,0x478226,0x477a93,0x477302,0x476b71, - 0x4763e2,0x475c53,0x4754c5,0x474d37,0x4745ab,0x473e20,0x473695,0x472f0b, - 0x472783,0x471ffa,0x471873,0x4710ed,0x470968,0x4701e3,0x46fa5f,0x46f2dc, - 0x46eb5a,0x46e3d9,0x46dc59,0x46d4d9,0x46cd5a,0x46c5dd,0x46be60,0x46b6e4, - 0x46af68,0x46a7ee,0x46a074,0x4698fb,0x469184,0x468a0c,0x468296,0x467b21, - 0x4673ac,0x466c39,0x4664c6,0x465d54,0x4655e3,0x464e72,0x464703,0x463f94, - 0x463826,0x4630b9,0x46294d,0x4621e2,0x461a77,0x46130e,0x460ba5,0x46043d, - 0x45fcd6,0x45f56f,0x45ee0a,0x45e6a5,0x45df41,0x45d7de,0x45d07c,0x45c91a, - 0x45c1ba,0x45ba5a,0x45b2fb,0x45ab9d,0x45a440,0x459ce4,0x459588,0x458e2d, - 0x4586d3,0x457f7a,0x457822,0x4570ca,0x456974,0x45621e,0x455ac9,0x455374, - 0x454c21,0x4544ce,0x453d7d,0x45362c,0x452edb,0x45278c,0x45203e,0x4518f0, - 0x4511a3,0x450a57,0x45030c,0x44fbc1,0x44f477,0x44ed2e,0x44e5e6,0x44de9f, - 0x44d759,0x44d013,0x44c8ce,0x44c18a,0x44ba47,0x44b305,0x44abc3,0x44a482, - 0x449d42,0x449603,0x448ec5,0x448787,0x44804a,0x44790e,0x4471d3,0x446a99, - 0x44635f,0x445c26,0x4454ee,0x444db7,0x444681,0x443f4b,0x443816,0x4430e2, - 0x4429af,0x44227c,0x441b4b,0x44141a,0x440cea,0x4405ba,0x43fe8c,0x43f75e, - 0x43f031,0x43e905,0x43e1da,0x43daaf,0x43d385,0x43cc5c,0x43c534,0x43be0d, - 0x43b6e6,0x43afc0,0x43a89b,0x43a177,0x439a54,0x439331,0x438c0f,0x4384ee, - 0x437dcd,0x4376ae,0x436f8f,0x436871,0x436154,0x435a37,0x43531b,0x434c00, - 0x4344e6,0x433dcd,0x4336b4,0x432f9c,0x432885,0x43216f,0x431a5a,0x431345, - 0x430c31,0x43051e,0x42fe0b,0x42f6f9,0x42efe9,0x42e8d8,0x42e1c9,0x42daba, - 0x42d3ad,0x42cca0,0x42c593,0x42be88,0x42b77d,0x42b073,0x42a96a,0x42a261, - 0x429b59,0x429452,0x428d4c,0x428647,0x427f42,0x42783e,0x42713b,0x426a39, - 0x426337,0x425c36,0x425536,0x424e37,0x424738,0x42403a,0x42393d,0x423241, - 0x422b45,0x42244a,0x421d50,0x421657,0x420f5e,0x420866,0x42016f,0x41fa79, - 0x41f383,0x41ec8e,0x41e59a,0x41dea7,0x41d7b4,0x41d0c2,0x41c9d1,0x41c2e1, - 0x41bbf1,0x41b503,0x41ae14,0x41a727,0x41a03a,0x41994e,0x419263,0x418b79, - 0x41848f,0x417da6,0x4176be,0x416fd7,0x4168f0,0x41620a,0x415b25,0x415440, - 0x414d5c,0x414679,0x413f97,0x4138b6,0x4131d5,0x412af5,0x412415,0x411d37, - 0x411659,0x410f7c,0x41089f,0x4101c3,0x40fae9,0x40f40e,0x40ed35,0x40e65c, - 0x40df84,0x40d8ad,0x40d1d6,0x40cb00,0x40c42b,0x40bd57,0x40b683,0x40afb0, - 0x40a8de,0x40a20c,0x409b3b,0x40946b,0x408d9c,0x4086cd,0x408000,0x407932, - 0x407266,0x406b9a,0x4064cf,0x405e05,0x40573b,0x405072,0x4049aa,0x4042e3, - 0x403c1c,0x403556,0x402e91,0x4027cc,0x402109,0x401a45,0x401383,0x400cc1, - 0x400600,0x3fff40,0x3ff880,0x3ff1c2,0x3feb03,0x3fe446,0x3fdd89,0x3fd6cd, - 0x3fd012,0x3fc957,0x3fc29d,0x3fbbe4,0x3fb52c,0x3fae74,0x3fa7bd,0x3fa107, - 0x3f9a51,0x3f939c,0x3f8ce8,0x3f8634,0x3f7f81,0x3f78cf,0x3f721e,0x3f6b6d, - 0x3f64bd,0x3f5e0e,0x3f575f,0x3f50b1,0x3f4a04,0x3f4357,0x3f3cac,0x3f3601, - 0x3f2f56,0x3f28ac,0x3f2203,0x3f1b5b,0x3f14b3,0x3f0e0c,0x3f0766,0x3f00c1, - 0x3efa1c,0x3ef377,0x3eecd4,0x3ee631,0x3edf8f,0x3ed8ee,0x3ed24d,0x3ecbad, - 0x3ec50e,0x3ebe6f,0x3eb7d1,0x3eb134,0x3eaa97,0x3ea3fb,0x3e9d60,0x3e96c6, - 0x3e902c,0x3e8993,0x3e82fa,0x3e7c62,0x3e75cb,0x3e6f35,0x3e689f,0x3e620a, - 0x3e5b76,0x3e54e2,0x3e4e4f,0x3e47bd,0x3e412b,0x3e3a9a,0x3e340a,0x3e2d7a, - 0x3e26eb,0x3e205d,0x3e19cf,0x3e1342,0x3e0cb6,0x3e062b,0x3dffa0,0x3df916, - 0x3df28c,0x3dec03,0x3de57b,0x3ddef4,0x3dd86d,0x3dd1e7,0x3dcb61,0x3dc4dc, - 0x3dbe58,0x3db7d5,0x3db152,0x3daad0,0x3da44f,0x3d9dce,0x3d974e,0x3d90ce, - 0x3d8a4f,0x3d83d1,0x3d7d54,0x3d76d7,0x3d705b,0x3d69e0,0x3d6365,0x3d5ceb, - 0x3d5671,0x3d4ff9,0x3d4980,0x3d4309,0x3d3c92,0x3d361c,0x3d2fa7,0x3d2932, - 0x3d22be,0x3d1c4a,0x3d15d7,0x3d0f65,0x3d08f4,0x3d0283,0x3cfc13,0x3cf5a3, - 0x3cef34,0x3ce8c6,0x3ce259,0x3cdbec,0x3cd57f,0x3ccf14,0x3cc8a9,0x3cc23f, - 0x3cbbd5,0x3cb56c,0x3caf04,0x3ca89c,0x3ca235,0x3c9bcf,0x3c9569,0x3c8f04, - 0x3c889f,0x3c823c,0x3c7bd8,0x3c7576,0x3c6f14,0x3c68b3,0x3c6253,0x3c5bf3, - 0x3c5593,0x3c4f35,0x3c48d7,0x3c427a,0x3c3c1d,0x3c35c1,0x3c2f66,0x3c290b, - 0x3c22b1,0x3c1c57,0x3c15ff,0x3c0fa7,0x3c094f,0x3c02f8,0x3bfca2,0x3bf64c, - 0x3beff7,0x3be9a3,0x3be34f,0x3bdcfc,0x3bd6aa,0x3bd058,0x3bca07,0x3bc3b7, - 0x3bbd67,0x3bb718,0x3bb0c9,0x3baa7b,0x3ba42e,0x3b9de1,0x3b9795,0x3b914a, - 0x3b8aff,0x3b84b5,0x3b7e6c,0x3b7823,0x3b71db,0x3b6b93,0x3b654c,0x3b5f06, - 0x3b58c0,0x3b527b,0x3b4c36,0x3b45f3,0x3b3faf,0x3b396d,0x3b332b,0x3b2cea, - 0x3b26a9,0x3b2069,0x3b1a2a,0x3b13eb,0x3b0dad,0x3b076f,0x3b0132,0x3afaf6, - 0x3af4ba,0x3aee7f,0x3ae845,0x3ae20b,0x3adbd2,0x3ad599,0x3acf61,0x3ac92a, - 0x3ac2f3,0x3abcbd,0x3ab688,0x3ab053,0x3aaa1f,0x3aa3eb,0x3a9db8,0x3a9786, - 0x3a9154,0x3a8b23,0x3a84f2,0x3a7ec2,0x3a7893,0x3a7264,0x3a6c36,0x3a6609, - 0x3a5fdc,0x3a59b0,0x3a5384,0x3a4d59,0x3a472f,0x3a4105,0x3a3adc,0x3a34b4, - 0x3a2e8c,0x3a2864,0x3a223e,0x3a1c18,0x3a15f2,0x3a0fcd,0x3a09a9,0x3a0385, - 0x39fd62,0x39f740,0x39f11e,0x39eafd,0x39e4dc,0x39debc,0x39d89d,0x39d27e, - 0x39cc60,0x39c642,0x39c025,0x39ba09,0x39b3ed,0x39add2,0x39a7b7,0x39a19d, - 0x399b84,0x39956b,0x398f53,0x39893b,0x398324,0x397d0e,0x3976f8,0x3970e3, - 0x396ace,0x3964ba,0x395ea7,0x395894,0x395282,0x394c70,0x39465f,0x39404f, - 0x393a3f,0x393430,0x392e21,0x392813,0x392206,0x391bf9,0x3915ed,0x390fe1, - 0x3909d6,0x3903cb,0x38fdc1,0x38f7b8,0x38f1af,0x38eba7,0x38e5a0,0x38df99, - 0x38d993,0x38d38d,0x38cd88,0x38c783,0x38c17f,0x38bb7c,0x38b579,0x38af77, - 0x38a975,0x38a374,0x389d73,0x389774,0x389174,0x388b76,0x388577,0x387f7a, - 0x38797d,0x387381,0x386d85,0x38678a,0x38618f,0x385b95,0x38559b,0x384fa2, - 0x3849aa,0x3843b2,0x383dbb,0x3837c5,0x3831cf,0x382bd9,0x3825e4,0x381ff0, - 0x3819fd,0x381409,0x380e17,0x380825,0x380234,0x37fc43,0x37f653,0x37f063, - 0x37ea74,0x37e485,0x37de97,0x37d8aa,0x37d2bd,0x37ccd1,0x37c6e5,0x37c0fa, - 0x37bb10,0x37b526,0x37af3d,0x37a954,0x37a36c,0x379d84,0x37979d,0x3791b6, - 0x378bd0,0x3785eb,0x378006,0x377a22,0x37743e,0x376e5b,0x376879,0x376297, - 0x375cb5,0x3756d5,0x3750f4,0x374b15,0x374535,0x373f57,0x373979,0x37339b, - 0x372dbf,0x3727e2,0x372206,0x371c2b,0x371651,0x371077,0x370a9d,0x3704c4, - 0x36feec,0x36f914,0x36f33d,0x36ed66,0x36e790,0x36e1ba,0x36dbe5,0x36d611, - 0x36d03d,0x36ca69,0x36c497,0x36bec4,0x36b8f3,0x36b321,0x36ad51,0x36a781, - 0x36a1b1,0x369be2,0x369614,0x369046,0x368a79,0x3684ac,0x367ee0,0x367915, - 0x36734a,0x366d7f,0x3667b5,0x3661ec,0x365c23,0x36565b,0x365093,0x364acc, - 0x364505,0x363f3f,0x363979,0x3633b4,0x362df0,0x36282c,0x362269,0x361ca6, - 0x3616e4,0x361122,0x360b61,0x3605a0,0x35ffe0,0x35fa20,0x35f461,0x35eea3, - 0x35e8e5,0x35e328,0x35dd6b,0x35d7af,0x35d1f3,0x35cc38,0x35c67d,0x35c0c3, - 0x35bb09,0x35b550,0x35af98,0x35a9e0,0x35a429,0x359e72,0x3598bb,0x359306, - 0x358d50,0x35879c,0x3581e8,0x357c34,0x357681,0x3570ce,0x356b1c,0x35656b, - 0x355fba,0x355a09,0x355459,0x354eaa,0x3548fb,0x35434d,0x353d9f,0x3537f2, - 0x353245,0x352c99,0x3526ee,0x352143,0x351b98,0x3515ee,0x351045,0x350a9c + 0x3504f3, 0x34f9a4, 0x34ee57, 0x34e30c, 0x34d7c3, 0x34cc7c, 0x34c137, 0x34b5f5, + 0x34aab4, 0x349f76, 0x34943a, 0x348900, 0x347dc7, 0x347291, 0x34675e, 0x345c2c, + 0x3450fc, 0x3445ce, 0x343aa3, 0x342f79, 0x342452, 0x34192c, 0x340e09, 0x3402e8, + 0x33f7c9, 0x33ecac, 0x33e191, 0x33d678, 0x33cb61, 0x33c04c, 0x33b539, 0x33aa28, + 0x339f19, 0x33940d, 0x338902, 0x337df9, 0x3372f3, 0x3367ee, 0x335cec, 0x3351eb, + 0x3346ed, 0x333bf0, 0x3330f6, 0x3325fd, 0x331b07, 0x331013, 0x330520, 0x32fa30, + 0x32ef41, 0x32e455, 0x32d96b, 0x32ce82, 0x32c39c, 0x32b8b7, 0x32add5, 0x32a2f5, + 0x329816, 0x328d3a, 0x32825f, 0x327787, 0x326cb0, 0x3261dc, 0x325709, 0x324c38, + 0x32416a, 0x32369d, 0x322bd2, 0x32210a, 0x321643, 0x320b7e, 0x3200bb, 0x31f5fa, + 0x31eb3b, 0x31e07e, 0x31d5c3, 0x31cb0a, 0x31c053, 0x31b59d, 0x31aaea, 0x31a038, + 0x319589, 0x318adb, 0x318030, 0x317586, 0x316ade, 0x316038, 0x315594, 0x314af2, + 0x314052, 0x3135b4, 0x312b18, 0x31207d, 0x3115e5, 0x310b4e, 0x3100b9, 0x30f627, + 0x30eb96, 0x30e107, 0x30d67a, 0x30cbee, 0x30c165, 0x30b6dd, 0x30ac58, 0x30a1d4, + 0x309752, 0x308cd2, 0x308254, 0x3077d8, 0x306d5e, 0x3062e5, 0x30586e, 0x304dfa, + 0x304387, 0x303916, 0x302ea7, 0x302439, 0x3019ce, 0x300f64, 0x3004fc, 0x2ffa96, + 0x2ff032, 0x2fe5d0, 0x2fdb6f, 0x2fd111, 0x2fc6b4, 0x2fbc59, 0x2fb200, 0x2fa7a9, + 0x2f9d53, 0x2f9300, 0x2f88ae, 0x2f7e5e, 0x2f7410, 0x2f69c3, 0x2f5f79, 0x2f5530, + 0x2f4ae9, 0x2f40a4, 0x2f3661, 0x2f2c1f, 0x2f21df, 0x2f17a1, 0x2f0d65, 0x2f032b, + 0x2ef8f2, 0x2eeebc, 0x2ee487, 0x2eda53, 0x2ed022, 0x2ec5f2, 0x2ebbc5, 0x2eb199, + 0x2ea76e, 0x2e9d46, 0x2e931f, 0x2e88fa, 0x2e7ed7, 0x2e74b5, 0x2e6a96, 0x2e6078, + 0x2e565c, 0x2e4c41, 0x2e4229, 0x2e3812, 0x2e2dfd, 0x2e23e9, 0x2e19d8, 0x2e0fc8, + 0x2e05ba, 0x2dfbad, 0x2df1a3, 0x2de79a, 0x2ddd93, 0x2dd38d, 0x2dc989, 0x2dbf87, + 0x2db587, 0x2dab89, 0x2da18c, 0x2d9791, 0x2d8d97, 0x2d83a0, 0x2d79aa, 0x2d6fb6, + 0x2d65c3, 0x2d5bd2, 0x2d51e3, 0x2d47f6, 0x2d3e0a, 0x2d3420, 0x2d2a38, 0x2d2051, + 0x2d166c, 0x2d0c89, 0x2d02a8, 0x2cf8c8, 0x2ceeea, 0x2ce50d, 0x2cdb33, 0x2cd15a, + 0x2cc782, 0x2cbdad, 0x2cb3d9, 0x2caa06, 0x2ca036, 0x2c9667, 0x2c8c99, 0x2c82ce, + 0x2c7904, 0x2c6f3b, 0x2c6575, 0x2c5bb0, 0x2c51ed, 0x2c482b, 0x2c3e6b, 0x2c34ad, + 0x2c2af0, 0x2c2135, 0x2c177b, 0x2c0dc4, 0x2c040e, 0x2bfa59, 0x2bf0a6, 0x2be6f5, + 0x2bdd46, 0x2bd398, 0x2bc9eb, 0x2bc041, 0x2bb698, 0x2bacf0, 0x2ba34b, 0x2b99a6, + 0x2b9004, 0x2b8663, 0x2b7cc4, 0x2b7326, 0x2b698a, 0x2b5ff0, 0x2b5657, 0x2b4cc0, + 0x2b432a, 0x2b3996, 0x2b3004, 0x2b2673, 0x2b1ce4, 0x2b1357, 0x2b09cb, 0x2b0040, + 0x2af6b7, 0x2aed30, 0x2ae3ab, 0x2ada27, 0x2ad0a4, 0x2ac724, 0x2abda4, 0x2ab427, + 0x2aaaab, 0x2aa130, 0x2a97b7, 0x2a8e40, 0x2a84ca, 0x2a7b56, 0x2a71e3, 0x2a6872, + 0x2a5f03, 0x2a5595, 0x2a4c29, 0x2a42be, 0x2a3955, 0x2a2fed, 0x2a2687, 0x2a1d23, + 0x2a13c0, 0x2a0a5e, 0x2a00fe, 0x29f7a0, 0x29ee43, 0x29e4e8, 0x29db8e, 0x29d236, + 0x29c8e0, 0x29bf8b, 0x29b637, 0x29ace5, 0x29a395, 0x299a46, 0x2990f8, 0x2987ad, + 0x297e62, 0x297519, 0x296bd2, 0x29628c, 0x295948, 0x295005, 0x2946c4, 0x293d85, + 0x293446, 0x292b0a, 0x2921cf, 0x291895, 0x290f5d, 0x290626, 0x28fcf1, 0x28f3be, + 0x28ea8c, 0x28e15b, 0x28d82c, 0x28cefe, 0x28c5d2, 0x28bca8, 0x28b37f, 0x28aa57, + 0x28a131, 0x28980c, 0x288ee9, 0x2885c7, 0x287ca7, 0x287389, 0x286a6b, 0x286150, + 0x285835, 0x284f1c, 0x284605, 0x283cef, 0x2833db, 0x282ac8, 0x2821b7, 0x2818a7, + 0x280f98, 0x28068b, 0x27fd80, 0x27f475, 0x27eb6d, 0x27e266, 0x27d960, 0x27d05c, + 0x27c759, 0x27be57, 0x27b557, 0x27ac59, 0x27a35c, 0x279a60, 0x279166, 0x27886d, + 0x277f76, 0x277680, 0x276d8c, 0x276499, 0x275ba7, 0x2752b7, 0x2749c9, 0x2740db, + 0x2737f0, 0x272f05, 0x27261c, 0x271d35, 0x27144f, 0x270b6a, 0x270287, 0x26f9a5, + 0x26f0c4, 0x26e7e5, 0x26df08, 0x26d62c, 0x26cd51, 0x26c477, 0x26bba0, 0x26b2c9, + 0x26a9f4, 0x26a120, 0x26984e, 0x268f7d, 0x2686ad, 0x267ddf, 0x267512, 0x266c47, + 0x26637d, 0x265ab4, 0x2651ed, 0x264927, 0x264063, 0x2637a0, 0x262ede, 0x26261e, + 0x261d5f, 0x2614a2, 0x260be6, 0x26032b, 0x25fa72, 0x25f1ba, 0x25e903, 0x25e04e, + 0x25d79a, 0x25cee7, 0x25c636, 0x25bd87, 0x25b4d8, 0x25ac2b, 0x25a37f, 0x259ad5, + 0x25922c, 0x258985, 0x2580de, 0x257839, 0x256f96, 0x2566f4, 0x255e53, 0x2555b3, + 0x254d15, 0x254479, 0x253bdd, 0x253343, 0x252aaa, 0x252213, 0x25197d, 0x2510e8, + 0x250855, 0x24ffc3, 0x24f732, 0x24eea3, 0x24e615, 0x24dd88, 0x24d4fc, 0x24cc72, + 0x24c3ea, 0x24bb62, 0x24b2dc, 0x24aa57, 0x24a1d4, 0x249952, 0x2490d1, 0x248852, + 0x247fd3, 0x247756, 0x246edb, 0x246661, 0x245de8, 0x245570, 0x244cfa, 0x244485, + 0x243c11, 0x24339f, 0x242b2e, 0x2422be, 0x241a4f, 0x2411e2, 0x240976, 0x24010c, + 0x23f8a2, 0x23f03a, 0x23e7d4, 0x23df6e, 0x23d70a, 0x23cea7, 0x23c646, 0x23bde6, + 0x23b587, 0x23ad29, 0x23a4cc, 0x239c71, 0x239417, 0x238bbf, 0x238368, 0x237b12, + 0x2372bd, 0x236a69, 0x236217, 0x2359c6, 0x235177, 0x234928, 0x2340db, 0x23388f, + 0x233045, 0x2327fb, 0x231fb3, 0x23176c, 0x230f27, 0x2306e2, 0x22fe9f, 0x22f65e, + 0x22ee1d, 0x22e5de, 0x22dda0, 0x22d563, 0x22cd28, 0x22c4ed, 0x22bcb4, 0x22b47c, + 0x22ac46, 0x22a411, 0x229bdd, 0x2293aa, 0x228b78, 0x228348, 0x227b19, 0x2272eb, + 0x226abe, 0x226293, 0x225a69, 0x225240, 0x224a18, 0x2241f2, 0x2239cc, 0x2231a8, + 0x222985, 0x222164, 0x221944, 0x221124, 0x220907, 0x2200ea, 0x21f8ce, 0x21f0b4, + 0x21e89b, 0x21e083, 0x21d86d, 0x21d057, 0x21c843, 0x21c030, 0x21b81e, 0x21b00e, + 0x21a7fe, 0x219ff0, 0x2197e3, 0x218fd8, 0x2187cd, 0x217fc4, 0x2177bc, 0x216fb5, + 0x2167af, 0x215faa, 0x2157a7, 0x214fa5, 0x2147a4, 0x213fa4, 0x2137a5, 0x212fa8, + 0x2127ac, 0x211fb1, 0x2117b7, 0x210fbe, 0x2107c7, 0x20ffd0, 0x20f7db, 0x20efe7, + 0x20e7f5, 0x20e003, 0x20d813, 0x20d023, 0x20c835, 0x20c048, 0x20b85d, 0x20b072, + 0x20a889, 0x20a0a1, 0x2098ba, 0x2090d4, 0x2088ef, 0x20810b, 0x207929, 0x207148, + 0x206968, 0x206189, 0x2059ab, 0x2051cf, 0x2049f3, 0x204219, 0x203a40, 0x203268, + 0x202a91, 0x2022bb, 0x201ae7, 0x201313, 0x200b41, 0x200370, 0x1ffba0, 0x1ff3d1, + 0x1fec04, 0x1fe437, 0x1fdc6c, 0x1fd4a2, 0x1fccd9, 0x1fc511, 0x1fbd4a, 0x1fb584, + 0x1fadc0, 0x1fa5fc, 0x1f9e3a, 0x1f9679, 0x1f8eb9, 0x1f86fa, 0x1f7f3c, 0x1f777f, + 0x1f6fc4, 0x1f680a, 0x1f6050, 0x1f5898, 0x1f50e1, 0x1f492b, 0x1f4176, 0x1f39c3, + 0x1f3210, 0x1f2a5f, 0x1f22af, 0x1f1aff, 0x1f1351, 0x1f0ba4, 0x1f03f8, 0x1efc4e, + 0x1ef4a4, 0x1eecfb, 0x1ee554, 0x1eddae, 0x1ed608, 0x1ece64, 0x1ec6c1, 0x1ebf1f, + 0x1eb77f, 0x1eafdf, 0x1ea840, 0x1ea0a3, 0x1e9906, 0x1e916b, 0x1e89d1, 0x1e8238, + 0x1e7aa0, 0x1e7309, 0x1e6b73, 0x1e63de, 0x1e5c4a, 0x1e54b8, 0x1e4d26, 0x1e4596, + 0x1e3e06, 0x1e3678, 0x1e2eeb, 0x1e275f, 0x1e1fd4, 0x1e184a, 0x1e10c1, 0x1e0939, + 0x1e01b3, 0x1dfa2d, 0x1df2a8, 0x1deb25, 0x1de3a2, 0x1ddc21, 0x1dd4a1, 0x1dcd22, + 0x1dc5a3, 0x1dbe26, 0x1db6aa, 0x1daf2f, 0x1da7b6, 0x1da03d, 0x1d98c5, 0x1d914e, + 0x1d89d9, 0x1d8264, 0x1d7af1, 0x1d737e, 0x1d6c0d, 0x1d649c, 0x1d5d2d, 0x1d55bf, + 0x1d4e52, 0x1d46e5, 0x1d3f7a, 0x1d3810, 0x1d30a7, 0x1d293f, 0x1d21d8, 0x1d1a73, + 0x1d130e, 0x1d0baa, 0x1d0447, 0x1cfce6, 0x1cf585, 0x1cee25, 0x1ce6c7, 0x1cdf69, + 0x1cd80d, 0x1cd0b1, 0x1cc957, 0x1cc1fe, 0x1cbaa5, 0x1cb34e, 0x1cabf8, 0x1ca4a2, + 0x1c9d4e, 0x1c95fb, 0x1c8ea9, 0x1c8758, 0x1c8008, 0x1c78b8, 0x1c716a, 0x1c6a1d, + 0x1c62d1, 0x1c5b86, 0x1c543c, 0x1c4cf3, 0x1c45ab, 0x1c3e65, 0x1c371f, 0x1c2fda, + 0x1c2896, 0x1c2153, 0x1c1a11, 0x1c12d0, 0x1c0b90, 0x1c0452, 0x1bfd14, 0x1bf5d7, + 0x1bee9b, 0x1be760, 0x1be027, 0x1bd8ee, 0x1bd1b6, 0x1bca7f, 0x1bc349, 0x1bbc15, + 0x1bb4e1, 0x1badae, 0x1ba67c, 0x1b9f4c, 0x1b981c, 0x1b90ed, 0x1b89bf, 0x1b8292, + 0x1b7b67, 0x1b743c, 0x1b6d12, 0x1b65e9, 0x1b5ec1, 0x1b579a, 0x1b5074, 0x1b4950, + 0x1b422c, 0x1b3b09, 0x1b33e7, 0x1b2cc6, 0x1b25a6, 0x1b1e87, 0x1b1769, 0x1b104c, + 0x1b0930, 0x1b0215, 0x1afafb, 0x1af3e2, 0x1aecc9, 0x1ae5b2, 0x1ade9c, 0x1ad787, + 0x1ad073, 0x1ac95f, 0x1ac24d, 0x1abb3c, 0x1ab42b, 0x1aad1c, 0x1aa60d, 0x1a9f00, + 0x1a97f3, 0x1a90e8, 0x1a89dd, 0x1a82d4, 0x1a7bcb, 0x1a74c3, 0x1a6dbd, 0x1a66b7, + 0x1a5fb2, 0x1a58ae, 0x1a51ab, 0x1a4aa9, 0x1a43a8, 0x1a3ca8, 0x1a35a9, 0x1a2eab, + 0x1a27ae, 0x1a20b1, 0x1a19b6, 0x1a12bc, 0x1a0bc2, 0x1a04ca, 0x19fdd2, 0x19f6dc, + 0x19efe6, 0x19e8f2, 0x19e1fe, 0x19db0b, 0x19d419, 0x19cd28, 0x19c638, 0x19bf49, + 0x19b85b, 0x19b16e, 0x19aa82, 0x19a396, 0x199cac, 0x1995c3, 0x198eda, 0x1987f3, + 0x19810c, 0x197a26, 0x197342, 0x196c5e, 0x19657b, 0x195e99, 0x1957b8, 0x1950d8, + 0x1949f8, 0x19431a, 0x193c3d, 0x193560, 0x192e85, 0x1927aa, 0x1920d1, 0x1919f8, + 0x191320, 0x190c49, 0x190573, 0x18fe9e, 0x18f7ca, 0x18f0f7, 0x18ea24, 0x18e353, + 0x18dc82, 0x18d5b3, 0x18cee4, 0x18c816, 0x18c149, 0x18ba7d, 0x18b3b2, 0x18ace8, + 0x18a61f, 0x189f56, 0x18988f, 0x1891c8, 0x188b03, 0x18843e, 0x187d7a, 0x1876b7, + 0x186ff5, 0x186934, 0x186274, 0x185bb4, 0x1854f6, 0x184e38, 0x18477c, 0x1840c0, + 0x183a05, 0x18334b, 0x182c92, 0x1825da, 0x181f23, 0x18186c, 0x1811b7, 0x180b02, + 0x18044e, 0x17fd9b, 0x17f6e9, 0x17f038, 0x17e988, 0x17e2d9, 0x17dc2a, 0x17d57d, + 0x17ced0, 0x17c824, 0x17c179, 0x17bacf, 0x17b426, 0x17ad7e, 0x17a6d6, 0x17a030, + 0x17998a, 0x1792e5, 0x178c41, 0x17859e, 0x177efc, 0x17785b, 0x1771ba, 0x176b1b, + 0x17647c, 0x175dde, 0x175741, 0x1750a5, 0x174a0a, 0x17436f, 0x173cd6, 0x17363d, + 0x172fa5, 0x17290f, 0x172278, 0x171be3, 0x17154f, 0x170ebb, 0x170829, 0x170197, + 0x16fb06, 0x16f476, 0x16ede7, 0x16e759, 0x16e0cb, 0x16da3e, 0x16d3b3, 0x16cd28, + 0x16c69e, 0x16c014, 0x16b98c, 0x16b305, 0x16ac7e, 0x16a5f8, 0x169f73, 0x1698ef, + 0x16926c, 0x168be9, 0x168568, 0x167ee7, 0x167867, 0x1671e8, 0x166b6a, 0x1664ec, + 0x165e70, 0x1657f4, 0x165179, 0x164aff, 0x164486, 0x163e0d, 0x163796, 0x16311f, + 0x162aa9, 0x162434, 0x161dc0, 0x16174d, 0x1610da, 0x160a68, 0x1603f8, 0x15fd88, + 0x15f718, 0x15f0aa, 0x15ea3c, 0x15e3d0, 0x15dd64, 0x15d6f9, 0x15d08e, 0x15ca25, + 0x15c3bc, 0x15bd55, 0x15b6ee, 0x15b087, 0x15aa22, 0x15a3be, 0x159d5a, 0x1596f7, + 0x159095, 0x158a34, 0x1583d3, 0x157d74, 0x157715, 0x1570b7, 0x156a5a, 0x1563fd, + 0x155da2, 0x155747, 0x1550ed, 0x154a94, 0x15443c, 0x153de4, 0x15378e, 0x153138, + 0x152ae3, 0x15248e, 0x151e3b, 0x1517e8, 0x151197, 0x150b45, 0x1504f5, 0x14fea6, + 0x14f857, 0x14f209, 0x14ebbc, 0x14e570, 0x14df25, 0x14d8da, 0x14d290, 0x14cc47, + 0x14c5ff, 0x14bfb7, 0x14b971, 0x14b32b, 0x14ace6, 0x14a6a1, 0x14a05e, 0x149a1b, + 0x1493d9, 0x148d98, 0x148758, 0x148118, 0x147ada, 0x14749c, 0x146e5f, 0x146822, + 0x1461e7, 0x145bac, 0x145572, 0x144f38, 0x144900, 0x1442c8, 0x143c91, 0x14365b, + 0x143026, 0x1429f1, 0x1423be, 0x141d8b, 0x141758, 0x141127, 0x140af6, 0x1404c6, + 0x13fe97, 0x13f869, 0x13f23b, 0x13ec0f, 0x13e5e3, 0x13dfb7, 0x13d98d, 0x13d363, + 0x13cd3a, 0x13c712, 0x13c0eb, 0x13bac4, 0x13b49e, 0x13ae79, 0x13a855, 0x13a231, + 0x139c0e, 0x1395ec, 0x138fcb, 0x1389ab, 0x13838b, 0x137d6c, 0x13774e, 0x137130, + 0x136b13, 0x1364f8, 0x135edc, 0x1358c2, 0x1352a8, 0x134c8f, 0x134677, 0x134060, + 0x133a49, 0x133433, 0x132e1e, 0x13280a, 0x1321f6, 0x131be3, 0x1315d1, 0x130fc0, + 0x1309af, 0x13039f, 0x12fd90, 0x12f782, 0x12f174, 0x12eb67, 0x12e55b, 0x12df50, + 0x12d945, 0x12d33b, 0x12cd32, 0x12c72a, 0x12c122, 0x12bb1b, 0x12b515, 0x12af10, + 0x12a90b, 0x12a307, 0x129d04, 0x129702, 0x129100, 0x128aff, 0x1284ff, 0x127eff, + 0x127900, 0x127302, 0x126d05, 0x126708, 0x12610d, 0x125b11, 0x125517, 0x124f1d, + 0x124925, 0x12432c, 0x123d35, 0x12373e, 0x123148, 0x122b53, 0x12255e, 0x121f6b, + 0x121978, 0x121385, 0x120d94, 0x1207a3, 0x1201b3, 0x11fbc3, 0x11f5d4, 0x11efe6, + 0x11e9f9, 0x11e40d, 0x11de21, 0x11d836, 0x11d24b, 0x11cc62, 0x11c679, 0x11c090, + 0x11baa9, 0x11b4c2, 0x11aedc, 0x11a8f7, 0x11a312, 0x119d2e, 0x11974b, 0x119168, + 0x118b87, 0x1185a6, 0x117fc5, 0x1179e5, 0x117407, 0x116e28, 0x11684b, 0x11626e, + 0x115c92, 0x1156b6, 0x1150dc, 0x114b02, 0x114529, 0x113f50, 0x113978, 0x1133a1, + 0x112dca, 0x1127f5, 0x112220, 0x111c4b, 0x111678, 0x1110a5, 0x110ad3, 0x110501, + 0x10ff30, 0x10f960, 0x10f391, 0x10edc2, 0x10e7f4, 0x10e226, 0x10dc5a, 0x10d68e, + 0x10d0c3, 0x10caf8, 0x10c52e, 0x10bf65, 0x10b99c, 0x10b3d5, 0x10ae0e, 0x10a847, + 0x10a281, 0x109cbc, 0x1096f8, 0x109134, 0x108b72, 0x1085af, 0x107fee, 0x107a2d, + 0x10746d, 0x106ead, 0x1068ee, 0x106330, 0x105d73, 0x1057b6, 0x1051fa, 0x104c3e, + 0x104684, 0x1040ca, 0x103b10, 0x103558, 0x102fa0, 0x1029e8, 0x102432, 0x101e7c, + 0x1018c6, 0x101312, 0x100d5e, 0x1007ab, 0x1001f8, 0xffc46, 0xff695, 0xff0e4, + 0xfeb35, 0xfe585, 0xfdfd7, 0xfda29, 0xfd47c, 0xfcecf, 0xfc923, 0xfc378, + 0xfbdce, 0xfb824, 0xfb27b, 0xfacd2, 0xfa72a, 0xfa183, 0xf9bdd, 0xf9637, + 0xf9092, 0xf8aed, 0xf854a, 0xf7fa6, 0xf7a04, 0xf7462, 0xf6ec1, 0xf6920, + 0xf6381, 0xf5de1, 0xf5843, 0xf52a5, 0xf4d08, 0xf476b, 0xf41cf, 0xf3c34, + 0xf369a, 0xf3100, 0xf2b66, 0xf25ce, 0xf2036, 0xf1a9f, 0xf1508, 0xf0f72, + 0xf09dd, 0xf0448, 0xefeb4, 0xef921, 0xef38e, 0xeedfc, 0xee86b, 0xee2da, + 0xedd4a, 0xed7ba, 0xed22b, 0xecc9d, 0xec710, 0xec183, 0xebbf7, 0xeb66b, + 0xeb0e0, 0xeab56, 0xea5cc, 0xea043, 0xe9abb, 0xe9533, 0xe8fac, 0xe8a26, + 0xe84a0, 0xe7f1b, 0xe7996, 0xe7413, 0xe6e8f, 0xe690d, 0xe638b, 0xe5e0a, + 0xe5889, 0xe5309, 0xe4d8a, 0xe480b, 0xe428d, 0xe3d0f, 0xe3792, 0xe3216, + 0xe2c9b, 0xe2720, 0xe21a5, 0xe1c2c, 0xe16b3, 0xe113a, 0xe0bc3, 0xe064c, + 0xe00d5, 0xdfb5f, 0xdf5ea, 0xdf075, 0xdeb01, 0xde58e, 0xde01b, 0xddaa9, + 0xdd538, 0xdcfc7, 0xdca57, 0xdc4e7, 0xdbf78, 0xdba0a, 0xdb49c, 0xdaf2f, + 0xda9c2, 0xda457, 0xd9eeb, 0xd9981, 0xd9417, 0xd8ead, 0xd8945, 0xd83dc, + 0xd7e75, 0xd790e, 0xd73a8, 0xd6e42, 0xd68dd, 0xd6379, 0xd5e15, 0xd58b2, + 0xd534f, 0xd4ded, 0xd488c, 0xd432b, 0xd3dcb, 0xd386c, 0xd330d, 0xd2dae, + 0xd2851, 0xd22f4, 0xd1d97, 0xd183b, 0xd12e0, 0xd0d86, 0xd082c, 0xd02d2, + 0xcfd79, 0xcf821, 0xcf2ca, 0xced73, 0xce81c, 0xce2c7, 0xcdd72, 0xcd81d, + 0xcd2c9, 0xccd76, 0xcc823, 0xcc2d1, 0xcbd7f, 0xcb82f, 0xcb2de, 0xcad8f, + 0xca83f, 0xca2f1, 0xc9da3, 0xc9856, 0xc9309, 0xc8dbd, 0xc8871, 0xc8326, + 0xc7ddc, 0xc7892, 0xc7349, 0xc6e01, 0xc68b9, 0xc6372, 0xc5e2b, 0xc58e5, + 0xc539f, 0xc4e5a, 0xc4916, 0xc43d2, 0xc3e8f, 0xc394c, 0xc340a, 0xc2ec9, + 0xc2988, 0xc2448, 0xc1f08, 0xc19c9, 0xc148b, 0xc0f4d, 0xc0a10, 0xc04d3, + 0xbff97, 0xbfa5b, 0xbf521, 0xbefe6, 0xbeaad, 0xbe573, 0xbe03b, 0xbdb03, + 0xbd5cb, 0xbd095, 0xbcb5e, 0xbc629, 0xbc0f4, 0xbbbbf, 0xbb68b, 0xbb158, + 0xbac25, 0xba6f3, 0xba1c1, 0xb9c90, 0xb9760, 0xb9230, 0xb8d01, 0xb87d2, + 0xb82a4, 0xb7d76, 0xb7849, 0xb731d, 0xb6df1, 0xb68c6, 0xb639b, 0xb5e71, + 0xb5948, 0xb541f, 0xb4ef6, 0xb49cf, 0xb44a7, 0xb3f81, 0xb3a5b, 0xb3535, + 0xb3010, 0xb2aec, 0xb25c8, 0xb20a5, 0xb1b82, 0xb1660, 0xb113e, 0xb0c1d, + 0xb06fd, 0xb01dd, 0xafcbe, 0xaf79f, 0xaf281, 0xaed64, 0xae847, 0xae32a, + 0xade0e, 0xad8f3, 0xad3d8, 0xacebe, 0xac9a4, 0xac48b, 0xabf73, 0xaba5b, + 0xab544, 0xab02d, 0xaab17, 0xaa601, 0xaa0ec, 0xa9bd7, 0xa96c3, 0xa91b0, + 0xa8c9d, 0xa878a, 0xa8279, 0xa7d67, 0xa7857, 0xa7347, 0xa6e37, 0xa6928, + 0xa641a, 0xa5f0c, 0xa59fe, 0xa54f2, 0xa4fe5, 0xa4ada, 0xa45ce, 0xa40c4, + 0xa3bba, 0xa36b0, 0xa31a7, 0xa2c9f, 0xa2797, 0xa2290, 0xa1d89, 0xa1883, + 0xa137d, 0xa0e78, 0xa0974, 0xa0470, 0x9ff6c, 0x9fa69, 0x9f567, 0x9f065, + 0x9eb64, 0x9e663, 0x9e163, 0x9dc63, 0x9d764, 0x9d266, 0x9cd68, 0x9c86a, + 0x9c36d, 0x9be71, 0x9b975, 0x9b47a, 0x9af7f, 0x9aa85, 0x9a58b, 0x9a092, + 0x99b9a, 0x996a1, 0x991aa, 0x98cb3, 0x987bd, 0x982c7, 0x97dd1, 0x978dc, + 0x973e8, 0x96ef4, 0x96a01, 0x9650e, 0x9601c, 0x95b2b, 0x9563a, 0x95149, + 0x94c59, 0x94769, 0x9427a, 0x93d8c, 0x9389e, 0x933b1, 0x92ec4, 0x929d8, + 0x924ec, 0x92001, 0x91b16, 0x9162c, 0x91142, 0x90c59, 0x90770, 0x90288, + 0x8fda1, 0x8f8ba, 0x8f3d3, 0x8eeed, 0x8ea08, 0x8e523, 0x8e03e, 0x8db5b, + 0x8d677, 0x8d194, 0x8ccb2, 0x8c7d0, 0x8c2ef, 0x8be0e, 0x8b92e, 0x8b44e, + 0x8af6f, 0x8aa91, 0x8a5b2, 0x8a0d5, 0x89bf8, 0x8971b, 0x8923f, 0x88d64, + 0x88889, 0x883ae, 0x87ed4, 0x879fb, 0x87522, 0x87049, 0x86b71, 0x8669a, + 0x861c3, 0x85ced, 0x85817, 0x85341, 0x84e6d, 0x84998, 0x844c5, 0x83ff1, + 0x83b1e, 0x8364c, 0x8317a, 0x82ca9, 0x827d8, 0x82308, 0x81e39, 0x81969, + 0x8149b, 0x80fcd, 0x80aff, 0x80632, 0x80165, 0x7fc99, 0x7f7cd, 0x7f302, + 0x7ee37, 0x7e96d, 0x7e4a4, 0x7dfdb, 0x7db12, 0x7d64a, 0x7d182, 0x7ccbb, + 0x7c7f5, 0x7c32f, 0x7be69, 0x7b9a4, 0x7b4df, 0x7b01b, 0x7ab58, 0x7a695, + 0x7a1d2, 0x79d10, 0x7984f, 0x7938e, 0x78ecd, 0x78a0d, 0x7854d, 0x7808e, + 0x77bd0, 0x77712, 0x77254, 0x76d97, 0x768da, 0x7641e, 0x75f63, 0x75aa8, + 0x755ed, 0x75133, 0x74c79, 0x747c0, 0x74308, 0x73e50, 0x73998, 0x734e1, + 0x7302a, 0x72b74, 0x726be, 0x72209, 0x71d55, 0x718a0, 0x713ed, 0x70f3a, + 0x70a87, 0x705d5, 0x70123, 0x6fc72, 0x6f7c1, 0x6f311, 0x6ee61, 0x6e9b2, + 0x6e503, 0x6e055, 0x6dba7, 0x6d6f9, 0x6d24d, 0x6cda0, 0x6c8f4, 0x6c449, + 0x6bf9e, 0x6baf4, 0x6b64a, 0x6b1a0, 0x6acf7, 0x6a84f, 0x6a3a7, 0x69eff, + 0x69a58, 0x695b2, 0x6910c, 0x68c66, 0x687c1, 0x6831d, 0x67e78, 0x679d5, + 0x67532, 0x6708f, 0x66bed, 0x6674b, 0x662aa, 0x65e09, 0x65969, 0x654c9, + 0x65029, 0x64b8a, 0x646ec, 0x6424e, 0x63db1, 0x63914, 0x63477, 0x62fdb, + 0x62b40, 0x626a5, 0x6220a, 0x61d70, 0x618d6, 0x6143d, 0x60fa4, 0x60b0c, + 0x60674, 0x601dd, 0x5fd46, 0x5f8b0, 0x5f41a, 0x5ef85, 0x5eaf0, 0x5e65b, + 0x5e1c7, 0x5dd34, 0x5d8a1, 0x5d40e, 0x5cf7c, 0x5caea, 0x5c659, 0x5c1c9, + 0x5bd38, 0x5b8a9, 0x5b419, 0x5af8a, 0x5aafc, 0x5a66e, 0x5a1e1, 0x59d54, + 0x598c7, 0x5943b, 0x58fb0, 0x58b24, 0x5869a, 0x58210, 0x57d86, 0x578fd, + 0x57474, 0x56feb, 0x56b64, 0x566dc, 0x56255, 0x55dcf, 0x55949, 0x554c3, + 0x5503e, 0x54bb9, 0x54735, 0x542b1, 0x53e2e, 0x539ab, 0x53529, 0x530a7, + 0x52c25, 0x527a4, 0x52324, 0x51ea4, 0x51a24, 0x515a5, 0x51126, 0x50ca8, + 0x5082a, 0x503ad, 0x4ff30, 0x4fab4, 0x4f638, 0x4f1bc, 0x4ed41, 0x4e8c6, + 0x4e44c, 0x4dfd3, 0x4db59, 0x4d6e0, 0x4d268, 0x4cdf0, 0x4c979, 0x4c502, + 0x4c08b, 0x4bc15, 0x4b79f, 0x4b32a, 0x4aeb5, 0x4aa41, 0x4a5cd, 0x4a15a, + 0x49ce7, 0x49874, 0x49402, 0x48f91, 0x48b1f, 0x486af, 0x4823e, 0x47dce, + 0x4795f, 0x474f0, 0x47082, 0x46c14, 0x467a6, 0x46339, 0x45ecc, 0x45a60, + 0x455f4, 0x45189, 0x44d1e, 0x448b3, 0x44449, 0x43fdf, 0x43b76, 0x4370d, + 0x432a5, 0x42e3d, 0x429d6, 0x4256f, 0x42108, 0x41ca2, 0x4183c, 0x413d7, + 0x40f72, 0x40b0e, 0x406aa, 0x40247, 0x3fde4, 0x3f981, 0x3f51f, 0x3f0bd, + 0x3ec5c, 0x3e7fb, 0x3e39b, 0x3df3b, 0x3dadb, 0x3d67c, 0x3d21d, 0x3cdbf, + 0x3c961, 0x3c504, 0x3c0a7, 0x3bc4a, 0x3b7ee, 0x3b393, 0x3af37, 0x3aadd, + 0x3a682, 0x3a228, 0x39dcf, 0x39976, 0x3951d, 0x390c5, 0x38c6d, 0x38816, + 0x383bf, 0x37f69, 0x37b13, 0x376bd, 0x37268, 0x36e13, 0x369bf, 0x3656b, + 0x36117, 0x35cc4, 0x35872, 0x3541f, 0x34fce, 0x34b7c, 0x3472b, 0x342db, + 0x33e8b, 0x33a3b, 0x335ec, 0x3319d, 0x32d4f, 0x32901, 0x324b3, 0x32066, + 0x31c1a, 0x317cd, 0x31381, 0x30f36, 0x30aeb, 0x306a1, 0x30256, 0x2fe0d, + 0x2f9c3, 0x2f57a, 0x2f132, 0x2ecea, 0x2e8a2, 0x2e45b, 0x2e014, 0x2dbce, + 0x2d788, 0x2d343, 0x2cefd, 0x2cab9, 0x2c675, 0x2c231, 0x2bded, 0x2b9aa, + 0x2b568, 0x2b125, 0x2ace4, 0x2a8a2, 0x2a461, 0x2a021, 0x29be1, 0x297a1, + 0x29362, 0x28f23, 0x28ae4, 0x286a6, 0x28269, 0x27e2c, 0x279ef, 0x275b2, + 0x27176, 0x26d3b, 0x26900, 0x264c5, 0x2608b, 0x25c51, 0x25817, 0x253de, + 0x24fa6, 0x24b6d, 0x24735, 0x242fe, 0x23ec7, 0x23a90, 0x2365a, 0x23224, + 0x22def, 0x229ba, 0x22585, 0x22151, 0x21d1d, 0x218ea, 0x214b7, 0x21084, + 0x20c52, 0x20821, 0x203ef, 0x1ffbe, 0x1fb8e, 0x1f75e, 0x1f32e, 0x1eeff, + 0x1ead0, 0x1e6a1, 0x1e273, 0x1de45, 0x1da18, 0x1d5eb, 0x1d1bf, 0x1cd93, + 0x1c967, 0x1c53c, 0x1c111, 0x1bce6, 0x1b8bc, 0x1b493, 0x1b069, 0x1ac40, + 0x1a818, 0x1a3f0, 0x19fc8, 0x19ba1, 0x1977a, 0x19354, 0x18f2d, 0x18b08, + 0x186e2, 0x182be, 0x17e99, 0x17a75, 0x17651, 0x1722e, 0x16e0b, 0x169e9, + 0x165c6, 0x161a5, 0x15d83, 0x15963, 0x15542, 0x15122, 0x14d02, 0x148e3, + 0x144c4, 0x140a5, 0x13c87, 0x13869, 0x1344c, 0x1302f, 0x12c12, 0x127f6, + 0x123da, 0x11fbf, 0x11ba4, 0x11789, 0x1136f, 0x10f55, 0x10b3c, 0x10723, + 0x1030a, 0xfef2, 0xfada, 0xf6c2, 0xf2ab, 0xee95, 0xea7e, 0xe668, + 0xe253, 0xde3e, 0xda29, 0xd614, 0xd200, 0xcded, 0xc9da, 0xc5c7, + 0xc1b4, 0xbda2, 0xb990, 0xb57f, 0xb16e, 0xad5e, 0xa94e, 0xa53e, + 0xa12e, 0x9d1f, 0x9911, 0x9503, 0x90f5, 0x8ce7, 0x88da, 0x84ce, + 0x80c1, 0x7cb5, 0x78aa, 0x749f, 0x7094, 0x6c89, 0x687f, 0x6476, + 0x606d, 0x5c64, 0x585b, 0x5453, 0x504b, 0x4c44, 0x483d, 0x4436, + 0x4030, 0x3c2a, 0x3825, 0x3420, 0x301b, 0x2c17, 0x2813, 0x240f, + 0x200c, 0x1c09, 0x1807, 0x1405, 0x1003, 0xc02, 0x801, 0x400, + 0x7fffff, 0x7ff001, 0x7fe006, 0x7fd00d, 0x7fc018, 0x7fb025, 0x7fa036, 0x7f9049, + 0x7f8060, 0x7f7079, 0x7f6095, 0x7f50b5, 0x7f40d7, 0x7f30fc, 0x7f2124, 0x7f114f, + 0x7f017e, 0x7ef1af, 0x7ee1e2, 0x7ed219, 0x7ec253, 0x7eb290, 0x7ea2d0, 0x7e9312, + 0x7e8358, 0x7e73a0, 0x7e63eb, 0x7e543a, 0x7e448b, 0x7e34df, 0x7e2536, 0x7e1590, + 0x7e05ec, 0x7df64c, 0x7de6ae, 0x7dd714, 0x7dc77c, 0x7db7e7, 0x7da855, 0x7d98c6, + 0x7d893a, 0x7d79b0, 0x7d6a2a, 0x7d5aa6, 0x7d4b25, 0x7d3ba7, 0x7d2c2c, 0x7d1cb3, + 0x7d0d3e, 0x7cfdcb, 0x7cee5b, 0x7cdeee, 0x7ccf84, 0x7cc01d, 0x7cb0b8, 0x7ca156, + 0x7c91f7, 0x7c829b, 0x7c7342, 0x7c63eb, 0x7c5497, 0x7c4546, 0x7c35f8, 0x7c26ad, + 0x7c1764, 0x7c081e, 0x7bf8db, 0x7be99b, 0x7bda5d, 0x7bcb23, 0x7bbbeb, 0x7bacb5, + 0x7b9d83, 0x7b8e53, 0x7b7f26, 0x7b6ffc, 0x7b60d4, 0x7b51b0, 0x7b428e, 0x7b336e, + 0x7b2452, 0x7b1538, 0x7b0621, 0x7af70c, 0x7ae7fb, 0x7ad8ec, 0x7ac9e0, 0x7abad6, + 0x7aabcf, 0x7a9ccb, 0x7a8dca, 0x7a7ecb, 0x7a6fcf, 0x7a60d5, 0x7a51df, 0x7a42eb, + 0x7a33f9, 0x7a250b, 0x7a161f, 0x7a0735, 0x79f84f, 0x79e96b, 0x79da89, 0x79cbab, + 0x79bccf, 0x79adf5, 0x799f1f, 0x79904a, 0x798179, 0x7972aa, 0x7963de, 0x795515, + 0x79464e, 0x793789, 0x7928c8, 0x791a09, 0x790b4c, 0x78fc92, 0x78eddb, 0x78df27, + 0x78d075, 0x78c1c5, 0x78b319, 0x78a46e, 0x7895c7, 0x788722, 0x78787f, 0x7869e0, + 0x785b42, 0x784ca8, 0x783e10, 0x782f7a, 0x7820e7, 0x781257, 0x7803c9, 0x77f53e, + 0x77e6b5, 0x77d82f, 0x77c9ab, 0x77bb2a, 0x77acac, 0x779e30, 0x778fb6, 0x77813f, + 0x7772cb, 0x776459, 0x7755ea, 0x77477d, 0x773913, 0x772aab, 0x771c46, 0x770de3, + 0x76ff83, 0x76f125, 0x76e2ca, 0x76d472, 0x76c61b, 0x76b7c8, 0x76a977, 0x769b28, + 0x768cdc, 0x767e92, 0x76704b, 0x766206, 0x7653c4, 0x764584, 0x763747, 0x76290c, + 0x761ad3, 0x760c9d, 0x75fe6a, 0x75f039, 0x75e20a, 0x75d3de, 0x75c5b5, 0x75b78e, + 0x75a969, 0x759b46, 0x758d27, 0x757f09, 0x7570ee, 0x7562d6, 0x7554bf, 0x7546ac, + 0x75389a, 0x752a8c, 0x751c7f, 0x750e75, 0x75006d, 0x74f268, 0x74e465, 0x74d665, + 0x74c867, 0x74ba6b, 0x74ac72, 0x749e7b, 0x749087, 0x748295, 0x7474a5, 0x7466b8, + 0x7458cd, 0x744ae4, 0x743cfe, 0x742f1a, 0x742139, 0x74135a, 0x74057d, 0x73f7a3, + 0x73e9cb, 0x73dbf5, 0x73ce22, 0x73c051, 0x73b282, 0x73a4b6, 0x7396ec, 0x738925, + 0x737b60, 0x736d9d, 0x735fdc, 0x73521e, 0x734462, 0x7336a9, 0x7328f1, 0x731b3c, + 0x730d8a, 0x72ffd9, 0x72f22c, 0x72e480, 0x72d6d7, 0x72c92f, 0x72bb8b, 0x72ade8, + 0x72a048, 0x7292aa, 0x72850f, 0x727775, 0x7269de, 0x725c4a, 0x724eb7, 0x724127, + 0x723399, 0x72260e, 0x721884, 0x720afd, 0x71fd79, 0x71eff6, 0x71e276, 0x71d4f8, + 0x71c77c, 0x71ba02, 0x71ac8b, 0x719f16, 0x7191a3, 0x718433, 0x7176c5, 0x716959, + 0x715bef, 0x714e87, 0x714122, 0x7133bf, 0x71265e, 0x711900, 0x710ba3, 0x70fe49, + 0x70f0f1, 0x70e39b, 0x70d648, 0x70c8f6, 0x70bba7, 0x70ae5a, 0x70a110, 0x7093c7, + 0x708681, 0x70793d, 0x706bfb, 0x705ebb, 0x70517d, 0x704442, 0x703709, 0x7029d2, + 0x701c9d, 0x700f6a, 0x70023a, 0x6ff50c, 0x6fe7e0, 0x6fdab6, 0x6fcd8e, 0x6fc068, + 0x6fb345, 0x6fa624, 0x6f9904, 0x6f8be7, 0x6f7ecd, 0x6f71b4, 0x6f649d, 0x6f5789, + 0x6f4a77, 0x6f3d67, 0x6f3059, 0x6f234d, 0x6f1643, 0x6f093c, 0x6efc36, 0x6eef33, + 0x6ee232, 0x6ed533, 0x6ec836, 0x6ebb3b, 0x6eae42, 0x6ea14c, 0x6e9457, 0x6e8765, + 0x6e7a74, 0x6e6d86, 0x6e609a, 0x6e53b0, 0x6e46c8, 0x6e39e3, 0x6e2cff, 0x6e201d, + 0x6e133e, 0x6e0661, 0x6df985, 0x6decac, 0x6ddfd5, 0x6dd300, 0x6dc62d, 0x6db95c, + 0x6dac8d, 0x6d9fc0, 0x6d92f5, 0x6d862d, 0x6d7966, 0x6d6ca2, 0x6d5fdf, 0x6d531f, + 0x6d4660, 0x6d39a4, 0x6d2cea, 0x6d2032, 0x6d137c, 0x6d06c7, 0x6cfa15, 0x6ced65, + 0x6ce0b7, 0x6cd40b, 0x6cc761, 0x6cbab9, 0x6cae14, 0x6ca170, 0x6c94ce, 0x6c882e, + 0x6c7b90, 0x6c6ef5, 0x6c625b, 0x6c55c3, 0x6c492d, 0x6c3c9a, 0x6c3008, 0x6c2378, + 0x6c16ea, 0x6c0a5f, 0x6bfdd5, 0x6bf14d, 0x6be4c8, 0x6bd844, 0x6bcbc2, 0x6bbf42, + 0x6bb2c5, 0x6ba649, 0x6b99cf, 0x6b8d57, 0x6b80e2, 0x6b746e, 0x6b67fc, 0x6b5b8c, + 0x6b4f1e, 0x6b42b2, 0x6b3648, 0x6b29e0, 0x6b1d7a, 0x6b1116, 0x6b04b4, 0x6af854, + 0x6aebf5, 0x6adf99, 0x6ad33f, 0x6ac6e6, 0x6aba90, 0x6aae3b, 0x6aa1e9, 0x6a9598, + 0x6a8949, 0x6a7cfd, 0x6a70b2, 0x6a6469, 0x6a5822, 0x6a4bdd, 0x6a3f9a, 0x6a3359, + 0x6a271a, 0x6a1adc, 0x6a0ea1, 0x6a0267, 0x69f630, 0x69e9fa, 0x69ddc6, 0x69d195, + 0x69c565, 0x69b937, 0x69ad0b, 0x69a0e0, 0x6994b8, 0x698892, 0x697c6d, 0x69704a, + 0x69642a, 0x69580b, 0x694bee, 0x693fd3, 0x6933ba, 0x6927a2, 0x691b8d, 0x690f79, + 0x690368, 0x68f758, 0x68eb4a, 0x68df3e, 0x68d334, 0x68c72b, 0x68bb25, 0x68af20, + 0x68a31d, 0x68971d, 0x688b1d, 0x687f20, 0x687325, 0x68672c, 0x685b34, 0x684f3e, + 0x68434a, 0x683758, 0x682b68, 0x681f7a, 0x68138d, 0x6807a2, 0x67fbb9, 0x67efd2, + 0x67e3ed, 0x67d80a, 0x67cc28, 0x67c048, 0x67b46a, 0x67a88e, 0x679cb4, 0x6790dc, + 0x678505, 0x677930, 0x676d5d, 0x67618c, 0x6755bd, 0x6749ef, 0x673e23, 0x673259, + 0x672691, 0x671acb, 0x670f06, 0x670343, 0x66f782, 0x66ebc3, 0x66e006, 0x66d44a, + 0x66c891, 0x66bcd8, 0x66b122, 0x66a56e, 0x6699bb, 0x668e0a, 0x66825b, 0x6676ae, + 0x666b02, 0x665f58, 0x6653b0, 0x66480a, 0x663c66, 0x6630c3, 0x662522, 0x661983, + 0x660de5, 0x66024a, 0x65f6b0, 0x65eb17, 0x65df81, 0x65d3ec, 0x65c859, 0x65bcc8, + 0x65b139, 0x65a5ab, 0x659a1f, 0x658e95, 0x65830d, 0x657786, 0x656c01, 0x65607e, + 0x6554fc, 0x65497c, 0x653dfe, 0x653282, 0x652707, 0x651b8e, 0x651017, 0x6504a2, + 0x64f92e, 0x64edbc, 0x64e24c, 0x64d6dd, 0x64cb70, 0x64c005, 0x64b49c, 0x64a934, + 0x649dce, 0x64926a, 0x648707, 0x647ba6, 0x647047, 0x6464ea, 0x64598e, 0x644e34, + 0x6442db, 0x643784, 0x642c2f, 0x6420dc, 0x64158a, 0x640a3a, 0x63feec, 0x63f39f, + 0x63e854, 0x63dd0b, 0x63d1c3, 0x63c67d, 0x63bb39, 0x63aff7, 0x63a4b6, 0x639976, + 0x638e39, 0x6382fd, 0x6377c3, 0x636c8a, 0x636153, 0x63561e, 0x634aea, 0x633fb8, + 0x633488, 0x632959, 0x631e2c, 0x631301, 0x6307d7, 0x62fcaf, 0x62f189, 0x62e664, + 0x62db41, 0x62d01f, 0x62c500, 0x62b9e1, 0x62aec5, 0x62a3aa, 0x629890, 0x628d79, + 0x628263, 0x62774e, 0x626c3b, 0x62612a, 0x62561b, 0x624b0d, 0x624000, 0x6234f6, + 0x6229ed, 0x621ee5, 0x6213df, 0x6208db, 0x61fdd8, 0x61f2d7, 0x61e7d8, 0x61dcda, + 0x61d1de, 0x61c6e3, 0x61bbea, 0x61b0f3, 0x61a5fd, 0x619b09, 0x619016, 0x618525, + 0x617a36, 0x616f48, 0x61645b, 0x615971, 0x614e88, 0x6143a0, 0x6138ba, 0x612dd6, + 0x6122f3, 0x611812, 0x610d32, 0x610254, 0x60f778, 0x60ec9d, 0x60e1c4, 0x60d6ec, + 0x60cc16, 0x60c141, 0x60b66e, 0x60ab9c, 0x60a0cc, 0x6095fe, 0x608b31, 0x608066, + 0x60759c, 0x606ad4, 0x60600e, 0x605549, 0x604a85, 0x603fc3, 0x603503, 0x602a44, + 0x601f87, 0x6014cb, 0x600a11, 0x5fff58, 0x5ff4a1, 0x5fe9eb, 0x5fdf37, 0x5fd485, + 0x5fc9d4, 0x5fbf24, 0x5fb476, 0x5fa9ca, 0x5f9f1f, 0x5f9476, 0x5f89ce, 0x5f7f28, + 0x5f7483, 0x5f69df, 0x5f5f3e, 0x5f549d, 0x5f49ff, 0x5f3f62, 0x5f34c6, 0x5f2a2c, + 0x5f1f93, 0x5f14fc, 0x5f0a66, 0x5effd2, 0x5ef53f, 0x5eeaae, 0x5ee01f, 0x5ed591, + 0x5ecb04, 0x5ec079, 0x5eb5ef, 0x5eab67, 0x5ea0e0, 0x5e965b, 0x5e8bd8, 0x5e8155, + 0x5e76d5, 0x5e6c55, 0x5e61d8, 0x5e575c, 0x5e4ce1, 0x5e4268, 0x5e37f0, 0x5e2d79, + 0x5e2305, 0x5e1891, 0x5e0e1f, 0x5e03af, 0x5df940, 0x5deed3, 0x5de467, 0x5dd9fc, + 0x5dcf93, 0x5dc52b, 0x5dbac5, 0x5db061, 0x5da5fd, 0x5d9b9c, 0x5d913b, 0x5d86dc, + 0x5d7c7f, 0x5d7223, 0x5d67c9, 0x5d5d70, 0x5d5318, 0x5d48c2, 0x5d3e6d, 0x5d341a, + 0x5d29c8, 0x5d1f78, 0x5d1529, 0x5d0adc, 0x5d0090, 0x5cf645, 0x5cebfc, 0x5ce1b4, + 0x5cd76e, 0x5ccd29, 0x5cc2e6, 0x5cb8a4, 0x5cae63, 0x5ca424, 0x5c99e6, 0x5c8faa, + 0x5c856f, 0x5c7b36, 0x5c70fe, 0x5c66c7, 0x5c5c92, 0x5c525e, 0x5c482c, 0x5c3dfb, + 0x5c33cc, 0x5c299d, 0x5c1f71, 0x5c1546, 0x5c0b1c, 0x5c00f3, 0x5bf6cc, 0x5beca7, + 0x5be282, 0x5bd85f, 0x5bce3e, 0x5bc41e, 0x5bb9ff, 0x5bafe2, 0x5ba5c6, 0x5b9bac, + 0x5b9193, 0x5b877b, 0x5b7d65, 0x5b7350, 0x5b693d, 0x5b5f2a, 0x5b551a, 0x5b4b0a, + 0x5b40fd, 0x5b36f0, 0x5b2ce5, 0x5b22db, 0x5b18d3, 0x5b0ecc, 0x5b04c6, 0x5afac2, + 0x5af0bf, 0x5ae6bd, 0x5adcbd, 0x5ad2be, 0x5ac8c1, 0x5abec5, 0x5ab4ca, 0x5aaad1, + 0x5aa0d9, 0x5a96e2, 0x5a8ced, 0x5a82f9, 0x5a7906, 0x5a6f15, 0x5a6525, 0x5a5b37, + 0x5a514a, 0x5a475e, 0x5a3d74, 0x5a338b, 0x5a29a3, 0x5a1fbd, 0x5a15d8, 0x5a0bf4, + 0x5a0212, 0x59f831, 0x59ee51, 0x59e473, 0x59da96, 0x59d0ba, 0x59c6e0, 0x59bd07, + 0x59b330, 0x59a959, 0x599f84, 0x5995b1, 0x598bde, 0x59820e, 0x59783e, 0x596e70, + 0x5964a3, 0x595ad7, 0x59510d, 0x594744, 0x593d7c, 0x5933b6, 0x5929f1, 0x59202d, + 0x59166b, 0x590caa, 0x5902ea, 0x58f92b, 0x58ef6e, 0x58e5b3, 0x58dbf8, 0x58d23f, + 0x58c887, 0x58bed0, 0x58b51b, 0x58ab67, 0x58a1b4, 0x589803, 0x588e53, 0x5884a4, + 0x587af7, 0x58714b, 0x5867a0, 0x585df6, 0x58544e, 0x584aa7, 0x584101, 0x58375d, + 0x582dba, 0x582418, 0x581a77, 0x5810d8, 0x58073a, 0x57fd9d, 0x57f402, 0x57ea68, + 0x57e0cf, 0x57d737, 0x57cda1, 0x57c40c, 0x57ba78, 0x57b0e6, 0x57a754, 0x579dc5, + 0x579436, 0x578aa9, 0x57811c, 0x577792, 0x576e08, 0x576480, 0x575af9, 0x575173, + 0x5747ee, 0x573e6b, 0x5734e9, 0x572b68, 0x5721e9, 0x57186b, 0x570eee, 0x570572, + 0x56fbf8, 0x56f27e, 0x56e906, 0x56df90, 0x56d61a, 0x56cca6, 0x56c333, 0x56b9c1, + 0x56b051, 0x56a6e2, 0x569d74, 0x569407, 0x568a9b, 0x568131, 0x5677c8, 0x566e60, + 0x5664fa, 0x565b95, 0x565231, 0x5648ce, 0x563f6c, 0x56360c, 0x562cad, 0x56234f, + 0x5619f2, 0x561097, 0x56073c, 0x55fde3, 0x55f48c, 0x55eb35, 0x55e1e0, 0x55d88c, + 0x55cf39, 0x55c5e7, 0x55bc97, 0x55b347, 0x55a9f9, 0x55a0ad, 0x559761, 0x558e17, + 0x5584cd, 0x557b86, 0x55723f, 0x5568f9, 0x555fb5, 0x555672, 0x554d30, 0x5543ef, + 0x553ab0, 0x553171, 0x552834, 0x551ef8, 0x5515be, 0x550c84, 0x55034c, 0x54fa15, + 0x54f0df, 0x54e7aa, 0x54de77, 0x54d544, 0x54cc13, 0x54c2e3, 0x54b9b4, 0x54b087, + 0x54a75a, 0x549e2f, 0x549505, 0x548bdc, 0x5482b5, 0x54798e, 0x547069, 0x546745, + 0x545e22, 0x545500, 0x544be0, 0x5442c0, 0x5439a2, 0x543085, 0x542769, 0x541e4f, + 0x541535, 0x540c1d, 0x540306, 0x53f9f0, 0x53f0db, 0x53e7c7, 0x53deb5, 0x53d5a3, + 0x53cc93, 0x53c384, 0x53ba76, 0x53b169, 0x53a85e, 0x539f54, 0x53964a, 0x538d42, + 0x53843b, 0x537b36, 0x537231, 0x53692e, 0x53602b, 0x53572a, 0x534e2a, 0x53452b, + 0x533c2e, 0x533331, 0x532a36, 0x53213b, 0x531842, 0x530f4a, 0x530654, 0x52fd5e, + 0x52f469, 0x52eb76, 0x52e284, 0x52d993, 0x52d0a3, 0x52c7b4, 0x52bec6, 0x52b5d9, + 0x52acee, 0x52a404, 0x529b1b, 0x529233, 0x52894c, 0x528066, 0x527781, 0x526e9e, + 0x5265bb, 0x525cda, 0x5253fa, 0x524b1b, 0x52423d, 0x523960, 0x523084, 0x5227aa, + 0x521ed0, 0x5215f8, 0x520d21, 0x52044b, 0x51fb76, 0x51f2a2, 0x51e9cf, 0x51e0fe, + 0x51d82d, 0x51cf5e, 0x51c68f, 0x51bdc2, 0x51b4f6, 0x51ac2b, 0x51a361, 0x519a98, + 0x5191d1, 0x51890a, 0x518045, 0x517780, 0x516ebd, 0x5165fb, 0x515d3a, 0x51547a, + 0x514bbb, 0x5142fd, 0x513a41, 0x513185, 0x5128cb, 0x512011, 0x511759, 0x510ea2, + 0x5105ec, 0x50fd36, 0x50f483, 0x50ebd0, 0x50e31e, 0x50da6d, 0x50d1be, 0x50c90f, + 0x50c062, 0x50b7b5, 0x50af0a, 0x50a660, 0x509db7, 0x50950f, 0x508c68, 0x5083c2, + 0x507b1d, 0x507279, 0x5069d7, 0x506135, 0x505894, 0x504ff5, 0x504757, 0x503eb9, + 0x50361d, 0x502d82, 0x5024e8, 0x501c4f, 0x5013b7, 0x500b20, 0x50028a, 0x4ff9f5, + 0x4ff162, 0x4fe8cf, 0x4fe03d, 0x4fd7ad, 0x4fcf1d, 0x4fc68f, 0x4fbe01, 0x4fb575, + 0x4facea, 0x4fa460, 0x4f9bd7, 0x4f934e, 0x4f8ac7, 0x4f8241, 0x4f79bc, 0x4f7139, + 0x4f68b6, 0x4f6034, 0x4f57b3, 0x4f4f33, 0x4f46b5, 0x4f3e37, 0x4f35bb, 0x4f2d3f, + 0x4f24c5, 0x4f1c4b, 0x4f13d3, 0x4f0b5b, 0x4f02e5, 0x4efa70, 0x4ef1fb, 0x4ee988, + 0x4ee116, 0x4ed8a5, 0x4ed035, 0x4ec7c6, 0x4ebf58, 0x4eb6ea, 0x4eae7e, 0x4ea613, + 0x4e9daa, 0x4e9541, 0x4e8cd9, 0x4e8472, 0x4e7c0c, 0x4e73a7, 0x4e6b43, 0x4e62e1, + 0x4e5a7f, 0x4e521e, 0x4e49be, 0x4e4160, 0x4e3902, 0x4e30a5, 0x4e284a, 0x4e1fef, + 0x4e1796, 0x4e0f3d, 0x4e06e5, 0x4dfe8f, 0x4df639, 0x4dede5, 0x4de591, 0x4ddd3f, + 0x4dd4ed, 0x4dcc9d, 0x4dc44d, 0x4dbbff, 0x4db3b1, 0x4dab65, 0x4da319, 0x4d9acf, + 0x4d9285, 0x4d8a3d, 0x4d81f5, 0x4d79af, 0x4d7169, 0x4d6925, 0x4d60e2, 0x4d589f, + 0x4d505e, 0x4d481d, 0x4d3fde, 0x4d379f, 0x4d2f62, 0x4d2725, 0x4d1eea, 0x4d16af, + 0x4d0e76, 0x4d063d, 0x4cfe05, 0x4cf5cf, 0x4ced99, 0x4ce565, 0x4cdd31, 0x4cd4fe, + 0x4ccccd, 0x4cc49c, 0x4cbc6c, 0x4cb43e, 0x4cac10, 0x4ca3e3, 0x4c9bb8, 0x4c938d, + 0x4c8b63, 0x4c833a, 0x4c7b12, 0x4c72eb, 0x4c6ac6, 0x4c62a1, 0x4c5a7d, 0x4c525a, + 0x4c4a38, 0x4c4217, 0x4c39f7, 0x4c31d7, 0x4c29b9, 0x4c219c, 0x4c1980, 0x4c1165, + 0x4c094b, 0x4c0131, 0x4bf919, 0x4bf102, 0x4be8eb, 0x4be0d6, 0x4bd8c1, 0x4bd0ae, + 0x4bc89b, 0x4bc089, 0x4bb879, 0x4bb069, 0x4ba85a, 0x4ba04d, 0x4b9840, 0x4b9034, + 0x4b8829, 0x4b801f, 0x4b7816, 0x4b700e, 0x4b6807, 0x4b6001, 0x4b57fc, 0x4b4ff7, + 0x4b47f4, 0x4b3ff2, 0x4b37f0, 0x4b2ff0, 0x4b27f0, 0x4b1ff2, 0x4b17f4, 0x4b0ff7, + 0x4b07fc, 0x4b0001, 0x4af807, 0x4af00e, 0x4ae816, 0x4ae01f, 0x4ad829, 0x4ad034, + 0x4ac83f, 0x4ac04c, 0x4ab85a, 0x4ab068, 0x4aa878, 0x4aa088, 0x4a989a, 0x4a90ac, + 0x4a88bf, 0x4a80d3, 0x4a78e8, 0x4a70fe, 0x4a6915, 0x4a612d, 0x4a5946, 0x4a5160, + 0x4a497a, 0x4a4196, 0x4a39b2, 0x4a31d0, 0x4a29ee, 0x4a220d, 0x4a1a2d, 0x4a124f, + 0x4a0a71, 0x4a0294, 0x49fab7, 0x49f2dc, 0x49eb02, 0x49e328, 0x49db50, 0x49d378, + 0x49cba2, 0x49c3cc, 0x49bbf7, 0x49b423, 0x49ac50, 0x49a47e, 0x499cad, 0x4994dd, + 0x498d0d, 0x49853f, 0x497d71, 0x4975a5, 0x496dd9, 0x49660e, 0x495e44, 0x49567b, + 0x494eb3, 0x4946ec, 0x493f25, 0x493760, 0x492f9b, 0x4927d8, 0x492015, 0x491853, + 0x491092, 0x4908d2, 0x490113, 0x48f955, 0x48f198, 0x48e9db, 0x48e21f, 0x48da65, + 0x48d2ab, 0x48caf2, 0x48c33a, 0x48bb83, 0x48b3cd, 0x48ac18, 0x48a463, 0x489cb0, + 0x4894fd, 0x488d4b, 0x48859a, 0x487dea, 0x48763b, 0x486e8d, 0x4866df, 0x485f33, + 0x485787, 0x484fdd, 0x484833, 0x48408a, 0x4838e2, 0x48313b, 0x482994, 0x4821ef, + 0x481a4a, 0x4812a6, 0x480b04, 0x480362, 0x47fbc1, 0x47f420, 0x47ec81, 0x47e4e3, + 0x47dd45, 0x47d5a8, 0x47ce0c, 0x47c672, 0x47bed7, 0x47b73e, 0x47afa6, 0x47a80e, + 0x47a078, 0x4798e2, 0x47914d, 0x4789b9, 0x478226, 0x477a93, 0x477302, 0x476b71, + 0x4763e2, 0x475c53, 0x4754c5, 0x474d37, 0x4745ab, 0x473e20, 0x473695, 0x472f0b, + 0x472783, 0x471ffa, 0x471873, 0x4710ed, 0x470968, 0x4701e3, 0x46fa5f, 0x46f2dc, + 0x46eb5a, 0x46e3d9, 0x46dc59, 0x46d4d9, 0x46cd5a, 0x46c5dd, 0x46be60, 0x46b6e4, + 0x46af68, 0x46a7ee, 0x46a074, 0x4698fb, 0x469184, 0x468a0c, 0x468296, 0x467b21, + 0x4673ac, 0x466c39, 0x4664c6, 0x465d54, 0x4655e3, 0x464e72, 0x464703, 0x463f94, + 0x463826, 0x4630b9, 0x46294d, 0x4621e2, 0x461a77, 0x46130e, 0x460ba5, 0x46043d, + 0x45fcd6, 0x45f56f, 0x45ee0a, 0x45e6a5, 0x45df41, 0x45d7de, 0x45d07c, 0x45c91a, + 0x45c1ba, 0x45ba5a, 0x45b2fb, 0x45ab9d, 0x45a440, 0x459ce4, 0x459588, 0x458e2d, + 0x4586d3, 0x457f7a, 0x457822, 0x4570ca, 0x456974, 0x45621e, 0x455ac9, 0x455374, + 0x454c21, 0x4544ce, 0x453d7d, 0x45362c, 0x452edb, 0x45278c, 0x45203e, 0x4518f0, + 0x4511a3, 0x450a57, 0x45030c, 0x44fbc1, 0x44f477, 0x44ed2e, 0x44e5e6, 0x44de9f, + 0x44d759, 0x44d013, 0x44c8ce, 0x44c18a, 0x44ba47, 0x44b305, 0x44abc3, 0x44a482, + 0x449d42, 0x449603, 0x448ec5, 0x448787, 0x44804a, 0x44790e, 0x4471d3, 0x446a99, + 0x44635f, 0x445c26, 0x4454ee, 0x444db7, 0x444681, 0x443f4b, 0x443816, 0x4430e2, + 0x4429af, 0x44227c, 0x441b4b, 0x44141a, 0x440cea, 0x4405ba, 0x43fe8c, 0x43f75e, + 0x43f031, 0x43e905, 0x43e1da, 0x43daaf, 0x43d385, 0x43cc5c, 0x43c534, 0x43be0d, + 0x43b6e6, 0x43afc0, 0x43a89b, 0x43a177, 0x439a54, 0x439331, 0x438c0f, 0x4384ee, + 0x437dcd, 0x4376ae, 0x436f8f, 0x436871, 0x436154, 0x435a37, 0x43531b, 0x434c00, + 0x4344e6, 0x433dcd, 0x4336b4, 0x432f9c, 0x432885, 0x43216f, 0x431a5a, 0x431345, + 0x430c31, 0x43051e, 0x42fe0b, 0x42f6f9, 0x42efe9, 0x42e8d8, 0x42e1c9, 0x42daba, + 0x42d3ad, 0x42cca0, 0x42c593, 0x42be88, 0x42b77d, 0x42b073, 0x42a96a, 0x42a261, + 0x429b59, 0x429452, 0x428d4c, 0x428647, 0x427f42, 0x42783e, 0x42713b, 0x426a39, + 0x426337, 0x425c36, 0x425536, 0x424e37, 0x424738, 0x42403a, 0x42393d, 0x423241, + 0x422b45, 0x42244a, 0x421d50, 0x421657, 0x420f5e, 0x420866, 0x42016f, 0x41fa79, + 0x41f383, 0x41ec8e, 0x41e59a, 0x41dea7, 0x41d7b4, 0x41d0c2, 0x41c9d1, 0x41c2e1, + 0x41bbf1, 0x41b503, 0x41ae14, 0x41a727, 0x41a03a, 0x41994e, 0x419263, 0x418b79, + 0x41848f, 0x417da6, 0x4176be, 0x416fd7, 0x4168f0, 0x41620a, 0x415b25, 0x415440, + 0x414d5c, 0x414679, 0x413f97, 0x4138b6, 0x4131d5, 0x412af5, 0x412415, 0x411d37, + 0x411659, 0x410f7c, 0x41089f, 0x4101c3, 0x40fae9, 0x40f40e, 0x40ed35, 0x40e65c, + 0x40df84, 0x40d8ad, 0x40d1d6, 0x40cb00, 0x40c42b, 0x40bd57, 0x40b683, 0x40afb0, + 0x40a8de, 0x40a20c, 0x409b3b, 0x40946b, 0x408d9c, 0x4086cd, 0x408000, 0x407932, + 0x407266, 0x406b9a, 0x4064cf, 0x405e05, 0x40573b, 0x405072, 0x4049aa, 0x4042e3, + 0x403c1c, 0x403556, 0x402e91, 0x4027cc, 0x402109, 0x401a45, 0x401383, 0x400cc1, + 0x400600, 0x3fff40, 0x3ff880, 0x3ff1c2, 0x3feb03, 0x3fe446, 0x3fdd89, 0x3fd6cd, + 0x3fd012, 0x3fc957, 0x3fc29d, 0x3fbbe4, 0x3fb52c, 0x3fae74, 0x3fa7bd, 0x3fa107, + 0x3f9a51, 0x3f939c, 0x3f8ce8, 0x3f8634, 0x3f7f81, 0x3f78cf, 0x3f721e, 0x3f6b6d, + 0x3f64bd, 0x3f5e0e, 0x3f575f, 0x3f50b1, 0x3f4a04, 0x3f4357, 0x3f3cac, 0x3f3601, + 0x3f2f56, 0x3f28ac, 0x3f2203, 0x3f1b5b, 0x3f14b3, 0x3f0e0c, 0x3f0766, 0x3f00c1, + 0x3efa1c, 0x3ef377, 0x3eecd4, 0x3ee631, 0x3edf8f, 0x3ed8ee, 0x3ed24d, 0x3ecbad, + 0x3ec50e, 0x3ebe6f, 0x3eb7d1, 0x3eb134, 0x3eaa97, 0x3ea3fb, 0x3e9d60, 0x3e96c6, + 0x3e902c, 0x3e8993, 0x3e82fa, 0x3e7c62, 0x3e75cb, 0x3e6f35, 0x3e689f, 0x3e620a, + 0x3e5b76, 0x3e54e2, 0x3e4e4f, 0x3e47bd, 0x3e412b, 0x3e3a9a, 0x3e340a, 0x3e2d7a, + 0x3e26eb, 0x3e205d, 0x3e19cf, 0x3e1342, 0x3e0cb6, 0x3e062b, 0x3dffa0, 0x3df916, + 0x3df28c, 0x3dec03, 0x3de57b, 0x3ddef4, 0x3dd86d, 0x3dd1e7, 0x3dcb61, 0x3dc4dc, + 0x3dbe58, 0x3db7d5, 0x3db152, 0x3daad0, 0x3da44f, 0x3d9dce, 0x3d974e, 0x3d90ce, + 0x3d8a4f, 0x3d83d1, 0x3d7d54, 0x3d76d7, 0x3d705b, 0x3d69e0, 0x3d6365, 0x3d5ceb, + 0x3d5671, 0x3d4ff9, 0x3d4980, 0x3d4309, 0x3d3c92, 0x3d361c, 0x3d2fa7, 0x3d2932, + 0x3d22be, 0x3d1c4a, 0x3d15d7, 0x3d0f65, 0x3d08f4, 0x3d0283, 0x3cfc13, 0x3cf5a3, + 0x3cef34, 0x3ce8c6, 0x3ce259, 0x3cdbec, 0x3cd57f, 0x3ccf14, 0x3cc8a9, 0x3cc23f, + 0x3cbbd5, 0x3cb56c, 0x3caf04, 0x3ca89c, 0x3ca235, 0x3c9bcf, 0x3c9569, 0x3c8f04, + 0x3c889f, 0x3c823c, 0x3c7bd8, 0x3c7576, 0x3c6f14, 0x3c68b3, 0x3c6253, 0x3c5bf3, + 0x3c5593, 0x3c4f35, 0x3c48d7, 0x3c427a, 0x3c3c1d, 0x3c35c1, 0x3c2f66, 0x3c290b, + 0x3c22b1, 0x3c1c57, 0x3c15ff, 0x3c0fa7, 0x3c094f, 0x3c02f8, 0x3bfca2, 0x3bf64c, + 0x3beff7, 0x3be9a3, 0x3be34f, 0x3bdcfc, 0x3bd6aa, 0x3bd058, 0x3bca07, 0x3bc3b7, + 0x3bbd67, 0x3bb718, 0x3bb0c9, 0x3baa7b, 0x3ba42e, 0x3b9de1, 0x3b9795, 0x3b914a, + 0x3b8aff, 0x3b84b5, 0x3b7e6c, 0x3b7823, 0x3b71db, 0x3b6b93, 0x3b654c, 0x3b5f06, + 0x3b58c0, 0x3b527b, 0x3b4c36, 0x3b45f3, 0x3b3faf, 0x3b396d, 0x3b332b, 0x3b2cea, + 0x3b26a9, 0x3b2069, 0x3b1a2a, 0x3b13eb, 0x3b0dad, 0x3b076f, 0x3b0132, 0x3afaf6, + 0x3af4ba, 0x3aee7f, 0x3ae845, 0x3ae20b, 0x3adbd2, 0x3ad599, 0x3acf61, 0x3ac92a, + 0x3ac2f3, 0x3abcbd, 0x3ab688, 0x3ab053, 0x3aaa1f, 0x3aa3eb, 0x3a9db8, 0x3a9786, + 0x3a9154, 0x3a8b23, 0x3a84f2, 0x3a7ec2, 0x3a7893, 0x3a7264, 0x3a6c36, 0x3a6609, + 0x3a5fdc, 0x3a59b0, 0x3a5384, 0x3a4d59, 0x3a472f, 0x3a4105, 0x3a3adc, 0x3a34b4, + 0x3a2e8c, 0x3a2864, 0x3a223e, 0x3a1c18, 0x3a15f2, 0x3a0fcd, 0x3a09a9, 0x3a0385, + 0x39fd62, 0x39f740, 0x39f11e, 0x39eafd, 0x39e4dc, 0x39debc, 0x39d89d, 0x39d27e, + 0x39cc60, 0x39c642, 0x39c025, 0x39ba09, 0x39b3ed, 0x39add2, 0x39a7b7, 0x39a19d, + 0x399b84, 0x39956b, 0x398f53, 0x39893b, 0x398324, 0x397d0e, 0x3976f8, 0x3970e3, + 0x396ace, 0x3964ba, 0x395ea7, 0x395894, 0x395282, 0x394c70, 0x39465f, 0x39404f, + 0x393a3f, 0x393430, 0x392e21, 0x392813, 0x392206, 0x391bf9, 0x3915ed, 0x390fe1, + 0x3909d6, 0x3903cb, 0x38fdc1, 0x38f7b8, 0x38f1af, 0x38eba7, 0x38e5a0, 0x38df99, + 0x38d993, 0x38d38d, 0x38cd88, 0x38c783, 0x38c17f, 0x38bb7c, 0x38b579, 0x38af77, + 0x38a975, 0x38a374, 0x389d73, 0x389774, 0x389174, 0x388b76, 0x388577, 0x387f7a, + 0x38797d, 0x387381, 0x386d85, 0x38678a, 0x38618f, 0x385b95, 0x38559b, 0x384fa2, + 0x3849aa, 0x3843b2, 0x383dbb, 0x3837c5, 0x3831cf, 0x382bd9, 0x3825e4, 0x381ff0, + 0x3819fd, 0x381409, 0x380e17, 0x380825, 0x380234, 0x37fc43, 0x37f653, 0x37f063, + 0x37ea74, 0x37e485, 0x37de97, 0x37d8aa, 0x37d2bd, 0x37ccd1, 0x37c6e5, 0x37c0fa, + 0x37bb10, 0x37b526, 0x37af3d, 0x37a954, 0x37a36c, 0x379d84, 0x37979d, 0x3791b6, + 0x378bd0, 0x3785eb, 0x378006, 0x377a22, 0x37743e, 0x376e5b, 0x376879, 0x376297, + 0x375cb5, 0x3756d5, 0x3750f4, 0x374b15, 0x374535, 0x373f57, 0x373979, 0x37339b, + 0x372dbf, 0x3727e2, 0x372206, 0x371c2b, 0x371651, 0x371077, 0x370a9d, 0x3704c4, + 0x36feec, 0x36f914, 0x36f33d, 0x36ed66, 0x36e790, 0x36e1ba, 0x36dbe5, 0x36d611, + 0x36d03d, 0x36ca69, 0x36c497, 0x36bec4, 0x36b8f3, 0x36b321, 0x36ad51, 0x36a781, + 0x36a1b1, 0x369be2, 0x369614, 0x369046, 0x368a79, 0x3684ac, 0x367ee0, 0x367915, + 0x36734a, 0x366d7f, 0x3667b5, 0x3661ec, 0x365c23, 0x36565b, 0x365093, 0x364acc, + 0x364505, 0x363f3f, 0x363979, 0x3633b4, 0x362df0, 0x36282c, 0x362269, 0x361ca6, + 0x3616e4, 0x361122, 0x360b61, 0x3605a0, 0x35ffe0, 0x35fa20, 0x35f461, 0x35eea3, + 0x35e8e5, 0x35e328, 0x35dd6b, 0x35d7af, 0x35d1f3, 0x35cc38, 0x35c67d, 0x35c0c3, + 0x35bb09, 0x35b550, 0x35af98, 0x35a9e0, 0x35a429, 0x359e72, 0x3598bb, 0x359306, + 0x358d50, 0x35879c, 0x3581e8, 0x357c34, 0x357681, 0x3570ce, 0x356b1c, 0x35656b, + 0x355fba, 0x355a09, 0x355459, 0x354eaa, 0x3548fb, 0x35434d, 0x353d9f, 0x3537f2, + 0x353245, 0x352c99, 0x3526ee, 0x352143, 0x351b98, 0x3515ee, 0x351045, 0x350a9c } }; @@ -638,9 +638,8 @@ F77_FUNC(gmxinvsqrtdata,GMXINVSQRTDATA) = /* Pointer to exponential table */ const unsigned int * -gmx_invsqrt_exptab = F77_FUNC(gmxinvsqrtdata,GMXINVSQRTDATA).exptab; +gmx_invsqrt_exptab = F77_FUNC(gmxinvsqrtdata, GMXINVSQRTDATA).exptab; /* Pointer to fraction table */ const unsigned int * -gmx_invsqrt_fracttab = F77_FUNC(gmxinvsqrtdata,GMXINVSQRTDATA).fracttab; - +gmx_invsqrt_fracttab = F77_FUNC(gmxinvsqrtdata, GMXINVSQRTDATA).fracttab; diff --git a/src/gromacs/gmxlib/confio.c b/src/gromacs/gmxlib/confio.c index 4167a51b50..8159c7442f 100644 --- a/src/gromacs/gmxlib/confio.c +++ b/src/gromacs/gmxlib/confio.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -62,1389 +62,1729 @@ #define CHAR_SHIFT 24 -static int read_g96_pos(char line[],t_symtab *symtab, - FILE *fp,const char *infile, - t_trxframe *fr) +static int read_g96_pos(char line[], t_symtab *symtab, + FILE *fp, const char *infile, + t_trxframe *fr) { - t_atoms *atoms; - gmx_bool bEnd; - int nwanted,natoms,atnr,resnr=0,oldres,newres,shift; - char anm[STRLEN],resnm[STRLEN]; - char c1,c2; - double db1,db2,db3; - - nwanted = fr->natoms; - - atoms = fr->atoms; - - natoms = 0; - - if (fr->bX) { - if (fr->bAtoms) - shift = CHAR_SHIFT; - else - shift = 0; - newres = -1; - oldres = -666; /* Unlikely number for the first residue! */ - bEnd = FALSE; - while (!bEnd && fgets2(line,STRLEN,fp)) { - bEnd = (strncmp(line,"END",3) == 0); - if (!bEnd && (line[0] != '#')) { - if (sscanf(line+shift,"%15lf%15lf%15lf",&db1,&db2,&db3) != 3) - gmx_fatal(FARGS,"Did not find 3 coordinates for atom %d in %s\n", - natoms+1,infile); - if ((nwanted != -1) && (natoms >= nwanted)) - gmx_fatal(FARGS, - "Found more coordinates (%d) in %s than expected %d\n", - natoms,infile,nwanted); - if (atoms) { - if (fr->bAtoms && - (sscanf(line,"%5d%c%5s%c%5s%7d",&resnr,&c1,resnm,&c2,anm,&atnr) - != 6)) { - if (oldres>=0) - resnr = oldres; - else { - resnr = 1; - strncpy(resnm,"???",sizeof(resnm)-1); - } - strncpy(anm,"???",sizeof(anm)-1); - } - atoms->atomname[natoms]=put_symtab(symtab,anm); - if (resnr != oldres) { - oldres = resnr; - newres++; - if (newres >= atoms->nr) - gmx_fatal(FARGS,"More residues than atoms in %s (natoms = %d)", - infile,atoms->nr); - atoms->atom[natoms].resind = newres; - if (newres+1 > atoms->nres) { - atoms->nres = newres+1; - } - t_atoms_set_resinfo(atoms,natoms,symtab,resnm,resnr,' ',0,' '); - } else { - atoms->atom[natoms].resind = newres; - } - } - if (fr->x) { - fr->x[natoms][0] = db1; - fr->x[natoms][1] = db2; - fr->x[natoms][2] = db3; - } - natoms++; - } + t_atoms *atoms; + gmx_bool bEnd; + int nwanted, natoms, atnr, resnr = 0, oldres, newres, shift; + char anm[STRLEN], resnm[STRLEN]; + char c1, c2; + double db1, db2, db3; + + nwanted = fr->natoms; + + atoms = fr->atoms; + + natoms = 0; + + if (fr->bX) + { + if (fr->bAtoms) + { + shift = CHAR_SHIFT; + } + else + { + shift = 0; + } + newres = -1; + oldres = -666; /* Unlikely number for the first residue! */ + bEnd = FALSE; + while (!bEnd && fgets2(line, STRLEN, fp)) + { + bEnd = (strncmp(line, "END", 3) == 0); + if (!bEnd && (line[0] != '#')) + { + if (sscanf(line+shift, "%15lf%15lf%15lf", &db1, &db2, &db3) != 3) + { + gmx_fatal(FARGS, "Did not find 3 coordinates for atom %d in %s\n", + natoms+1, infile); + } + if ((nwanted != -1) && (natoms >= nwanted)) + { + gmx_fatal(FARGS, + "Found more coordinates (%d) in %s than expected %d\n", + natoms, infile, nwanted); + } + if (atoms) + { + if (fr->bAtoms && + (sscanf(line, "%5d%c%5s%c%5s%7d", &resnr, &c1, resnm, &c2, anm, &atnr) + != 6)) + { + if (oldres >= 0) + { + resnr = oldres; + } + else + { + resnr = 1; + strncpy(resnm, "???", sizeof(resnm)-1); + } + strncpy(anm, "???", sizeof(anm)-1); + } + atoms->atomname[natoms] = put_symtab(symtab, anm); + if (resnr != oldres) + { + oldres = resnr; + newres++; + if (newres >= atoms->nr) + { + gmx_fatal(FARGS, "More residues than atoms in %s (natoms = %d)", + infile, atoms->nr); + } + atoms->atom[natoms].resind = newres; + if (newres+1 > atoms->nres) + { + atoms->nres = newres+1; + } + t_atoms_set_resinfo(atoms, natoms, symtab, resnm, resnr, ' ', 0, ' '); + } + else + { + atoms->atom[natoms].resind = newres; + } + } + if (fr->x) + { + fr->x[natoms][0] = db1; + fr->x[natoms][1] = db2; + fr->x[natoms][2] = db3; + } + natoms++; + } + } + if ((nwanted != -1) && natoms != nwanted) + { + fprintf(stderr, + "Warning: found less coordinates (%d) in %s than expected %d\n", + natoms, infile, nwanted); + } } - if ((nwanted != -1) && natoms != nwanted) - fprintf(stderr, - "Warning: found less coordinates (%d) in %s than expected %d\n", - natoms,infile,nwanted); - } - fr->natoms = natoms; + fr->natoms = natoms; - return natoms; + return natoms; } -static int read_g96_vel(char line[],FILE *fp,const char *infile, - t_trxframe *fr) +static int read_g96_vel(char line[], FILE *fp, const char *infile, + t_trxframe *fr) { - gmx_bool bEnd; - int nwanted,natoms=-1,shift; - double db1,db2,db3; + gmx_bool bEnd; + int nwanted, natoms = -1, shift; + double db1, db2, db3; + + nwanted = fr->natoms; + + if (fr->v && fr->bV) + { + if (strcmp(line, "VELOCITYRED") == 0) + { + shift = 0; + } + else + { + shift = CHAR_SHIFT; + } + natoms = 0; + bEnd = FALSE; + while (!bEnd && fgets2(line, STRLEN, fp)) + { + bEnd = (strncmp(line, "END", 3) == 0); + if (!bEnd && (line[0] != '#')) + { + if (sscanf(line+shift, "%15lf%15lf%15lf", &db1, &db2, &db3) != 3) + { + gmx_fatal(FARGS, "Did not find 3 velocities for atom %d in %s", + natoms+1, infile); + } + if ((nwanted != -1) && (natoms >= nwanted)) + { + gmx_fatal(FARGS, "Found more velocities (%d) in %s than expected %d\n", + natoms, infile, nwanted); + } + if (fr->v) + { + fr->v[natoms][0] = db1; + fr->v[natoms][1] = db2; + fr->v[natoms][2] = db3; + } + natoms++; + } + } + if ((nwanted != -1) && (natoms != nwanted)) + { + fprintf(stderr, + "Warning: found less velocities (%d) in %s than expected %d\n", + natoms, infile, nwanted); + } + } - nwanted = fr->natoms; + return natoms; +} + +int read_g96_conf(FILE *fp, const char *infile, t_trxframe *fr, char *line) +{ + t_symtab *symtab = NULL; + gmx_bool bAtStart, bTime, bAtoms, bPos, bVel, bBox, bEnd, bFinished; + int natoms, nbp; + double db1, db2, db3, db4, db5, db6, db7, db8, db9; + + bAtStart = (ftell(fp) == 0); + + clear_trxframe(fr, FALSE); + + if (!symtab) + { + snew(symtab, 1); + open_symtab(symtab); + } - if (fr->v && fr->bV) { - if (strcmp(line,"VELOCITYRED") == 0) - shift = 0; - else - shift = CHAR_SHIFT; natoms = 0; - bEnd = FALSE; - while (!bEnd && fgets2(line,STRLEN,fp)) { - bEnd = (strncmp(line,"END",3) == 0); - if (!bEnd && (line[0] != '#')) { - if (sscanf(line+shift,"%15lf%15lf%15lf",&db1,&db2,&db3) != 3) - gmx_fatal(FARGS,"Did not find 3 velocities for atom %d in %s", - natoms+1,infile); - if ((nwanted != -1) && (natoms >= nwanted)) - gmx_fatal(FARGS,"Found more velocities (%d) in %s than expected %d\n", - natoms,infile,nwanted); - if (fr->v) { - fr->v[natoms][0] = db1; - fr->v[natoms][1] = db2; - fr->v[natoms][2] = db3; - } - natoms++; - } + + if (bAtStart) + { + while (!fr->bTitle && fgets2(line, STRLEN, fp)) + { + fr->bTitle = (strcmp(line, "TITLE") == 0); + } + if (fr->title == NULL) + { + fgets2(line, STRLEN, fp); + fr->title = strdup(line); + } + bEnd = FALSE; + while (!bEnd && fgets2(line, STRLEN, fp)) + { + bEnd = (strcmp(line, "END") == 0); + } + fgets2(line, STRLEN, fp); } - if ((nwanted != -1) && (natoms != nwanted)) - fprintf(stderr, - "Warning: found less velocities (%d) in %s than expected %d\n", - natoms,infile,nwanted); - } - - return natoms; + + /* Do not get a line if we are not at the start of the file, * + * because without a parameter file we don't know what is in * + * the trajectory and we have already read the line in the * + * previous call (VERY DIRTY). */ + bFinished = FALSE; + do + { + bTime = (strcmp(line, "TIMESTEP") == 0); + bAtoms = (strcmp(line, "POSITION") == 0); + bPos = (bAtoms || (strcmp(line, "POSITIONRED") == 0)); + bVel = (strncmp(line, "VELOCITY", 8) == 0); + bBox = (strcmp(line, "BOX") == 0); + if (bTime) + { + if (!fr->bTime && !fr->bX) + { + fr->bStep = bTime; + fr->bTime = bTime; + do + { + bFinished = (fgets2(line, STRLEN, fp) == NULL); + } + while (!bFinished && (line[0] == '#')); + sscanf(line, "%15d%15lf", &(fr->step), &db1); + fr->time = db1; + } + else + { + bFinished = TRUE; + } + } + if (bPos) + { + if (!fr->bX) + { + fr->bAtoms = bAtoms; + fr->bX = bPos; + natoms = read_g96_pos(line, symtab, fp, infile, fr); + } + else + { + bFinished = TRUE; + } + } + if (fr->v && bVel) + { + fr->bV = bVel; + natoms = read_g96_vel(line, fp, infile, fr); + } + if (bBox) + { + fr->bBox = bBox; + clear_mat(fr->box); + bEnd = FALSE; + while (!bEnd && fgets2(line, STRLEN, fp)) + { + bEnd = (strncmp(line, "END", 3) == 0); + if (!bEnd && (line[0] != '#')) + { + nbp = sscanf(line, "%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf", + &db1, &db2, &db3, &db4, &db5, &db6, &db7, &db8, &db9); + if (nbp < 3) + { + gmx_fatal(FARGS, "Found a BOX line, but no box in %s", infile); + } + fr->box[XX][XX] = db1; + fr->box[YY][YY] = db2; + fr->box[ZZ][ZZ] = db3; + if (nbp == 9) + { + fr->box[XX][YY] = db4; + fr->box[XX][ZZ] = db5; + fr->box[YY][XX] = db6; + fr->box[YY][ZZ] = db7; + fr->box[ZZ][XX] = db8; + fr->box[ZZ][YY] = db9; + } + } + } + bFinished = TRUE; + } + } + while (!bFinished && fgets2(line, STRLEN, fp)); + + free_symtab(symtab); + + fr->natoms = natoms; + + return natoms; } -int read_g96_conf(FILE *fp,const char *infile,t_trxframe *fr, char *line) +void write_g96_conf(FILE *out, t_trxframe *fr, + int nindex, const atom_id *index) { - t_symtab *symtab=NULL; - gmx_bool bAtStart,bTime,bAtoms,bPos,bVel,bBox,bEnd,bFinished; - int natoms,nbp; - double db1,db2,db3,db4,db5,db6,db7,db8,db9; - - bAtStart = (ftell(fp) == 0); - - clear_trxframe(fr,FALSE); - - if (!symtab) { - snew(symtab,1); - open_symtab(symtab); - } - - natoms=0; - - if (bAtStart) { - while ( !fr->bTitle && fgets2(line,STRLEN,fp)) - fr->bTitle = (strcmp(line,"TITLE") == 0); - if (fr->title == NULL) { - fgets2(line,STRLEN,fp); - fr->title = strdup(line); + t_atoms *atoms; + int nout, i, a; + + atoms = fr->atoms; + + if (index) + { + nout = nindex; } - bEnd = FALSE; - while (!bEnd && fgets2(line,STRLEN,fp)) - bEnd = (strcmp(line,"END") == 0); - fgets2(line,STRLEN,fp); - } - - /* Do not get a line if we are not at the start of the file, * - * because without a parameter file we don't know what is in * - * the trajectory and we have already read the line in the * - * previous call (VERY DIRTY). */ - bFinished = FALSE; - do { - bTime = (strcmp(line,"TIMESTEP") == 0); - bAtoms = (strcmp(line,"POSITION") == 0); - bPos = (bAtoms || (strcmp(line,"POSITIONRED") == 0)); - bVel = (strncmp(line,"VELOCITY",8) == 0); - bBox = (strcmp(line,"BOX") == 0); - if (bTime) { - if (!fr->bTime && !fr->bX) { - fr->bStep = bTime; - fr->bTime = bTime; - do - bFinished = (fgets2(line,STRLEN,fp) == NULL); - while (!bFinished && (line[0] == '#')); - sscanf(line,"%15d%15lf",&(fr->step),&db1); - fr->time = db1; - } else - bFinished = TRUE; + else + { + nout = fr->natoms; } - if (bPos) { - if (!fr->bX) { - fr->bAtoms = bAtoms; - fr->bX = bPos; - natoms = read_g96_pos(line,symtab,fp,infile,fr); - } else - bFinished = TRUE; + + if (fr->bTitle) + { + fprintf(out, "TITLE\n%s\nEND\n", fr->title); } - if (fr->v && bVel) { - fr->bV = bVel; - natoms = read_g96_vel(line,fp,infile,fr); + if (fr->bStep || fr->bTime) + { + /* Officially the time format is %15.9, which is not enough for 10 ns */ + fprintf(out, "TIMESTEP\n%15d%15.6f\nEND\n", fr->step, fr->time); } - if (bBox) { - fr->bBox = bBox; - clear_mat(fr->box); - bEnd = FALSE; - while (!bEnd && fgets2(line,STRLEN,fp)) { - bEnd = (strncmp(line,"END",3) == 0); - if (!bEnd && (line[0] != '#')) { - nbp = sscanf(line,"%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf%15lf", - &db1,&db2,&db3,&db4,&db5,&db6,&db7,&db8,&db9); - if (nbp < 3) - gmx_fatal(FARGS,"Found a BOX line, but no box in %s",infile); - fr->box[XX][XX] = db1; - fr->box[YY][YY] = db2; - fr->box[ZZ][ZZ] = db3; - if (nbp == 9) { - fr->box[XX][YY] = db4; - fr->box[XX][ZZ] = db5; - fr->box[YY][XX] = db6; - fr->box[YY][ZZ] = db7; - fr->box[ZZ][XX] = db8; - fr->box[ZZ][YY] = db9; - } - } - } - bFinished = TRUE; + if (fr->bX) + { + if (fr->bAtoms) + { + fprintf(out, "POSITION\n"); + for (i = 0; i < nout; i++) + { + if (index) + { + a = index[i]; + } + else + { + a = i; + } + fprintf(out, "%5d %-5s %-5s%7d%15.9f%15.9f%15.9f\n", + (atoms->resinfo[atoms->atom[a].resind].nr) % 100000, + *atoms->resinfo[atoms->atom[a].resind].name, + *atoms->atomname[a], (i+1) % 10000000, + fr->x[a][XX], fr->x[a][YY], fr->x[a][ZZ]); + } + } + else + { + fprintf(out, "POSITIONRED\n"); + for (i = 0; i < nout; i++) + { + if (index) + { + a = index[i]; + } + else + { + a = i; + } + fprintf(out, "%15.9f%15.9f%15.9f\n", + fr->x[a][XX], fr->x[a][YY], fr->x[a][ZZ]); + } + } + fprintf(out, "END\n"); } - } while (!bFinished && fgets2(line,STRLEN,fp)); - - free_symtab(symtab); - - fr->natoms = natoms; - - return natoms; -} - -void write_g96_conf(FILE *out,t_trxframe *fr, - int nindex,const atom_id *index) -{ - t_atoms *atoms; - int nout,i,a; - - atoms = fr->atoms; - - if (index) - nout = nindex; - else - nout = fr->natoms; - - if (fr->bTitle) - fprintf(out,"TITLE\n%s\nEND\n",fr->title); - if (fr->bStep || fr->bTime) - /* Officially the time format is %15.9, which is not enough for 10 ns */ - fprintf(out,"TIMESTEP\n%15d%15.6f\nEND\n",fr->step,fr->time); - if (fr->bX) { - if (fr->bAtoms) { - fprintf(out,"POSITION\n"); - for(i=0; iresinfo[atoms->atom[a].resind].nr) % 100000, - *atoms->resinfo[atoms->atom[a].resind].name, - *atoms->atomname[a],(i+1) % 10000000, - fr->x[a][XX],fr->x[a][YY],fr->x[a][ZZ]); - } - } else { - fprintf(out,"POSITIONRED\n"); - for(i=0; ix[a][XX],fr->x[a][YY],fr->x[a][ZZ]); - } + if (fr->bV) + { + if (fr->bAtoms) + { + fprintf(out, "VELOCITY\n"); + for (i = 0; i < nout; i++) + { + if (index) + { + a = index[i]; + } + else + { + a = i; + } + fprintf(out, "%5d %-5s %-5s%7d%15.9f%15.9f%15.9f\n", + (atoms->resinfo[atoms->atom[a].resind].nr) % 100000, + *atoms->resinfo[atoms->atom[a].resind].name, + *atoms->atomname[a], (i+1) % 10000000, + fr->v[a][XX], fr->v[a][YY], fr->v[a][ZZ]); + } + } + else + { + fprintf(out, "VELOCITYRED\n"); + for (i = 0; i < nout; i++) + { + if (index) + { + a = index[i]; + } + else + { + a = i; + } + fprintf(out, "%15.9f%15.9f%15.9f\n", + fr->v[a][XX], fr->v[a][YY], fr->v[a][ZZ]); + } + } + fprintf(out, "END\n"); } - fprintf(out,"END\n"); - } - if (fr->bV) { - if (fr->bAtoms) { - fprintf(out,"VELOCITY\n"); - for(i=0; iresinfo[atoms->atom[a].resind].nr) % 100000, - *atoms->resinfo[atoms->atom[a].resind].name, - *atoms->atomname[a],(i+1) % 10000000, - fr->v[a][XX],fr->v[a][YY],fr->v[a][ZZ]); - } - } else { - fprintf(out,"VELOCITYRED\n"); - for(i=0; iv[a][XX],fr->v[a][YY],fr->v[a][ZZ]); - } + if (fr->bBox) + { + fprintf(out, "BOX\n"); + fprintf(out, "%15.9f%15.9f%15.9f", + fr->box[XX][XX], fr->box[YY][YY], fr->box[ZZ][ZZ]); + if (fr->box[XX][YY] || fr->box[XX][ZZ] || fr->box[YY][XX] || + fr->box[YY][ZZ] || fr->box[ZZ][XX] || fr->box[ZZ][YY]) + { + fprintf(out, "%15.9f%15.9f%15.9f%15.9f%15.9f%15.9f", + fr->box[XX][YY], fr->box[XX][ZZ], fr->box[YY][XX], + fr->box[YY][ZZ], fr->box[ZZ][XX], fr->box[ZZ][YY]); + } + fprintf(out, "\n"); + fprintf(out, "END\n"); } - fprintf(out,"END\n"); - } - if (fr->bBox) { - fprintf(out,"BOX\n"); - fprintf(out,"%15.9f%15.9f%15.9f", - fr->box[XX][XX],fr->box[YY][YY],fr->box[ZZ][ZZ]); - if (fr->box[XX][YY] || fr->box[XX][ZZ] || fr->box[YY][XX] || - fr->box[YY][ZZ] || fr->box[ZZ][XX] ||fr->box[ZZ][YY]) - fprintf(out,"%15.9f%15.9f%15.9f%15.9f%15.9f%15.9f", - fr->box[XX][YY],fr->box[XX][ZZ],fr->box[YY][XX], - fr->box[YY][ZZ],fr->box[ZZ][XX],fr->box[ZZ][YY]); - fprintf(out,"\n"); - fprintf(out,"END\n"); - } } -static int get_espresso_word(FILE *fp,char word[]) +static int get_espresso_word(FILE *fp, char word[]) { - int ret,nc,i; - - ret = 0; - nc = 0; - - do { - i = fgetc(fp); - if (i != EOF) { - if (i == ' ' || i == '\n' || i == '\t') { - if (nc > 0) - ret = 1; - } else if (i == '{') { - if (nc == 0) - word[nc++] = '{'; - ret = 2; - } else if (i == '}') { - if (nc == 0) - word[nc++] = '}'; - ret = 3; - } else { - word[nc++] = (char)i; - } + int ret, nc, i; + + ret = 0; + nc = 0; + + do + { + i = fgetc(fp); + if (i != EOF) + { + if (i == ' ' || i == '\n' || i == '\t') + { + if (nc > 0) + { + ret = 1; + } + } + else if (i == '{') + { + if (nc == 0) + { + word[nc++] = '{'; + } + ret = 2; + } + else if (i == '}') + { + if (nc == 0) + { + word[nc++] = '}'; + } + ret = 3; + } + else + { + word[nc++] = (char)i; + } + } } - } while (i != EOF && ret == 0); - - word[nc] = '\0'; + while (i != EOF && ret == 0); + + word[nc] = '\0'; - /* printf("'%s'\n",word); */ - - return ret; + /* printf("'%s'\n",word); */ + + return ret; } -static int check_open_parenthesis(FILE *fp,int r, - const char *infile,const char *keyword) +static int check_open_parenthesis(FILE *fp, int r, + const char *infile, const char *keyword) { - int level_inc; - char word[STRLEN]; - - level_inc = 0; - if (r == 2) { - level_inc++; - } else { - r = get_espresso_word(fp,word); + int level_inc; + char word[STRLEN]; + + level_inc = 0; if (r == 2) - level_inc++; + { + level_inc++; + } else - gmx_fatal(FARGS,"Expected '{' after '%s' in file '%s'", - keyword,infile); - } + { + r = get_espresso_word(fp, word); + if (r == 2) + { + level_inc++; + } + else + { + gmx_fatal(FARGS, "Expected '{' after '%s' in file '%s'", + keyword, infile); + } + } - return level_inc; + return level_inc; } -static int check_close_parenthesis(FILE *fp,int r, - const char *infile,const char *keyword) +static int check_close_parenthesis(FILE *fp, int r, + const char *infile, const char *keyword) { - int level_inc; - char word[STRLEN]; - - level_inc = 0; - if (r == 3) { - level_inc--; - } else { - r = get_espresso_word(fp,word); + int level_inc; + char word[STRLEN]; + + level_inc = 0; if (r == 3) - level_inc--; + { + level_inc--; + } else - gmx_fatal(FARGS,"Expected '}' after section '%s' in file '%s'", - keyword,infile); - } + { + r = get_espresso_word(fp, word); + if (r == 3) + { + level_inc--; + } + else + { + gmx_fatal(FARGS, "Expected '}' after section '%s' in file '%s'", + keyword, infile); + } + } - return level_inc; + return level_inc; } -enum { espID, espPOS, espTYPE, espQ, espV, espF, espMOLECULE, espNR }; -const char *esp_prop[espNR] = { "id", "pos", "type", "q", "v", "f", - "molecule" }; +enum { + espID, espPOS, espTYPE, espQ, espV, espF, espMOLECULE, espNR +}; +const char *esp_prop[espNR] = { + "id", "pos", "type", "q", "v", "f", + "molecule" +}; static void read_espresso_conf(const char *infile, - t_atoms *atoms,rvec x[],rvec *v,matrix box) + t_atoms *atoms, rvec x[], rvec *v, matrix box) { - t_symtab *symtab=NULL; - FILE *fp; - char word[STRLEN],buf[STRLEN]; - int natoms,level,npar,r,nprop,p,i,m,molnr; - int prop[32]; - double d; - gmx_bool bFoundParticles,bFoundProp,bFoundVariable,bMol; - - if (!symtab) { - snew(symtab,1); - open_symtab(symtab); - } - - clear_mat(box); - - fp = gmx_fio_fopen(infile,"r"); - - bFoundParticles = FALSE; - bFoundVariable = FALSE; - bMol = FALSE; - level = 0; - while ((r=get_espresso_word(fp,word))) { - if (level==1 && strcmp(word,"particles")==0 && !bFoundParticles) { - bFoundParticles = TRUE; - level += check_open_parenthesis(fp,r,infile,"particles"); - nprop = 0; - while (level == 2 && (r=get_espresso_word(fp,word))) { - bFoundProp = FALSE; - for(p=0; p 0 && (r=get_espresso_word(fp,word))) { - if (r == 2) { - level++; - } else if (r == 3) { - level--; - } - if (level == 2) { - for(p=0; patom[i].type = strtol(word, NULL, 10); - break; - case espQ: - r = get_espresso_word(fp,word); - sscanf(word,"%lf",&d); - atoms->atom[i].q = d; - break; - case espV: - for(m=0; m<3; m++) { - r = get_espresso_word(fp,word); - sscanf(word,"%lf",&d); - v[i][m] = d; - } - break; - case espF: - for(m=0; m<3; m++) { - r = get_espresso_word(fp,word); - /* not used */ - } - break; - case espMOLECULE: - r = get_espresso_word(fp,word); - molnr = strtol(word, NULL, 10); - if (i == 0 || - atoms->resinfo[atoms->atom[i-1].resind].nr != molnr) { - atoms->atom[i].resind = - (i == 0 ? 0 : atoms->atom[i-1].resind+1); - atoms->resinfo[atoms->atom[i].resind].nr = molnr; - atoms->resinfo[atoms->atom[i].resind].ic = ' '; - atoms->resinfo[atoms->atom[i].resind].chainid = ' '; - atoms->resinfo[atoms->atom[i].resind].chainnum = molnr; /* Not sure if this is right? */ - } else { - atoms->atom[i].resind = atoms->atom[i-1].resind; - } - break; - } - } - /* Generate an atom name from the particle type */ - sprintf(buf,"T%d",atoms->atom[i].type); - atoms->atomname[i] = put_symtab(symtab,buf); - if (bMol) { - if (i == 0 || atoms->atom[i].resind != atoms->atom[i-1].resind) { - atoms->resinfo[atoms->atom[i].resind].name = - put_symtab(symtab,"MOL"); - } - } else { - /* Residue number is the atom number */ - atoms->atom[i].resind = i; - /* Generate an residue name from the particle type */ - if (atoms->atom[i].type < 26) { - sprintf(buf,"T%c",'A'+atoms->atom[i].type); - } else { - sprintf(buf,"T%c%c", - 'A'+atoms->atom[i].type/26,'A'+atoms->atom[i].type%26); - } - t_atoms_set_resinfo(atoms,i,symtab,buf,i,' ',0,' '); - } - - if (r == 3) - level--; - i++; - } - } - atoms->nres = atoms->nr; - - if (i != atoms->nr) { - gmx_fatal(FARGS,"Internal inconsistency in Espresso routines, read %d atoms, expected %d atoms",i,atoms->nr); - } - } else if (level==1 && strcmp(word,"variable")==0 && !bFoundVariable) { - bFoundVariable = TRUE; - level += check_open_parenthesis(fp,r,infile,"variable"); - while (level==2 && (r=get_espresso_word(fp,word))) { - if (level==2 && strcmp(word,"box_l") == 0) { - for(m=0; m<3; m++) { - r = get_espresso_word(fp,word); - sscanf(word,"%lf",&d); - box[m][m] = d; - } - level += check_close_parenthesis(fp,r,infile,"box_l"); - } - } - } else if (r == 2) { - level++; - } else if (r == 3) { - level--; + t_symtab *symtab = NULL; + FILE *fp; + char word[STRLEN], buf[STRLEN]; + int natoms, level, npar, r, nprop, p, i, m, molnr; + int prop[32]; + double d; + gmx_bool bFoundParticles, bFoundProp, bFoundVariable, bMol; + + if (!symtab) + { + snew(symtab, 1); + open_symtab(symtab); + } + + clear_mat(box); + + fp = gmx_fio_fopen(infile, "r"); + + bFoundParticles = FALSE; + bFoundVariable = FALSE; + bMol = FALSE; + level = 0; + while ((r = get_espresso_word(fp, word))) + { + if (level == 1 && strcmp(word, "particles") == 0 && !bFoundParticles) + { + bFoundParticles = TRUE; + level += check_open_parenthesis(fp, r, infile, "particles"); + nprop = 0; + while (level == 2 && (r = get_espresso_word(fp, word))) + { + bFoundProp = FALSE; + for (p = 0; p < espNR; p++) + { + if (strcmp(word, esp_prop[p]) == 0) + { + bFoundProp = TRUE; + prop[nprop++] = p; + /* printf(" prop[%d] = %s\n",nprop-1,esp_prop[prop[nprop-1]]); */ + } + } + if (!bFoundProp && word[0] != '}') + { + gmx_fatal(FARGS, "Can not read Espresso files with particle property '%s'", word); + } + if (bFoundProp && p == espMOLECULE) + { + bMol = TRUE; + } + if (r == 3) + { + level--; + } + } + + i = 0; + while (level > 0 && (r = get_espresso_word(fp, word))) + { + if (r == 2) + { + level++; + } + else if (r == 3) + { + level--; + } + if (level == 2) + { + for (p = 0; p < nprop; p++) + { + switch (prop[p]) + { + case espID: + r = get_espresso_word(fp, word); + /* Not used */ + break; + case espPOS: + for (m = 0; m < 3; m++) + { + r = get_espresso_word(fp, word); + sscanf(word, "%lf", &d); + x[i][m] = d; + } + break; + case espTYPE: + r = get_espresso_word(fp, word); + atoms->atom[i].type = strtol(word, NULL, 10); + break; + case espQ: + r = get_espresso_word(fp, word); + sscanf(word, "%lf", &d); + atoms->atom[i].q = d; + break; + case espV: + for (m = 0; m < 3; m++) + { + r = get_espresso_word(fp, word); + sscanf(word, "%lf", &d); + v[i][m] = d; + } + break; + case espF: + for (m = 0; m < 3; m++) + { + r = get_espresso_word(fp, word); + /* not used */ + } + break; + case espMOLECULE: + r = get_espresso_word(fp, word); + molnr = strtol(word, NULL, 10); + if (i == 0 || + atoms->resinfo[atoms->atom[i-1].resind].nr != molnr) + { + atoms->atom[i].resind = + (i == 0 ? 0 : atoms->atom[i-1].resind+1); + atoms->resinfo[atoms->atom[i].resind].nr = molnr; + atoms->resinfo[atoms->atom[i].resind].ic = ' '; + atoms->resinfo[atoms->atom[i].resind].chainid = ' '; + atoms->resinfo[atoms->atom[i].resind].chainnum = molnr; /* Not sure if this is right? */ + } + else + { + atoms->atom[i].resind = atoms->atom[i-1].resind; + } + break; + } + } + /* Generate an atom name from the particle type */ + sprintf(buf, "T%d", atoms->atom[i].type); + atoms->atomname[i] = put_symtab(symtab, buf); + if (bMol) + { + if (i == 0 || atoms->atom[i].resind != atoms->atom[i-1].resind) + { + atoms->resinfo[atoms->atom[i].resind].name = + put_symtab(symtab, "MOL"); + } + } + else + { + /* Residue number is the atom number */ + atoms->atom[i].resind = i; + /* Generate an residue name from the particle type */ + if (atoms->atom[i].type < 26) + { + sprintf(buf, "T%c", 'A'+atoms->atom[i].type); + } + else + { + sprintf(buf, "T%c%c", + 'A'+atoms->atom[i].type/26, 'A'+atoms->atom[i].type%26); + } + t_atoms_set_resinfo(atoms, i, symtab, buf, i, ' ', 0, ' '); + } + + if (r == 3) + { + level--; + } + i++; + } + } + atoms->nres = atoms->nr; + + if (i != atoms->nr) + { + gmx_fatal(FARGS, "Internal inconsistency in Espresso routines, read %d atoms, expected %d atoms", i, atoms->nr); + } + } + else if (level == 1 && strcmp(word, "variable") == 0 && !bFoundVariable) + { + bFoundVariable = TRUE; + level += check_open_parenthesis(fp, r, infile, "variable"); + while (level == 2 && (r = get_espresso_word(fp, word))) + { + if (level == 2 && strcmp(word, "box_l") == 0) + { + for (m = 0; m < 3; m++) + { + r = get_espresso_word(fp, word); + sscanf(word, "%lf", &d); + box[m][m] = d; + } + level += check_close_parenthesis(fp, r, infile, "box_l"); + } + } + } + else if (r == 2) + { + level++; + } + else if (r == 3) + { + level--; + } + } + + if (!bFoundParticles) + { + fprintf(stderr, "Did not find a particles section in Espresso file '%s'\n", + infile); } - } - - if (!bFoundParticles) { - fprintf(stderr,"Did not find a particles section in Espresso file '%s'\n", - infile); - } - - gmx_fio_fclose(fp); + + gmx_fio_fclose(fp); } static int get_espresso_coordnum(const char *infile) { - FILE *fp; - char word[STRLEN]; - int natoms,level,r; - gmx_bool bFoundParticles; - - natoms = 0; - - fp = gmx_fio_fopen(infile,"r"); - - bFoundParticles = FALSE; - level = 0; - while ((r=get_espresso_word(fp,word)) && !bFoundParticles) { - if (level==1 && strcmp(word,"particles")==0 && !bFoundParticles) { - bFoundParticles = TRUE; - level += check_open_parenthesis(fp,r,infile,"particles"); - while (level > 0 && (r=get_espresso_word(fp,word))) { - if (r == 2) { - level++; - if (level == 2) - natoms++; - } else if (r == 3) { - level--; - } - } - } else if (r == 2) { - level++; - } else if (r == 3) { - level--; + FILE *fp; + char word[STRLEN]; + int natoms, level, r; + gmx_bool bFoundParticles; + + natoms = 0; + + fp = gmx_fio_fopen(infile, "r"); + + bFoundParticles = FALSE; + level = 0; + while ((r = get_espresso_word(fp, word)) && !bFoundParticles) + { + if (level == 1 && strcmp(word, "particles") == 0 && !bFoundParticles) + { + bFoundParticles = TRUE; + level += check_open_parenthesis(fp, r, infile, "particles"); + while (level > 0 && (r = get_espresso_word(fp, word))) + { + if (r == 2) + { + level++; + if (level == 2) + { + natoms++; + } + } + else if (r == 3) + { + level--; + } + } + } + else if (r == 2) + { + level++; + } + else if (r == 3) + { + level--; + } + } + if (!bFoundParticles) + { + fprintf(stderr, "Did not find a particles section in Espresso file '%s'\n", + infile); } - } - if (!bFoundParticles) { - fprintf(stderr,"Did not find a particles section in Espresso file '%s'\n", - infile); - } - - gmx_fio_fclose(fp); - - return natoms; + + gmx_fio_fclose(fp); + + return natoms; } -static void write_espresso_conf_indexed(FILE *out,const char *title, - t_atoms *atoms,int nx,atom_id *index, - rvec *x,rvec *v,matrix box) +static void write_espresso_conf_indexed(FILE *out, const char *title, + t_atoms *atoms, int nx, atom_id *index, + rvec *x, rvec *v, matrix box) { - int i,j; - - fprintf(out,"# %s\n",title); - if (TRICLINIC(box)) { - gmx_warning("The Espresso format does not support triclinic unit-cells"); - } - fprintf(out,"{variable {box_l %f %f %f}}\n",box[0][0],box[1][1],box[2][2]); - - fprintf(out,"{particles {id pos type q%s}\n",v ? " v" : ""); - for(i=0; iatom[j].type,atoms->atom[j].q); - if (v) - fprintf(out," %f %f %f",v[j][XX],v[j][YY],v[j][ZZ]); - fprintf(out,"}\n"); - } - fprintf(out,"}\n"); + int i, j; + + fprintf(out, "# %s\n", title); + if (TRICLINIC(box)) + { + gmx_warning("The Espresso format does not support triclinic unit-cells"); + } + fprintf(out, "{variable {box_l %f %f %f}}\n", box[0][0], box[1][1], box[2][2]); + + fprintf(out, "{particles {id pos type q%s}\n", v ? " v" : ""); + for (i = 0; i < nx; i++) + { + if (index) + { + j = index[i]; + } + else + { + j = i; + } + fprintf(out, "\t{%d %f %f %f %d %g", + j, x[j][XX], x[j][YY], x[j][ZZ], + atoms->atom[j].type, atoms->atom[j].q); + if (v) + { + fprintf(out, " %f %f %f", v[j][XX], v[j][YY], v[j][ZZ]); + } + fprintf(out, "}\n"); + } + fprintf(out, "}\n"); } static void get_coordnum_fp (FILE *in, char *title, int *natoms) { - char line[STRLEN+1]; + char line[STRLEN+1]; - fgets2 (title,STRLEN,in); - fgets2 (line,STRLEN,in); - if (sscanf (line,"%d",natoms) != 1) { - gmx_fatal(FARGS,"gro file does not have the number of atoms on the second line"); - } + fgets2 (title, STRLEN, in); + fgets2 (line, STRLEN, in); + if (sscanf (line, "%d", natoms) != 1) + { + gmx_fatal(FARGS, "gro file does not have the number of atoms on the second line"); + } } -static void get_coordnum (const char *infile,int *natoms) +static void get_coordnum (const char *infile, int *natoms) { - FILE *in; - char title[STRLEN]; - - in=gmx_fio_fopen(infile,"r"); - get_coordnum_fp(in,title,natoms); - gmx_fio_fclose (in); + FILE *in; + char title[STRLEN]; + + in = gmx_fio_fopen(infile, "r"); + get_coordnum_fp(in, title, natoms); + gmx_fio_fclose (in); } static gmx_bool get_w_conf(FILE *in, const char *infile, char *title, t_symtab *symtab, t_atoms *atoms, int *ndec, rvec x[], rvec *v, matrix box) { - char name[6]; - char line[STRLEN+1],*ptr; - char buf[256]; - double x1,y1,z1,x2,y2,z2; - rvec xmin,xmax; - int natoms,i,m,resnr,newres,oldres,ddist,c; - gmx_bool bFirst,bVel; - char *p1,*p2,*p3; - - newres = -1; - oldres = NOTSET; /* Unlikely number for the first residue! */ - ddist = 0; - - /* Read the title and number of atoms */ - get_coordnum_fp(in,title,&natoms); - - if (natoms > atoms->nr) - gmx_fatal(FARGS,"gro file contains more atoms (%d) than expected (%d)", - natoms,atoms->nr); - else if (natoms < atoms->nr) - fprintf(stderr,"Warning: gro file contains less atoms (%d) than expected" - " (%d)\n",natoms,atoms->nr); - - bFirst=TRUE; - - bVel = FALSE; - - /* just pray the arrays are big enough */ - for (i=0; (i < natoms) ; i++) { - if ((fgets2 (line,STRLEN,in)) == NULL) { - unexpected_eof(infile,i+2); - } - if (strlen(line) < 39) - gmx_fatal(FARGS,"Invalid line in %s for atom %d:\n%s",infile,i+1,line); - - /* determine read precision from distance between periods - (decimal points) */ - if (bFirst) { - bFirst=FALSE; - p1=strchr(line,'.'); - if (p1 == NULL) - gmx_fatal(FARGS,"A coordinate in file %s does not contain a '.'",infile); - p2=strchr(&p1[1],'.'); - if (p2 == NULL) - gmx_fatal(FARGS,"A coordinate in file %s does not contain a '.'",infile); - ddist = p2 - p1; - *ndec = ddist - 5; - - p3=strchr(&p2[1],'.'); - if (p3 == NULL) - gmx_fatal(FARGS,"A coordinate in file %s does not contain a '.'",infile); - - if (p3 - p2 != ddist) - gmx_fatal(FARGS,"The spacing of the decimal points in file %s is not consistent for x, y and z",infile); + char name[6]; + char line[STRLEN+1], *ptr; + char buf[256]; + double x1, y1, z1, x2, y2, z2; + rvec xmin, xmax; + int natoms, i, m, resnr, newres, oldres, ddist, c; + gmx_bool bFirst, bVel; + char *p1, *p2, *p3; + + newres = -1; + oldres = NOTSET; /* Unlikely number for the first residue! */ + ddist = 0; + + /* Read the title and number of atoms */ + get_coordnum_fp(in, title, &natoms); + + if (natoms > atoms->nr) + { + gmx_fatal(FARGS, "gro file contains more atoms (%d) than expected (%d)", + natoms, atoms->nr); } - - /* residue number*/ - memcpy(name,line,5); - name[5]='\0'; - sscanf(name,"%d",&resnr); - memcpy(name,line+5,5); - name[5]='\0'; - if (resnr != oldres) { - oldres = resnr; - newres++; - if (newres >= natoms) - gmx_fatal(FARGS,"More residues than atoms in %s (natoms = %d)", - infile,natoms); - atoms->atom[i].resind = newres; - t_atoms_set_resinfo(atoms,i,symtab,name,resnr,' ',0,' '); - } else { - atoms->atom[i].resind = newres; + else if (natoms < atoms->nr) + { + fprintf(stderr, "Warning: gro file contains less atoms (%d) than expected" + " (%d)\n", natoms, atoms->nr); } - /* atomname */ - memcpy(name,line+10,5); - atoms->atomname[i]=put_symtab(symtab,name); - - /* eventueel controle atomnumber met i+1 */ - - /* coordinates (start after residue shit) */ - ptr = line + 20; - /* Read fixed format */ - for(m=0; m= natoms) + { + gmx_fatal(FARGS, "More residues than atoms in %s (natoms = %d)", + infile, natoms); + } + atoms->atom[i].resind = newres; + t_atoms_set_resinfo(atoms, i, symtab, name, resnr, ' ', 0, ' '); + } + else + { + atoms->atom[i].resind = newres; + } + + /* atomname */ + memcpy(name, line+10, 5); + atoms->atomname[i] = put_symtab(symtab, name); + + /* eventueel controle atomnumber met i+1 */ + + /* coordinates (start after residue shit) */ + ptr = line + 20; + /* Read fixed format */ + for (m = 0; m < DIM; m++) + { + for (c = 0; (c < ddist && ptr[0]); c++) + { + buf[c] = ptr[0]; + ptr++; + } + buf[c] = '\0'; + if (sscanf (buf, "%lf %lf", &x1, &x2) != 1) + { + gmx_fatal(FARGS, "Something is wrong in the coordinate formatting of file %s. Note that gro is fixed format (see the manual)", infile); + } + else + { + x[i][m] = x1; + } + } + + /* velocities (start after residues and coordinates) */ + if (v) + { + /* Read fixed format */ + for (m = 0; m < DIM; m++) + { + for (c = 0; (c < ddist && ptr[0]); c++) + { + buf[c] = ptr[0]; + ptr++; + } + buf[c] = '\0'; + if (sscanf (buf, "%lf", &x1) != 1) + { + v[i][m] = 0; + } + else + { + v[i][m] = x1; + bVel = TRUE; + } + } + } } - - /* velocities (start after residues and coordinates) */ - if (v) { - /* Read fixed format */ - for(m=0; mnres = newres + 1; + + /* box */ + fgets2 (line, STRLEN, in); + if (sscanf (line, "%lf%lf%lf", &x1, &y1, &z1) != 3) + { + gmx_warning("Bad box in file %s", infile); + + /* Generate a cubic box */ + for (m = 0; (m < DIM); m++) + { + xmin[m] = xmax[m] = x[0][m]; + } + for (i = 1; (i < atoms->nr); i++) + { + for (m = 0; (m < DIM); m++) + { + xmin[m] = min(xmin[m], x[i][m]); + xmax[m] = max(xmax[m], x[i][m]); + } + } + for (i = 0; i < DIM; i++) + { + for (m = 0; m < DIM; m++) + { + box[i][m] = 0.0; + } + } + for (m = 0; (m < DIM); m++) + { + box[m][m] = (xmax[m]-xmin[m]); + } + fprintf(stderr, "Generated a cubic box %8.3f x %8.3f x %8.3f\n", + box[XX][XX], box[YY][YY], box[ZZ][ZZ]); } - } - atoms->nres = newres + 1; - - /* box */ - fgets2 (line,STRLEN,in); - if (sscanf (line,"%lf%lf%lf",&x1,&y1,&z1) != 3) { - gmx_warning("Bad box in file %s",infile); - - /* Generate a cubic box */ - for(m=0; (mnr); i++) - for(m=0; (mnatoms; - snew(atoms.atom,fr->natoms); - atoms.nres=fr->natoms; - snew(atoms.resinfo,fr->natoms); - snew(atoms.atomname,fr->natoms); - - fr->bV = get_w_conf(status,title,title,&symtab,&atoms,&ndec,fr->x,fr->v,fr->box); - fr->bPrec = TRUE; - fr->prec = 1; - /* prec = 10^ndec: */ - for(i=0; iprec *= 10; - fr->title = title; - fr->bTitle = TRUE; - fr->bX = TRUE; - fr->bBox = TRUE; - - sfree(atoms.atom); - sfree(atoms.resinfo); - sfree(atoms.atomname); - done_symtab(&symtab); - - if ((p=strstr(title,"t=")) != NULL) { - p+=2; - if (sscanf(p,"%lf",&tt)==1) { - fr->time = tt; - fr->bTime = TRUE; - } else { - fr->time = 0; - fr->bTime = FALSE; + t_atoms atoms; + t_symtab symtab; + char title[STRLEN], *p; + double tt; + int ndec = 0, i; + + if (gmx_eof(status)) + { + return FALSE; } - } - - if (atoms.nr != fr->natoms) - gmx_fatal(FARGS,"Number of atoms in gro frame (%d) doesn't match the number in the previous frame (%d)",atoms.nr,fr->natoms); - - return TRUE; -} -int gro_first_x_or_v(FILE *status,t_trxframe *fr) -{ - char title[STRLEN]; - - frewind(status); - fprintf(stderr,"Reading frames from gro file"); - get_coordnum_fp(status, title, &fr->natoms); - frewind(status); - fprintf(stderr," '%s', %d atoms.\n",title, fr->natoms); - fr->bTitle = TRUE; - fr->title = title; - if (fr->natoms==0) - gmx_file("No coordinates in gro file"); - - snew(fr->x,fr->natoms); - snew(fr->v,fr->natoms); - gro_next_x_or_v(status, fr); - - return fr->natoms; + open_symtab(&symtab); + atoms.nr = fr->natoms; + snew(atoms.atom, fr->natoms); + atoms.nres = fr->natoms; + snew(atoms.resinfo, fr->natoms); + snew(atoms.atomname, fr->natoms); + + fr->bV = get_w_conf(status, title, title, &symtab, &atoms, &ndec, fr->x, fr->v, fr->box); + fr->bPrec = TRUE; + fr->prec = 1; + /* prec = 10^ndec: */ + for (i = 0; i < ndec; i++) + { + fr->prec *= 10; + } + fr->title = title; + fr->bTitle = TRUE; + fr->bX = TRUE; + fr->bBox = TRUE; + + sfree(atoms.atom); + sfree(atoms.resinfo); + sfree(atoms.atomname); + done_symtab(&symtab); + + if ((p = strstr(title, "t=")) != NULL) + { + p += 2; + if (sscanf(p, "%lf", &tt) == 1) + { + fr->time = tt; + fr->bTime = TRUE; + } + else + { + fr->time = 0; + fr->bTime = FALSE; + } + } + + if (atoms.nr != fr->natoms) + { + gmx_fatal(FARGS, "Number of atoms in gro frame (%d) doesn't match the number in the previous frame (%d)", atoms.nr, fr->natoms); + } + + return TRUE; } -static void make_hconf_format(int pr,gmx_bool bVel,char format[]) +int gro_first_x_or_v(FILE *status, t_trxframe *fr) { - int l,vpr; - - /* build format string for printing, - something like "%8.3f" for x and "%8.4f" for v */ - if (pr<0) - pr=0; - if (pr>30) - pr=30; - l=pr+5; - vpr=pr+1; - if (bVel) - sprintf(format,"%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df\n", - l,pr,l,pr,l,pr,l,vpr,l,vpr,l,vpr); - else - sprintf(format,"%%%d.%df%%%d.%df%%%d.%df\n",l,pr,l,pr,l,pr); + char title[STRLEN]; + + frewind(status); + fprintf(stderr, "Reading frames from gro file"); + get_coordnum_fp(status, title, &fr->natoms); + frewind(status); + fprintf(stderr, " '%s', %d atoms.\n", title, fr->natoms); + fr->bTitle = TRUE; + fr->title = title; + if (fr->natoms == 0) + { + gmx_file("No coordinates in gro file"); + } + + snew(fr->x, fr->natoms); + snew(fr->v, fr->natoms); + gro_next_x_or_v(status, fr); + return fr->natoms; } -static void write_hconf_box(FILE *out,int pr,matrix box) +static void make_hconf_format(int pr, gmx_bool bVel, char format[]) { - char format[100]; - int l; - - if (pr<5) - pr=5; - l=pr+5; - - if (box[XX][YY] || box[XX][ZZ] || box[YY][XX] || box[YY][ZZ] || - box[ZZ][XX] || box[ZZ][YY]) { - sprintf(format,"%%%d.%df%%%d.%df%%%d.%df" - "%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df\n", - l,pr,l,pr,l,pr,l,pr,l,pr,l,pr,l,pr,l,pr,l,pr); - fprintf(out,format, - box[XX][XX],box[YY][YY],box[ZZ][ZZ], - box[XX][YY],box[XX][ZZ],box[YY][XX], - box[YY][ZZ],box[ZZ][XX],box[ZZ][YY]); - } else { - sprintf(format,"%%%d.%df%%%d.%df%%%d.%df\n",l,pr,l,pr,l,pr); - fprintf(out,format, - box[XX][XX],box[YY][YY],box[ZZ][ZZ]); - } + int l, vpr; + + /* build format string for printing, + something like "%8.3f" for x and "%8.4f" for v */ + if (pr < 0) + { + pr = 0; + } + if (pr > 30) + { + pr = 30; + } + l = pr+5; + vpr = pr+1; + if (bVel) + { + sprintf(format, "%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df\n", + l, pr, l, pr, l, pr, l, vpr, l, vpr, l, vpr); + } + else + { + sprintf(format, "%%%d.%df%%%d.%df%%%d.%df\n", l, pr, l, pr, l, pr); + } + } -void write_hconf_indexed_p(FILE *out,const char *title,t_atoms *atoms, - int nx,const atom_id index[], int pr, - rvec *x,rvec *v,matrix box) +static void write_hconf_box(FILE *out, int pr, matrix box) { - char resnm[6],nm[6],format[100]; - int ai,i,resind,resnr; - - bromacs(format,99); - fprintf (out,"%s\n",(title && title[0])?title:format); - fprintf (out,"%5d\n",nx); - - make_hconf_format(pr,v!=NULL,format); - - for (i=0; (iatom[ai].resind; - strncpy(resnm," ??? ",sizeof(resnm)-1); - if (resind < atoms->nres) { - strncpy(resnm,*atoms->resinfo[resind].name,sizeof(resnm)-1); - resnr = atoms->resinfo[resind].nr; - } else { - strncpy(resnm," ??? ",sizeof(resnm)-1); - resnr = resind + 1; + char format[100]; + int l; + + if (pr < 5) + { + pr = 5; + } + l = pr+5; + + if (box[XX][YY] || box[XX][ZZ] || box[YY][XX] || box[YY][ZZ] || + box[ZZ][XX] || box[ZZ][YY]) + { + sprintf(format, "%%%d.%df%%%d.%df%%%d.%df" + "%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df%%%d.%df\n", + l, pr, l, pr, l, pr, l, pr, l, pr, l, pr, l, pr, l, pr, l, pr); + fprintf(out, format, + box[XX][XX], box[YY][YY], box[ZZ][ZZ], + box[XX][YY], box[XX][ZZ], box[YY][XX], + box[YY][ZZ], box[ZZ][XX], box[ZZ][YY]); } - - if (atoms->atom) - strncpy(nm,*atoms->atomname[ai],sizeof(nm)-1); else - strncpy(nm," ??? ",sizeof(nm)-1); + { + sprintf(format, "%%%d.%df%%%d.%df%%%d.%df\n", l, pr, l, pr, l, pr); + fprintf(out, format, + box[XX][XX], box[YY][YY], box[ZZ][ZZ]); + } +} - fprintf(out,"%5d%-5.5s%5.5s%5d",resnr%100000,resnm,nm,(ai+1)%100000); - /* next fprintf uses built format string */ - if (v) - fprintf(out,format, - x[ai][XX], x[ai][YY], x[ai][ZZ], v[ai][XX],v[ai][YY],v[ai][ZZ]); - else - fprintf(out,format, - x[ai][XX], x[ai][YY], x[ai][ZZ]); - } +void write_hconf_indexed_p(FILE *out, const char *title, t_atoms *atoms, + int nx, const atom_id index[], int pr, + rvec *x, rvec *v, matrix box) +{ + char resnm[6], nm[6], format[100]; + int ai, i, resind, resnr; + + bromacs(format, 99); + fprintf (out, "%s\n", (title && title[0]) ? title : format); + fprintf (out, "%5d\n", nx); + + make_hconf_format(pr, v != NULL, format); + + for (i = 0; (i < nx); i++) + { + ai = index[i]; + + resind = atoms->atom[ai].resind; + strncpy(resnm, " ??? ", sizeof(resnm)-1); + if (resind < atoms->nres) + { + strncpy(resnm, *atoms->resinfo[resind].name, sizeof(resnm)-1); + resnr = atoms->resinfo[resind].nr; + } + else + { + strncpy(resnm, " ??? ", sizeof(resnm)-1); + resnr = resind + 1; + } + + if (atoms->atom) + { + strncpy(nm, *atoms->atomname[ai], sizeof(nm)-1); + } + else + { + strncpy(nm, " ??? ", sizeof(nm)-1); + } + + fprintf(out, "%5d%-5.5s%5.5s%5d", resnr%100000, resnm, nm, (ai+1)%100000); + /* next fprintf uses built format string */ + if (v) + { + fprintf(out, format, + x[ai][XX], x[ai][YY], x[ai][ZZ], v[ai][XX], v[ai][YY], v[ai][ZZ]); + } + else + { + fprintf(out, format, + x[ai][XX], x[ai][YY], x[ai][ZZ]); + } + } - write_hconf_box(out,pr,box); + write_hconf_box(out, pr, box); - fflush(out); + fflush(out); } -static void write_hconf_mtop(FILE *out,const char *title,gmx_mtop_t *mtop, - int pr, - rvec *x,rvec *v,matrix box) +static void write_hconf_mtop(FILE *out, const char *title, gmx_mtop_t *mtop, + int pr, + rvec *x, rvec *v, matrix box) { - char format[100]; - int i,resnr; - gmx_mtop_atomloop_all_t aloop; - t_atom *atom; - char *atomname,*resname; - - bromacs(format,99); - fprintf (out,"%s\n",(title && title[0])?title:format); - fprintf (out,"%5d\n",mtop->natoms); - - make_hconf_format(pr,v!=NULL,format); - - aloop = gmx_mtop_atomloop_all_init(mtop); - while (gmx_mtop_atomloop_all_next(aloop,&i,&atom)) { - gmx_mtop_atomloop_all_names(aloop,&atomname,&resnr,&resname); - - fprintf(out,"%5d%-5.5s%5.5s%5d", - resnr%100000,resname,atomname,(i+1)%100000); - /* next fprintf uses built format string */ - if (v) - fprintf(out,format, - x[i][XX], x[i][YY], x[i][ZZ], v[i][XX],v[i][YY],v[i][ZZ]); - else - fprintf(out,format, - x[i][XX], x[i][YY], x[i][ZZ]); - } + char format[100]; + int i, resnr; + gmx_mtop_atomloop_all_t aloop; + t_atom *atom; + char *atomname, *resname; + + bromacs(format, 99); + fprintf (out, "%s\n", (title && title[0]) ? title : format); + fprintf (out, "%5d\n", mtop->natoms); + + make_hconf_format(pr, v != NULL, format); + + aloop = gmx_mtop_atomloop_all_init(mtop); + while (gmx_mtop_atomloop_all_next(aloop, &i, &atom)) + { + gmx_mtop_atomloop_all_names(aloop, &atomname, &resnr, &resname); + + fprintf(out, "%5d%-5.5s%5.5s%5d", + resnr%100000, resname, atomname, (i+1)%100000); + /* next fprintf uses built format string */ + if (v) + { + fprintf(out, format, + x[i][XX], x[i][YY], x[i][ZZ], v[i][XX], v[i][YY], v[i][ZZ]); + } + else + { + fprintf(out, format, + x[i][XX], x[i][YY], x[i][ZZ]); + } + } - write_hconf_box(out,pr,box); + write_hconf_box(out, pr, box); - fflush(out); + fflush(out); } -void write_hconf_p(FILE *out,const char *title,t_atoms *atoms, int pr, - rvec *x,rvec *v,matrix box) +void write_hconf_p(FILE *out, const char *title, t_atoms *atoms, int pr, + rvec *x, rvec *v, matrix box) { - atom_id *aa; - int i; - - snew(aa,atoms->nr); - for(i=0; (inr); i++) - aa[i]=i; - write_hconf_indexed_p(out,title,atoms,atoms->nr,aa,pr,x,v,box); - sfree(aa); + atom_id *aa; + int i; + + snew(aa, atoms->nr); + for (i = 0; (i < atoms->nr); i++) + { + aa[i] = i; + } + write_hconf_indexed_p(out, title, atoms, atoms->nr, aa, pr, x, v, box); + sfree(aa); } void write_conf_p(const char *outfile, const char *title, - t_atoms *atoms, int pr, - rvec *x, rvec *v,matrix box) + t_atoms *atoms, int pr, + rvec *x, rvec *v, matrix box) { - FILE *out; + FILE *out; - out=gmx_fio_fopen(outfile,"w"); - write_hconf_p(out,title,atoms,pr,x,v,box); + out = gmx_fio_fopen(outfile, "w"); + write_hconf_p(out, title, atoms, pr, x, v, box); - gmx_fio_fclose (out); + gmx_fio_fclose (out); } static void write_conf(const char *outfile, const char *title, t_atoms *atoms, - rvec *x, rvec *v,matrix box) + rvec *x, rvec *v, matrix box) { - write_conf_p(outfile, title, atoms, 3, x, v, box); + write_conf_p(outfile, title, atoms, 3, x, v, box); } -void write_sto_conf_indexed(const char *outfile,const char *title, - t_atoms *atoms, - rvec x[],rvec *v,int ePBC,matrix box, - atom_id nindex,atom_id index[]) +void write_sto_conf_indexed(const char *outfile, const char *title, + t_atoms *atoms, + rvec x[], rvec *v, int ePBC, matrix box, + atom_id nindex, atom_id index[]) { - FILE *out; - int ftp; - t_trxframe fr; - - ftp=fn2ftp(outfile); - switch (ftp) { - case efGRO: - out=gmx_fio_fopen(outfile,"w"); - write_hconf_indexed_p(out, title, atoms, nindex, index, 3, x, v, box); - gmx_fio_fclose(out); - break; - case efG96: - clear_trxframe(&fr,TRUE); - fr.bTitle = TRUE; - fr.title = title; - fr.natoms = atoms->nr; - fr.bAtoms = TRUE; - fr.atoms = atoms; - fr.bX = TRUE; - fr.x = x; - if (v) { - fr.bV = TRUE; - fr.v = v; + FILE *out; + int ftp; + t_trxframe fr; + + ftp = fn2ftp(outfile); + switch (ftp) + { + case efGRO: + out = gmx_fio_fopen(outfile, "w"); + write_hconf_indexed_p(out, title, atoms, nindex, index, 3, x, v, box); + gmx_fio_fclose(out); + break; + case efG96: + clear_trxframe(&fr, TRUE); + fr.bTitle = TRUE; + fr.title = title; + fr.natoms = atoms->nr; + fr.bAtoms = TRUE; + fr.atoms = atoms; + fr.bX = TRUE; + fr.x = x; + if (v) + { + fr.bV = TRUE; + fr.v = v; + } + fr.bBox = TRUE; + copy_mat(box, fr.box); + out = gmx_fio_fopen(outfile, "w"); + write_g96_conf(out, &fr, nindex, index); + gmx_fio_fclose(out); + break; + case efPDB: + case efBRK: + case efENT: + case efPQR: + out = gmx_fio_fopen(outfile, "w"); + write_pdbfile_indexed(out, title, atoms, x, ePBC, box, ' ', -1, nindex, index, NULL, TRUE); + gmx_fio_fclose(out); + break; + case efESP: + out = gmx_fio_fopen(outfile, "w"); + write_espresso_conf_indexed(out, title, atoms, nindex, index, x, v, box); + gmx_fio_fclose(out); + break; + case efTPR: + case efTPB: + case efTPA: + gmx_fatal(FARGS, "Sorry, can not write a topology to %s", outfile); + break; + default: + gmx_incons("Not supported in write_sto_conf_indexed"); } - fr.bBox = TRUE; - copy_mat(box,fr.box); - out=gmx_fio_fopen(outfile,"w"); - write_g96_conf(out, &fr, nindex, index); - gmx_fio_fclose(out); - break; - case efPDB: - case efBRK: - case efENT: - case efPQR: - out=gmx_fio_fopen(outfile,"w"); - write_pdbfile_indexed(out,title,atoms,x,ePBC,box,' ',-1,nindex,index,NULL,TRUE); - gmx_fio_fclose(out); - break; - case efESP: - out=gmx_fio_fopen(outfile,"w"); - write_espresso_conf_indexed(out, title, atoms, nindex, index, x, v, box); - gmx_fio_fclose(out); - break; - case efTPR: - case efTPB: - case efTPA: - gmx_fatal(FARGS,"Sorry, can not write a topology to %s",outfile); - break; - default: - gmx_incons("Not supported in write_sto_conf_indexed"); - } } -static void write_xyz_conf(const char *outfile,const char *title, - t_atoms *atoms,rvec *x) +static void write_xyz_conf(const char *outfile, const char *title, + t_atoms *atoms, rvec *x) { - FILE *fp; - int i,anr; - real value; - char *ptr,*name; - gmx_atomprop_t aps=gmx_atomprop_init(); - - fp = gmx_fio_fopen(outfile,"w"); - fprintf(fp,"%3d\n",atoms->nr); - fprintf(fp,"%s\n",title); - for(i=0; (inr); i++) { - anr = atoms->atom[i].atomnumber; - name = *atoms->atomname[i]; - if (anr == NOTSET) { - if (gmx_atomprop_query(aps,epropElement,"???",name,&value)) - anr = gmx_nint(value); + FILE *fp; + int i, anr; + real value; + char *ptr, *name; + gmx_atomprop_t aps = gmx_atomprop_init(); + + fp = gmx_fio_fopen(outfile, "w"); + fprintf(fp, "%3d\n", atoms->nr); + fprintf(fp, "%s\n", title); + for (i = 0; (i < atoms->nr); i++) + { + anr = atoms->atom[i].atomnumber; + name = *atoms->atomname[i]; + if (anr == NOTSET) + { + if (gmx_atomprop_query(aps, epropElement, "???", name, &value)) + { + anr = gmx_nint(value); + } + } + if ((ptr = gmx_atomprop_element(aps, anr)) == NULL) + { + ptr = name; + } + fprintf(fp, "%3s%10.5f%10.5f%10.5f\n", ptr, + 10*x[i][XX], 10*x[i][YY], 10*x[i][ZZ]); } - if ((ptr = gmx_atomprop_element(aps,anr)) == NULL) - ptr = name; - fprintf(fp,"%3s%10.5f%10.5f%10.5f\n",ptr, - 10*x[i][XX],10*x[i][YY],10*x[i][ZZ]); - } - gmx_fio_fclose(fp); - gmx_atomprop_destroy(aps); + gmx_fio_fclose(fp); + gmx_atomprop_destroy(aps); } -void write_sto_conf(const char *outfile,const char *title,t_atoms *atoms, - rvec x[],rvec *v,int ePBC,matrix box) +void write_sto_conf(const char *outfile, const char *title, t_atoms *atoms, + rvec x[], rvec *v, int ePBC, matrix box) { - FILE *out; - int ftp; - t_trxframe fr; - - ftp=fn2ftp(outfile); - switch (ftp) { - case efGRO: - write_conf(outfile, title, atoms, x, v, box); - break; - case efG96: - clear_trxframe(&fr,TRUE); - fr.bTitle = TRUE; - fr.title = title; - fr.natoms = atoms->nr; - fr.bAtoms = TRUE; - fr.atoms = atoms; - fr.bX = TRUE; - fr.x = x; - if (v) { - fr.bV = TRUE; - fr.v = v; + FILE *out; + int ftp; + t_trxframe fr; + + ftp = fn2ftp(outfile); + switch (ftp) + { + case efGRO: + write_conf(outfile, title, atoms, x, v, box); + break; + case efG96: + clear_trxframe(&fr, TRUE); + fr.bTitle = TRUE; + fr.title = title; + fr.natoms = atoms->nr; + fr.bAtoms = TRUE; + fr.atoms = atoms; + fr.bX = TRUE; + fr.x = x; + if (v) + { + fr.bV = TRUE; + fr.v = v; + } + fr.bBox = TRUE; + copy_mat(box, fr.box); + out = gmx_fio_fopen(outfile, "w"); + write_g96_conf(out, &fr, -1, NULL); + gmx_fio_fclose(out); + break; + case efXYZ: + write_xyz_conf(outfile, (strlen(title) > 0) ? title : outfile, atoms, x); + break; + case efPDB: + case efBRK: + case efENT: + out = gmx_fio_fopen(outfile, "w"); + write_pdbfile(out, title, atoms, x, ePBC, box, ' ', -1, NULL, TRUE); + gmx_fio_fclose(out); + break; + case efESP: + out = gmx_fio_fopen(outfile, "w"); + write_espresso_conf_indexed(out, title, atoms, atoms->nr, NULL, x, v, box); + gmx_fio_fclose(out); + break; + case efTPR: + case efTPB: + case efTPA: + gmx_fatal(FARGS, "Sorry, can not write a topology to %s", outfile); + break; + default: + gmx_incons("Not supported in write_sto_conf"); } - fr.bBox = TRUE; - copy_mat(box,fr.box); - out=gmx_fio_fopen(outfile,"w"); - write_g96_conf(out, &fr, -1, NULL); - gmx_fio_fclose(out); - break; - case efXYZ: - write_xyz_conf(outfile,(strlen(title) > 0) ? title : outfile,atoms,x); - break; - case efPDB: - case efBRK: - case efENT: - out=gmx_fio_fopen(outfile,"w"); - write_pdbfile(out, title, atoms, x, ePBC, box, ' ', -1,NULL,TRUE); - gmx_fio_fclose(out); - break; - case efESP: - out=gmx_fio_fopen(outfile,"w"); - write_espresso_conf_indexed(out, title, atoms, atoms->nr, NULL, x, v, box); - gmx_fio_fclose(out); - break; - case efTPR: - case efTPB: - case efTPA: - gmx_fatal(FARGS,"Sorry, can not write a topology to %s",outfile); - break; - default: - gmx_incons("Not supported in write_sto_conf"); - } } -void write_sto_conf_mtop(const char *outfile,const char *title, - gmx_mtop_t *mtop, - rvec x[],rvec *v,int ePBC,matrix box) +void write_sto_conf_mtop(const char *outfile, const char *title, + gmx_mtop_t *mtop, + rvec x[], rvec *v, int ePBC, matrix box) { - int ftp; - FILE *out; - t_atoms atoms; - - ftp=fn2ftp(outfile); - switch (ftp) { - case efGRO: - out = gmx_fio_fopen(outfile,"w"); - write_hconf_mtop(out,title,mtop,3,x,v,box); - gmx_fio_fclose(out); - break; - default: - /* This is a brute force approach which requires a lot of memory. - * We should implement mtop versions of all writing routines. - */ - atoms = gmx_mtop_global_atoms(mtop); - - write_sto_conf(outfile,title,&atoms,x,v,ePBC,box); - - done_atom(&atoms); - break; - } + int ftp; + FILE *out; + t_atoms atoms; + + ftp = fn2ftp(outfile); + switch (ftp) + { + case efGRO: + out = gmx_fio_fopen(outfile, "w"); + write_hconf_mtop(out, title, mtop, 3, x, v, box); + gmx_fio_fclose(out); + break; + default: + /* This is a brute force approach which requires a lot of memory. + * We should implement mtop versions of all writing routines. + */ + atoms = gmx_mtop_global_atoms(mtop); + + write_sto_conf(outfile, title, &atoms, x, v, ePBC, box); + + done_atom(&atoms); + break; + } } static int get_xyz_coordnum(const char *infile) { - FILE *fp; - int n; - - fp = gmx_fio_fopen(infile,"r"); - if (fscanf(fp,"%d",&n) != 1) - gmx_fatal(FARGS,"Can not read number of atoms from %s",infile); - gmx_fio_fclose(fp); - - return n; + FILE *fp; + int n; + + fp = gmx_fio_fopen(infile, "r"); + if (fscanf(fp, "%d", &n) != 1) + { + gmx_fatal(FARGS, "Can not read number of atoms from %s", infile); + } + gmx_fio_fclose(fp); + + return n; } -static void read_xyz_conf(const char *infile,char *title, - t_atoms *atoms,rvec *x) +static void read_xyz_conf(const char *infile, char *title, + t_atoms *atoms, rvec *x) { - FILE *fp; - int i,n; - double xx,yy,zz; - t_symtab *tab; - char atomnm[32],buf[STRLEN]; - - snew(tab,1); - fp = gmx_fio_fopen(infile,"r"); - fgets2(buf,STRLEN-1,fp); - if (sscanf(buf,"%d",&n) != 1) - gmx_fatal(FARGS,"Can not read number of atoms from %s",infile); - fgets2(buf,STRLEN-1,fp); - strcpy(title,buf); - for(i=0; (iatomname[i] = put_symtab(tab,atomnm); - x[i][XX] = xx*0.1; - x[i][YY] = yy*0.1; - x[i][ZZ] = zz*0.1; - } - gmx_fio_fclose(fp); + FILE *fp; + int i, n; + double xx, yy, zz; + t_symtab *tab; + char atomnm[32], buf[STRLEN]; + + snew(tab, 1); + fp = gmx_fio_fopen(infile, "r"); + fgets2(buf, STRLEN-1, fp); + if (sscanf(buf, "%d", &n) != 1) + { + gmx_fatal(FARGS, "Can not read number of atoms from %s", infile); + } + fgets2(buf, STRLEN-1, fp); + strcpy(title, buf); + for (i = 0; (i < n); i++) + { + fgets2(buf, STRLEN-1, fp); + if (sscanf(buf, "%s%lf%lf%lf", atomnm, &xx, &yy, &zz) != 4) + { + gmx_fatal(FARGS, "Can not read coordinates from %s", infile); + } + atoms->atomname[i] = put_symtab(tab, atomnm); + x[i][XX] = xx*0.1; + x[i][YY] = yy*0.1; + x[i][ZZ] = zz*0.1; + } + gmx_fio_fclose(fp); } -void get_stx_coordnum(const char *infile,int *natoms) +void get_stx_coordnum(const char *infile, int *natoms) { - FILE *in; - int ftp,tpxver,tpxgen; - t_trxframe fr; - char g96_line[STRLEN+1]; - - ftp=fn2ftp(infile); - range_check(ftp,0,efNR); - switch (ftp) { - case efGRO: - get_coordnum(infile, natoms); - break; - case efG96: - in=gmx_fio_fopen(infile,"r"); - fr.title = NULL; - fr.natoms = -1; - fr.atoms = NULL; - fr.x = NULL; - fr.v = NULL; - fr.f = NULL; - *natoms=read_g96_conf(in,infile,&fr,g96_line); - gmx_fio_fclose(in); - break; - case efXYZ: - *natoms = get_xyz_coordnum(infile); - break; - case efPDB: - case efBRK: - case efENT: - in=gmx_fio_fopen(infile,"r"); - get_pdb_coordnum(in, natoms); - gmx_fio_fclose(in); - break; - case efESP: - *natoms = get_espresso_coordnum(infile); - break; - case efTPA: - case efTPB: - case efTPR: { - t_tpxheader tpx; - - read_tpxheader(infile,&tpx,TRUE,&tpxver,&tpxgen); - *natoms = tpx.natoms; - break; - } - default: - gmx_fatal(FARGS,"File type %s not supported in get_stx_coordnum", - ftp2ext(ftp)); - } + FILE *in; + int ftp, tpxver, tpxgen; + t_trxframe fr; + char g96_line[STRLEN+1]; + + ftp = fn2ftp(infile); + range_check(ftp, 0, efNR); + switch (ftp) + { + case efGRO: + get_coordnum(infile, natoms); + break; + case efG96: + in = gmx_fio_fopen(infile, "r"); + fr.title = NULL; + fr.natoms = -1; + fr.atoms = NULL; + fr.x = NULL; + fr.v = NULL; + fr.f = NULL; + *natoms = read_g96_conf(in, infile, &fr, g96_line); + gmx_fio_fclose(in); + break; + case efXYZ: + *natoms = get_xyz_coordnum(infile); + break; + case efPDB: + case efBRK: + case efENT: + in = gmx_fio_fopen(infile, "r"); + get_pdb_coordnum(in, natoms); + gmx_fio_fclose(in); + break; + case efESP: + *natoms = get_espresso_coordnum(infile); + break; + case efTPA: + case efTPB: + case efTPR: + { + t_tpxheader tpx; + + read_tpxheader(infile, &tpx, TRUE, &tpxver, &tpxgen); + *natoms = tpx.natoms; + break; + } + default: + gmx_fatal(FARGS, "File type %s not supported in get_stx_coordnum", + ftp2ext(ftp)); + } } -void read_stx_conf(const char *infile,char *title,t_atoms *atoms, - rvec x[],rvec *v,int *ePBC,matrix box) +void read_stx_conf(const char *infile, char *title, t_atoms *atoms, + rvec x[], rvec *v, int *ePBC, matrix box) { - FILE *in; - char buf[256]; - gmx_mtop_t *mtop; - t_topology top; - t_trxframe fr; - int i,ftp,natoms; - real d; - char g96_line[STRLEN+1]; - - if (atoms->nr == 0) - fprintf(stderr,"Warning: Number of atoms in %s is 0\n",infile); - else if (atoms->atom == NULL) - gmx_mem("Uninitialized array atom"); - - if (ePBC) - *ePBC = -1; - - ftp=fn2ftp(infile); - switch (ftp) { - case efGRO: - read_whole_conf(infile, title, atoms, x, v, box); - break; - case efXYZ: - read_xyz_conf(infile,title,atoms,x); - break; - case efG96: - fr.title = NULL; - fr.natoms = atoms->nr; - fr.atoms = atoms; - fr.x = x; - fr.v = v; - fr.f = NULL; - in = gmx_fio_fopen(infile,"r"); - read_g96_conf(in, infile, &fr, g96_line); - gmx_fio_fclose(in); - copy_mat(fr.box,box); - strncpy(title, fr.title, STRLEN); - break; - case efPDB: - case efBRK: - case efENT: - read_pdb_conf(infile, title, atoms, x, ePBC, box, TRUE, NULL); - break; - case efESP: - read_espresso_conf(infile,atoms,x,v,box); - break; - case efTPR: - case efTPB: - case efTPA: - snew(mtop,1); - i = read_tpx(infile,NULL,box,&natoms,x,v,NULL,mtop); + FILE *in; + char buf[256]; + gmx_mtop_t *mtop; + t_topology top; + t_trxframe fr; + int i, ftp, natoms; + real d; + char g96_line[STRLEN+1]; + + if (atoms->nr == 0) + { + fprintf(stderr, "Warning: Number of atoms in %s is 0\n", infile); + } + else if (atoms->atom == NULL) + { + gmx_mem("Uninitialized array atom"); + } + if (ePBC) - *ePBC = i; - - strcpy(title,*(mtop->name)); - - /* Free possibly allocated memory */ - done_atom(atoms); - - *atoms = gmx_mtop_global_atoms(mtop); - top = gmx_mtop_t_to_t_topology(mtop); - tpx_make_chain_identifiers(atoms,&top.mols); - - sfree(mtop); - /* The strings in the symtab are still in use in the returned t_atoms - * structure, so we should not free them. But there is no place to put the - * symbols; the only choice is to leak the memory... - * So we clear the symbol table before freeing the topology structure. */ - free_symtab(&top.symtab); - done_top(&top); - - break; - default: - gmx_incons("Not supported in read_stx_conf"); - } -} + { + *ePBC = -1; + } + ftp = fn2ftp(infile); + switch (ftp) + { + case efGRO: + read_whole_conf(infile, title, atoms, x, v, box); + break; + case efXYZ: + read_xyz_conf(infile, title, atoms, x); + break; + case efG96: + fr.title = NULL; + fr.natoms = atoms->nr; + fr.atoms = atoms; + fr.x = x; + fr.v = v; + fr.f = NULL; + in = gmx_fio_fopen(infile, "r"); + read_g96_conf(in, infile, &fr, g96_line); + gmx_fio_fclose(in); + copy_mat(fr.box, box); + strncpy(title, fr.title, STRLEN); + break; + case efPDB: + case efBRK: + case efENT: + read_pdb_conf(infile, title, atoms, x, ePBC, box, TRUE, NULL); + break; + case efESP: + read_espresso_conf(infile, atoms, x, v, box); + break; + case efTPR: + case efTPB: + case efTPA: + snew(mtop, 1); + i = read_tpx(infile, NULL, box, &natoms, x, v, NULL, mtop); + if (ePBC) + { + *ePBC = i; + } + + strcpy(title, *(mtop->name)); + + /* Free possibly allocated memory */ + done_atom(atoms); + + *atoms = gmx_mtop_global_atoms(mtop); + top = gmx_mtop_t_to_t_topology(mtop); + tpx_make_chain_identifiers(atoms, &top.mols); + + sfree(mtop); + /* The strings in the symtab are still in use in the returned t_atoms + * structure, so we should not free them. But there is no place to put the + * symbols; the only choice is to leak the memory... + * So we clear the symbol table before freeing the topology structure. */ + free_symtab(&top.symtab); + done_top(&top); + + break; + default: + gmx_incons("Not supported in read_stx_conf"); + } +} diff --git a/src/gromacs/gmxlib/copyrite.c b/src/gromacs/gmxlib/copyrite.c index 734a11164a..b875dabb5f 100644 --- a/src/gromacs/gmxlib/copyrite.c +++ b/src/gromacs/gmxlib/copyrite.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -65,190 +65,225 @@ #include "buildinfo.h" #include "gmx_cpuid.h" -static void pr_two(FILE *out,int c,int i) +static void pr_two(FILE *out, int c, int i) { - if (i < 10) - fprintf(out,"%c0%1d",c,i); - else - fprintf(out,"%c%2d",c,i); + if (i < 10) + { + fprintf(out, "%c0%1d", c, i); + } + else + { + fprintf(out, "%c%2d", c, i); + } } -void pr_difftime(FILE *out,double dt) +void pr_difftime(FILE *out, double dt) { - int ndays,nhours,nmins,nsecs; - gmx_bool bPrint,bPrinted; - - ndays = dt/(24*3600); - dt = dt-24*3600*ndays; - nhours= dt/3600; - dt = dt-3600*nhours; - nmins = dt/60; - dt = dt-nmins*60; - nsecs = dt; - bPrint= (ndays > 0); - bPrinted=bPrint; - if (bPrint) - fprintf(out,"%d",ndays); - bPrint=bPrint || (nhours > 0); - if (bPrint) { - if (bPrinted) - pr_two(out,'d',nhours); - else - fprintf(out,"%d",nhours); - } - bPrinted=bPrinted || bPrint; - bPrint=bPrint || (nmins > 0); - if (bPrint) { + int ndays, nhours, nmins, nsecs; + gmx_bool bPrint, bPrinted; + + ndays = dt/(24*3600); + dt = dt-24*3600*ndays; + nhours = dt/3600; + dt = dt-3600*nhours; + nmins = dt/60; + dt = dt-nmins*60; + nsecs = dt; + bPrint = (ndays > 0); + bPrinted = bPrint; + if (bPrint) + { + fprintf(out, "%d", ndays); + } + bPrint = bPrint || (nhours > 0); + if (bPrint) + { + if (bPrinted) + { + pr_two(out, 'd', nhours); + } + else + { + fprintf(out, "%d", nhours); + } + } + bPrinted = bPrinted || bPrint; + bPrint = bPrint || (nmins > 0); + if (bPrint) + { + if (bPrinted) + { + pr_two(out, 'h', nmins); + } + else + { + fprintf(out, "%d", nmins); + } + } + bPrinted = bPrinted || bPrint; if (bPrinted) - pr_two(out,'h',nmins); - else - fprintf(out,"%d",nmins); - } - bPrinted=bPrinted || bPrint; - if (bPrinted) - pr_two(out,':',nsecs); - else - fprintf(out,"%ds",nsecs); - fprintf(out,"\n"); + { + pr_two(out, ':', nsecs); + } + else + { + fprintf(out, "%ds", nsecs); + } + fprintf(out, "\n"); } gmx_bool be_cool(void) { - /* Yes, it is bad to check the environment variable every call, - * but we dont call this routine often, and it avoids using - * a mutex for locking the variable... - */ + /* Yes, it is bad to check the environment variable every call, + * but we dont call this routine often, and it avoids using + * a mutex for locking the variable... + */ #ifdef GMX_COOL_QUOTES - return (getenv("GMX_NO_QUOTES") == NULL); + return (getenv("GMX_NO_QUOTES") == NULL); #else - /*be uncool*/ - return FALSE; + /*be uncool*/ + return FALSE; #endif } void space(FILE *out, int n) { - fprintf(out,"%*s",n,""); + fprintf(out, "%*s", n, ""); } void f(char *a) { int i; - int len=strlen(a); - - for(i=0;i= STRLEN) - help[*cqnum][STRLEN-1] = '\0'; - strncpy(retstring,help[*cqnum],retsize); - f(retstring); - for(i=0; (i= STRLEN) + { + help[*cqnum][STRLEN-1] = '\0'; + } + strncpy(retstring, help[*cqnum], retsize); + f(retstring); + for (i = 0; (i < nhlp); i++) + { + sfree(help[i]); + } + sfree(help); + } + else + { + strncpy(retstring, defstring, retsize); + } } void bromacs(char *retstring, int retsize) { - int dum; + int dum; - pukeit("bromacs.dat", - "Groningen Machine for Chemical Simulation", - retstring,retsize,&dum); + pukeit("bromacs.dat", + "Groningen Machine for Chemical Simulation", + retstring, retsize, &dum); } void cool_quote(char *retstring, int retsize, int *cqnum) { - char *tmpstr; - char *s,*ptr; - int tmpcq,*p; - - if (cqnum!=NULL) - p = cqnum; - else - p = &tmpcq; - - /* protect audience from explicit lyrics */ - snew(tmpstr,retsize+1); - pukeit("gurgle.dat","Thanx for Using GROMACS - Have a Nice Day", - tmpstr,retsize-2,p); - - if ((ptr = strchr(tmpstr,'_')) != NULL) { - *ptr='\0'; - ptr++; - sprintf(retstring,"\"%s\" %s",tmpstr,ptr); - } - else { - strcpy(retstring,tmpstr); - } - sfree(tmpstr); + char *tmpstr; + char *s, *ptr; + int tmpcq, *p; + + if (cqnum != NULL) + { + p = cqnum; + } + else + { + p = &tmpcq; + } + + /* protect audience from explicit lyrics */ + snew(tmpstr, retsize+1); + pukeit("gurgle.dat", "Thanx for Using GROMACS - Have a Nice Day", + tmpstr, retsize-2, p); + + if ((ptr = strchr(tmpstr, '_')) != NULL) + { + *ptr = '\0'; + ptr++; + sprintf(retstring, "\"%s\" %s", tmpstr, ptr); + } + else + { + strcpy(retstring, tmpstr); + } + sfree(tmpstr); } -void CopyRight(FILE *out,const char *szProgram) +void CopyRight(FILE *out, const char *szProgram) { - 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, Pieter Meulenhoff, ", - "Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schulz, ", - "Michael Shirts, Alfons Sijbers, Peter Tieleman,\n", - "Berk Hess, David van der Spoel, and Erik Lindahl.\n", - "Copyright (c) 1991-2000, University of Groningen, The Netherlands.", - "Copyright (c) 2001-2010, The GROMACS development team at", - "Uppsala University & The Royal Institute of Technology, Sweden.", - "check out http://www.gromacs.org for more information.\n" - }; - - static const char * LicenseText[] = { - "This program is free software; you can redistribute it and/or", - "modify it under the terms of the GNU Lesser General Public License", - "as published by the Free Software Foundation; either version 2.1", - "of the License, or (at your option) any later version." - }; - - /* Dont change szProgram arbitrarily - it must be argv[0], i.e. the - * name of a file. Otherwise, we won't be able to find the library dir. - */ + 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, Pieter Meulenhoff, ", + "Teemu Murtola, Szilard Pall, Sander Pronk, Roland Schulz, ", + "Michael Shirts, Alfons Sijbers, Peter Tieleman,\n", + "Berk Hess, David van der Spoel, and Erik Lindahl.\n", + "Copyright (c) 1991-2000, University of Groningen, The Netherlands.", + "Copyright (c) 2001-2010, The GROMACS development team at", + "Uppsala University & The Royal Institute of Technology, Sweden.", + "check out http://www.gromacs.org for more information.\n" + }; + + static const char * LicenseText[] = { + "This program is free software; you can redistribute it and/or", + "modify it under the terms of the GNU Lesser General Public License", + "as published by the Free Software Foundation; either version 2.1", + "of the License, or (at your option) any later version." + }; + + /* Dont change szProgram arbitrarily - it must be argv[0], i.e. the + * name of a file. Otherwise, we won't be able to find the library dir. + */ #define NCR (int)asize(CopyrightText) /* TODO: Is this exception still needed? */ #ifdef GMX_FAHCORE @@ -257,379 +292,393 @@ void CopyRight(FILE *out,const char *szProgram) #define NLICENSE (int)asize(LicenseText) #endif - char buf[256],tmpstr[1024]; - int i; + char buf[256], tmpstr[1024]; + int i; #ifdef GMX_FAHCORE - set_program_name("Gromacs"); + set_program_name("Gromacs"); #else - set_program_name(szProgram); + set_program_name(szProgram); #endif - ster_print(out,"G R O M A C S"); - fprintf(out,"\n"); - - bromacs(tmpstr,1023); - sp_print(out,tmpstr); - fprintf(out,"\n"); + ster_print(out, "G R O M A C S"); + fprintf(out, "\n"); - ster_print(out,GromacsVersion()); - fprintf(out,"\n"); + bromacs(tmpstr, 1023); + sp_print(out, tmpstr); + fprintf(out, "\n"); - /* fprintf(out,"\n");*/ + ster_print(out, GromacsVersion()); + fprintf(out, "\n"); - /* sp_print(out,"PLEASE NOTE: THIS IS A BETA VERSION\n"); - - fprintf(out,"\n"); */ + /* fprintf(out,"\n");*/ - for(i=0; (idisres); - if (gmx_mtop_ftype_count(mtop,F_DISRES) == 0) + if (gmx_mtop_ftype_count(mtop, F_DISRES) == 0) { dd->nres = 0; return; } - + if (fplog) { - fprintf(fplog,"Initializing the distance restraints\n"); + fprintf(fplog, "Initializing the distance restraints\n"); } - + if (ir->eDisre == edrEnsemble) { - gmx_fatal(FARGS,"Sorry, distance restraints with ensemble averaging over multiple molecules in one system are not functional in this version of GROMACS"); + gmx_fatal(FARGS, "Sorry, distance restraints with ensemble averaging over multiple molecules in one system are not functional in this version of GROMACS"); } dd->dr_weighting = ir->eDisreWeighting; @@ -98,31 +98,32 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop, if (dd->dr_tau == 0.0) { dd->dr_bMixed = FALSE; - dd->ETerm = 0.0; + dd->ETerm = 0.0; } else { dd->dr_bMixed = ir->bDisreMixed; - dd->ETerm = exp(-(ir->delta_t/ir->dr_tau)); + dd->ETerm = exp(-(ir->delta_t/ir->dr_tau)); } dd->ETerm1 = 1.0 - dd->ETerm; - + ip = mtop->ffparams.iparams; dd->nres = 0; dd->npair = 0; - iloop = gmx_mtop_ilistloop_init(mtop); - while (gmx_mtop_ilistloop_next(iloop,&il,&nmol)) { + iloop = gmx_mtop_ilistloop_init(mtop); + while (gmx_mtop_ilistloop_next(iloop, &il, &nmol)) + { np = 0; - for(fa=0; faffparams.iparams[il[F_DISRES].iatoms[fa]].disres.npair; if (np == npair) { - dd->nres += (ir->eDisre==edrEnsemble ? 1 : nmol)*npair; + dd->nres += (ir->eDisre == edrEnsemble ? 1 : nmol)*npair; dd->npair += nmol*npair; - np = 0; + np = 0; } } } @@ -130,54 +131,58 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop, if (cr && PAR(cr) && !bPartDecomp) { /* Temporary check, will be removed when disre is implemented with DD */ - const char *notestr="NOTE: atoms involved in distance restraints should be within the longest cut-off distance, if this is not the case mdrun generates a fatal error, in that case use particle decomposition (mdrun option -pd)"; - + const char *notestr = "NOTE: atoms involved in distance restraints should be within the longest cut-off distance, if this is not the case mdrun generates a fatal error, in that case use particle decomposition (mdrun option -pd)"; + if (MASTER(cr)) - fprintf(stderr,"\n%s\n\n",notestr); + { + fprintf(stderr, "\n%s\n\n", notestr); + } if (fplog) - fprintf(fplog,"%s\n",notestr); + { + fprintf(fplog, "%s\n", notestr); + } if (dd->dr_tau != 0 || ir->eDisre == edrEnsemble || cr->ms != NULL || dd->nres != dd->npair) { - gmx_fatal(FARGS,"Time or ensemble averaged or multiple pair distance restraints do not work (yet) with domain decomposition, use particle decomposition (mdrun option -pd)"); + gmx_fatal(FARGS, "Time or ensemble averaged or multiple pair distance restraints do not work (yet) with domain decomposition, use particle decomposition (mdrun option -pd)"); } if (ir->nstdisreout != 0) { if (fplog) { - fprintf(fplog,"\nWARNING: Can not write distance restraint data to energy file with domain decomposition\n\n"); + fprintf(fplog, "\nWARNING: Can not write distance restraint data to energy file with domain decomposition\n\n"); } if (MASTER(cr)) { - fprintf(stderr,"\nWARNING: Can not write distance restraint data to energy file with domain decomposition\n"); + fprintf(stderr, "\nWARNING: Can not write distance restraint data to energy file with domain decomposition\n"); } ir->nstdisreout = 0; } } - snew(dd->rt,dd->npair); - + snew(dd->rt, dd->npair); + if (dd->dr_tau != 0.0) { hist = &state->hist; /* Set the "history lack" factor to 1 */ - state->flags |= (1<flags |= (1<disre_initf = 1.0; /* Allocate space for the r^-3 time averages */ - state->flags |= (1<flags |= (1<ndisrepairs = dd->npair; - snew(hist->disre_rm3tav,hist->ndisrepairs); + snew(hist->disre_rm3tav, hist->ndisrepairs); } /* Allocate space for a copy of rm3tav, * so we can call do_force without modifying the state. */ - snew(dd->rm3tav,dd->npair); + snew(dd->rm3tav, dd->npair); /* Allocate Rt_6 and Rtav_6 consecutively in memory so they can be * averaged over the processors in one call (in calc_disre_R_6) */ - snew(dd->Rt_6,2*dd->nres); + snew(dd->Rt_6, 2*dd->nres); dd->Rtav_6 = &(dd->Rt_6[dd->nres]); ptr = getenv("GMX_DISRE_ENSEMBLE_SIZE"); @@ -185,17 +190,17 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop, { #ifdef GMX_MPI dd->nsystems = 0; - sscanf(ptr,"%d",&dd->nsystems); + sscanf(ptr, "%d", &dd->nsystems); if (fplog) { - fprintf(fplog,"Found GMX_DISRE_ENSEMBLE_SIZE set to %d systems per ensemble\n",dd->nsystems); + fprintf(fplog, "Found GMX_DISRE_ENSEMBLE_SIZE set to %d systems per ensemble\n", dd->nsystems); } /* This check is only valid on MASTER(cr), so probably * ensemble-averaged distance restraints are broken on more * than one processor per simulation system. */ if (MASTER(cr)) { - check_multi_int(fplog,cr->ms,dd->nsystems, + check_multi_int(fplog, cr->ms, dd->nsystems, "the number of systems per ensemble", FALSE); } @@ -207,31 +212,32 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop, */ if (!(cr->ms->nsim == 1 || cr->ms->nsim == dd->nsystems)) { - gmx_fatal(FARGS,"GMX_DISRE_ENSEMBLE_SIZE (%d) is not equal to 1 or the number of systems (option -multi) %d",dd->nsystems,cr->ms->nsim); + gmx_fatal(FARGS, "GMX_DISRE_ENSEMBLE_SIZE (%d) is not equal to 1 or the number of systems (option -multi) %d", dd->nsystems, cr->ms->nsim); } if (fplog) { - fprintf(fplog,"Our ensemble consists of systems:"); - for(i=0; insystems; i++) + fprintf(fplog, "Our ensemble consists of systems:"); + for (i = 0; i < dd->nsystems; i++) { - fprintf(fplog," %d", + fprintf(fplog, " %d", (cr->ms->sim/dd->nsystems)*dd->nsystems+i); } - fprintf(fplog,"\n"); - } - snew(dd->Rtl_6,dd->nres); + fprintf(fplog, "\n"); + } + snew(dd->Rtl_6, dd->nres); #endif } else { dd->nsystems = 1; - dd->Rtl_6 = dd->Rt_6; + dd->Rtl_6 = dd->Rt_6; } - + if (dd->npair > 0) { - if (fplog) { - fprintf(fplog,"There are %d distance restraints involving %d atom pairs\n",dd->nres,dd->npair); + if (fplog) + { + fprintf(fplog, "There are %d distance restraints involving %d atom pairs\n", dd->nres, dd->npair); } /* Have to avoid g_disre de-referencing cr blindly, mdrun not * doing consistency checks for ensemble-averaged distance @@ -241,32 +247,32 @@ void init_disres(FILE *fplog,const gmx_mtop_t *mtop, * succeed...) */ if (cr && cr->ms && dd->nsystems > 1 && MASTER(cr)) { - check_multi_int(fplog,cr->ms,fcd->disres.nres, + check_multi_int(fplog, cr->ms, fcd->disres.nres, "the number of distance restraints", FALSE); } - please_cite(fplog,"Tropp80a"); - please_cite(fplog,"Torda89a"); + please_cite(fplog, "Tropp80a"); + please_cite(fplog, "Torda89a"); } } void calc_disres_R_6(const gmx_multisim_t *ms, - int nfa,const t_iatom forceatoms[],const t_iparams ip[], - const rvec x[],const t_pbc *pbc, - t_fcdata *fcd,history_t *hist) + int nfa, const t_iatom forceatoms[], const t_iparams ip[], + const rvec x[], const t_pbc *pbc, + t_fcdata *fcd, history_t *hist) { - atom_id ai,aj; - int fa,res,i,pair,ki,kj,m; - int type,npair,np; - rvec dx; - real *rt,*rm3tav,*Rtl_6,*Rt_6,*Rtav_6; - real rt_1,rt_3,rt2; - ivec it,jt,dt; - t_disresdata *dd; - real ETerm,ETerm1,cf1=0,cf2=0,invn=0; + atom_id ai, aj; + int fa, res, i, pair, ki, kj, m; + int type, npair, np; + rvec dx; + real *rt, *rm3tav, *Rtl_6, *Rt_6, *Rtav_6; + real rt_1, rt_3, rt2; + ivec it, jt, dt; + t_disresdata *dd; + real ETerm, ETerm1, cf1 = 0, cf2 = 0, invn = 0; gmx_bool bTav; - dd = &(fcd->disres); + dd = &(fcd->disres); bTav = (dd->dr_tau != 0); ETerm = dd->ETerm; ETerm1 = dd->ETerm1; @@ -275,22 +281,22 @@ void calc_disres_R_6(const gmx_multisim_t *ms, Rtl_6 = dd->Rtl_6; Rt_6 = dd->Rt_6; Rtav_6 = dd->Rtav_6; - + if (bTav) { /* scaling factor to smoothly turn on the restraint forces * * when using time averaging */ dd->exp_min_t_tau = hist->disre_initf*ETerm; - + cf1 = dd->exp_min_t_tau; cf2 = 1.0/(1.0 - dd->exp_min_t_tau); } - + if (dd->nsystems > 1) { invn = 1.0/dd->nsystems; } - + /* 'loop' over all atom pairs (pair_nr=fa/3) involved in restraints, * * the total number of atoms pairs is nfa/3 */ res = 0; @@ -299,10 +305,10 @@ void calc_disres_R_6(const gmx_multisim_t *ms, { type = forceatoms[fa]; npair = ip[type].disres.npair; - + Rtav_6[res] = 0.0; Rt_6[res] = 0.0; - + /* Loop over the atom pairs of 'this' restraint */ np = 0; while (fa < nfa && np < npair) @@ -310,19 +316,19 @@ void calc_disres_R_6(const gmx_multisim_t *ms, pair = fa/3; ai = forceatoms[fa+1]; aj = forceatoms[fa+2]; - + if (pbc) { - pbc_dx_aiuc(pbc,x[ai],x[aj],dx); + pbc_dx_aiuc(pbc, x[ai], x[aj], dx); } else { - rvec_sub(x[ai],x[aj],dx); + rvec_sub(x[ai], x[aj], dx); } - rt2 = iprod(dx,dx); + rt2 = iprod(dx, dx); rt_1 = gmx_invsqrt(rt2); rt_3 = rt_1*rt_1*rt_1; - + rt[pair] = sqrt(rt2); if (bTav) { @@ -354,61 +360,61 @@ void calc_disres_R_6(const gmx_multisim_t *ms, res++; } - + #ifdef GMX_MPI if (dd->nsystems > 1) { - gmx_sum_sim(2*dd->nres,Rt_6,ms); + gmx_sum_sim(2*dd->nres, Rt_6, ms); } #endif } -real ta_disres(int nfa,const t_iatom forceatoms[],const t_iparams ip[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, +real ta_disres(int nfa, const t_iatom forceatoms[], const t_iparams ip[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, int *global_atom_index) { - const real sixth=1.0/6.0; - const real seven_three=7.0/3.0; - - atom_id ai,aj; - int fa,res,npair,p,pair,ki=CENTRAL,m; - int type; - rvec dx; - real weight_rt_1; - real smooth_fc,Rt,Rtav,rt2,*Rtl_6,*Rt_6,*Rtav_6; - real k0,f_scal=0,fmax_scal,fk_scal,fij; - real tav_viol,instant_viol,mixed_viol,violtot,vtot; - real tav_viol_Rtav7,instant_viol_Rtav7; - real up1,up2,low; - gmx_bool bConservative,bMixed,bViolation; - ivec it,jt,dt; - t_disresdata *dd; - int dr_weighting; + const real sixth = 1.0/6.0; + const real seven_three = 7.0/3.0; + + atom_id ai, aj; + int fa, res, npair, p, pair, ki = CENTRAL, m; + int type; + rvec dx; + real weight_rt_1; + real smooth_fc, Rt, Rtav, rt2, *Rtl_6, *Rt_6, *Rtav_6; + real k0, f_scal = 0, fmax_scal, fk_scal, fij; + real tav_viol, instant_viol, mixed_viol, violtot, vtot; + real tav_viol_Rtav7, instant_viol_Rtav7; + real up1, up2, low; + gmx_bool bConservative, bMixed, bViolation; + ivec it, jt, dt; + t_disresdata *dd; + int dr_weighting; gmx_bool dr_bMixed; - - dd = &(fcd->disres); + + dd = &(fcd->disres); dr_weighting = dd->dr_weighting; dr_bMixed = dd->dr_bMixed; Rtl_6 = dd->Rtl_6; Rt_6 = dd->Rt_6; Rtav_6 = dd->Rtav_6; - tav_viol=instant_viol=mixed_viol=tav_viol_Rtav7=instant_viol_Rtav7=0; + tav_viol = instant_viol = mixed_viol = tav_viol_Rtav7 = instant_viol_Rtav7 = 0; smooth_fc = dd->dr_fc; if (dd->dr_tau != 0) { /* scaling factor to smoothly turn on the restraint forces * * when using time averaging */ - smooth_fc *= (1.0 - dd->exp_min_t_tau); + smooth_fc *= (1.0 - dd->exp_min_t_tau); } - + violtot = 0; vtot = 0; - + /* 'loop' over all atom pairs (pair_nr=fa/3) involved in restraints, * * the total number of atoms pairs is nfa/3 */ res = 0; @@ -422,39 +428,39 @@ real ta_disres(int nfa,const t_iatom forceatoms[],const t_iparams ip[], up2 = ip[type].disres.up2; low = ip[type].disres.low; k0 = smooth_fc*ip[type].disres.kfac; - + /* save some flops when there is only one pair */ if (ip[type].disres.type != 2) { bConservative = (dr_weighting == edrwConservative) && (npair > 1); bMixed = dr_bMixed; - Rt = pow(Rt_6[res],-sixth); - Rtav = pow(Rtav_6[res],-sixth); + Rt = pow(Rt_6[res], -sixth); + Rtav = pow(Rtav_6[res], -sixth); } else { /* When rtype=2 use instantaneous not ensemble avereged distance */ bConservative = (npair > 1); bMixed = FALSE; - Rt = pow(Rtl_6[res],-sixth); - Rtav = Rt; + Rt = pow(Rtl_6[res], -sixth); + Rtav = Rt; } - + if (Rtav > up1) { bViolation = TRUE; - tav_viol = Rtav - up1; + tav_viol = Rtav - up1; } else if (Rtav < low) { bViolation = TRUE; - tav_viol = Rtav - low; + tav_viol = Rtav - low; } else { bViolation = FALSE; } - + if (bViolation) { /* NOTE: @@ -463,7 +469,7 @@ real ta_disres(int nfa,const t_iatom forceatoms[],const t_iparams ip[], vtot += 0.5*k0*sqr(tav_viol); if (1/vtot == 0) { - printf("vtot is inf: %f\n",vtot); + printf("vtot is inf: %f\n", vtot); } if (!bMixed) { @@ -513,14 +519,14 @@ real ta_disres(int nfa,const t_iatom forceatoms[],const t_iparams ip[], /* Correct the force for the number of restraints */ if (bConservative) { - f_scal = max(f_scal,fmax_scal); + f_scal = max(f_scal, fmax_scal); if (!bMixed) { f_scal *= Rtav/Rtav_6[res]; } else { - f_scal /= 2*mixed_viol; + f_scal /= 2*mixed_viol; tav_viol_Rtav7 = tav_viol*Rtav/Rtav_6[res]; instant_viol_Rtav7 = instant_viol*Rt/Rt_6[res]; } @@ -528,58 +534,58 @@ real ta_disres(int nfa,const t_iatom forceatoms[],const t_iparams ip[], else { f_scal /= (real)npair; - f_scal = max(f_scal,fmax_scal); - } - + f_scal = max(f_scal, fmax_scal); + } + /* Exert the force ... */ - + /* Loop over the atom pairs of 'this' restraint */ - for(p=0; prm3tav[pair],seven_three); + weight_rt_1 *= pow(dd->rm3tav[pair], seven_three); } else { - weight_rt_1 *= tav_viol_Rtav7*pow(dd->rm3tav[pair],seven_three)+ - instant_viol_Rtav7*pow(dd->rt[pair],-7); + weight_rt_1 *= tav_viol_Rtav7*pow(dd->rm3tav[pair], seven_three)+ + instant_viol_Rtav7*pow(dd->rt[pair], -7); } } - + fk_scal = f_scal*weight_rt_1; - + if (g) { - ivec_sub(SHIFT_IVEC(g,ai),SHIFT_IVEC(g,aj),dt); - ki=IVEC2IS(dt); + ivec_sub(SHIFT_IVEC(g, ai), SHIFT_IVEC(g, aj), dt); + ki = IVEC2IS(dt); } - - for(m=0; msumviol = violtot; - + /* Return energy */ return vtot; } -void update_disres_history(t_fcdata *fcd,history_t *hist) +void update_disres_history(t_fcdata *fcd, history_t *hist) { t_disresdata *dd; - int pair; - + int pair; + dd = &(fcd->disres); if (dd->dr_tau != 0) { @@ -611,7 +617,7 @@ void update_disres_history(t_fcdata *fcd,history_t *hist) * in calc_disres_R_6. */ hist->disre_initf = dd->exp_min_t_tau; - for(pair=0; pairnpair; pair++) + for (pair = 0; pair < dd->npair; pair++) { hist->disre_rm3tav[pair] = dd->rm3tav[pair]; } diff --git a/src/gromacs/gmxlib/dlb.h b/src/gromacs/gmxlib/dlb.h index 3780c9487c..0612aab1b6 100644 --- a/src/gromacs/gmxlib/dlb.h +++ b/src/gromacs/gmxlib/dlb.h @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -38,7 +38,7 @@ #include "typedefs.h" -extern void count_nb(t_commrec *cr,t_nsborder *nsb,t_block *cgs,int nns, - int nlr,t_idef *idef,int ngner); +extern void count_nb(t_commrec *cr, t_nsborder *nsb, t_block *cgs, int nns, + int nlr, t_idef *idef, int ngner); -#endif /* _dlb_h */ +#endif /* _dlb_h */ diff --git a/src/gromacs/gmxlib/do_fit.c b/src/gromacs/gmxlib/do_fit.c index bea7e005df..09a39fa714 100644 --- a/src/gromacs/gmxlib/do_fit.c +++ b/src/gromacs/gmxlib/do_fit.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -48,203 +48,258 @@ #define EPS 1.0e-09 -real calc_similar_ind(gmx_bool bRho,int nind,atom_id *index,real mass[], - rvec x[],rvec xp[]) +real calc_similar_ind(gmx_bool bRho, int nind, atom_id *index, real mass[], + rvec x[], rvec xp[]) { - int i, j, d; - real m, tm, xs, xd, rs, rd; - - tm=0; - rs=0; - rd=0; - for(j=0; j omega==omega' */ + for (r = 0; r < 2*ndim; r++) + { + for (c = 0; c <= r; c++) + { + if (r >= ndim && c < ndim) + { + omega[r][c] = u[r-ndim][c]; + omega[c][r] = u[r-ndim][c]; + } + else + { + omega[r][c] = 0; + omega[c][r] = 0; + } + } + } - if (ndim != 3 && ndim != 2) - gmx_fatal(FARGS,"calc_fit_R called with ndim=%d instead of 3 or 2",ndim); + /*determine h and k*/ + jacobi(omega, 2*ndim, d, om, &irot); + /*real **omega = input matrix a[0..n-1][0..n-1] must be symmetric + * int natoms = number of rows and columns + * real NULL = d[0]..d[n-1] are the eigenvalues of a[][] + * real **v = v[0..n-1][0..n-1] contains the vectors in columns + * int *irot = number of jacobi rotations + */ - snew(omega,2*ndim); - snew(om,2*ndim); - for(i=0; i<2*ndim; i++) { - snew(omega[i],2*ndim); - snew(om[i],2*ndim); - } - - for(i=0; i<2*ndim; i++) { - d[i]=0; - for(j=0; j<2*ndim; j++) { - omega[i][j]=0; - om[i][j]=0; + if (debug && irot == 0) + { + fprintf(debug, "IROT=0\n"); } - } - - /*calculate the matrix U*/ - clear_mat(u); - for(n=0;(n omega==omega' */ - for(r=0; r<2*ndim; r++) - for(c=0; c<=r; c++) - if (r>=ndim && cmax_d) { - max_d=d[i]; - index=i; - } - d[index]=-10000; - for(i=0; i max_d) + { + max_d = d[i]; + index = i; + } + } + d[index] = -10000; + for (i = 0; i < ndim; i++) + { + vh[j][i] = M_SQRT2*om[i][index]; + vk[j][i] = M_SQRT2*om[i+ndim][index]; + } + } + if (ndim == 3) + { + /* Calculate the last eigenvector as the outer-product of the first two. + * This insures that the conformation is not mirrored and + * prevents problems with completely flat reference structures. + */ + cprod(vh[0], vh[1], vh[2]); + cprod(vk[0], vk[1], vk[2]); + } + else if (ndim == 2) + { + /* Calculate the last eigenvector from the first one */ + vh[1][XX] = -vh[0][YY]; + vh[1][YY] = vh[0][XX]; + vk[1][XX] = -vk[0][YY]; + vk[1][YY] = vk[0][XX]; } - } - if (ndim == 3) { - /* Calculate the last eigenvector as the outer-product of the first two. - * This insures that the conformation is not mirrored and - * prevents problems with completely flat reference structures. - */ - cprod(vh[0],vh[1],vh[2]); - cprod(vk[0],vk[1],vk[2]); - } else if (ndim == 2) { - /* Calculate the last eigenvector from the first one */ - vh[1][XX] = -vh[0][YY]; - vh[1][YY] = vh[0][XX]; - vk[1][XX] = -vk[0][YY]; - vk[1][YY] = vk[0][XX]; - } - /* determine R */ - clear_mat(R); - for(r=0; rDIM) + real tm, mm; + + if (ndim > DIM) { gmx_incons("More than 3 dimensions not supported."); } @@ -252,11 +307,11 @@ void reset_x_ndim(int ndim,int ncm,const atom_id *ind_cm, clear_rvec(xcm); if (ind_cm != NULL) { - for(i=0; inr=0; + sb->nr = 0; #ifdef GMX_DOUBLE - sb->type=xdr_datatype_double; + sb->type = xdr_datatype_double; #else - sb->type=xdr_datatype_float; + sb->type = xdr_datatype_float; #endif - sb->fval = NULL; - sb->dval = NULL; - sb->ival = NULL; - sb->lval = NULL; - sb->cval = NULL; - sb->sval = NULL; + sb->fval = NULL; + sb->dval = NULL; + sb->ival = NULL; + sb->lval = NULL; + sb->cval = NULL; + sb->sval = NULL; sb->fval_alloc = 0; sb->dval_alloc = 0; sb->ival_alloc = 0; @@ -109,38 +109,38 @@ static void enxsubblock_free(t_enxsubblock *sb) if (sb->fval_alloc) { free(sb->fval); - sb->fval_alloc=0; - sb->fval=NULL; + sb->fval_alloc = 0; + sb->fval = NULL; } if (sb->dval_alloc) { free(sb->dval); - sb->dval_alloc=0; - sb->dval=NULL; + sb->dval_alloc = 0; + sb->dval = NULL; } if (sb->ival_alloc) { free(sb->ival); - sb->ival_alloc=0; - sb->ival=NULL; + sb->ival_alloc = 0; + sb->ival = NULL; } if (sb->lval_alloc) { free(sb->lval); - sb->lval_alloc=0; - sb->lval=NULL; + sb->lval_alloc = 0; + sb->lval = NULL; } if (sb->cval_alloc) { free(sb->cval); - sb->cval_alloc=0; - sb->cval=NULL; + sb->cval_alloc = 0; + sb->cval = NULL; } if (sb->sval_alloc) { int i; - for(i=0;isval_alloc;i++) + for (i = 0; i < sb->sval_alloc; i++) { if (sb->sval[i]) { @@ -148,8 +148,8 @@ static void enxsubblock_free(t_enxsubblock *sb) } } free(sb->sval); - sb->sval_alloc=0; - sb->sval=NULL; + sb->sval_alloc = 0; + sb->sval = NULL; } } @@ -157,41 +157,41 @@ static void enxsubblock_free(t_enxsubblock *sb) static void enxsubblock_alloc(t_enxsubblock *sb) { /* allocate the appropriate amount of memory */ - switch(sb->type) + switch (sb->type) { case xdr_datatype_float: if (sb->nr > sb->fval_alloc) { srenew(sb->fval, sb->nr); - sb->fval_alloc=sb->nr; + sb->fval_alloc = sb->nr; } break; case xdr_datatype_double: if (sb->nr > sb->dval_alloc) { srenew(sb->dval, sb->nr); - sb->dval_alloc=sb->nr; + sb->dval_alloc = sb->nr; } break; case xdr_datatype_int: if (sb->nr > sb->ival_alloc) { srenew(sb->ival, sb->nr); - sb->ival_alloc=sb->nr; + sb->ival_alloc = sb->nr; } break; case xdr_datatype_large_int: if (sb->nr > sb->lval_alloc) { srenew(sb->lval, sb->nr); - sb->lval_alloc=sb->nr; + sb->lval_alloc = sb->nr; } break; case xdr_datatype_char: if (sb->nr > sb->cval_alloc) { srenew(sb->cval, sb->nr); - sb->cval_alloc=sb->nr; + sb->cval_alloc = sb->nr; } break; case xdr_datatype_string: @@ -200,11 +200,11 @@ static void enxsubblock_alloc(t_enxsubblock *sb) int i; srenew(sb->sval, sb->nr); - for(i=sb->sval_alloc;inr;i++) + for (i = sb->sval_alloc; i < sb->nr; i++) { - sb->sval[i]=NULL; + sb->sval[i] = NULL; } - sb->sval_alloc=sb->nr; + sb->sval_alloc = sb->nr; } break; default: @@ -214,104 +214,106 @@ static void enxsubblock_alloc(t_enxsubblock *sb) static void enxblock_init(t_enxblock *eb) { - eb->id=enxOR; - eb->nsub=0; - eb->sub=NULL; - eb->nsub_alloc=0; + eb->id = enxOR; + eb->nsub = 0; + eb->sub = NULL; + eb->nsub_alloc = 0; } static void enxblock_free(t_enxblock *eb) { - if (eb->nsub_alloc>0) + if (eb->nsub_alloc > 0) { int i; - for(i=0;insub_alloc;i++) + for (i = 0; i < eb->nsub_alloc; i++) { enxsubblock_free(&(eb->sub[i])); } free(eb->sub); - eb->nsub_alloc=0; - eb->sub=NULL; + eb->nsub_alloc = 0; + eb->sub = NULL; } } void init_enxframe(t_enxframe *fr) { - fr->e_alloc=0; - fr->ener=NULL; + fr->e_alloc = 0; + fr->ener = NULL; /*fr->d_alloc=0;*/ - fr->ener=NULL; + fr->ener = NULL; /*fr->ndisre=0;*/ - fr->nblock=0; - fr->nblock_alloc=0; - fr->block=NULL; + fr->nblock = 0; + fr->nblock_alloc = 0; + fr->block = NULL; } void free_enxframe(t_enxframe *fr) { - int b; - - if (fr->e_alloc) - { - sfree(fr->ener); - } - for(b=0; bnblock_alloc; b++) - { - enxblock_free(&(fr->block[b])); - } - free(fr->block); + int b; + + if (fr->e_alloc) + { + sfree(fr->ener); + } + for (b = 0; b < fr->nblock_alloc; b++) + { + enxblock_free(&(fr->block[b])); + } + free(fr->block); } void add_blocks_enxframe(t_enxframe *fr, int n) { - fr->nblock=n; + fr->nblock = n; if (n > fr->nblock_alloc) { int b; srenew(fr->block, n); - for(b=fr->nblock_alloc;bnblock;b++) + for (b = fr->nblock_alloc; b < fr->nblock; b++) { enxblock_init(&(fr->block[b])); } - fr->nblock_alloc=n; + fr->nblock_alloc = n; } } t_enxblock *find_block_id_enxframe(t_enxframe *ef, int id, t_enxblock *prev) { - gmx_off_t starti=0; + gmx_off_t starti = 0; gmx_off_t i; if (prev) { - starti=(prev - ef->block) + 1; + starti = (prev - ef->block) + 1; } - for(i=starti; inblock; i++) + for (i = starti; i < ef->nblock; i++) { if (ef->block[i].id == id) + { return &(ef->block[i]); + } } return NULL; } void add_subblocks_enxblock(t_enxblock *eb, int n) { - eb->nsub=n; + eb->nsub = n; if (eb->nsub > eb->nsub_alloc) { int b; srenew(eb->sub, n); - for(b=eb->nsub_alloc; bnsub_alloc; b < n; b++) { enxsubblock_init(&(eb->sub[b])); - } - eb->nsub_alloc=n; + } + eb->nsub_alloc = n; } } @@ -323,23 +325,23 @@ static void enx_warning(const char *msg) } else { - gmx_fatal(FARGS,"%s\n%s", + gmx_fatal(FARGS, "%s\n%s", msg, "If you want to use the correct frames before the corrupted frame and avoid this fatal error set the env.var. GMX_ENX_NO_FATAL"); } } -static void edr_strings(XDR *xdr,gmx_bool bRead,int file_version, - int n,gmx_enxnm_t **nms) +static void edr_strings(XDR *xdr, gmx_bool bRead, int file_version, + int n, gmx_enxnm_t **nms) { - int i; + int i; gmx_enxnm_t *nm; if (*nms == NULL) { - snew(*nms,n); + snew(*nms, n); } - for(i=0; iunit = NULL; } } - if(!xdr_string(xdr,&(nm->name),STRLEN)) + if (!xdr_string(xdr, &(nm->name), STRLEN)) { gmx_file("Cannot write energy names to file; maybe you are out of disk space?"); } if (file_version >= 2) { - if(!xdr_string(xdr,&(nm->unit),STRLEN)) + if (!xdr_string(xdr, &(nm->unit), STRLEN)) { gmx_file("Cannot write energy names to file; maybe you are out of disk space?"); } @@ -373,83 +375,83 @@ static void edr_strings(XDR *xdr,gmx_bool bRead,int file_version, } } -void do_enxnms(ener_file_t ef,int *nre,gmx_enxnm_t **nms) +void do_enxnms(ener_file_t ef, int *nre, gmx_enxnm_t **nms) { - int magic=-55555; - XDR *xdr; + int magic = -55555; + XDR *xdr; gmx_bool bRead = gmx_fio_getread(ef->fio); - int file_version; - int i; - - gmx_fio_checktype(ef->fio); + int file_version; + int i; + + gmx_fio_checktype(ef->fio); xdr = gmx_fio_getxdr(ef->fio); - - if (!xdr_int(xdr,&magic)) + + if (!xdr_int(xdr, &magic)) { - if(!bRead) + if (!bRead) { gmx_file("Cannot write energy names to file; maybe you are out of disk space?"); } - *nre=0; + *nre = 0; return; } if (magic > 0) { /* Assume this is an old edr format */ - file_version = 1; - *nre = magic; - ef->eo.bOldFileOpen = TRUE; + file_version = 1; + *nre = magic; + ef->eo.bOldFileOpen = TRUE; ef->eo.bReadFirstStep = FALSE; - srenew(ef->eo.ener_prev,*nre); + srenew(ef->eo.ener_prev, *nre); } else { - ef->eo.bOldFileOpen=FALSE; + ef->eo.bOldFileOpen = FALSE; if (magic != -55555) { - gmx_fatal(FARGS,"Energy names magic number mismatch, this is not a GROMACS edr file"); + gmx_fatal(FARGS, "Energy names magic number mismatch, this is not a GROMACS edr file"); } file_version = enx_version; - xdr_int(xdr,&file_version); + xdr_int(xdr, &file_version); if (file_version > enx_version) { - gmx_fatal(FARGS,"reading tpx file (%s) version %d with version %d program",gmx_fio_getname(ef->fio),file_version,enx_version); + gmx_fatal(FARGS, "reading tpx file (%s) version %d with version %d program", gmx_fio_getname(ef->fio), file_version, enx_version); } - xdr_int(xdr,nre); + xdr_int(xdr, nre); } if (file_version != enx_version) { - fprintf(stderr,"Note: enx file_version %d, software version %d\n", - file_version,enx_version); + fprintf(stderr, "Note: enx file_version %d, software version %d\n", + file_version, enx_version); } - edr_strings(xdr,bRead,file_version,*nre,nms); + edr_strings(xdr, bRead, file_version, *nre, nms); } -static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr, - int nre_test,gmx_bool *bWrongPrecision,gmx_bool *bOK) +static gmx_bool do_eheader(ener_file_t ef, int *file_version, t_enxframe *fr, + int nre_test, gmx_bool *bWrongPrecision, gmx_bool *bOK) { - int magic=-7777777; - real first_real_to_check; - int b,i,zero=0,dum=0; - gmx_bool bRead = gmx_fio_getread(ef->fio); - int tempfix_nr=0; - int ndisre=0; - int startb=0; + int magic = -7777777; + real first_real_to_check; + int b, i, zero = 0, dum = 0; + gmx_bool bRead = gmx_fio_getread(ef->fio); + int tempfix_nr = 0; + int ndisre = 0; + int startb = 0; #ifndef GMX_DOUBLE - xdr_datatype dtreal=xdr_datatype_float; + xdr_datatype dtreal = xdr_datatype_float; #else - xdr_datatype dtreal=xdr_datatype_double; + xdr_datatype dtreal = xdr_datatype_double; #endif - + if (bWrongPrecision) { *bWrongPrecision = FALSE; } - *bOK=TRUE; + *bOK = TRUE; /* The original energy frame started with a real, * so we have to use a real for compatibility. * This is VERY DIRTY code, since do_eheader can be called @@ -469,75 +471,120 @@ static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr, { /* Assume we are reading an old format */ *file_version = 1; - fr->t = first_real_to_check; - if (!gmx_fio_do_int(ef->fio, dum)) *bOK = FALSE; + fr->t = first_real_to_check; + if (!gmx_fio_do_int(ef->fio, dum)) + { + *bOK = FALSE; + } fr->step = dum; } else { - if (!gmx_fio_do_int(ef->fio, magic)) *bOK = FALSE; + if (!gmx_fio_do_int(ef->fio, magic)) + { + *bOK = FALSE; + } if (magic != -7777777) { enx_warning("Energy header magic number mismatch, this is not a GROMACS edr file"); - *bOK=FALSE; + *bOK = FALSE; return FALSE; } *file_version = enx_version; - if (!gmx_fio_do_int(ef->fio, *file_version)) *bOK = FALSE; + if (!gmx_fio_do_int(ef->fio, *file_version)) + { + *bOK = FALSE; + } if (*bOK && *file_version > enx_version) { - gmx_fatal(FARGS,"reading tpx file (%s) version %d with version %d program",gmx_fio_getname(ef->fio),file_version,enx_version); + gmx_fatal(FARGS, "reading tpx file (%s) version %d with version %d program", gmx_fio_getname(ef->fio), file_version, enx_version); } - if (!gmx_fio_do_double(ef->fio, fr->t)) *bOK = FALSE; - if (!gmx_fio_do_gmx_large_int(ef->fio, fr->step)) *bOK = FALSE; - if (!bRead && fr->nsum == 1) { + if (!gmx_fio_do_double(ef->fio, fr->t)) + { + *bOK = FALSE; + } + if (!gmx_fio_do_gmx_large_int(ef->fio, fr->step)) + { + *bOK = FALSE; + } + if (!bRead && fr->nsum == 1) + { /* Do not store sums of length 1, * since this does not add information. */ - if (!gmx_fio_do_int(ef->fio, zero)) *bOK = FALSE; - } else { - if (!gmx_fio_do_int(ef->fio, fr->nsum)) *bOK = FALSE; + if (!gmx_fio_do_int(ef->fio, zero)) + { + *bOK = FALSE; + } + } + else + { + if (!gmx_fio_do_int(ef->fio, fr->nsum)) + { + *bOK = FALSE; + } } if (*file_version >= 3) { - if (!gmx_fio_do_gmx_large_int(ef->fio, fr->nsteps)) *bOK = FALSE; + if (!gmx_fio_do_gmx_large_int(ef->fio, fr->nsteps)) + { + *bOK = FALSE; + } } else { - fr->nsteps = max(1,fr->nsum); + fr->nsteps = max(1, fr->nsum); } if (*file_version >= 5) { - if (!gmx_fio_do_double(ef->fio, fr->dt)) *bOK = FALSE; + if (!gmx_fio_do_double(ef->fio, fr->dt)) + { + *bOK = FALSE; + } } else { fr->dt = 0; } } - if (!gmx_fio_do_int(ef->fio, fr->nre)) *bOK = FALSE; + if (!gmx_fio_do_int(ef->fio, fr->nre)) + { + *bOK = FALSE; + } if (*file_version < 4) { - if (!gmx_fio_do_int(ef->fio, ndisre)) *bOK = FALSE; + if (!gmx_fio_do_int(ef->fio, ndisre)) + { + *bOK = FALSE; + } } else { /* now reserved for possible future use */ - if (!gmx_fio_do_int(ef->fio, dum)) *bOK = FALSE; + if (!gmx_fio_do_int(ef->fio, dum)) + { + *bOK = FALSE; + } } - if (!gmx_fio_do_int(ef->fio, fr->nblock)) *bOK = FALSE; - if (fr->nblock < 0) *bOK=FALSE; + if (!gmx_fio_do_int(ef->fio, fr->nblock)) + { + *bOK = FALSE; + } + if (fr->nblock < 0) + { + *bOK = FALSE; + } - if (ndisre!=0) + if (ndisre != 0) { if (*file_version >= 4) { enx_warning("Distance restraint blocks in old style in new style file"); - *bOK=FALSE; + *bOK = FALSE; return FALSE; } - fr->nblock+=1; + fr->nblock += 1; } @@ -552,10 +599,10 @@ static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr, /* we now know what these should be, or we've already bailed out because of wrong precision */ - if ( *file_version==1 && (fr->t < 0 || fr->t > 1e20 || fr->step < 0 ) ) + if (*file_version == 1 && (fr->t < 0 || fr->t > 1e20 || fr->step < 0 ) ) { enx_warning("edr file with negative step number or unreasonable time (and without version number)."); - *bOK=FALSE; + *bOK = FALSE; return FALSE; } @@ -565,25 +612,25 @@ static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr, add_blocks_enxframe(fr, fr->nblock); } - startb=0; - if (ndisre>0) + startb = 0; + if (ndisre > 0) { /* sub[0] is the instantaneous data, sub[1] is time averaged */ add_subblocks_enxblock(&(fr->block[0]), 2); - fr->block[0].id=enxDISRE; - fr->block[0].sub[0].nr=ndisre; - fr->block[0].sub[1].nr=ndisre; - fr->block[0].sub[0].type=dtreal; - fr->block[0].sub[1].type=dtreal; + fr->block[0].id = enxDISRE; + fr->block[0].sub[0].nr = ndisre; + fr->block[0].sub[1].nr = ndisre; + fr->block[0].sub[0].type = dtreal; + fr->block[0].sub[1].type = dtreal; startb++; } /* read block header info */ - for(b=startb; bnblock; b++) + for (b = startb; b < fr->nblock; b++) { - if (*file_version<4) + if (*file_version < 4) { - /* blocks in old version files always have 1 subblock that + /* blocks in old version files always have 1 subblock that consists of reals. */ int nrint; @@ -603,7 +650,7 @@ static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr, } } nrint = fr->block[b].sub[0].nr; - + if (!gmx_fio_do_int(ef->fio, nrint)) { *bOK = FALSE; @@ -617,35 +664,46 @@ static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr, int i; /* in the new version files, the block header only contains the ID and the number of subblocks */ - int nsub=fr->block[b].nsub; + int nsub = fr->block[b].nsub; *bOK = *bOK && gmx_fio_do_int(ef->fio, fr->block[b].id); *bOK = *bOK && gmx_fio_do_int(ef->fio, nsub); - fr->block[b].nsub=nsub; + fr->block[b].nsub = nsub; if (bRead) + { add_subblocks_enxblock(&(fr->block[b]), nsub); + } /* read/write type & size for each subblock */ - for(i=0;iblock[b].sub[i]); /* shortcut */ - int typenr=sub->type; + t_enxsubblock *sub = &(fr->block[b].sub[i]); /* shortcut */ + int typenr = sub->type; - *bOK=*bOK && gmx_fio_do_int(ef->fio, typenr); - *bOK=*bOK && gmx_fio_do_int(ef->fio, sub->nr); + *bOK = *bOK && gmx_fio_do_int(ef->fio, typenr); + *bOK = *bOK && gmx_fio_do_int(ef->fio, sub->nr); sub->type = (xdr_datatype)typenr; } } } - if (!gmx_fio_do_int(ef->fio, fr->e_size)) *bOK = FALSE; + if (!gmx_fio_do_int(ef->fio, fr->e_size)) + { + *bOK = FALSE; + } /* now reserved for possible future use */ - if (!gmx_fio_do_int(ef->fio, dum)) *bOK = FALSE; + if (!gmx_fio_do_int(ef->fio, dum)) + { + *bOK = FALSE; + } /* Do a dummy int to keep the format compatible with the old code */ - if (!gmx_fio_do_int(ef->fio, dum)) *bOK = FALSE; - + if (!gmx_fio_do_int(ef->fio, dum)) + { + *bOK = FALSE; + } + if (*bOK && *file_version == 1 && nre_test < 0) { #if 0 @@ -654,7 +712,7 @@ static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr, gmx_incons("Problem with reading old format energy files"); } #endif - + if (!ef->eo.bReadFirstStep) { ef->eo.bReadFirstStep = TRUE; @@ -662,20 +720,20 @@ static gmx_bool do_eheader(ener_file_t ef,int *file_version,t_enxframe *fr, ef->eo.step_prev = fr->step; ef->eo.nsum_prev = 0; } - + fr->nsum = fr->step - ef->eo.first_step + 1; fr->nsteps = fr->step - ef->eo.step_prev; fr->dt = 0; } - + return *bOK; } -void free_enxnms(int n,gmx_enxnm_t *nms) +void free_enxnms(int n, gmx_enxnm_t *nms) { int i; - for(i=0; ifio) != 0) + if (gmx_fio_close(ef->fio) != 0) { gmx_file("Cannot close energy file; it might be corrupt, or maybe you are out of disk space?"); } @@ -694,85 +752,95 @@ void close_enx(ener_file_t ef) static gmx_bool empty_file(const char *fn) { - FILE *fp; - char dum; - int ret; + FILE *fp; + char dum; + int ret; gmx_bool bEmpty; - - fp = gmx_fio_fopen(fn,"r"); - ret = fread(&dum,sizeof(dum),1,fp); + + fp = gmx_fio_fopen(fn, "r"); + ret = fread(&dum, sizeof(dum), 1, fp); bEmpty = feof(fp); gmx_fio_fclose(fp); - + return bEmpty; } -ener_file_t open_enx(const char *fn,const char *mode) +ener_file_t open_enx(const char *fn, const char *mode) { - int nre,i; - gmx_enxnm_t *nms=NULL; - int file_version=-1; - t_enxframe *fr; - gmx_bool bWrongPrecision,bOK=TRUE; + int nre, i; + gmx_enxnm_t *nms = NULL; + int file_version = -1; + t_enxframe *fr; + gmx_bool bWrongPrecision, bOK = TRUE; struct ener_file *ef; - snew(ef,1); + snew(ef, 1); - if (mode[0]=='r') { - ef->fio=gmx_fio_open(fn,mode); + if (mode[0] == 'r') + { + ef->fio = gmx_fio_open(fn, mode); gmx_fio_checktype(ef->fio); - gmx_fio_setprecision(ef->fio,FALSE); - do_enxnms(ef,&nre,&nms); - snew(fr,1); - do_eheader(ef,&file_version,fr,nre,&bWrongPrecision,&bOK); - if(!bOK) + gmx_fio_setprecision(ef->fio, FALSE); + do_enxnms(ef, &nre, &nms); + snew(fr, 1); + do_eheader(ef, &file_version, fr, nre, &bWrongPrecision, &bOK); + if (!bOK) { gmx_file("Cannot read energy file header. Corrupt file?"); } /* Now check whether this file is in single precision */ if (!bWrongPrecision && - ((fr->e_size && (fr->nre == nre) && + ((fr->e_size && (fr->nre == nre) && (nre*4*(long int)sizeof(float) == fr->e_size)) ) ) { - fprintf(stderr,"Opened %s as single precision energy file\n",fn); - free_enxnms(nre,nms); + fprintf(stderr, "Opened %s as single precision energy file\n", fn); + free_enxnms(nre, nms); } else { gmx_fio_rewind(ef->fio); gmx_fio_checktype(ef->fio); - gmx_fio_setprecision(ef->fio,TRUE); - do_enxnms(ef,&nre,&nms); - do_eheader(ef,&file_version,fr,nre,&bWrongPrecision,&bOK); - if(!bOK) + gmx_fio_setprecision(ef->fio, TRUE); + do_enxnms(ef, &nre, &nms); + do_eheader(ef, &file_version, fr, nre, &bWrongPrecision, &bOK); + if (!bOK) { gmx_file("Cannot write energy file header; maybe you are out of disk space?"); } - if (((fr->e_size && (fr->nre == nre) && - (nre*4*(long int)sizeof(double) == fr->e_size)) )) - fprintf(stderr,"Opened %s as double precision energy file\n", + if (((fr->e_size && (fr->nre == nre) && + (nre*4*(long int)sizeof(double) == fr->e_size)) )) + { + fprintf(stderr, "Opened %s as double precision energy file\n", fn); - else { + } + else + { if (empty_file(fn)) - gmx_fatal(FARGS,"File %s is empty",fn); + { + gmx_fatal(FARGS, "File %s is empty", fn); + } else - gmx_fatal(FARGS,"Energy file %s not recognized, maybe different CPU?", + { + gmx_fatal(FARGS, "Energy file %s not recognized, maybe different CPU?", fn); + } } - free_enxnms(nre,nms); + free_enxnms(nre, nms); } free_enxframe(fr); sfree(fr); gmx_fio_rewind(ef->fio); } - else - ef->fio = gmx_fio_open(fn,mode); + else + { + ef->fio = gmx_fio_open(fn, mode); + } - ef->framenr=0; - ef->frametime=0; + ef->framenr = 0; + ef->frametime = 0; return ef; } @@ -781,20 +849,26 @@ t_fileio *enx_file_pointer(const ener_file_t ef) return ef->fio; } -static void convert_full_sums(ener_old_t *ener_old,t_enxframe *fr) +static void convert_full_sums(ener_old_t *ener_old, t_enxframe *fr) { - int nstep_all; - int ne,ns,i; - double esum_all,eav_all; - + int nstep_all; + int ne, ns, i; + double esum_all, eav_all; + if (fr->nsum > 0) { ne = 0; ns = 0; - for(i=0; inre; i++) + for (i = 0; i < fr->nre; i++) { - if (fr->ener[i].e != 0) ne++; - if (fr->ener[i].esum != 0) ns++; + if (fr->ener[i].e != 0) + { + ne++; + } + if (fr->ener[i].esum != 0) + { + ns++; + } } if (ne > 0 && ns == 0) { @@ -802,17 +876,17 @@ static void convert_full_sums(ener_old_t *ener_old,t_enxframe *fr) fr->nsum = 0; } } - + /* Convert old full simulation sums to sums between energy frames */ nstep_all = fr->step - ener_old->first_step + 1; if (fr->nsum > 1 && fr->nsum == nstep_all && ener_old->nsum_prev > 0) { /* Set the new sum length: the frame step difference */ fr->nsum = fr->step - ener_old->step_prev; - for(i=0; inre; i++) + for (i = 0; i < fr->nre; i++) { - esum_all = fr->ener[i].esum; - eav_all = fr->ener[i].eav; + esum_all = fr->ener[i].esum; + eav_all = fr->ener[i].eav; fr->ener[i].esum = esum_all - ener_old->ener_prev[i].esum; fr->ener[i].eav = eav_all - ener_old->ener_prev[i].eav - dsqr(ener_old->ener_prev[i].esum/(nstep_all - fr->nsum) @@ -827,7 +901,7 @@ static void convert_full_sums(ener_old_t *ener_old,t_enxframe *fr) { if (fr->nsum != nstep_all) { - fprintf(stderr,"\nWARNING: something is wrong with the energy sums, will not use exact averages\n"); + fprintf(stderr, "\nWARNING: something is wrong with the energy sums, will not use exact averages\n"); ener_old->nsum_prev = 0; } else @@ -835,45 +909,45 @@ static void convert_full_sums(ener_old_t *ener_old,t_enxframe *fr) ener_old->nsum_prev = nstep_all; } /* Copy all sums to ener_prev */ - for(i=0; inre; i++) + for (i = 0; i < fr->nre; i++) { ener_old->ener_prev[i].esum = fr->ener[i].esum; ener_old->ener_prev[i].eav = fr->ener[i].eav; } } - + ener_old->step_prev = fr->step; } -gmx_bool do_enx(ener_file_t ef,t_enxframe *fr) +gmx_bool do_enx(ener_file_t ef, t_enxframe *fr) { - int file_version=-1; - int i,b; - gmx_bool bRead,bOK,bOK1,bSane; - real tmp1,tmp2,rdum; - char buf[22]; + int file_version = -1; + int i, b; + gmx_bool bRead, bOK, bOK1, bSane; + real tmp1, tmp2, rdum; + char buf[22]; /*int d_size;*/ - - bOK = TRUE; + + bOK = TRUE; bRead = gmx_fio_getread(ef->fio); if (!bRead) - { + { fr->e_size = fr->nre*sizeof(fr->ener[0].e)*4; /*d_size = fr->ndisre*(sizeof(real)*2);*/ } gmx_fio_checktype(ef->fio); - if (!do_eheader(ef,&file_version,fr,-1,NULL,&bOK)) + if (!do_eheader(ef, &file_version, fr, -1, NULL, &bOK)) { if (bRead) { - fprintf(stderr,"\rLast energy frame read %d time %8.3f ", - ef->framenr-1,ef->frametime); + fprintf(stderr, "\rLast energy frame read %d time %8.3f ", + ef->framenr-1, ef->frametime); if (!bOK) { fprintf(stderr, "\nWARNING: Incomplete energy frame: nr %d time %8.3f\n", - ef->framenr,fr->t); + ef->framenr, fr->t); } } else @@ -888,30 +962,30 @@ gmx_bool do_enx(ener_file_t ef,t_enxframe *fr) (ef->framenr < 200 || ef->framenr % 100 == 0) && (ef->framenr < 2000 || ef->framenr % 1000 == 0)) { - fprintf(stderr,"\rReading energy frame %6d time %8.3f ", - ef->framenr,fr->t); + fprintf(stderr, "\rReading energy frame %6d time %8.3f ", + ef->framenr, fr->t); } ef->framenr++; ef->frametime = fr->t; } /* Check sanity of this header */ - bSane = fr->nre > 0 ; - for(b=0; bnblock; b++) + bSane = fr->nre > 0; + for (b = 0; b < fr->nblock; b++) { bSane = bSane || (fr->block[b].nsub > 0); } if (!((fr->step >= 0) && bSane)) { - fprintf(stderr,"\nWARNING: there may be something wrong with energy file %s\n", + fprintf(stderr, "\nWARNING: there may be something wrong with energy file %s\n", gmx_fio_getname(ef->fio)); - fprintf(stderr,"Found: step=%s, nre=%d, nblock=%d, time=%g.\n" + fprintf(stderr, "Found: step=%s, nre=%d, nblock=%d, time=%g.\n" "Trying to skip frame expect a crash though\n", - gmx_step_str(fr->step,buf),fr->nre,fr->nblock,fr->t); + gmx_step_str(fr->step, buf), fr->nre, fr->nblock, fr->t); } if (bRead && fr->nre > fr->e_alloc) { - srenew(fr->ener,fr->nre); - for(i=fr->e_alloc; (inre); i++) + srenew(fr->ener, fr->nre); + for (i = fr->e_alloc; (i < fr->nre); i++) { fr->ener[i].e = 0; fr->ener[i].eav = 0; @@ -919,11 +993,11 @@ gmx_bool do_enx(ener_file_t ef,t_enxframe *fr) } fr->e_alloc = fr->nre; } - - for(i=0; inre; i++) + + for (i = 0; i < fr->nre; i++) { bOK = bOK && gmx_fio_do_real(ef->fio, fr->ener[i].e); - + /* Do not store sums of length 1, * since this does not add information. */ @@ -931,43 +1005,47 @@ gmx_bool do_enx(ener_file_t ef,t_enxframe *fr) (bRead && fr->nsum > 0) || fr->nsum > 1) { tmp1 = fr->ener[i].eav; - bOK = bOK && gmx_fio_do_real(ef->fio, tmp1); + bOK = bOK && gmx_fio_do_real(ef->fio, tmp1); if (bRead) + { fr->ener[i].eav = tmp1; - + } + /* This is to save only in single precision (unless compiled in DP) */ tmp2 = fr->ener[i].esum; - bOK = bOK && gmx_fio_do_real(ef->fio, tmp2); + bOK = bOK && gmx_fio_do_real(ef->fio, tmp2); if (bRead) + { fr->ener[i].esum = tmp2; - + } + if (file_version == 1) { /* Old, unused real */ rdum = 0; - bOK = bOK && gmx_fio_do_real(ef->fio, rdum); + bOK = bOK && gmx_fio_do_real(ef->fio, rdum); } } } - + /* Here we can not check for file_version==1, since one could have * continued an old format simulation with a new one with mdrun -append. */ if (bRead && ef->eo.bOldFileOpen) { /* Convert old full simulation sums to sums between energy frames */ - convert_full_sums(&(ef->eo),fr); + convert_full_sums(&(ef->eo), fr); } /* read the blocks */ - for(b=0; bnblock; b++) + for (b = 0; b < fr->nblock; b++) { /* now read the subblocks. */ - int nsub=fr->block[b].nsub; /* shortcut */ + int nsub = fr->block[b].nsub; /* shortcut */ int i; - for(i=0;iblock[b].sub[i]); /* shortcut */ + t_enxsubblock *sub = &(fr->block[b].sub[i]); /* shortcut */ if (bRead) { @@ -975,26 +1053,26 @@ gmx_bool do_enx(ener_file_t ef,t_enxframe *fr) } /* read/write data */ - bOK1=TRUE; + bOK1 = TRUE; switch (sub->type) { case xdr_datatype_float: - bOK1=gmx_fio_ndo_float(ef->fio, sub->fval, sub->nr); + bOK1 = gmx_fio_ndo_float(ef->fio, sub->fval, sub->nr); break; case xdr_datatype_double: - bOK1=gmx_fio_ndo_double(ef->fio, sub->dval, sub->nr); + bOK1 = gmx_fio_ndo_double(ef->fio, sub->dval, sub->nr); break; case xdr_datatype_int: - bOK1=gmx_fio_ndo_int(ef->fio, sub->ival, sub->nr); + bOK1 = gmx_fio_ndo_int(ef->fio, sub->ival, sub->nr); break; case xdr_datatype_large_int: - bOK1=gmx_fio_ndo_gmx_large_int(ef->fio, sub->lval, sub->nr); + bOK1 = gmx_fio_ndo_gmx_large_int(ef->fio, sub->lval, sub->nr); break; case xdr_datatype_char: - bOK1=gmx_fio_ndo_uchar(ef->fio, sub->cval, sub->nr); + bOK1 = gmx_fio_ndo_uchar(ef->fio, sub->cval, sub->nr); break; case xdr_datatype_string: - bOK1=gmx_fio_ndo_string(ef->fio, sub->sval, sub->nr); + bOK1 = gmx_fio_ndo_string(ef->fio, sub->sval, sub->nr); break; default: gmx_incons("Reading unknown block data type: this file is corrupted or from the future"); @@ -1002,31 +1080,31 @@ gmx_bool do_enx(ener_file_t ef,t_enxframe *fr) bOK = bOK && bOK1; } } - - if(!bRead) + + if (!bRead) { - if( gmx_fio_flush(ef->fio) != 0) + if (gmx_fio_flush(ef->fio) != 0) { gmx_file("Cannot write energy file; maybe you are out of disk space?"); } } - + if (!bOK) { if (bRead) { - fprintf(stderr,"\nLast energy frame read %d", + fprintf(stderr, "\nLast energy frame read %d", ef->framenr-1); - fprintf(stderr,"\nWARNING: Incomplete energy frame: nr %d time %8.3f\n", - ef->framenr,fr->t); + fprintf(stderr, "\nWARNING: Incomplete energy frame: nr %d time %8.3f\n", + ef->framenr, fr->t); } else { - gmx_fatal(FARGS,"could not write energies"); + gmx_fatal(FARGS, "could not write energies"); } - return FALSE; + return FALSE; } - + return TRUE; } @@ -1034,17 +1112,17 @@ static real find_energy(const char *name, int nre, gmx_enxnm_t *enm, t_enxframe *fr) { int i; - - for(i=0; iener[i].e; + return fr->ener[i].e; } } - - gmx_fatal(FARGS,"Could not find energy term named '%s'",name); - + + gmx_fatal(FARGS, "Could not find energy term named '%s'", name); + return 0; } @@ -1052,95 +1130,101 @@ static real find_energy(const char *name, int nre, gmx_enxnm_t *enm, void get_enx_state(const char *fn, real t, gmx_groups_t *groups, t_inputrec *ir, t_state *state) { - /* Should match the names in mdebin.c */ - static const char *boxvel_nm[] = { - "Box-Vel-XX", "Box-Vel-YY", "Box-Vel-ZZ", - "Box-Vel-YX", "Box-Vel-ZX", "Box-Vel-ZY" - }; - - static const char *pcouplmu_nm[] = { - "Pcoupl-Mu-XX", "Pcoupl-Mu-YY", "Pcoupl-Mu-ZZ", - "Pcoupl-Mu-YX", "Pcoupl-Mu-ZX", "Pcoupl-Mu-ZY" - }; - static const char *baro_nm[] = { - "Barostat" - }; - - - int ind0[] = { XX,YY,ZZ,YY,ZZ,ZZ }; - int ind1[] = { XX,YY,ZZ,XX,XX,YY }; - int nre,nfr,i,j,ni,npcoupl; - char buf[STRLEN]; - const char *bufi; - gmx_enxnm_t *enm=NULL; - t_enxframe *fr; - ener_file_t in; - - in = open_enx(fn,"r"); - do_enxnms(in,&nre,&enm); - snew(fr,1); - nfr = 0; - while ((nfr==0 || fr->t != t) && do_enx(in,fr)) { - nfr++; - } - close_enx(in); - fprintf(stderr,"\n"); - - if (nfr == 0 || fr->t != t) - gmx_fatal(FARGS,"Could not find frame with time %f in '%s'",t,fn); - - npcoupl = TRICLINIC(ir->compress) ? 6 : 3; - if (ir->epc == epcPARRINELLORAHMAN) { - clear_mat(state->boxv); - for(i=0; iboxv[ind0[i]][ind1[i]] = - find_energy(boxvel_nm[i],nre,enm,fr); - } - fprintf(stderr,"\nREAD %d BOX VELOCITIES FROM %s\n\n",npcoupl,fn); - } - - if (ir->etc == etcNOSEHOOVER) - { - char cns[20]; - - cns[0] = '\0'; - - for(i=0; ingtc; i++) { - ni = groups->grps[egcTC].nm_ind[i]; - bufi = *(groups->grpname[ni]); - for(j=0; (jnhchainlength); j++) - { - if (IR_NVT_TROTTER(ir)) - { - sprintf(cns,"-%d",j); - } - sprintf(buf,"Xi%s-%s",cns,bufi); - state->nosehoover_xi[i] = find_energy(buf,nre,enm,fr); - sprintf(buf,"vXi%s-%s",cns,bufi); - state->nosehoover_vxi[i] = find_energy(buf,nre,enm,fr); - } - - } - fprintf(stderr,"\nREAD %d NOSE-HOOVER Xi chains FROM %s\n\n",state->ngtc,fn); - - if (IR_NPT_TROTTER(ir) || IR_NPH_TROTTER(ir)) - { - for(i=0; innhpres; i++) { - bufi = baro_nm[0]; /* All barostat DOF's together for now */ - for(j=0; (jnhchainlength); j++) - { - sprintf(buf,"Xi-%d-%s",j,bufi); - state->nhpres_xi[i] = find_energy(buf,nre,enm,fr); - sprintf(buf,"vXi-%d-%s",j,bufi); - state->nhpres_vxi[i] = find_energy(buf,nre,enm,fr); - } - } - fprintf(stderr,"\nREAD %d NOSE-HOOVER BAROSTAT Xi chains FROM %s\n\n",state->nnhpres,fn); - } - } - - free_enxnms(nre,enm); - free_enxframe(fr); - sfree(fr); -} + /* Should match the names in mdebin.c */ + static const char *boxvel_nm[] = { + "Box-Vel-XX", "Box-Vel-YY", "Box-Vel-ZZ", + "Box-Vel-YX", "Box-Vel-ZX", "Box-Vel-ZY" + }; + + static const char *pcouplmu_nm[] = { + "Pcoupl-Mu-XX", "Pcoupl-Mu-YY", "Pcoupl-Mu-ZZ", + "Pcoupl-Mu-YX", "Pcoupl-Mu-ZX", "Pcoupl-Mu-ZY" + }; + static const char *baro_nm[] = { + "Barostat" + }; + + + int ind0[] = { XX, YY, ZZ, YY, ZZ, ZZ }; + int ind1[] = { XX, YY, ZZ, XX, XX, YY }; + int nre, nfr, i, j, ni, npcoupl; + char buf[STRLEN]; + const char *bufi; + gmx_enxnm_t *enm = NULL; + t_enxframe *fr; + ener_file_t in; + + in = open_enx(fn, "r"); + do_enxnms(in, &nre, &enm); + snew(fr, 1); + nfr = 0; + while ((nfr == 0 || fr->t != t) && do_enx(in, fr)) + { + nfr++; + } + close_enx(in); + fprintf(stderr, "\n"); + + if (nfr == 0 || fr->t != t) + { + gmx_fatal(FARGS, "Could not find frame with time %f in '%s'", t, fn); + } + + npcoupl = TRICLINIC(ir->compress) ? 6 : 3; + if (ir->epc == epcPARRINELLORAHMAN) + { + clear_mat(state->boxv); + for (i = 0; i < npcoupl; i++) + { + state->boxv[ind0[i]][ind1[i]] = + find_energy(boxvel_nm[i], nre, enm, fr); + } + fprintf(stderr, "\nREAD %d BOX VELOCITIES FROM %s\n\n", npcoupl, fn); + } + + if (ir->etc == etcNOSEHOOVER) + { + char cns[20]; + + cns[0] = '\0'; + for (i = 0; i < state->ngtc; i++) + { + ni = groups->grps[egcTC].nm_ind[i]; + bufi = *(groups->grpname[ni]); + for (j = 0; (j < state->nhchainlength); j++) + { + if (IR_NVT_TROTTER(ir)) + { + sprintf(cns, "-%d", j); + } + sprintf(buf, "Xi%s-%s", cns, bufi); + state->nosehoover_xi[i] = find_energy(buf, nre, enm, fr); + sprintf(buf, "vXi%s-%s", cns, bufi); + state->nosehoover_vxi[i] = find_energy(buf, nre, enm, fr); + } + + } + fprintf(stderr, "\nREAD %d NOSE-HOOVER Xi chains FROM %s\n\n", state->ngtc, fn); + + if (IR_NPT_TROTTER(ir) || IR_NPH_TROTTER(ir)) + { + for (i = 0; i < state->nnhpres; i++) + { + bufi = baro_nm[0]; /* All barostat DOF's together for now */ + for (j = 0; (j < state->nhchainlength); j++) + { + sprintf(buf, "Xi-%d-%s", j, bufi); + state->nhpres_xi[i] = find_energy(buf, nre, enm, fr); + sprintf(buf, "vXi-%d-%s", j, bufi); + state->nhpres_vxi[i] = find_energy(buf, nre, enm, fr); + } + } + fprintf(stderr, "\nREAD %d NOSE-HOOVER BAROSTAT Xi chains FROM %s\n\n", state->nnhpres, fn); + } + } + + free_enxnms(nre, enm); + free_enxframe(fr); + sfree(fr); +} diff --git a/src/gromacs/gmxlib/ewald_util.c b/src/gromacs/gmxlib/ewald_util.c index b88d86adcf..f7eea7f2d9 100644 --- a/src/gromacs/gmxlib/ewald_util.c +++ b/src/gromacs/gmxlib/ewald_util.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -50,341 +50,417 @@ #include "writeps.h" #include "macros.h" -real calc_ewaldcoeff(real rc,real dtol) +real calc_ewaldcoeff(real rc, real dtol) { - real x=5,low,high; - int n,i=0; - - - do { - i++; - x*=2; - } while (gmx_erfc(x*rc) > dtol); - - n=i+60; /* search tolerance is 2^-60 */ - low=0; - high=x; - for(i=0;i dtol) - low=x; - else - high=x; - } - return x; + real x = 5, low, high; + int n, i = 0; + + + do + { + i++; + x *= 2; + } + while (gmx_erfc(x*rc) > dtol); + + n = i+60; /* search tolerance is 2^-60 */ + low = 0; + high = x; + for (i = 0; i < n; i++) + { + x = (low+high)/2; + if (gmx_erfc(x*rc) > dtol) + { + low = x; + } + else + { + high = x; + } + } + return x; } real ewald_LRcorrection(FILE *fplog, - int start,int end, - t_commrec *cr,int thread,t_forcerec *fr, - real *chargeA,real *chargeB, - gmx_bool calc_excl_corr, - t_blocka *excl,rvec x[], - matrix box,rvec mu_tot[], - int ewald_geometry,real epsilon_surface, - rvec *f,tensor vir, - real lambda,real *dvdlambda) + int start, int end, + t_commrec *cr, int thread, t_forcerec *fr, + real *chargeA, real *chargeB, + gmx_bool calc_excl_corr, + t_blocka *excl, rvec x[], + matrix box, rvec mu_tot[], + int ewald_geometry, real epsilon_surface, + rvec *f, tensor vir, + real lambda, real *dvdlambda) { - int i,i1,i2,j,k,m,iv,jv,q; - atom_id *AA; - double q2sumA,q2sumB,Vexcl,dvdl_excl; /* Necessary for precision */ - real one_4pi_eps; - real v,vc,qiA,qiB,dr,dr2,rinv,fscal,enercorr; - real Vself[2],Vdipole[2],rinv2,ewc=fr->ewaldcoeff,ewcdr; - rvec df,dx,mutot[2],dipcorrA,dipcorrB; - tensor dxdf; - real vol = box[XX][XX]*box[YY][YY]*box[ZZ][ZZ]; - real L1,dipole_coeff,qqA,qqB,qqL,vr0; - /*#define TABLES*/ + int i, i1, i2, j, k, m, iv, jv, q; + atom_id *AA; + double q2sumA, q2sumB, Vexcl, dvdl_excl; /* Necessary for precision */ + real one_4pi_eps; + real v, vc, qiA, qiB, dr, dr2, rinv, fscal, enercorr; + real Vself[2], Vdipole[2], rinv2, ewc = fr->ewaldcoeff, ewcdr; + rvec df, dx, mutot[2], dipcorrA, dipcorrB; + tensor dxdf; + real vol = box[XX][XX]*box[YY][YY]*box[ZZ][ZZ]; + real L1, dipole_coeff, qqA, qqB, qqL, vr0; + /*#define TABLES*/ #ifdef TABLES - real tabscale=fr->tabscale; - real eps,eps2,VV,FF,F,Y,Geps,Heps2,Fp,fijC,r1t; - real *VFtab=fr->coulvdwtab; - int n0,n1,nnn; + real tabscale = fr->tabscale; + real eps, eps2, VV, FF, F, Y, Geps, Heps2, Fp, fijC, r1t; + real *VFtab = fr->coulvdwtab; + int n0, n1, nnn; #endif - gmx_bool bFreeEnergy = (chargeB != NULL); - gmx_bool bMolPBC = fr->bMolPBC; - - one_4pi_eps = ONE_4PI_EPS0/fr->epsilon_r; - vr0 = ewc*M_2_SQRTPI; - - AA = excl->a; - Vexcl = 0; - dvdl_excl = 0; - q2sumA = 0; - q2sumB = 0; - Vdipole[0] = 0; - Vdipole[1] = 0; - L1 = 1.0-lambda; - - /* Note that we have to transform back to gromacs units, since - * mu_tot contains the dipole in debye units (for output). - */ - for(i=0; (iepsilon_r)*vol); - for(i=0; (ibMolPBC; + + one_4pi_eps = ONE_4PI_EPS0/fr->epsilon_r; + vr0 = ewc*M_2_SQRTPI; + + AA = excl->a; + Vexcl = 0; + dvdl_excl = 0; + q2sumA = 0; + q2sumB = 0; + Vdipole[0] = 0; + Vdipole[1] = 0; + L1 = 1.0-lambda; + + /* Note that we have to transform back to gromacs units, since + * mu_tot contains the dipole in debye units (for output). + */ + for (i = 0; (i < DIM); i++) + { + mutot[0][i] = mu_tot[0][i]*DEBYE2ENM; + mutot[1][i] = mu_tot[1][i]*DEBYE2ENM; + dipcorrA[i] = 0; + dipcorrB[i] = 0; + } + dipole_coeff = 0; + switch (ewald_geometry) + { + case eewg3D: + if (epsilon_surface != 0) + { + dipole_coeff = + 2*M_PI*ONE_4PI_EPS0/((2*epsilon_surface + fr->epsilon_r)*vol); + for (i = 0; (i < DIM); i++) + { + dipcorrA[i] = 2*dipole_coeff*mutot[0][i]; + dipcorrB[i] = 2*dipole_coeff*mutot[1][i]; + } + } + break; + case eewg3DC: + dipole_coeff = 2*M_PI*one_4pi_eps/vol; + dipcorrA[ZZ] = 2*dipole_coeff*mutot[0][ZZ]; + dipcorrB[ZZ] = 2*dipole_coeff*mutot[1][ZZ]; + break; + default: + gmx_incons("Unsupported Ewald geometry"); + break; } - break; - case eewg3DC: - dipole_coeff = 2*M_PI*one_4pi_eps/vol; - dipcorrA[ZZ] = 2*dipole_coeff*mutot[0][ZZ]; - dipcorrB[ZZ] = 2*dipole_coeff*mutot[1][ZZ]; - break; - default: - gmx_incons("Unsupported Ewald geometry"); - break; - } - if (debug) { - fprintf(debug,"dipcorr = %8.3f %8.3f %8.3f\n", - dipcorrA[XX],dipcorrA[YY],dipcorrA[ZZ]); - fprintf(debug,"mutot = %8.3f %8.3f %8.3f\n", - mutot[0][XX],mutot[0][YY],mutot[0][ZZ]); - } - - clear_mat(dxdf); - if ((calc_excl_corr || dipole_coeff != 0) && !bFreeEnergy) { - for(i=start; (iindex[i]; - i2 = excl->index[i+1]; - - /* Loop over excluded neighbours */ - for(j=i1; (j i, and then, because the - * exclusions are all listed twice i->k and k->i we must select - * just one of the two. - * As a minor optimization we only compute forces when the charges - * are non-zero. - */ - if (k > i) { - qqA = qiA*chargeA[k]; - if (qqA != 0.0) { - rvec_sub(x[i],x[k],dx); - if (bMolPBC) { - /* Cheap pbc_dx, assume excluded pairs are at short distance. */ - for(m=DIM-1; (m>=0); m--) { - if (dx[m] > 0.5*box[m][m]) - rvec_dec(dx,box[m]); - else if (dx[m] < -0.5*box[m][m]) - rvec_inc(dx,box[m]); - } - } - dr2 = norm2(dx); - /* Distance between two excluded particles may be zero in the - * case of shells - */ - if (dr2 != 0) { - rinv = gmx_invsqrt(dr2); - rinv2 = rinv*rinv; - dr = 1.0/rinv; + if (debug) + { + fprintf(debug, "dipcorr = %8.3f %8.3f %8.3f\n", + dipcorrA[XX], dipcorrA[YY], dipcorrA[ZZ]); + fprintf(debug, "mutot = %8.3f %8.3f %8.3f\n", + mutot[0][XX], mutot[0][YY], mutot[0][ZZ]); + } + + clear_mat(dxdf); + if ((calc_excl_corr || dipole_coeff != 0) && !bFreeEnergy) + { + for (i = start; (i < end); i++) + { + /* Initiate local variables (for this i-particle) to 0 */ + qiA = chargeA[i]*one_4pi_eps; + + if (calc_excl_corr) + { + i1 = excl->index[i]; + i2 = excl->index[i+1]; + + /* Loop over excluded neighbours */ + for (j = i1; (j < i2); j++) + { + k = AA[j]; + /* + * First we must test whether k <> i, and then, because the + * exclusions are all listed twice i->k and k->i we must select + * just one of the two. + * As a minor optimization we only compute forces when the charges + * are non-zero. + */ + if (k > i) + { + qqA = qiA*chargeA[k]; + if (qqA != 0.0) + { + rvec_sub(x[i], x[k], dx); + if (bMolPBC) + { + /* Cheap pbc_dx, assume excluded pairs are at short distance. */ + for (m = DIM-1; (m >= 0); m--) + { + if (dx[m] > 0.5*box[m][m]) + { + rvec_dec(dx, box[m]); + } + else if (dx[m] < -0.5*box[m][m]) + { + rvec_inc(dx, box[m]); + } + } + } + dr2 = norm2(dx); + /* Distance between two excluded particles may be zero in the + * case of shells + */ + if (dr2 != 0) + { + rinv = gmx_invsqrt(dr2); + rinv2 = rinv*rinv; + dr = 1.0/rinv; #ifdef TABLES - r1t = tabscale*dr; - n0 = r1t; - assert(n0 >= 3); - n1 = 12*n0; - eps = r1t-n0; - eps2 = eps*eps; - nnn = n1; - Y = VFtab[nnn]; - F = VFtab[nnn+1]; - Geps = eps*VFtab[nnn+2]; - Heps2 = eps2*VFtab[nnn+3]; - Fp = F+Geps+Heps2; - VV = Y+eps*Fp; - FF = Fp+Geps+2.0*Heps2; - vc = qqA*(rinv-VV); - fijC = qqA*FF; - Vexcl += vc; - - fscal = vc*rinv2+fijC*tabscale*rinv; - /* End of tabulated interaction part */ + r1t = tabscale*dr; + n0 = r1t; + assert(n0 >= 3); + n1 = 12*n0; + eps = r1t-n0; + eps2 = eps*eps; + nnn = n1; + Y = VFtab[nnn]; + F = VFtab[nnn+1]; + Geps = eps*VFtab[nnn+2]; + Heps2 = eps2*VFtab[nnn+3]; + Fp = F+Geps+Heps2; + VV = Y+eps*Fp; + FF = Fp+Geps+2.0*Heps2; + vc = qqA*(rinv-VV); + fijC = qqA*FF; + Vexcl += vc; + + fscal = vc*rinv2+fijC*tabscale*rinv; + /* End of tabulated interaction part */ #else - - /* This is the code you would want instead if not using - * tables: - */ - ewcdr = ewc*dr; - vc = qqA*gmx_erf(ewcdr)*rinv; - Vexcl += vc; + + /* This is the code you would want instead if not using + * tables: + */ + ewcdr = ewc*dr; + vc = qqA*gmx_erf(ewcdr)*rinv; + Vexcl += vc; #ifdef GMX_DOUBLE - /* Relative accuracy at R_ERF_R_INACC of 3e-10 */ -#define R_ERF_R_INACC 0.006 + /* Relative accuracy at R_ERF_R_INACC of 3e-10 */ +#define R_ERF_R_INACC 0.006 #else - /* Relative accuracy at R_ERF_R_INACC of 2e-5 */ -#define R_ERF_R_INACC 0.1 + /* Relative accuracy at R_ERF_R_INACC of 2e-5 */ +#define R_ERF_R_INACC 0.1 #endif - if (ewcdr > R_ERF_R_INACC) { - fscal = rinv2*(vc - qqA*ewc*M_2_SQRTPI*exp(-ewcdr*ewcdr)); - } else { - /* Use a fourth order series expansion for small ewcdr */ - fscal = ewc*ewc*qqA*vr0*(2.0/3.0 - 0.4*ewcdr*ewcdr); - } + if (ewcdr > R_ERF_R_INACC) + { + fscal = rinv2*(vc - qqA*ewc*M_2_SQRTPI*exp(-ewcdr*ewcdr)); + } + else + { + /* Use a fourth order series expansion for small ewcdr */ + fscal = ewc*ewc*qqA*vr0*(2.0/3.0 - 0.4*ewcdr*ewcdr); + } #endif - /* The force vector is obtained by multiplication with the - * distance vector - */ - svmul(fscal,dx,df); - rvec_inc(f[k],df); - rvec_dec(f[i],df); - for(iv=0; (ivindex[i]; - i2 = excl->index[i+1]; - - /* Loop over excluded neighbours */ - for(j=i1; (j i) { - qqA = qiA*chargeA[k]; - qqB = qiB*chargeB[k]; - if (qqA != 0.0 || qqB != 0.0) { - qqL = L1*qqA + lambda*qqB; - rvec_sub(x[i],x[k],dx); - if (bMolPBC) { - /* Cheap pbc_dx, assume excluded pairs are at short distance. */ - for(m=DIM-1; (m>=0); m--) { - if (dx[m] > 0.5*box[m][m]) - rvec_dec(dx,box[m]); - else if (dx[m] < -0.5*box[m][m]) - rvec_inc(dx,box[m]); - } - } - dr2 = norm2(dx); - if (dr2 != 0) { - rinv = gmx_invsqrt(dr2); - rinv2 = rinv*rinv; - dr = 1.0/rinv; - v = gmx_erf(ewc*dr)*rinv; - vc = qqL*v; - Vexcl += vc; - fscal = rinv2*(vc-qqL*ewc*M_2_SQRTPI*exp(-ewc*ewc*dr2)); - svmul(fscal,dx,df); - rvec_inc(f[k],df); - rvec_dec(f[i],df); - for(iv=0; (ivindex[i]; + i2 = excl->index[i+1]; + + /* Loop over excluded neighbours */ + for (j = i1; (j < i2); j++) + { + k = AA[j]; + if (k > i) + { + qqA = qiA*chargeA[k]; + qqB = qiB*chargeB[k]; + if (qqA != 0.0 || qqB != 0.0) + { + qqL = L1*qqA + lambda*qqB; + rvec_sub(x[i], x[k], dx); + if (bMolPBC) + { + /* Cheap pbc_dx, assume excluded pairs are at short distance. */ + for (m = DIM-1; (m >= 0); m--) + { + if (dx[m] > 0.5*box[m][m]) + { + rvec_dec(dx, box[m]); + } + else if (dx[m] < -0.5*box[m][m]) + { + rvec_inc(dx, box[m]); + } + } + } + dr2 = norm2(dx); + if (dr2 != 0) + { + rinv = gmx_invsqrt(dr2); + rinv2 = rinv*rinv; + dr = 1.0/rinv; + v = gmx_erf(ewc*dr)*rinv; + vc = qqL*v; + Vexcl += vc; + fscal = rinv2*(vc-qqL*ewc*M_2_SQRTPI*exp(-ewc*ewc*dr2)); + svmul(fscal, dx, df); + rvec_inc(f[k], df); + rvec_dec(f[i], df); + for (iv = 0; (iv < DIM); iv++) + { + for (jv = 0; (jv < DIM); jv++) + { + dxdf[iv][jv] += dx[iv]*df[jv]; + } + } + dvdl_excl += (qqB - qqA)*v; + } + else + { + Vexcl += qqL*vr0; + dvdl_excl += (qqB - qqA)*vr0; + } + } + } + } + } + /* Dipole correction on force */ + if (dipole_coeff != 0) + { + for (j = 0; (j < DIM); j++) + { + f[i][j] -= L1*dipcorrA[j]*chargeA[i] + + lambda*dipcorrB[j]*chargeB[i]; + } + } + } + } + for (iv = 0; (iv < DIM); iv++) + { + for (jv = 0; (jv < DIM); jv++) + { + vir[iv][jv] += 0.5*dxdf[iv][jv]; + } + } + + + Vself[0] = 0; + Vself[1] = 0; + /* Global corrections only on master process */ + if (MASTER(cr) && thread == 0) + { + for (q = 0; q < (bFreeEnergy ? 2 : 1); q++) + { + if (calc_excl_corr) + { + /* Self-energy correction */ + Vself[q] = ewc*one_4pi_eps*fr->q2sum[q]*M_1_SQRTPI; + } + + /* Apply surface dipole correction: + * correction = dipole_coeff * (dipole)^2 + */ + if (dipole_coeff != 0) + { + if (ewald_geometry == eewg3D) + { + Vdipole[q] = dipole_coeff*iprod(mutot[q], mutot[q]); + } + else if (ewald_geometry == eewg3DC) + { + Vdipole[q] = dipole_coeff*mutot[q][ZZ]*mutot[q][ZZ]; + } + } + } + } + + if (!bFreeEnergy) + { + enercorr = Vdipole[0] - Vself[0] - Vexcl; } - } - for(iv=0; (ivq2sum[q]*M_1_SQRTPI; - } - - /* Apply surface dipole correction: - * correction = dipole_coeff * (dipole)^2 - */ - if (dipole_coeff != 0) { - if (ewald_geometry == eewg3D) - Vdipole[q] = dipole_coeff*iprod(mutot[q],mutot[q]); - else if (ewald_geometry == eewg3DC) - Vdipole[q] = dipole_coeff*mutot[q][ZZ]*mutot[q][ZZ]; - } + else + { + enercorr = L1*(Vdipole[0] - Vself[0]) + + lambda*(Vdipole[1] - Vself[1]) + - Vexcl; + *dvdlambda += Vdipole[1] - Vself[1] + - (Vdipole[0] - Vself[0]) - dvdl_excl; } - } - - if (!bFreeEnergy) { - enercorr = Vdipole[0] - Vself[0] - Vexcl; - } else { - enercorr = L1*(Vdipole[0] - Vself[0]) - + lambda*(Vdipole[1] - Vself[1]) - - Vexcl; - *dvdlambda += Vdipole[1] - Vself[1] - - (Vdipole[0] - Vself[0]) - dvdl_excl; - } - - if (debug) { - fprintf(debug,"Long Range corrections for Ewald interactions:\n"); - fprintf(debug,"start=%d,natoms=%d\n",start,end-start); - fprintf(debug,"q2sum = %g, Vself=%g\n", - L1*q2sumA+lambda*q2sumB,L1*Vself[0]+lambda*Vself[1]); - fprintf(debug,"Long Range correction: Vexcl=%g\n",Vexcl); - if (MASTER(cr) && thread == 0) { - if (epsilon_surface > 0 || ewald_geometry == eewg3DC) { - fprintf(debug,"Total dipole correction: Vdipole=%g\n", - L1*Vdipole[0]+lambda*Vdipole[1]); - } + + if (debug) + { + fprintf(debug, "Long Range corrections for Ewald interactions:\n"); + fprintf(debug, "start=%d,natoms=%d\n", start, end-start); + fprintf(debug, "q2sum = %g, Vself=%g\n", + L1*q2sumA+lambda*q2sumB, L1*Vself[0]+lambda*Vself[1]); + fprintf(debug, "Long Range correction: Vexcl=%g\n", Vexcl); + if (MASTER(cr) && thread == 0) + { + if (epsilon_surface > 0 || ewald_geometry == eewg3DC) + { + fprintf(debug, "Total dipole correction: Vdipole=%g\n", + L1*Vdipole[0]+lambda*Vdipole[1]); + } + } } - } - - /* Return the correction to the energy */ - return enercorr; + + /* Return the correction to the energy */ + return enercorr; } -real ewald_charge_correction(t_commrec *cr,t_forcerec *fr,real lambda, +real ewald_charge_correction(t_commrec *cr, t_forcerec *fr, real lambda, matrix box, - real *dvdlambda,tensor vir) + real *dvdlambda, tensor vir) { - real vol,fac,qs2A,qs2B,vc,enercorr; + real vol, fac, qs2A, qs2B, vc, enercorr; int d; if (MASTER(cr)) @@ -392,25 +468,25 @@ real ewald_charge_correction(t_commrec *cr,t_forcerec *fr,real lambda, /* Apply charge correction */ vol = box[XX][XX]*box[YY][YY]*box[ZZ][ZZ]; - fac = M_PI*ONE_4PI_EPS0/(fr->epsilon_r*2.0*vol*vol*sqr(fr->ewaldcoeff)); + fac = M_PI*ONE_4PI_EPS0/(fr->epsilon_r*2.0*vol*vol*sqr(fr->ewaldcoeff)); - qs2A = fr->qsum[0]*fr->qsum[0]; - qs2B = fr->qsum[1]*fr->qsum[1]; + qs2A = fr->qsum[0]*fr->qsum[0]; + qs2B = fr->qsum[1]*fr->qsum[1]; vc = (qs2A*(1 - lambda) + qs2B*lambda)*fac; - enercorr = -vol*vc; + enercorr = -vol*vc; - *dvdlambda += -vol*(qs2B - qs2A)*fac; + *dvdlambda += -vol*(qs2B - qs2A)*fac; - for(d=0; dftype) { - case eftASC: - s = "Asc"; - break; - case eftBIN: - s = "Bin"; - break; - case eftXDR: - s = "xdr"; - break; - case eftGEN: - s = ""; - break; - default: - gmx_fatal(FARGS, "Unimplemented filetype %d %d",ftp, - df->ftype); - } - fprintf(fp,"\\tt %8s & \\tt %3s & %3s & \\tt %2s & %s%s \\\\[-0.1ex]\n", - defnm, ext, s, df->defopt ? df->defopt : "", - check_tex(desc),check_tex(flst)); + case eftASC: + s = "Asc"; + break; + case eftBIN: + s = "Bin"; + break; + case eftXDR: + s = "xdr"; + break; + case eftGEN: + s = ""; + break; + default: + gmx_fatal(FARGS, "Unimplemented filetype %d %d", ftp, + df->ftype); + } + fprintf(fp, "\\tt %8s & \\tt %3s & %3s & \\tt %2s & %s%s \\\\[-0.1ex]\n", + defnm, ext, s, df->defopt ? df->defopt : "", + check_tex(desc), check_tex(flst)); free(desc); } void pr_fns(FILE *fp, int nf, const t_filenm tfn[]) { - int i, f; + int i, f; size_t j; - char buf[256], *wbuf, opt_buf[32]; + char buf[256], *wbuf, opt_buf[32]; #define OPTLEN 4 #define NAMELEN 14 fprintf(fp, "%6s %12s %-12s %s\n", "Option", "Filename", "Type", @@ -396,20 +419,24 @@ void pr_fns(FILE *fp, int nf, const t_filenm tfn[]) { sprintf(buf, "%4s %14s %-12s ", (f == 0) ? tfn[i].opt : "", tfn[i].fns[f], (f == 0) ? fileopt(tfn[i].flag, opt_buf, 32) - : ""); + : ""); if (f < tfn[i].nfiles - 1) + { fprintf(fp, "%s\n", buf); + } } if (tfn[i].nfiles > 0) { strcat(buf, deffile[tfn[i].ftp].descr); if ((strlen(tfn[i].opt) > OPTLEN) && (strlen(tfn[i].opt) <= ((OPTLEN + NAMELEN) - - strlen(tfn[i].fns[tfn[i].nfiles - 1])))) + - strlen(tfn[i].fns[tfn[i].nfiles - 1])))) { for (j = strlen(tfn[i].opt); j < strlen(buf) - - (strlen(tfn[i].opt) - OPTLEN) + 1; j++) + - (strlen(tfn[i].opt) - OPTLEN) + 1; j++) + { buf[j] = buf[j + strlen(tfn[i].opt) - OPTLEN]; + } } wbuf = wrap_lines(buf, 78, 35, FALSE); fprintf(fp, "%s\n", wbuf); @@ -426,88 +453,106 @@ void pr_fopts(FILE *fp, int nf, const t_filenm tfn[], int shell) switch (shell) { - case eshellCSH: - for (i = 0; (i < nf); i++) - { - fprintf(fp, " \"n/%s/f:*.", tfn[i].opt); - if (deffile[tfn[i].ftp].ntps) + case eshellCSH: + for (i = 0; (i < nf); i++) { + fprintf(fp, " \"n/%s/f:*.", tfn[i].opt); + if (deffile[tfn[i].ftp].ntps) + { + fprintf(fp, "{"); + for (j = 0; j < deffile[tfn[i].ftp].ntps; j++) + { + if (j > 0) + { + fprintf(fp, ","); + } + fprintf(fp, "%s", deffile[deffile[tfn[i].ftp].tps[j]].ext + + 1); + } + fprintf(fp, "}"); + } + else + { + fprintf(fp, "%s", deffile[tfn[i].ftp].ext + 1); + } fprintf(fp, "{"); - for (j = 0; j < deffile[tfn[i].ftp].ntps; j++) + for (j = 0; j < NZEXT; j++) { - if (j > 0) - fprintf(fp, ","); - fprintf(fp, "%s", deffile[deffile[tfn[i].ftp].tps[j]].ext - + 1); + fprintf(fp, ",%s", z_ext[j]); } - fprintf(fp, "}"); + fprintf(fp, "}/\""); } - else - fprintf(fp, "%s", deffile[tfn[i].ftp].ext + 1); - fprintf(fp, "{"); - for (j = 0; j < NZEXT; j++) - fprintf(fp, ",%s", z_ext[j]); - fprintf(fp, "}/\""); - } - break; - case eshellBASH: - for (i = 0; (i < nf); i++) - { - fprintf(fp, "%s) COMPREPLY=( $(compgen -X '!*.", tfn[i].opt); - if (deffile[tfn[i].ftp].ntps) + break; + case eshellBASH: + for (i = 0; (i < nf); i++) { - fprintf(fp, "+("); - for (j = 0; j < deffile[tfn[i].ftp].ntps; j++) + fprintf(fp, "%s) COMPREPLY=( $(compgen -X '!*.", tfn[i].opt); + if (deffile[tfn[i].ftp].ntps) + { + fprintf(fp, "+("); + for (j = 0; j < deffile[tfn[i].ftp].ntps; j++) + { + if (j > 0) + { + fprintf(fp, "|"); + } + fprintf(fp, "%s", deffile[deffile[tfn[i].ftp].tps[j]].ext + + 1); + } + fprintf(fp, ")"); + } + else + { + fprintf(fp, "%s", deffile[tfn[i].ftp].ext + 1); + } + fprintf(fp, "*("); + for (j = 0; j < NZEXT; j++) { if (j > 0) + { fprintf(fp, "|"); - fprintf(fp, "%s", deffile[deffile[tfn[i].ftp].tps[j]].ext - + 1); + } + fprintf(fp, "%s", z_ext[j]); } - fprintf(fp, ")"); - } - else - fprintf(fp, "%s", deffile[tfn[i].ftp].ext + 1); - fprintf(fp, "*("); - for (j = 0; j < NZEXT; j++) - { - if (j > 0) - fprintf(fp, "|"); - fprintf(fp, "%s", z_ext[j]); + fprintf(fp, ")' -f $c ; compgen -S '/' -X '.*' -d $c ));;\n"); } - fprintf(fp, ")' -f $c ; compgen -S '/' -X '.*' -d $c ));;\n"); - } - break; - case eshellZSH: - for (i = 0; (i < nf); i++) - { - fprintf(fp, "- 'c[-1,%s]' -g '*.", tfn[i].opt); - if (deffile[tfn[i].ftp].ntps) + break; + case eshellZSH: + for (i = 0; (i < nf); i++) { + fprintf(fp, "- 'c[-1,%s]' -g '*.", tfn[i].opt); + if (deffile[tfn[i].ftp].ntps) + { + fprintf(fp, "("); + for (j = 0; j < deffile[tfn[i].ftp].ntps; j++) + { + if (j > 0) + { + fprintf(fp, "|"); + } + fprintf(fp, "%s", deffile[deffile[tfn[i].ftp].tps[j]].ext + + 1); + } + fprintf(fp, ")"); + } + else + { + fprintf(fp, "%s", deffile[tfn[i].ftp].ext + 1); + } fprintf(fp, "("); - for (j = 0; j < deffile[tfn[i].ftp].ntps; j++) + for (j = 0; j < NZEXT; j++) { - if (j > 0) - fprintf(fp, "|"); - fprintf(fp, "%s", deffile[deffile[tfn[i].ftp].tps[j]].ext - + 1); + fprintf(fp, "|%s", z_ext[j]); } - fprintf(fp, ")"); + fprintf(fp, ") *(/)' "); } - else - fprintf(fp, "%s", deffile[tfn[i].ftp].ext + 1); - fprintf(fp, "("); - for (j = 0; j < NZEXT; j++) - fprintf(fp, "|%s", z_ext[j]); - fprintf(fp, ") *(/)' "); - } - break; + break; } } static void check_opts(int nf, t_filenm fnm[]) { - int i; + int i; const t_deffile *df; for (i = 0; (i < nf); i++) @@ -518,11 +563,11 @@ static void check_opts(int nf, t_filenm fnm[]) if (df->defopt == NULL) { gmx_fatal(FARGS, "No default cmd-line option for %s (type %d)\n", - deffile[fnm[i].ftp].ext,fnm[i].ftp); + deffile[fnm[i].ftp].ext, fnm[i].ftp); } else { - fnm[i].opt=df->defopt; + fnm[i].opt = df->defopt; } } } @@ -530,38 +575,52 @@ static void check_opts(int nf, t_filenm fnm[]) int fn2ftp(const char *fn) { - int i, len; + int i, len; const char *feptr; const char *eptr; if (!fn) + { return efNR; + } len = strlen(fn); if ((len >= 4) && (fn[len - 4] == '.')) + { feptr = &(fn[len - 4]); + } else + { return efNR; + } for (i = 0; (i < efNR); i++) + { if ((eptr = deffile[i].ext) != NULL) + { if (gmx_strcasecmp(feptr, eptr) == 0) + { break; + } + } + } return i; } static void set_extension(char *buf, int ftp) { - int len, extlen; + int len, extlen; const t_deffile *df; /* check if extension is already at end of filename */ - df = &(deffile[ftp]); - len = strlen(buf); + df = &(deffile[ftp]); + len = strlen(buf); extlen = strlen(df->ext); if ((len <= extlen) || (gmx_strcasecmp(&(buf[len - extlen]), df->ext) != 0)) + { strcat(buf, df->ext); + } } static void add_filenm(t_filenm *fnm, const char *filenm) @@ -573,29 +632,31 @@ static void add_filenm(t_filenm *fnm, const char *filenm) static void set_grpfnm(t_filenm *fnm, const char *name, gmx_bool bCanNotOverride) { - char buf[256], buf2[256]; - int i, type; - gmx_bool bValidExt; - int nopts; + char buf[256], buf2[256]; + int i, type; + gmx_bool bValidExt; + int nopts; const int *ftps; nopts = deffile[fnm->ftp].ntps; - ftps = deffile[fnm->ftp].tps; + ftps = deffile[fnm->ftp].tps; if ((nopts == 0) || (ftps == NULL)) + { gmx_fatal(FARGS, "nopts == 0 || ftps == NULL"); + } bValidExt = FALSE; if (name && (bCanNotOverride || (default_file_name == NULL))) { - strcpy(buf,name); + strcpy(buf, name); /* First check whether we have a valid filename already */ type = fn2ftp(name); if ((fnm->flag & ffREAD) && (fnm->ftp == efTRX)) { /*if file exist don't add an extension for trajectory reading*/ - bValidExt = gmx_fexist(name); + bValidExt = gmx_fexist(name); } - for(i=0; (iftp)); + strcpy(buf, ftp2defnm(fnm->ftp)); + } if (!bValidExt && (fnm->flag & ffREAD)) { /* for input-files only: search for filenames in the directory */ - for(i=0; (iflag & ffREAD) && !bReadNode) { @@ -648,22 +711,26 @@ static void set_filenm(t_filenm *fnm, const char *name, gmx_bool bCanNotOverride } if ((fnm->ftp < 0) || (fnm->ftp >= efNR)) - gmx_fatal(FARGS, "file type out of range (%d)",fnm->ftp); + { + gmx_fatal(FARGS, "file type out of range (%d)", fnm->ftp); + } if (name) + { strcpy(buf, name); + } if ((fnm->flag & ffREAD) && name && gmx_fexist(name)) { /* check if filename ends in .gz or .Z, if so remove that: */ len = strlen(name); - for (i=0; i extlen) { - if (gmx_strcasecmp(name+len-extlen,z_ext[i]) == 0) + if (gmx_strcasecmp(name+len-extlen, z_ext[i]) == 0) { - buf[len-extlen]='\0'; + buf[len-extlen] = '\0'; break; } } @@ -672,17 +739,17 @@ static void set_filenm(t_filenm *fnm, const char *name, gmx_bool bCanNotOverride if (deffile[fnm->ftp].ntps) { - set_grpfnm(fnm,name ? buf : NULL,bCanNotOverride); + set_grpfnm(fnm, name ? buf : NULL, bCanNotOverride); } else { - if ((name == NULL) || !(bCanNotOverride || (default_file_name ==NULL))) + if ((name == NULL) || !(bCanNotOverride || (default_file_name == NULL))) { - const char *defnm=ftp2defnm(fnm->ftp); - strcpy(buf,defnm); + const char *defnm = ftp2defnm(fnm->ftp); + strcpy(buf, defnm); } - set_extension(buf,fnm->ftp); - + set_extension(buf, fnm->ftp); + add_filenm(fnm, buf); } } @@ -692,24 +759,30 @@ static void set_filenms(int nf, t_filenm fnm[], gmx_bool bReadNode) int i; for (i = 0; (i < nf); i++) + { if (!IS_SET(fnm[i])) + { set_filenm(&(fnm[i]), fnm[i].fn, FALSE, bReadNode); + } + } } void parse_file_args(int *argc, char *argv[], int nf, t_filenm fnm[], gmx_bool bKeep, gmx_bool bReadNode) { - int i, j; + int i, j; gmx_bool *bRemove; check_opts(nf, fnm); for (i = 0; (i < nf); i++) + { UN_SET(fnm[i]); + } if (*argc > 1) { - snew(bRemove,(*argc)+1); + snew(bRemove, (*argc)+1); i = 1; do { @@ -722,7 +795,9 @@ void parse_file_args(int *argc, char *argv[], int nf, t_filenm fnm[], i++; /* check if we are out of arguments for this option */ if ((i >= *argc) || (argv[i][0] == '-')) + { set_filenm(&fnm[j], fnm[j].fn, FALSE, bReadNode); + } /* sweep up all file arguments for this option */ while ((i < *argc) && (argv[i][0] != '-')) { @@ -731,7 +806,9 @@ void parse_file_args(int *argc, char *argv[], int nf, t_filenm fnm[], i++; /* only repeat for 'multiple' file options: */ if (!IS_MULT(fnm[j])) + { break; + } } break; /* jump out of 'j' loop */ @@ -739,8 +816,11 @@ void parse_file_args(int *argc, char *argv[], int nf, t_filenm fnm[], } /* No file found corresponding to option argv[i] */ if (j == nf) + { i++; - } while (i < *argc); + } + } + while (i < *argc); if (!bKeep) { @@ -748,7 +828,9 @@ void parse_file_args(int *argc, char *argv[], int nf, t_filenm fnm[], for (i = j = 0; (i <= *argc); i++) { if (!bRemove[i]) + { argv[j++] = argv[i]; + } } (*argc) = j - 1; } @@ -764,10 +846,12 @@ const char *opt2fn(const char *opt, int nfile, const t_filenm fnm[]) int i; for (i = 0; (i < nfile); i++) + { if (strcmp(opt, fnm[i].opt) == 0) { return fnm[i].fns[0]; } + } fprintf(stderr, "No option %s\n", opt); @@ -785,11 +869,13 @@ int opt2fns(char **fns[], const char *opt, int nfile, const t_filenm fnm[]) int i; for (i = 0; (i < nfile); i++) + { if (strcmp(opt, fnm[i].opt) == 0) { *fns = fnm[i].fns; return fnm[i].nfiles; } + } fprintf(stderr, "No option %s\n", opt); return 0; @@ -800,8 +886,12 @@ const char *ftp2fn(int ftp, int nfile, const t_filenm fnm[]) int i; for (i = 0; (i < nfile); i++) + { if (ftp == fnm[i].ftp) + { return fnm[i].fns[0]; + } + } fprintf(stderr, "ftp2fn: No filetype %s\n", deffile[ftp].ext); return NULL; @@ -812,11 +902,13 @@ int ftp2fns(char **fns[], int ftp, int nfile, const t_filenm fnm[]) int i; for (i = 0; (i < nfile); i++) + { if (ftp == fnm[i].ftp) { *fns = fnm[i].fns; return fnm[i].nfiles; } + } fprintf(stderr, "ftp2fn: No filetype %s\n", deffile[ftp].ext); return 0; @@ -827,8 +919,12 @@ gmx_bool ftp2bSet(int ftp, int nfile, const t_filenm fnm[]) int i; for (i = 0; (i < nfile); i++) + { if (ftp == fnm[i].ftp) + { return (gmx_bool) IS_SET(fnm[i]); + } + } fprintf(stderr, "ftp2bSet: No filetype %s\n", deffile[ftp].ext); @@ -840,8 +936,12 @@ gmx_bool opt2bSet(const char *opt, int nfile, const t_filenm fnm[]) int i; for (i = 0; (i < nfile); i++) + { if (strcmp(opt, fnm[i].opt) == 0) + { return (gmx_bool) IS_SET(fnm[i]); + } + } fprintf(stderr, "No option %s\n", opt); @@ -853,13 +953,19 @@ const char *opt2fn_null(const char *opt, int nfile, const t_filenm fnm[]) int i; for (i = 0; (i < nfile); i++) + { if (strcmp(opt, fnm[i].opt) == 0) { if (IS_OPT(fnm[i]) && !IS_SET(fnm[i])) + { return NULL; + } else + { return fnm[i].fns[0]; + } } + } fprintf(stderr, "No option %s\n", opt); return NULL; } @@ -869,62 +975,70 @@ const char *ftp2fn_null(int ftp, int nfile, const t_filenm fnm[]) int i; for (i = 0; (i < nfile); i++) + { if (ftp == fnm[i].ftp) { if (IS_OPT(fnm[i]) && !IS_SET(fnm[i])) + { return NULL; + } else + { return fnm[i].fns[0]; + } } + } fprintf(stderr, "ftp2fn: No filetype %s\n", deffile[ftp].ext); return NULL; } #if 0 -static void add_filters(char *filter,int *n,int nf,const int ftp[]) +static void add_filters(char *filter, int *n, int nf, const int ftp[]) { char buf[8]; - int i; + int i; - sprintf(filter,"*.{"); - for(i=0; (i 0) - strcat(filter,","); - strcat(filter,buf); - (*n) ++; + { + strcat(filter, ","); + } + strcat(filter, buf); + (*n)++; } - strcat(filter,"}"); + strcat(filter, "}"); } char *ftp2filter(int ftp) { - int n; + int n; static char filter[128]; filter[0] = '\0'; - n = 0; + n = 0; switch (ftp) { - case efTRX: - add_filters(filter,&n,NTRXS,trxs); - break; - case efTRN: - add_filters(filter,&n,NTRNS,trns); - break; - case efSTO: - add_filters(filter,&n,NSTOS,stos); - break; - case efSTX: - add_filters(filter,&n,NSTXS,stxs); - break; - case efTPX: - add_filters(filter,&n,NTPXS,tpxs); - break; - default: - sprintf(filter,"*%s",ftp2ext(ftp)); - break; + case efTRX: + add_filters(filter, &n, NTRXS, trxs); + break; + case efTRN: + add_filters(filter, &n, NTRNS, trns); + break; + case efSTO: + add_filters(filter, &n, NSTOS, stos); + break; + case efSTX: + add_filters(filter, &n, NSTXS, stxs); + break; + case efTPX: + add_filters(filter, &n, NTPXS, tpxs); + break; + default: + sprintf(filter, "*%s", ftp2ext(ftp)); + break; } return filter; } @@ -947,20 +1061,20 @@ gmx_bool is_set(const t_filenm *fnm) int add_suffix_to_output_names(t_filenm *fnm, int nfile, const char *suffix) { - int i, j, pos; - char buf[STRLEN], newname[STRLEN]; + int i, j, pos; + char buf[STRLEN], newname[STRLEN]; char *extpos; for (i = 0; i < nfile; i++) { if (is_output(&fnm[i]) && fnm[i].ftp != efCPT) { - /* We never use multiple _outputs_, but we might as well check - for it, just in case... */ + /* We never use multiple _outputs_, but we might as well check + for it, just in case... */ for (j = 0; j < fnm[i].nfiles; j++) { strncpy(buf, fnm[i].fns[j], STRLEN - 1); - extpos = strrchr(buf, '.'); + extpos = strrchr(buf, '.'); *extpos = '\0'; sprintf(newname, "%s%s.%s", buf, suffix, extpos + 1); free(fnm[i].fns[j]); @@ -973,7 +1087,7 @@ int add_suffix_to_output_names(t_filenm *fnm, int nfile, const char *suffix) t_filenm *dup_tfn(int nf, const t_filenm tfn[]) { - int i, j; + int i, j; t_filenm *ret; snew(ret, nf); @@ -981,18 +1095,26 @@ t_filenm *dup_tfn(int nf, const t_filenm tfn[]) { ret[i] = tfn[i]; /* just directly copy all non-string fields */ if (tfn[i].opt) + { ret[i].opt = strdup(tfn[i].opt); + } else + { ret[i].opt = NULL; + } if (tfn[i].fn) + { ret[i].fn = strdup(tfn[i].fn); + } else + { ret[i].fn = NULL; + } if (tfn[i].nfiles > 0) { - snew(ret[i].fns,tfn[i].nfiles); + snew(ret[i].fns, tfn[i].nfiles); for (j = 0; j < tfn[i].nfiles; j++) { ret[i].fns[j] = strdup(tfn[i].fns[j]); diff --git a/src/gromacs/gmxlib/futil.c b/src/gromacs/gmxlib/futil.c index b00e2887c8..befa0679a8 100644 --- a/src/gromacs/gmxlib/futil.c +++ b/src/gromacs/gmxlib/futil.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -76,27 +76,27 @@ #include "windows.h" #endif -/* we keep a linked list of all files opened through pipes (i.e. +/* we keep a linked list of all files opened through pipes (i.e. compressed or .gzipped files. This way we can distinguish between them - without having to change the semantics of reading from/writing to files) - */ + without having to change the semantics of reading from/writing to files) + */ typedef struct t_pstack { - FILE *fp; + FILE *fp; struct t_pstack *prev; } t_pstack; -static t_pstack *pstack=NULL; -static gmx_bool bUnbuffered=FALSE; +static t_pstack *pstack = NULL; +static gmx_bool bUnbuffered = FALSE; #ifdef GMX_THREAD_MPI /* this linked list is an intrinsically globally shared object, so we have to protect it with mutexes */ -static tMPI_Thread_mutex_t pstack_mutex=TMPI_THREAD_MUTEX_INITIALIZER; +static tMPI_Thread_mutex_t pstack_mutex = TMPI_THREAD_MUTEX_INITIALIZER; #endif void no_buffers(void) { - bUnbuffered=TRUE; + bUnbuffered = TRUE; } void push_ps(FILE *fp) @@ -107,7 +107,7 @@ void push_ps(FILE *fp) tMPI_Thread_mutex_lock(&pstack_mutex); #endif - snew(ps,1); + snew(ps, 1); ps->fp = fp; ps->prev = pstack; pstack = ps; @@ -129,7 +129,7 @@ void push_ps(FILE *fp) #ifndef GMX_FAHCORE #ifndef HAVE_PIPES -static FILE *popen(const char *nm,const char *mode) +static FILE *popen(const char *nm, const char *mode) { gmx_impl("Sorry no pipes..."); @@ -150,36 +150,51 @@ int ffclose(FILE *fp) #ifdef SKIP_FFOPS return fclose(fp); #else - t_pstack *ps,*tmp; - int ret=0; + t_pstack *ps, *tmp; + int ret = 0; #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&pstack_mutex); #endif - ps=pstack; - if (ps == NULL) { - if (fp != NULL) + ps = pstack; + if (ps == NULL) + { + if (fp != NULL) + { ret = fclose(fp); + } } - else if (ps->fp == fp) { + else if (ps->fp == fp) + { if (fp != NULL) + { ret = pclose(fp); - pstack=pstack->prev; + } + pstack = pstack->prev; sfree(ps); } - else { + else + { while ((ps->prev != NULL) && (ps->prev->fp != fp)) - ps=ps->prev; - if ((ps->prev != NULL) && ps->prev->fp == fp) { + { + ps = ps->prev; + } + if ((ps->prev != NULL) && ps->prev->fp == fp) + { if (ps->prev->fp != NULL) + { ret = pclose(ps->prev->fp); - tmp=ps->prev; - ps->prev=ps->prev->prev; + } + tmp = ps->prev; + ps->prev = ps->prev->prev; sfree(tmp); } - else { + else + { if (fp != NULL) + { ret = fclose(fp); + } } } #ifdef GMX_THREAD_MPI @@ -201,16 +216,18 @@ void frewind(FILE *fp) tMPI_Thread_mutex_lock(&pstack_mutex); #endif - ps=pstack; - while (ps != NULL) { - if (ps->fp == fp) { - fprintf(stderr,"Cannot rewind compressed file!\n"); + ps = pstack; + while (ps != NULL) + { + if (ps->fp == fp) + { + fprintf(stderr, "Cannot rewind compressed file!\n"); #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&pstack_mutex); #endif return; } - ps=ps->prev; + ps = ps->prev; } rewind(fp); #ifdef GMX_THREAD_MPI @@ -236,7 +253,7 @@ gmx_off_t gmx_ftell(FILE *stream) #ifdef HAVE_FSEEKO return ftello(stream); #else -#ifdef HAVE__FSEEKI64 +#ifdef HAVE__FSEEKI64 return _ftelli64(stream); #else return ftell(stream); @@ -252,15 +269,17 @@ gmx_bool is_pipe(FILE *fp) tMPI_Thread_mutex_lock(&pstack_mutex); #endif - ps=pstack; - while (ps != NULL) { - if (ps->fp == fp) { + ps = pstack; + while (ps != NULL) + { + if (ps->fp == fp) + { #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&pstack_mutex); #endif return TRUE; } - ps=ps->prev; + ps = ps->prev; } #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&pstack_mutex); @@ -269,29 +288,33 @@ gmx_bool is_pipe(FILE *fp) } -static FILE *uncompress(const char *fn,const char *mode) +static FILE *uncompress(const char *fn, const char *mode) { FILE *fp; - char buf[256]; + char buf[256]; - sprintf(buf,"uncompress -c < %s",fn); - fprintf(stderr,"Going to execute '%s'\n",buf); - if ((fp=popen(buf,mode)) == NULL) + sprintf(buf, "uncompress -c < %s", fn); + fprintf(stderr, "Going to execute '%s'\n", buf); + if ((fp = popen(buf, mode)) == NULL) + { gmx_open(fn); + } push_ps(fp); return fp; } -static FILE *gunzip(const char *fn,const char *mode) +static FILE *gunzip(const char *fn, const char *mode) { FILE *fp; - char buf[256]; + char buf[256]; - sprintf(buf,"gunzip -c < %s",fn); - fprintf(stderr,"Going to execute '%s'\n",buf); - if ((fp=popen(buf,mode)) == NULL) + sprintf(buf, "gunzip -c < %s", fn); + fprintf(stderr, "Going to execute '%s'\n", buf); + if ((fp = popen(buf, mode)) == NULL) + { gmx_open(fn); + } push_ps(fp); return fp; @@ -302,17 +325,22 @@ gmx_bool gmx_fexist(const char *fname) FILE *test; if (fname == NULL) + { return FALSE; - test=fopen(fname,"r"); - if (test == NULL) { + } + test = fopen(fname, "r"); + if (test == NULL) + { /*Windows doesn't allow fopen of directory - so we need to check this seperately */ #ifdef GMX_NATIVE_WINDOWS - DWORD attr = GetFileAttributes(fname); - return (attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY); - #else - return FALSE; + DWORD attr = GetFileAttributes(fname); + return (attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY); + #else + return FALSE; #endif - } else { + } + else + { fclose(test); return TRUE; } @@ -323,8 +351,10 @@ static gmx_bool gmx_is_file(const char *fname) FILE *test; if (fname == NULL) + { return FALSE; - test=fopen(fname,"r"); + } + test = fopen(fname, "r"); if (test == NULL) { return FALSE; @@ -335,7 +365,7 @@ static gmx_bool gmx_is_file(const char *fname) /*Windows doesn't allow fopen of directory - so we don't need to check this seperately */ #if (!((defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64) && !defined __CYGWIN__ && !defined __CYGWIN32__)) { - int status; + int status; struct stat st_buf; status = stat (fname, &st_buf); if (status != 0 || !S_ISREG(st_buf.st_mode)) @@ -351,42 +381,47 @@ static gmx_bool gmx_is_file(const char *fname) gmx_bool gmx_fexist_master(const char *fname, t_commrec *cr) { - gmx_bool bExist; - - if (SIMMASTER(cr)) - { - bExist = gmx_fexist(fname); - } - if (PAR(cr)) - { - gmx_bcast(sizeof(bExist),&bExist,cr); - } - return bExist; + gmx_bool bExist; + + if (SIMMASTER(cr)) + { + bExist = gmx_fexist(fname); + } + if (PAR(cr)) + { + gmx_bcast(sizeof(bExist), &bExist, cr); + } + return bExist; } gmx_bool gmx_eof(FILE *fp) { - char data[4]; + char data[4]; gmx_bool beof; if (is_pipe(fp)) + { return feof(fp); - else { - if ((beof=fread(data,1,1,fp))==1) - gmx_fseek(fp,-1,SEEK_CUR); + } + else + { + if ((beof = fread(data, 1, 1, fp)) == 1) + { + gmx_fseek(fp, -1, SEEK_CUR); + } return !beof; } } -static char *backup_fn(const char *file,int count_max) +static char *backup_fn(const char *file, int count_max) { /* Use a reasonably low value for countmax; we might * generate 4-5 files in each round, and we dont * want to hit directory limits of 1024 or 2048 files. */ #define COUNTMAX 99 - int i,count=1; - char *directory,*fn; + int i, count = 1; + char *directory, *fn; char *buf; if (count_max == -1) @@ -396,31 +431,39 @@ static char *backup_fn(const char *file,int count_max) smalloc(buf, GMX_PATH_MAX); - for(i=strlen(file)-1; ((i > 0) && (file[i] != DIR_SEPARATOR)); i--) + for (i = strlen(file)-1; ((i > 0) && (file[i] != DIR_SEPARATOR)); i--) + { ; + } /* Must check whether i > 0, i.e. whether there is a directory * in the file name. In that case we overwrite the / sign with * a '\0' to end the directory string . */ - if (i > 0) { + if (i > 0) + { directory = gmx_strdup(file); directory[i] = '\0'; fn = gmx_strdup(file+i+1); } - else { + else + { directory = gmx_strdup("."); fn = gmx_strdup(file); } - do { - sprintf(buf,"%s/#%s.%d#",directory,fn,count); + do + { + sprintf(buf, "%s/#%s.%d#", directory, fn, count); count++; - } while ((count <= count_max) && gmx_fexist(buf)); + } + while ((count <= count_max) && gmx_fexist(buf)); /* Arbitrarily bail out */ - if (count > count_max) - gmx_fatal(FARGS,"Won't make more than %d backups of %s for you.\n" + if (count > count_max) + { + gmx_fatal(FARGS, "Won't make more than %d backups of %s for you.\n" "The env.var. GMX_MAXBACKUP controls this maximum, -1 disables backups.", - count_max,fn); + count_max, fn); + } sfree(directory); sfree(fn); @@ -431,7 +474,7 @@ static char *backup_fn(const char *file,int count_max) gmx_bool make_backup(const char * name) { char * env; - int count_max; + int count_max; char * backup; #ifdef GMX_FAHCORE @@ -444,7 +487,7 @@ gmx_bool make_backup(const char * name) if (env != NULL) { count_max = 0; - sscanf(env,"%d",&count_max); + sscanf(env, "%d", &count_max); if (count_max == -1) { /* Do not make backups and possibly overwrite old files */ @@ -456,11 +499,14 @@ gmx_bool make_backup(const char * name) /* Use the default maximum */ count_max = -1; } - backup = backup_fn(name,count_max); - if(rename(name, backup) == 0) { + backup = backup_fn(name, count_max); + if (rename(name, backup) == 0) + { fprintf(stderr, "\nBack Off! I just backed up %s to %s\n", name, backup); - } else { + } + else + { fprintf(stderr, "Sorry couldn't backup %s to %s\n", name, backup); return FALSE; } @@ -470,63 +516,83 @@ gmx_bool make_backup(const char * name) #endif } -FILE *ffopen(const char *file,const char *mode) +FILE *ffopen(const char *file, const char *mode) { #ifdef SKIP_FFOPS - return fopen(file,mode); + return fopen(file, mode); #else - FILE *ff=NULL; - char buf[256],*bf,*bufsize=0,*ptr; + FILE *ff = NULL; + char buf[256], *bf, *bufsize = 0, *ptr; gmx_bool bRead; - int bs; + int bs; - if (file == NULL) + if (file == NULL) { return NULL; } - if (mode[0]=='w') { + if (mode[0] == 'w') + { make_backup(file); } where(); - bRead= (mode[0]=='r'&&mode[1]!='+'); - strcpy(buf,file); - if (!bRead || gmx_fexist(buf)) { - if ((ff=fopen(buf,mode))==NULL) + bRead = (mode[0] == 'r' && mode[1] != '+'); + strcpy(buf, file); + if (!bRead || gmx_fexist(buf)) + { + if ((ff = fopen(buf, mode)) == NULL) + { gmx_file(buf); + } where(); /* Check whether we should be using buffering (default) or not * (for debugging) */ - if (bUnbuffered || ((bufsize=getenv("LOG_BUFS")) != NULL)) { + if (bUnbuffered || ((bufsize = getenv("LOG_BUFS")) != NULL)) + { /* Check whether to use completely unbuffered */ if (bUnbuffered) + { bs = 0; + } else - bs=strtol(bufsize, NULL, 10); + { + bs = strtol(bufsize, NULL, 10); + } if (bs <= 0) - setbuf(ff,NULL); - else { - snew(ptr,bs+8); - if (setvbuf(ff,ptr,_IOFBF,bs) != 0) + { + setbuf(ff, NULL); + } + else + { + snew(ptr, bs+8); + if (setvbuf(ff, ptr, _IOFBF, bs) != 0) + { gmx_file("Buffering File"); + } } } where(); } - else { - sprintf(buf,"%s.Z",file); - if (gmx_fexist(buf)) { - ff=uncompress(buf,mode); + else + { + sprintf(buf, "%s.Z", file); + if (gmx_fexist(buf)) + { + ff = uncompress(buf, mode); } - else { - sprintf(buf,"%s.gz",file); - if (gmx_fexist(buf)) { - ff=gunzip(buf,mode); + else + { + sprintf(buf, "%s.gz", file); + if (gmx_fexist(buf)) + { + ff = gunzip(buf, mode); } - else + else + { gmx_file(file); + } } } return ff; @@ -543,66 +609,66 @@ struct gmx_directory struct _finddata_t finddata; int first; #else - int dummy; + int dummy; #endif }; int -gmx_directory_open(gmx_directory_t *p_gmxdir,const char *dirname) +gmx_directory_open(gmx_directory_t *p_gmxdir, const char *dirname) { struct gmx_directory * gmxdir; int rc; - - snew(gmxdir,1); - + + snew(gmxdir, 1); + *p_gmxdir = gmxdir; - + #ifdef HAVE_DIRENT_H - if( (gmxdir->dirent_handle = opendir(dirname)) != NULL) + if ( (gmxdir->dirent_handle = opendir(dirname)) != NULL) { rc = 0; } - else + else { sfree(gmxdir); *p_gmxdir = NULL; rc = EINVAL; } #elif (defined GMX_NATIVE_WINDOWS) - - if(dirname!=NULL && strlen(dirname)>0) + + if (dirname != NULL && strlen(dirname) > 0) { char * tmpname; size_t namelength; int len; - + len = strlen(dirname); - snew(tmpname,len+3); - - strncpy(tmpname,dirname,len+1); - + snew(tmpname, len+3); + + strncpy(tmpname, dirname, len+1); + /* Remove possible trailing directory separator */ - if(tmpname[len]=='/' || tmpname[len]=='\\') + if (tmpname[len] == '/' || tmpname[len] == '\\') { - tmpname[len]='\0'; + tmpname[len] = '\0'; } - + /* Add wildcard */ - strcat(tmpname,"/*"); - + strcat(tmpname, "/*"); + gmxdir->first = 1; - if( (gmxdir->windows_handle=_findfirst(tmpname,&gmxdir->finddata))>0L) + if ( (gmxdir->windows_handle = _findfirst(tmpname, &gmxdir->finddata)) > 0L) { rc = 0; } else { - if(errno==EINVAL) + if (errno == EINVAL) { sfree(gmxdir); *p_gmxdir = NULL; - rc = EINVAL; + rc = EINVAL; } else { @@ -627,17 +693,17 @@ gmx_directory_open(gmx_directory_t *p_gmxdir,const char *dirname) int -gmx_directory_nextfile(gmx_directory_t gmxdir,char *name,int maxlength_name) +gmx_directory_nextfile(gmx_directory_t gmxdir, char *name, int maxlength_name) { int rc; - + #ifdef HAVE_DIRENT_H - + struct dirent * direntp_large; struct dirent * p; - - - if(gmxdir!=NULL && gmxdir->dirent_handle!=NULL) + + + if (gmxdir != NULL && gmxdir->dirent_handle != NULL) { /* On some platforms no space is present for d_name in dirent. * Since d_name is guaranteed to be the last entry, allocating @@ -645,11 +711,11 @@ gmx_directory_nextfile(gmx_directory_t gmxdir,char *name,int maxlength_name) * GMX_MAX_PATH should always be >= the max possible d_name. */ smalloc(direntp_large, sizeof(*direntp_large) + GMX_PATH_MAX); - rc = readdir_r(gmxdir->dirent_handle,direntp_large,&p); + rc = readdir_r(gmxdir->dirent_handle, direntp_large, &p); - if(p!=NULL && rc==0) + if (p != NULL && rc == 0) { - strncpy(name,direntp_large->d_name,maxlength_name); + strncpy(name, direntp_large->d_name, maxlength_name); } else { @@ -658,33 +724,33 @@ gmx_directory_nextfile(gmx_directory_t gmxdir,char *name,int maxlength_name) } sfree(direntp_large); } - else + else { name[0] = '\0'; rc = EINVAL; } - + #elif (defined GMX_NATIVE_WINDOWS) - - if(gmxdir!=NULL) + + if (gmxdir != NULL) { - if(gmxdir->windows_handle<=0) + if (gmxdir->windows_handle <= 0) { - + name[0] = '\0'; rc = ENOENT; } - else if(gmxdir->first==1) + else if (gmxdir->first == 1) { - strncpy(name,gmxdir->finddata.name,maxlength_name); + strncpy(name, gmxdir->finddata.name, maxlength_name); rc = 0; gmxdir->first = 0; } else { - if(_findnext(gmxdir->windows_handle,&gmxdir->finddata)==0) + if (_findnext(gmxdir->windows_handle, &gmxdir->finddata) == 0) { - strncpy(name,gmxdir->finddata.name,maxlength_name); + strncpy(name, gmxdir->finddata.name, maxlength_name); rc = 0; } else @@ -694,7 +760,7 @@ gmx_directory_nextfile(gmx_directory_t gmxdir,char *name,int maxlength_name) } } } - + #else gmx_fatal(FARGS, "Source compiled without POSIX dirent or windows support - cannot scan directories.\n"); @@ -704,7 +770,7 @@ gmx_directory_nextfile(gmx_directory_t gmxdir,char *name,int maxlength_name) } -int +int gmx_directory_close(gmx_directory_t gmxdir) { int rc; @@ -717,7 +783,7 @@ gmx_directory_close(gmx_directory_t gmxdir) "Source compiled without POSIX dirent or windows support - cannot scan directories.\n"); rc = -1; #endif - + sfree(gmxdir); return rc; } @@ -725,36 +791,40 @@ gmx_directory_close(gmx_directory_t gmxdir) static gmx_bool search_subdirs(const char *parent, char *libdir) { - char *ptr; + char *ptr; gmx_bool found; /* Search a few common subdirectory names for the gromacs library dir */ - sprintf(libdir,"%s%cshare%ctop%cgurgle.dat",parent, - DIR_SEPARATOR,DIR_SEPARATOR,DIR_SEPARATOR); - found=gmx_fexist(libdir); - if(!found) { - sprintf(libdir,"%s%cshare%cgromacs%ctop%cgurgle.dat",parent, - DIR_SEPARATOR,DIR_SEPARATOR, - DIR_SEPARATOR,DIR_SEPARATOR); - found=gmx_fexist(libdir); - } - if(!found) { - sprintf(libdir,"%s%cshare%cgromacs-%s%ctop%cgurgle.dat",parent, - DIR_SEPARATOR,DIR_SEPARATOR,VERSION, - DIR_SEPARATOR,DIR_SEPARATOR); - found=gmx_fexist(libdir); - } - if(!found) { - sprintf(libdir,"%s%cshare%cgromacs%cgromacs-%s%ctop%cgurgle.dat",parent, - DIR_SEPARATOR,DIR_SEPARATOR,DIR_SEPARATOR, - VERSION,DIR_SEPARATOR,DIR_SEPARATOR); - found=gmx_fexist(libdir); - } + sprintf(libdir, "%s%cshare%ctop%cgurgle.dat", parent, + DIR_SEPARATOR, DIR_SEPARATOR, DIR_SEPARATOR); + found = gmx_fexist(libdir); + if (!found) + { + sprintf(libdir, "%s%cshare%cgromacs%ctop%cgurgle.dat", parent, + DIR_SEPARATOR, DIR_SEPARATOR, + DIR_SEPARATOR, DIR_SEPARATOR); + found = gmx_fexist(libdir); + } + if (!found) + { + sprintf(libdir, "%s%cshare%cgromacs-%s%ctop%cgurgle.dat", parent, + DIR_SEPARATOR, DIR_SEPARATOR, VERSION, + DIR_SEPARATOR, DIR_SEPARATOR); + found = gmx_fexist(libdir); + } + if (!found) + { + sprintf(libdir, "%s%cshare%cgromacs%cgromacs-%s%ctop%cgurgle.dat", parent, + DIR_SEPARATOR, DIR_SEPARATOR, DIR_SEPARATOR, + VERSION, DIR_SEPARATOR, DIR_SEPARATOR); + found = gmx_fexist(libdir); + } /* Remove the gurgle.dat part from libdir if we found something */ - if(found) { - ptr=strrchr(libdir,DIR_SEPARATOR); /* slash or backslash always present, no check necessary */ - *ptr='\0'; + if (found) + { + ptr = strrchr(libdir, DIR_SEPARATOR); /* slash or backslash always present, no check necessary */ + *ptr = '\0'; } return found; } @@ -767,7 +837,7 @@ static gmx_bool search_subdirs(const char *parent, char *libdir) static gmx_bool filename_is_absolute(char *name) { #ifdef GMX_NATIVE_WINDOWS - return ((name[0] == DIR_SEPARATOR) || ((strlen(name)>3) && strncmp(name+1,":\\",2)) == 0); + return ((name[0] == DIR_SEPARATOR) || ((strlen(name) > 3) && strncmp(name+1, ":\\", 2)) == 0); #else return (name[0] == DIR_SEPARATOR); #endif @@ -776,120 +846,140 @@ static gmx_bool filename_is_absolute(char *name) gmx_bool get_libdir(char *libdir) { #define GMX_BINNAME_MAX 512 - char bin_name[GMX_BINNAME_MAX]; - char buf[GMX_BINNAME_MAX]; - char full_path[GMX_PATH_MAX+GMX_BINNAME_MAX]; - char system_path[GMX_PATH_MAX]; - char *dir,*ptr,*s,*pdum; - gmx_bool found=FALSE; - int i; + char bin_name[GMX_BINNAME_MAX]; + char buf[GMX_BINNAME_MAX]; + char full_path[GMX_PATH_MAX+GMX_BINNAME_MAX]; + char system_path[GMX_PATH_MAX]; + char *dir, *ptr, *s, *pdum; + gmx_bool found = FALSE; + int i; if (Program() != NULL) { - /* First - detect binary name */ - if (strlen(Program()) >= GMX_BINNAME_MAX) - { - gmx_fatal(FARGS,"The name of the binary is longer than the allowed buffer size (%d):\n'%s'",GMX_BINNAME_MAX,Program()); - } - strncpy(bin_name,Program(),GMX_BINNAME_MAX-1); + /* First - detect binary name */ + if (strlen(Program()) >= GMX_BINNAME_MAX) + { + gmx_fatal(FARGS, "The name of the binary is longer than the allowed buffer size (%d):\n'%s'", GMX_BINNAME_MAX, Program()); + } + strncpy(bin_name, Program(), GMX_BINNAME_MAX-1); - /* On windows & cygwin we need to add the .exe extension - * too, or we wont be able to detect that the file exists - */ + /* On windows & cygwin we need to add the .exe extension + * too, or we wont be able to detect that the file exists + */ #if (defined GMX_NATIVE_WINDOWS || defined GMX_CYGWIN) - if(strlen(bin_name)<3 || gmx_strncasecmp(bin_name+strlen(bin_name)-4,".exe",4)) - strcat(bin_name,".exe"); + if (strlen(bin_name) < 3 || gmx_strncasecmp(bin_name+strlen(bin_name)-4, ".exe", 4)) + { + strcat(bin_name, ".exe"); + } #endif - /* Only do the smart search part if we got a real name */ - if (NULL!=bin_name && strncmp(bin_name,"GROMACS",GMX_BINNAME_MAX)) { + /* Only do the smart search part if we got a real name */ + if (NULL != bin_name && strncmp(bin_name, "GROMACS", GMX_BINNAME_MAX)) + { - if (!strchr(bin_name,DIR_SEPARATOR)) { - /* No slash or backslash in name means it must be in the path - search it! */ - /* Add the local dir since it is not in the path on windows */ - gmx_getcwd(system_path, sizeof(system_path)); - sprintf(full_path,"%s%c%s",system_path,DIR_SEPARATOR,bin_name); - found = gmx_is_file(full_path); - if (!found && (s=getenv("PATH")) != NULL) + if (!strchr(bin_name, DIR_SEPARATOR)) { - char *dupped; - - dupped=gmx_strdup(s); - s=dupped; - while(!found && (dir=gmx_strsep(&s, PATH_SEPARATOR)) != NULL) + /* No slash or backslash in name means it must be in the path - search it! */ + /* Add the local dir since it is not in the path on windows */ + gmx_getcwd(system_path, sizeof(system_path)); + sprintf(full_path, "%s%c%s", system_path, DIR_SEPARATOR, bin_name); + found = gmx_is_file(full_path); + if (!found && (s = getenv("PATH")) != NULL) + { + char *dupped; + + dupped = gmx_strdup(s); + s = dupped; + while (!found && (dir = gmx_strsep(&s, PATH_SEPARATOR)) != NULL) + { + sprintf(full_path, "%s%c%s", dir, DIR_SEPARATOR, bin_name); + found = gmx_is_file(full_path); + } + sfree(dupped); + } + if (!found) { - sprintf(full_path,"%s%c%s",dir,DIR_SEPARATOR,bin_name); - found = gmx_is_file(full_path); + return FALSE; } - sfree(dupped); } - if (!found) + else if (!filename_is_absolute(bin_name)) { - return FALSE; + /* name contains directory separators, but + * it does not start at the root, i.e. + * name is relative to the current dir + */ + gmx_getcwd(buf, sizeof(buf)); + sprintf(full_path, "%s%c%s", buf, DIR_SEPARATOR, bin_name); + } + else + { + strncpy(full_path, bin_name, GMX_PATH_MAX); } - } else if (!filename_is_absolute(bin_name)) { - /* name contains directory separators, but - * it does not start at the root, i.e. - * name is relative to the current dir - */ - gmx_getcwd(buf, sizeof(buf)); - sprintf(full_path,"%s%c%s",buf,DIR_SEPARATOR,bin_name); - } else { - strncpy(full_path,bin_name,GMX_PATH_MAX); - } - /* Now we should have a full path and name in full_path, - * but on unix it might be a link, or a link to a link to a link.. - */ + /* Now we should have a full path and name in full_path, + * but on unix it might be a link, or a link to a link to a link.. + */ #ifndef GMX_NATIVE_WINDOWS - while( (i=readlink(full_path,buf,sizeof(buf)-1)) > 0 ) { - buf[i]='\0'; - /* If it doesn't start with "/" it is relative */ - if (buf[0]!=DIR_SEPARATOR) { - strncpy(strrchr(full_path,DIR_SEPARATOR)+1,buf,GMX_PATH_MAX); - } else - strncpy(full_path,buf,GMX_PATH_MAX); - } + while ( (i = readlink(full_path, buf, sizeof(buf)-1)) > 0) + { + buf[i] = '\0'; + /* If it doesn't start with "/" it is relative */ + if (buf[0] != DIR_SEPARATOR) + { + strncpy(strrchr(full_path, DIR_SEPARATOR)+1, buf, GMX_PATH_MAX); + } + else + { + strncpy(full_path, buf, GMX_PATH_MAX); + } + } #endif - /* If running directly from the build tree, try to use the source - * directory. - */ + /* If running directly from the build tree, try to use the source + * directory. + */ #if (defined CMAKE_SOURCE_DIR && defined CMAKE_BINARY_DIR) - if (strncmp(full_path, CMAKE_BINARY_DIR, strlen(CMAKE_BINARY_DIR)) == 0) - { - if (search_subdirs(CMAKE_SOURCE_DIR, libdir)) + if (strncmp(full_path, CMAKE_BINARY_DIR, strlen(CMAKE_BINARY_DIR)) == 0) { - return TRUE; + if (search_subdirs(CMAKE_SOURCE_DIR, libdir)) + { + return TRUE; + } } - } #endif - /* Remove the executable name - it always contains at least one slash */ - *(strrchr(full_path,DIR_SEPARATOR)+1)='\0'; - /* Now we have the full path to the gromacs executable. - * Use it to find the library dir. - */ - found=FALSE; - while(!found && ( (ptr=strrchr(full_path,DIR_SEPARATOR)) != NULL ) ) { - *ptr='\0'; - found=search_subdirs(full_path,libdir); + /* Remove the executable name - it always contains at least one slash */ + *(strrchr(full_path, DIR_SEPARATOR)+1) = '\0'; + /* Now we have the full path to the gromacs executable. + * Use it to find the library dir. + */ + found = FALSE; + while (!found && ( (ptr = strrchr(full_path, DIR_SEPARATOR)) != NULL ) ) + { + *ptr = '\0'; + found = search_subdirs(full_path, libdir); + } } } - } /* End of smart searching. If we didn't find it in our parent tree, - * or if the program name wasn't set, at least try some standard - * locations before giving up, in case we are running from e.g. + * or if the program name wasn't set, at least try some standard + * locations before giving up, in case we are running from e.g. * a users home directory. This only works on unix or cygwin... */ #ifndef GMX_NATIVE_WINDOWS - if(!found) - found=search_subdirs("/usr/local",libdir); - if(!found) - found=search_subdirs("/usr",libdir); - if(!found) - found=search_subdirs("/opt",libdir); + if (!found) + { + found = search_subdirs("/usr/local", libdir); + } + if (!found) + { + found = search_subdirs("/usr", libdir); + } + if (!found) + { + found = search_subdirs("/opt", libdir); + } #endif return found; } @@ -897,23 +987,23 @@ gmx_bool get_libdir(char *libdir) char *low_gmxlibfn(const char *file, gmx_bool bAddCWD, gmx_bool bFatal) { - char *ret; - char *lib,*dir; - char buf[1024]; - char libpath[GMX_PATH_MAX]; - gmx_bool env_is_set=FALSE; - char *s,tmppath[GMX_PATH_MAX]; + char *ret; + char *lib, *dir; + char buf[1024]; + char libpath[GMX_PATH_MAX]; + gmx_bool env_is_set = FALSE; + char *s, tmppath[GMX_PATH_MAX]; /* GMXLIB can be a path now */ - lib=getenv("GMXLIB"); + lib = getenv("GMXLIB"); if (lib != NULL) { - env_is_set=TRUE; - strncpy(libpath,lib,GMX_PATH_MAX); - } + env_is_set = TRUE; + strncpy(libpath, lib, GMX_PATH_MAX); + } else if (!get_libdir(libpath)) { - strncpy(libpath,GMXLIBDIR,GMX_PATH_MAX); + strncpy(libpath, GMXLIBDIR, GMX_PATH_MAX); } ret = NULL; @@ -921,21 +1011,21 @@ char *low_gmxlibfn(const char *file, gmx_bool bAddCWD, gmx_bool bFatal) { ret = gmx_strdup(file); } - else + else { - strncpy(tmppath,libpath,GMX_PATH_MAX); - s=tmppath; - while(ret == NULL && (dir=gmx_strsep(&s, PATH_SEPARATOR)) != NULL ) + strncpy(tmppath, libpath, GMX_PATH_MAX); + s = tmppath; + while (ret == NULL && (dir = gmx_strsep(&s, PATH_SEPARATOR)) != NULL) { - sprintf(buf,"%s%c%s",dir,DIR_SEPARATOR,file); + sprintf(buf, "%s%c%s", dir, DIR_SEPARATOR, file); if (gmx_fexist(buf)) { ret = gmx_strdup(buf); } } - if (ret == NULL && bFatal) + if (ret == NULL && bFatal) { - if (env_is_set) + if (env_is_set) { gmx_fatal(FARGS, "Library file %s not found %sin your GMXLIB path.", @@ -945,7 +1035,7 @@ char *low_gmxlibfn(const char *file, gmx_bool bAddCWD, gmx_bool bFatal) { gmx_fatal(FARGS, "Library file %s not found %sin default directories.\n" - "(You can set the directories to search with the GMXLIB path variable)", + "(You can set the directories to search with the GMXLIB path variable)", file, bAddCWD ? "in current dir nor " : ""); } } @@ -958,19 +1048,24 @@ char *low_gmxlibfn(const char *file, gmx_bool bAddCWD, gmx_bool bFatal) -FILE *low_libopen(const char *file,gmx_bool bFatal) +FILE *low_libopen(const char *file, gmx_bool bFatal) { FILE *ff; char *fn; - fn=low_gmxlibfn(file,TRUE,bFatal); + fn = low_gmxlibfn(file, TRUE, bFatal); - if (fn==NULL) { - ff=NULL; - } else { - if (debug) - fprintf(debug,"Opening library file %s\n",fn); - ff=fopen(fn,"r"); + if (fn == NULL) + { + ff = NULL; + } + else + { + if (debug) + { + fprintf(debug, "Opening library file %s\n", fn); + } + ff = fopen(fn, "r"); } sfree(fn); @@ -979,24 +1074,27 @@ FILE *low_libopen(const char *file,gmx_bool bFatal) char *gmxlibfn(const char *file) { - return low_gmxlibfn(file,TRUE,TRUE); + return low_gmxlibfn(file, TRUE, TRUE); } FILE *libopen(const char *file) { - return low_libopen(file,TRUE); + return low_libopen(file, TRUE); } void gmx_tmpnam(char *buf) { - int i,len,fd; + int i, len, fd; if ((len = strlen(buf)) < 7) - gmx_fatal(FARGS,"Buf passed to gmx_tmpnam must be at least 7 bytes long"); - for(i=len-6; (i0) + + nread = fread(buf, sizeof(char), FILECOPY_BUFSIZE, in); + if (nread > 0) { size_t ret; if (!out) { /* so this is where we open when copy_if_empty is false: here we know we read something. */ - out=fopen(newname, "wb"); + out = fopen(newname, "wb"); if (!out) + { goto error; + } } - ret=fwrite(buf, sizeof(char), nread, out); - if (ret!=nread) + ret = fwrite(buf, sizeof(char), nread, out); + if (ret != nread) { goto error; } } if (ferror(in)) + { goto error; + } } sfree(buf); fclose(in); @@ -1114,9 +1225,13 @@ int gmx_file_copy(const char *oldname, const char *newname, gmx_bool copy_if_emp error: sfree(buf); if (in) + { fclose(in); + } if (out) + { fclose(out); + } return 1; #undef FILECOPY_BUFSIZE } @@ -1124,29 +1239,29 @@ error: int gmx_fsync(FILE *fp) { - int rc=0; + int rc = 0; #ifdef GMX_FAHCORE /* the fahcore defines its own os-independent fsync */ - rc=fah_fsync(fp); + rc = fah_fsync(fp); #else /* GMX_FAHCORE */ { - int fn=-1; + int fn = -1; /* get the file number */ #if defined(HAVE_FILENO) - fn= fileno(fp); + fn = fileno(fp); #elif defined(HAVE__FILENO) - fn= _fileno(fp); + fn = _fileno(fp); #endif /* do the actual fsync */ if (fn >= 0) { #if (defined(HAVE_FSYNC)) - rc=fsync(fn); -#elif (defined(HAVE__COMMIT)) - rc=_commit(fn); + rc = fsync(fn); +#elif (defined(HAVE__COMMIT)) + rc = _commit(fn); #endif } } @@ -1157,14 +1272,18 @@ int gmx_fsync(FILE *fp) #ifdef EINTR /* we don't want to report an error just because fsync() caught a signal. For our purposes, we can just ignore this. */ - if (rc && errno==EINTR) - rc=0; + if (rc && errno == EINTR) + { + rc = 0; + } #endif #ifdef EINVAL - /* we don't want to report an error just because we tried to fsync() + /* we don't want to report an error just because we tried to fsync() stdout, a socket or a pipe. */ - if (rc && errno==EINVAL) - rc=0; + if (rc && errno == EINVAL) + { + rc = 0; + } #endif return rc; } diff --git a/src/gromacs/gmxlib/gbutil.c b/src/gromacs/gmxlib/gbutil.c index bf3f5ada76..9cee81c08a 100644 --- a/src/gromacs/gmxlib/gbutil.c +++ b/src/gromacs/gmxlib/gbutil.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -45,231 +45,281 @@ #include "pbc.h" #include "gbutil.h" -static real dist2(t_pbc *pbc,rvec x,rvec y) +static real dist2(t_pbc *pbc, rvec x, rvec y) { - rvec dx; - - pbc_dx(pbc,x,y,dx); - - return norm2(dx); + rvec dx; + + pbc_dx(pbc, x, y, dx); + + return norm2(dx); } real distance_to_z(rvec x) { - return (sqr(x[XX])+sqr(x[YY])); + return (sqr(x[XX])+sqr(x[YY])); } /*distance_to_z()*/ -static void low_rotate_conf(int natom,rvec *x,real alfa, real beta,real gamma) +static void low_rotate_conf(int natom, rvec *x, real alfa, real beta, real gamma) { - int i; - rvec x_old; - - for (i=0; i longest) + { + max_i = i; + max_j = j; + longest = rij; + } + } + } + /* first check if x[max_i] x[max_j][2]) + { + temp = max_i; + max_i = max_j; + max_j = temp; + } - /*first i am going to look for the longest atom-atom distance*/ - longest=dist2(&pbc,x[0],x[1]); - i=0; - j=1; - for (i=0;(ilongest) { - max_i=i; - max_j=j; - longest=rij; - } + /*set the origin to x[i]*/ + for (m = 0; (m < DIM); m++) + { + origin[m] = x[max_i][m]; } - } - /* first check if x[max_i]x[max_j][2]) { - temp=max_i; - max_i=max_j; - max_j=temp; - } - - /*set the origin to x[i]*/ - for(m=0;(mlongest) { - longest = rzi; - max_i=i; + for (i = 0; (i < natom); i++) + { + for (m = 0; (m < DIM); m++) + { + x[i][m] -= origin[m]; + } } - } - gamma=atan(x[max_i][YY]/x[max_i][XX])-M_PI_2; - rotate_conf(natom,x,v,0,0,gamma); - angle[0]=alfa; - angle[1]=beta; - angle[2]=gamma; + + /* calculate the rotation angles alfa(x_axis) and beta(y_axis) + * the rotation angles must be calculated clockwise looking + * along the rotation axis to the origin* + * alfa (x-axis) + */ + alfa = atan(x[max_j][ZZ]/x[max_j][YY])-M_PI_2; + beta = M_PI_2-atan(x[max_j][ZZ]/x[max_j][XX]); + rotate_conf(natom, x, v, alfa, beta, gamma); + + /* now search the longest distance for rotation along the z_axis */ + longest = distance_to_z(x[0]); + max_i = 0; + for (i = 1; (i < natom); i++) + { + rzi = distance_to_z(x[i]); + if (rzi > longest) + { + longest = rzi; + max_i = i; + } + } + gamma = atan(x[max_i][YY]/x[max_i][XX])-M_PI_2; + rotate_conf(natom, x, v, 0, 0, gamma); + angle[0] = alfa; + angle[1] = beta; + angle[2] = gamma; } /*orient()*/ -void genconf(t_atoms *atoms,rvec *x,rvec *v,real *r,matrix box,ivec n_box) +void genconf(t_atoms *atoms, rvec *x, rvec *v, real *r, matrix box, ivec n_box) { - int i,ix,iy,iz,m,j,imol,offset; - rvec delta; - int nmol; - - nmol=n_box[XX]*n_box[YY]*n_box[ZZ]; - - /*print message*/ - fprintf(stderr,"Generating configuration\n"); - imol=0; - for(ix=0; (ix < n_box[XX]); ix++) { - delta[XX]=ix*box[XX][XX]; - for(iy=0; (iy < n_box[YY]); iy++) { - delta[YY]=iy*box[YY][YY]; - for(iz=0; (iz < n_box[ZZ]); iz++) { - delta[ZZ]=iz*box[ZZ][ZZ]; - offset=imol*atoms->nr; - for (i=0;(i < atoms->nr);i++) { - for (m=0;(m < DIM);m++) - x[offset+i][m]=delta[m]+x[i][m]; - if (v) - for (m=0;(m < DIM);m++) - v[offset+i][m]=v[i][m]; - r[offset+i]=r[i]; + int i, ix, iy, iz, m, j, imol, offset; + rvec delta; + int nmol; + + nmol = n_box[XX]*n_box[YY]*n_box[ZZ]; + + /*print message*/ + fprintf(stderr, "Generating configuration\n"); + imol = 0; + for (ix = 0; (ix < n_box[XX]); ix++) + { + delta[XX] = ix*box[XX][XX]; + for (iy = 0; (iy < n_box[YY]); iy++) + { + delta[YY] = iy*box[YY][YY]; + for (iz = 0; (iz < n_box[ZZ]); iz++) + { + delta[ZZ] = iz*box[ZZ][ZZ]; + offset = imol*atoms->nr; + for (i = 0; (i < atoms->nr); i++) + { + for (m = 0; (m < DIM); m++) + { + x[offset+i][m] = delta[m]+x[i][m]; + } + if (v) + { + for (m = 0; (m < DIM); m++) + { + v[offset+i][m] = v[i][m]; + } + } + r[offset+i] = r[i]; + } + imol++; + } } - imol++; - } } - } - for (i=1;(inr; - int offsres = i*atoms->nres; - for (j=0;(jnr);j++) { - atoms->atomname[offs+j] = atoms->atomname[j]; - atoms->atom[offs+j].resind = atoms->atom[j].resind + offsres; - atoms->resinfo[atoms->atom[offs+j].resind] = - atoms->resinfo[atoms->atom[j].resind]; - atoms->resinfo[atoms->atom[offs+j].resind].nr += offsres; + for (i = 1; (i < nmol); i++) + { + int offs = i*atoms->nr; + int offsres = i*atoms->nres; + for (j = 0; (j < atoms->nr); j++) + { + atoms->atomname[offs+j] = atoms->atomname[j]; + atoms->atom[offs+j].resind = atoms->atom[j].resind + offsres; + atoms->resinfo[atoms->atom[offs+j].resind] = + atoms->resinfo[atoms->atom[j].resind]; + atoms->resinfo[atoms->atom[offs+j].resind].nr += offsres; + } + } + atoms->nr *= nmol; + atoms->nres *= nmol; + for (i = 0; i < DIM; i++) + { + for (j = 0; j < DIM; j++) + { + box[j][i] *= n_box[j]; + } } - } - atoms->nr*=nmol; - atoms->nres*=nmol; - for(i=0; ifeature[feature]!=0); + return (cpuid->feature[feature] != 0); } @@ -196,23 +196,23 @@ gmx_cpuid_feature (gmx_cpuid_t cpuid, #ifdef GMX_X86_AVX_256 static const enum gmx_cpuid_acceleration -compiled_acc = GMX_CPUID_ACCELERATION_X86_AVX_256; + compiled_acc = GMX_CPUID_ACCELERATION_X86_AVX_256; #elif defined GMX_X86_AVX_128_FMA static const enum gmx_cpuid_acceleration -compiled_acc = GMX_CPUID_ACCELERATION_X86_AVX_128_FMA; + compiled_acc = GMX_CPUID_ACCELERATION_X86_AVX_128_FMA; #elif defined GMX_X86_SSE4_1 static const enum gmx_cpuid_acceleration -compiled_acc = GMX_CPUID_ACCELERATION_X86_SSE4_1; + compiled_acc = GMX_CPUID_ACCELERATION_X86_SSE4_1; #elif defined GMX_X86_SSE2 static const enum gmx_cpuid_acceleration -compiled_acc = GMX_CPUID_ACCELERATION_X86_SSE2; + compiled_acc = GMX_CPUID_ACCELERATION_X86_SSE2; #else static const enum gmx_cpuid_acceleration -compiled_acc = GMX_CPUID_ACCELERATION_NONE; + compiled_acc = GMX_CPUID_ACCELERATION_NONE; #endif @@ -242,19 +242,19 @@ execute_x86cpuid(unsigned int level, #if (defined _MSC_VER) int CPUInfo[4]; -#if (_MSC_VER > 1500) || (_MSC_VER==1500 & _MSC_FULL_VER >= 150030729) +#if (_MSC_VER > 1500) || (_MSC_VER == 1500 & _MSC_FULL_VER >= 150030729) /* MSVC 9.0 SP1 or later */ - __cpuidex(CPUInfo,level,ecxval); + __cpuidex(CPUInfo, level, ecxval); rc = 0; #else - __cpuid(CPUInfo,level); + __cpuid(CPUInfo, level); /* Set an error code if the user wanted a non-zero ecxval, since we did not have cpuidex */ - rc = (ecxval>0) ? -1 : 0; + rc = (ecxval > 0) ? -1 : 0; #endif - *eax=CPUInfo[0]; - *ebx=CPUInfo[1]; - *ecx=CPUInfo[2]; - *edx=CPUInfo[3]; + *eax = CPUInfo[0]; + *ebx = CPUInfo[1]; + *ecx = CPUInfo[2]; + *edx = CPUInfo[3]; #elif (defined GMX_X86_GCC_INLINE_ASM) /* for now this means GMX_X86_GCC_INLINE_ASM should be defined, @@ -269,11 +269,11 @@ execute_x86cpuid(unsigned int level, __asm__ __volatile__ ("xchgl %%ebx, %1 \n\t" "cpuid \n\t" "xchgl %%ebx, %1 \n\t" - : "+a"(*eax), "+r"(*ebx), "+c"(*ecx), "+d"(*edx)); + : "+a" (*eax), "+r" (*ebx), "+c" (*ecx), "+d" (*edx)); #else /* i386 without PIC, or x86-64. Things are easy and we can clobber any reg we want :-) */ __asm__ __volatile__ ("cpuid \n\t" - : "+a"(*eax), "+b"(*ebx), "+c"(*ecx), "+d"(*edx)); + : "+a" (*eax), "+b" (*ebx), "+c" (*ecx), "+d" (*edx)); #endif rc = 0; #else @@ -299,49 +299,49 @@ execute_x86cpuid(unsigned int level, static int cpuid_check_common_x86(gmx_cpuid_t cpuid) { - int fn,max_stdfn,max_extfn; - unsigned int eax,ebx,ecx,edx; + int fn, max_stdfn, max_extfn; + unsigned int eax, ebx, ecx, edx; char str[GMX_CPUID_BRAND_MAXLEN]; char * p; /* Find largest standard/extended function input value */ - execute_x86cpuid(0x0,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); max_stdfn = eax; - execute_x86cpuid(0x80000000,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x80000000, 0, &eax, &ebx, &ecx, &edx); max_extfn = eax; p = str; - if(max_extfn>=0x80000005) + if (max_extfn >= 0x80000005) { /* Get CPU brand string */ - for(fn=0x80000002;fn<0x80000005;fn++) + for (fn = 0x80000002; fn < 0x80000005; fn++) { - execute_x86cpuid(fn,0,&eax,&ebx,&ecx,&edx); - memcpy(p,&eax,4); - memcpy(p+4,&ebx,4); - memcpy(p+8,&ecx,4); - memcpy(p+12,&edx,4); - p+=16; + execute_x86cpuid(fn, 0, &eax, &ebx, &ecx, &edx); + memcpy(p, &eax, 4); + memcpy(p+4, &ebx, 4); + memcpy(p+8, &ecx, 4); + memcpy(p+12, &edx, 4); + p += 16; } - *p='\0'; + *p = '\0'; /* Remove empty initial space */ p = str; - while(isspace(*(p))) + while (isspace(*(p))) { p++; } - strncpy(cpuid->brand,p,GMX_CPUID_BRAND_MAXLEN); + strncpy(cpuid->brand, p, GMX_CPUID_BRAND_MAXLEN); } else { - strncpy(cpuid->brand,"Unknown CPU brand",GMX_CPUID_BRAND_MAXLEN); + strncpy(cpuid->brand, "Unknown CPU brand", GMX_CPUID_BRAND_MAXLEN); } /* Find basic CPU properties */ - if(max_stdfn>=1) + if (max_stdfn >= 1) { - execute_x86cpuid(0x1,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); cpuid->family = ((eax & 0x0FF00000) >> 20) + ((eax & 0x00000F00) >> 8); /* Note that extended model should be shifted left 4, so only shift right 12 iso 16. */ @@ -379,17 +379,17 @@ cpuid_check_common_x86(gmx_cpuid_t cpuid) cpuid->stepping = -1; } - if(max_extfn>=0x80000001) + if (max_extfn >= 0x80000001) { - execute_x86cpuid(0x80000001,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x80000001, 0, &eax, &ebx, &ecx, &edx); cpuid->feature[GMX_CPUID_FEATURE_X86_LAHF_LM] = (ecx & (1 << 0)) != 0; cpuid->feature[GMX_CPUID_FEATURE_X86_PDPE1GB] = (edx & (1 << 26)) != 0; cpuid->feature[GMX_CPUID_FEATURE_X86_RDTSCP] = (edx & (1 << 27)) != 0; } - if(max_extfn>=0x80000007) + if (max_extfn >= 0x80000007) { - execute_x86cpuid(0x80000007,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x80000007, 0, &eax, &ebx, &ecx, &edx); cpuid->feature[GMX_CPUID_FEATURE_X86_NONSTOP_TSC] = (edx & (1 << 8)) != 0; } return 0; @@ -404,35 +404,35 @@ static int cpuid_renumber_elements(int *data, int n) { int *unique; - int i,j,nunique,found; + int i, j, nunique, found; unique = malloc(sizeof(int)*n); - - nunique=0; - for(i=0;i0 && unique[j-1]>data[i];j--) + for (j = nunique++; j > 0 && unique[j-1] > data[i]; j--) { - unique[j]=unique[j-1]; + unique[j] = unique[j-1]; } - unique[j]=data[i]; + unique[j] = data[i]; } } /* renumber */ - for(i=0;ihwthread_id = malloc(sizeof(int)*cpuid->nproc); cpuid->core_id = malloc(sizeof(int)*cpuid->nproc); cpuid->package_id = malloc(sizeof(int)*cpuid->nproc); @@ -461,25 +461,25 @@ cpuid_x86_decode_apic_id(gmx_cpuid_t cpuid,int *apic_id,int core_bits,int hwthre hwthread_mask = (1 << hwthread_bits) - 1; core_mask_after_shift = (1 << core_bits) - 1; - - for(i=0;inproc;i++) + + for (i = 0; i < cpuid->nproc; i++) { cpuid->hwthread_id[i] = apic_id[i] & hwthread_mask; cpuid->core_id[i] = (apic_id[i] >> hwthread_bits) & core_mask_after_shift; cpuid->package_id[i] = apic_id[i] >> (core_bits + hwthread_bits); } - - cpuid->npackages = cpuid_renumber_elements(cpuid->package_id,cpuid->nproc); - cpuid->ncores_per_package = cpuid_renumber_elements(cpuid->core_id,cpuid->nproc); - cpuid->nhwthreads_per_core = cpuid_renumber_elements(cpuid->hwthread_id,cpuid->nproc); - + + cpuid->npackages = cpuid_renumber_elements(cpuid->package_id, cpuid->nproc); + cpuid->ncores_per_package = cpuid_renumber_elements(cpuid->core_id, cpuid->nproc); + cpuid->nhwthreads_per_core = cpuid_renumber_elements(cpuid->hwthread_id, cpuid->nproc); + /* Create a locality order array, i.e. first all resources in package0, which in turn * are sorted so we first have all resources in core0, where threads are sorted in order, etc. */ - for(i=0;inproc;i++) + for (i = 0; i < cpuid->nproc; i++) { idx = (cpuid->package_id[i]*cpuid->ncores_per_package + cpuid->core_id[i])*cpuid->nhwthreads_per_core + cpuid->hwthread_id[i]; - cpuid->locality_order[idx]=i; + cpuid->locality_order[idx] = i; } } @@ -488,85 +488,88 @@ cpuid_x86_decode_apic_id(gmx_cpuid_t cpuid,int *apic_id,int core_bits,int hwthre static int cpuid_check_amd_x86(gmx_cpuid_t cpuid) { - int max_stdfn,max_extfn; - unsigned int eax,ebx,ecx,edx; - int hwthread_bits,core_bits; + int max_stdfn, max_extfn; + unsigned int eax, ebx, ecx, edx; + int hwthread_bits, core_bits; int * apic_id; - + cpuid_check_common_x86(cpuid); - execute_x86cpuid(0x0,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); max_stdfn = eax; - execute_x86cpuid(0x80000000,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x80000000, 0, &eax, &ebx, &ecx, &edx); max_extfn = eax; - if(max_extfn>=0x80000001) + if (max_extfn >= 0x80000001) { - execute_x86cpuid(0x80000001,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x80000001, 0, &eax, &ebx, &ecx, &edx); cpuid->feature[GMX_CPUID_FEATURE_X86_SSE4A] = (ecx & (1 << 6)) != 0; cpuid->feature[GMX_CPUID_FEATURE_X86_MISALIGNSSE] = (ecx & (1 << 7)) != 0; cpuid->feature[GMX_CPUID_FEATURE_X86_XOP] = (ecx & (1 << 11)) != 0; cpuid->feature[GMX_CPUID_FEATURE_X86_FMA4] = (ecx & (1 << 16)) != 0; } - + /* Query APIC information on AMD */ - if(max_extfn>=0x80000008) + if (max_extfn >= 0x80000008) { #if (defined HAVE_SCHED_H && defined HAVE_SCHED_SETAFFINITY && defined HAVE_SYSCONF && defined __linux__) /* Linux */ unsigned int i; - cpu_set_t cpuset,save_cpuset; + cpu_set_t cpuset, save_cpuset; cpuid->nproc = sysconf(_SC_NPROCESSORS_ONLN); apic_id = malloc(sizeof(int)*cpuid->nproc); - sched_getaffinity(0,sizeof(cpu_set_t),&save_cpuset); + sched_getaffinity(0, sizeof(cpu_set_t), &save_cpuset); /* Get APIC id from each core */ CPU_ZERO(&cpuset); - for(i=0;inproc;i++) + for (i = 0; i < cpuid->nproc; i++) { - CPU_SET(i,&cpuset); - sched_setaffinity(0,sizeof(cpu_set_t),&cpuset); - execute_x86cpuid(0x1,0,&eax,&ebx,&ecx,&edx); - apic_id[i]=ebx >> 24; - CPU_CLR(i,&cpuset); + CPU_SET(i, &cpuset); + sched_setaffinity(0, sizeof(cpu_set_t), &cpuset); + execute_x86cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); + apic_id[i] = ebx >> 24; + CPU_CLR(i, &cpuset); } /* Reset affinity to the value it had when calling this routine */ - sched_setaffinity(0,sizeof(cpu_set_t),&save_cpuset); + sched_setaffinity(0, sizeof(cpu_set_t), &save_cpuset); #define CPUID_HAVE_APIC #elif defined GMX_NATIVE_WINDOWS /* Windows */ DWORD_PTR i; SYSTEM_INFO sysinfo; - unsigned int save_affinity,affinity; + unsigned int save_affinity, affinity; GetSystemInfo( &sysinfo ); cpuid->nproc = sysinfo.dwNumberOfProcessors; apic_id = malloc(sizeof(int)*cpuid->nproc); /* Get previous affinity mask */ - save_affinity = SetThreadAffinityMask(GetCurrentThread(),1); - for(i=0;inproc;i++) + save_affinity = SetThreadAffinityMask(GetCurrentThread(), 1); + for (i = 0; i < cpuid->nproc; i++) { - SetThreadAffinityMask(GetCurrentThread(),(((DWORD_PTR)1)<> 24; + execute_x86cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); + apic_id[i] = ebx >> 24; } - SetThreadAffinityMask(GetCurrentThread(),save_affinity); + SetThreadAffinityMask(GetCurrentThread(), save_affinity); #define CPUID_HAVE_APIC #endif #ifdef CPUID_HAVE_APIC /* AMD does not support SMT yet - there are no hwthread bits in apic ID */ hwthread_bits = 0; /* Get number of core bits in apic ID - try modern extended method first */ - execute_x86cpuid(0x80000008,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x80000008, 0, &eax, &ebx, &ecx, &edx); core_bits = (ecx >> 12) & 0xf; - if(core_bits==0) + if (core_bits == 0) { /* Legacy method for old single/dual core AMD CPUs */ int i = ecx & 0xF; - for(core_bits=0;(i>>core_bits)>0;core_bits++) ; + for (core_bits = 0; (i>>core_bits) > 0; core_bits++) + { + ; + } } - cpuid_x86_decode_apic_id(cpuid,apic_id,core_bits,hwthread_bits); + cpuid_x86_decode_apic_id(cpuid, apic_id, core_bits, hwthread_bits); cpuid->have_cpu_topology = 1; #endif } @@ -577,99 +580,99 @@ cpuid_check_amd_x86(gmx_cpuid_t cpuid) static int cpuid_check_intel_x86(gmx_cpuid_t cpuid) { - unsigned int max_stdfn,max_extfn; - unsigned int eax,ebx,ecx,edx; - unsigned int max_logical_cores,max_physical_cores; - int hwthread_bits,core_bits; + unsigned int max_stdfn, max_extfn; + unsigned int eax, ebx, ecx, edx; + unsigned int max_logical_cores, max_physical_cores; + int hwthread_bits, core_bits; int * apic_id; cpuid_check_common_x86(cpuid); - execute_x86cpuid(0x0,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); max_stdfn = eax; - execute_x86cpuid(0x80000000,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x80000000, 0, &eax, &ebx, &ecx, &edx); max_extfn = eax; - if(max_stdfn>=1) + if (max_stdfn >= 1) { - execute_x86cpuid(0x1,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); cpuid->feature[GMX_CPUID_FEATURE_X86_PDCM] = (ecx & (1 << 15)) != 0; cpuid->feature[GMX_CPUID_FEATURE_X86_PCID] = (ecx & (1 << 17)) != 0; cpuid->feature[GMX_CPUID_FEATURE_X86_X2APIC] = (ecx & (1 << 21)) != 0; cpuid->feature[GMX_CPUID_FEATURE_X86_TDT] = (ecx & (1 << 24)) != 0; } - if(max_stdfn>=7) + if (max_stdfn >= 7) { - execute_x86cpuid(0x7,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x7, 0, &eax, &ebx, &ecx, &edx); cpuid->feature[GMX_CPUID_FEATURE_X86_AVX2] = (ebx & (1 << 5)) != 0; } /* Check whether Hyper-Threading is enabled, not only supported */ - if(cpuid->feature[GMX_CPUID_FEATURE_X86_HTT] && max_stdfn>=4) + if (cpuid->feature[GMX_CPUID_FEATURE_X86_HTT] && max_stdfn >= 4) { - execute_x86cpuid(0x1,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); max_logical_cores = (ebx >> 16) & 0x0FF; - execute_x86cpuid(0x4,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x4, 0, &eax, &ebx, &ecx, &edx); max_physical_cores = ((eax >> 26) & 0x3F) + 1; /* Clear HTT flag if we only have 1 logical core per physical */ - if(max_logical_cores/max_physical_cores < 2) + if (max_logical_cores/max_physical_cores < 2) { cpuid->feature[GMX_CPUID_FEATURE_X86_HTT] = 0; } } - - if(max_stdfn>=0xB) + + if (max_stdfn >= 0xB) { /* Query x2 APIC information from cores */ #if (defined HAVE_SCHED_H && defined HAVE_SCHED_SETAFFINITY && defined HAVE_SYSCONF && defined __linux__) /* Linux */ unsigned int i; - cpu_set_t cpuset,save_cpuset; + cpu_set_t cpuset, save_cpuset; cpuid->nproc = sysconf(_SC_NPROCESSORS_ONLN); apic_id = malloc(sizeof(int)*cpuid->nproc); - sched_getaffinity(0,sizeof(cpu_set_t),&save_cpuset); + sched_getaffinity(0, sizeof(cpu_set_t), &save_cpuset); /* Get x2APIC ID from each hardware thread */ CPU_ZERO(&cpuset); - for(i=0;inproc;i++) + for (i = 0; i < cpuid->nproc; i++) { - CPU_SET(i,&cpuset); - sched_setaffinity(0,sizeof(cpu_set_t),&cpuset); - execute_x86cpuid(0xB,0,&eax,&ebx,&ecx,&edx); - apic_id[i]=edx; - CPU_CLR(i,&cpuset); + CPU_SET(i, &cpuset); + sched_setaffinity(0, sizeof(cpu_set_t), &cpuset); + execute_x86cpuid(0xB, 0, &eax, &ebx, &ecx, &edx); + apic_id[i] = edx; + CPU_CLR(i, &cpuset); } /* Reset affinity to the value it had when calling this routine */ - sched_setaffinity(0,sizeof(cpu_set_t),&save_cpuset); + sched_setaffinity(0, sizeof(cpu_set_t), &save_cpuset); #define CPUID_HAVE_APIC #elif defined GMX_NATIVE_WINDOWS /* Windows */ DWORD_PTR i; SYSTEM_INFO sysinfo; - unsigned int save_affinity,affinity; + unsigned int save_affinity, affinity; GetSystemInfo( &sysinfo ); cpuid->nproc = sysinfo.dwNumberOfProcessors; apic_id = malloc(sizeof(int)*cpuid->nproc); /* Get previous affinity mask */ - save_affinity = SetThreadAffinityMask(GetCurrentThread(),1); - for(i=0;inproc;i++) + save_affinity = SetThreadAffinityMask(GetCurrentThread(), 1); + for (i = 0; i < cpuid->nproc; i++) { - SetThreadAffinityMask(GetCurrentThread(),(((DWORD_PTR)1)<have_cpu_topology = 1; #endif } @@ -685,26 +688,26 @@ cpuid_check_intel_x86(gmx_cpuid_t cpuid) static enum gmx_cpuid_vendor cpuid_check_vendor(void) { - enum gmx_cpuid_vendor i,vendor; + enum gmx_cpuid_vendor i, vendor; /* Register data used on x86 */ - unsigned int eax,ebx,ecx,edx; + unsigned int eax, ebx, ecx, edx; char vendorstring[13]; /* Set default first */ vendor = GMX_CPUID_VENDOR_UNKNOWN; #ifdef GMX_CPUID_X86 - execute_x86cpuid(0x0,0,&eax,&ebx,&ecx,&edx); + execute_x86cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); - memcpy(vendorstring,&ebx,4); - memcpy(vendorstring+4,&edx,4); - memcpy(vendorstring+8,&ecx,4); + memcpy(vendorstring, &ebx, 4); + memcpy(vendorstring+4, &edx, 4); + memcpy(vendorstring+8, &ecx, 4); - vendorstring[12]='\0'; + vendorstring[12] = '\0'; - for(i=GMX_CPUID_VENDOR_UNKNOWN;ihave_cpu_topology) + + if (cpuid->have_cpu_topology) { *nprocessors = cpuid->nproc; *npackages = cpuid->npackages; @@ -741,7 +744,7 @@ gmx_cpuid_topology(gmx_cpuid_t cpuid, *core_id = cpuid->core_id; *hwthread_id = cpuid->hwthread_id; *locality_order = cpuid->locality_order; - rc = 0; + rc = 0; } else { @@ -755,12 +758,12 @@ enum gmx_cpuid_x86_smt gmx_cpuid_x86_smt(gmx_cpuid_t cpuid) { enum gmx_cpuid_x86_smt rc; - - if(cpuid->have_cpu_topology) + + if (cpuid->have_cpu_topology) { - rc = (cpuid->nhwthreads_per_core>1) ? GMX_CPUID_X86_SMT_ENABLED : GMX_CPUID_X86_SMT_DISABLED; + rc = (cpuid->nhwthreads_per_core > 1) ? GMX_CPUID_X86_SMT_ENABLED : GMX_CPUID_X86_SMT_DISABLED; } - else if(cpuid->vendor==GMX_CPUID_VENDOR_AMD || gmx_cpuid_feature(cpuid,GMX_CPUID_FEATURE_X86_HTT)==0) + else if (cpuid->vendor == GMX_CPUID_VENDOR_AMD || gmx_cpuid_feature(cpuid, GMX_CPUID_FEATURE_X86_HTT) == 0) { rc = GMX_CPUID_X86_SMT_DISABLED; } @@ -776,15 +779,15 @@ int gmx_cpuid_init (gmx_cpuid_t * pcpuid) { gmx_cpuid_t cpuid; - int i; + int i; cpuid = malloc(sizeof(*cpuid)); *pcpuid = cpuid; - for(i=0;ifeature[i]=0; + cpuid->feature[i] = 0; } cpuid->have_cpu_topology = 0; cpuid->nproc = 0; @@ -795,10 +798,10 @@ gmx_cpuid_init (gmx_cpuid_t * pcpuid) cpuid->core_id = NULL; cpuid->hwthread_id = NULL; cpuid->locality_order = NULL; - + cpuid->vendor = cpuid_check_vendor(); - - switch(cpuid->vendor) + + switch (cpuid->vendor) { #ifdef GMX_CPUID_X86 case GMX_CPUID_VENDOR_INTEL: @@ -810,14 +813,14 @@ gmx_cpuid_init (gmx_cpuid_t * pcpuid) #endif default: /* Could not find vendor */ - strncpy(cpuid->brand,"Unknown CPU brand",GMX_CPUID_BRAND_MAXLEN); + strncpy(cpuid->brand, "Unknown CPU brand", GMX_CPUID_BRAND_MAXLEN); cpuid->family = 0; cpuid->model = 0; cpuid->stepping = 0; - - for(i=0;ifeature[i]=0; + cpuid->feature[i] = 0; } cpuid->feature[GMX_CPUID_FEATURE_CANNOTDETECT] = 1; break; @@ -840,54 +843,54 @@ gmx_cpuid_formatstring (gmx_cpuid_t cpuid, char * str, int n) { - int c; - int i; + int c; + int i; enum gmx_cpuid_feature feature; #ifdef _MSC_VER - _snprintf(str,n, + _snprintf(str, n, "Vendor: %s\n" "Brand: %s\n" "Family: %2d Model: %2d Stepping: %2d\n" "Features:", gmx_cpuid_vendor_string[gmx_cpuid_vendor(cpuid)], gmx_cpuid_brand(cpuid), - gmx_cpuid_family(cpuid),gmx_cpuid_model(cpuid),gmx_cpuid_stepping(cpuid)); + gmx_cpuid_family(cpuid), gmx_cpuid_model(cpuid), gmx_cpuid_stepping(cpuid)); #else - snprintf(str,n, + snprintf(str, n, "Vendor: %s\n" "Brand: %s\n" "Family: %2d Model: %2d Stepping: %2d\n" "Features:", gmx_cpuid_vendor_string[gmx_cpuid_vendor(cpuid)], gmx_cpuid_brand(cpuid), - gmx_cpuid_family(cpuid),gmx_cpuid_model(cpuid),gmx_cpuid_stepping(cpuid)); + gmx_cpuid_family(cpuid), gmx_cpuid_model(cpuid), gmx_cpuid_stepping(cpuid)); #endif str[n-1] = '\0'; - c = strlen(str); - n -= c; - str += c; + c = strlen(str); + n -= c; + str += c; - for(feature=GMX_CPUID_FEATURE_CANNOTDETECT;featurevendor]); + printf("%s\n", gmx_cpuid_vendor_string[cpuid->vendor]); } - else if(!strncmp(argv[1],"-brand",3)) + else if (!strncmp(argv[1], "-brand", 3)) { - printf("%s\n",cpuid->brand); + printf("%s\n", cpuid->brand); } - else if(!strncmp(argv[1],"-family",3)) + else if (!strncmp(argv[1], "-family", 3)) { - printf("%d\n",cpuid->family); + printf("%d\n", cpuid->family); } - else if(!strncmp(argv[1],"-model",3)) + else if (!strncmp(argv[1], "-model", 3)) { - printf("%d\n",cpuid->model); + printf("%d\n", cpuid->model); } - else if(!strncmp(argv[1],"-stepping",3)) + else if (!strncmp(argv[1], "-stepping", 3)) { - printf("%d\n",cpuid->stepping); + printf("%d\n", cpuid->stepping); } - else if(!strncmp(argv[1],"-features",3)) + else if (!strncmp(argv[1], "-features", 3)) { cnt = 0; - for(i=0;ifeature[i]==1) + if (cpuid->feature[i] == 1) { - if(cnt++ > 0) + if (cnt++ > 0) { printf(" "); } - printf("%s",gmx_cpuid_feature_string[i]); + printf("%s", gmx_cpuid_feature_string[i]); } } printf("\n"); } - else if(!strncmp(argv[1],"-acceleration",3)) + else if (!strncmp(argv[1], "-acceleration", 3)) { acc = gmx_cpuid_acceleration_suggest(cpuid); - fprintf(stdout,"%s\n",gmx_cpuid_acceleration_string[acc]); + fprintf(stdout, "%s\n", gmx_cpuid_acceleration_string[acc]); } gmx_cpuid_done(cpuid); diff --git a/src/gromacs/gmxlib/gmx_cyclecounter.c b/src/gromacs/gmxlib/gmx_cyclecounter.c index a1f9b4755e..35f8bf07e3 100644 --- a/src/gromacs/gmxlib/gmx_cyclecounter.c +++ b/src/gromacs/gmxlib/gmx_cyclecounter.c @@ -1,6 +1,6 @@ - /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- +/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- + * * - * * This file is part of Gromacs Copyright (c) 1991-2006 * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen. * @@ -11,7 +11,7 @@ * * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org - * + * * And Hey: * Gnomes, ROck Monsters And Chili Sauce */ @@ -35,98 +35,98 @@ /*! \brief Calculate number of seconds per cycle tick on host -* -* This routine runs a timer loop to calibrate the number of -* seconds per the units returned fro gmx_cycles_read(). -* -* \param sampletime Minimum real sample time. It takes some trial-and-error -* to find the correct delay loop size, so the total runtime of -* this routine is about twice this time. -* \return Number of seconds per cycle unit. If it is not possible to -* calculate on this system (for whatever reason) the return value -* will be -1, so check that it is positive before using it. -*/ -double + * + * This routine runs a timer loop to calibrate the number of + * seconds per the units returned fro gmx_cycles_read(). + * + * \param sampletime Minimum real sample time. It takes some trial-and-error + * to find the correct delay loop size, so the total runtime of + * this routine is about twice this time. + * \return Number of seconds per cycle unit. If it is not possible to + * calculate on this system (for whatever reason) the return value + * will be -1, so check that it is positive before using it. + */ +double gmx_cycles_calibrate(double sampletime) { #ifdef _MSC_VER - - /* Windows does not have gettimeofday, but it provides a special - * routine that returns the cycle counter frequency. - */ - LARGE_INTEGER i; - - QueryPerformanceFrequency(&i); - - return 1.0/((double) i.QuadPart); - /* end of MS Windows implementation */ - + + /* Windows does not have gettimeofday, but it provides a special + * routine that returns the cycle counter frequency. + */ + LARGE_INTEGER i; + + QueryPerformanceFrequency(&i); + + return 1.0/((double) i.QuadPart); + /* end of MS Windows implementation */ + #elif (defined HAVE_GETTIMEOFDAY) - - /* generic implementation with gettimeofday() */ - struct timeval t1,t2; - gmx_cycles_t c1,c2; - double timediff,cyclediff; - double d=0.1; /* Dummy variable so we don't optimize away delay loop */ - int i; - - if(!gmx_cycles_have_counter()) + + /* generic implementation with gettimeofday() */ + struct timeval t1, t2; + gmx_cycles_t c1, c2; + double timediff, cyclediff; + double d = 0.1; /* Dummy variable so we don't optimize away delay loop */ + int i; + + if (!gmx_cycles_have_counter()) { return -1; } - -#if (defined(__alpha__) || defined(__alpha)) + +#if (defined(__alpha__) || defined(__alpha)) /* Alpha cannot count to more than 4e9, but I don't expect - * that the architecture will go over 2GHz before it dies, so - * up to 2.0 seconds of sampling should be safe. - */ - if(sampletime>2.0) + * that the architecture will go over 2GHz before it dies, so + * up to 2.0 seconds of sampling should be safe. + */ + if (sampletime > 2.0) { - sampletime=2.0; + sampletime = 2.0; } #endif - + /* Start a timing loop. We want this to be largely independent - * of machine speed, so we need to start with a very small number + * of machine speed, so we need to start with a very small number * of iterations and repeat it until we reach the requested time. * * We call gettimeofday an extra time at the start to avoid cache misses. */ - gettimeofday(&t1,NULL); - gettimeofday(&t1,NULL); - c1=gmx_cycles_read(); - - do + gettimeofday(&t1, NULL); + gettimeofday(&t1, NULL); + c1 = gmx_cycles_read(); + + do { /* just a delay loop. To avoid optimizing it away, we calculate a number - * that will underflow to zero in most cases. By conditionally adding it - * to a result at the end it cannot be removed. n=10000 is arbitrary... - */ - for(i=0;i<10000;i++) - d=d/(1.0+(double)i); + * that will underflow to zero in most cases. By conditionally adding it + * to a result at the end it cannot be removed. n=10000 is arbitrary... + */ + for (i = 0; i < 10000; i++) + { + d = d/(1.0+(double)i); + } /* Read the time again */ - gettimeofday(&t2,NULL); - c2=gmx_cycles_read(); - timediff=(double)(t2.tv_sec-t1.tv_sec)+ + gettimeofday(&t2, NULL); + c2 = gmx_cycles_read(); + timediff = (double)(t2.tv_sec-t1.tv_sec)+ (double)(t2.tv_usec-t1.tv_usec)*1e-6; - } - while( timediff < sampletime ); - - cyclediff=c2-c1; - + } + while (timediff < sampletime); + + cyclediff = c2-c1; + /* Add a very small result so the delay loop cannot be optimized away */ - if(d<1e-30) + if (d < 1e-30) { - timediff+=d; + timediff += d; } - + /* Return seconds per cycle */ return timediff/cyclediff; - + #else /* No timing function available */ return -1; #endif -} - - +} diff --git a/src/gromacs/gmxlib/gmx_detect_hardware.c b/src/gromacs/gmxlib/gmx_detect_hardware.c index 150027514c..2a4dfb470f 100644 --- a/src/gromacs/gmxlib/gmx_detect_hardware.c +++ b/src/gromacs/gmxlib/gmx_detect_hardware.c @@ -1,8 +1,8 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This file is part of GROMACS. - * Copyright (c) 2012- + * Copyright (c) 2012- * * Written by the Gromacs development team under coordination of * David van der Spoel, Berk Hess, and Erik Lindahl. @@ -14,7 +14,7 @@ * * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org - * + * * And Hey: * GROup of MAchos and Cynical Suckers */ @@ -49,7 +49,7 @@ * ridiculous number. */ static unsigned int max_gpu_ids_user = 64; -static const char* invalid_gpuid_hint = +static const char * invalid_gpuid_hint = "A delimiter-free sequence of valid numeric IDs of available GPUs is expected."; /* FW decl. */ @@ -75,22 +75,22 @@ static void sprint_gpus(char *sbuf, const gmx_gpu_info_t *gpu_info, gmx_bool bPr } } -static void print_gpu_detection_stats(FILE *fplog, +static void print_gpu_detection_stats(FILE *fplog, const gmx_gpu_info_t *gpu_info, - const t_commrec *cr) + const t_commrec *cr) { - char onhost[266],stmp[STRLEN]; + char onhost[266], stmp[STRLEN]; int ngpu; ngpu = gpu_info->ncuda_dev; #if defined GMX_MPI && !defined GMX_THREAD_MPI /* We only print the detection on one, of possibly multiple, nodes */ - strncpy(onhost," on host ",10); - gmx_gethostname(onhost+9,256); + strncpy(onhost, " on host ", 10); + gmx_gethostname(onhost+9, 256); #else /* We detect all relevant GPUs */ - strncpy(onhost,"",1); + strncpy(onhost, "", 1); #endif if (ngpu > 0) @@ -105,9 +105,9 @@ static void print_gpu_detection_stats(FILE *fplog, } } -static void print_gpu_use_stats(FILE *fplog, +static void print_gpu_use_stats(FILE *fplog, const gmx_gpu_info_t *gpu_info, - const t_commrec *cr) + const t_commrec *cr) { char sbuf[STRLEN], stmp[STRLEN]; int i, ngpu, ngpu_all; @@ -145,14 +145,14 @@ static void print_gpu_use_stats(FILE *fplog, * to GPU IDs; the order will indicate the process/tMPI thread - GPU assignment. */ static void parse_gpu_id_plain_string(const char *idstr, int *nid, int *idlist) { - int i; + int i; size_t len_idstr; len_idstr = strlen(idstr); if (len_idstr > max_gpu_ids_user) { - gmx_fatal(FARGS,"%d GPU IDs provided, but only at most %d are supported", + gmx_fatal(FARGS, "%d GPU IDs provided, but only at most %d are supported", len_idstr, max_gpu_ids_user); } @@ -187,10 +187,10 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, gmx_hw_info_t *hwinfo, assert(hwinfo); assert(cr); - btMPI = bMPI = FALSE; + btMPI = bMPI = FALSE; bNthreadsAuto = FALSE; #if defined(GMX_THREAD_MPI) - btMPI = TRUE; + btMPI = TRUE; bNthreadsAuto = (ntmpi_requested < 1); #elif defined(GMX_LIB_MPI) bMPI = TRUE; @@ -231,7 +231,7 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, gmx_hw_info_t *hwinfo, /* number of PP processes per node */ npppn = cr->nrank_pp_intranode; - pernode[0] = '\0'; + pernode[0] = '\0'; th_or_proc_plural[0] = '\0'; if (btMPI) { @@ -284,7 +284,7 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, gmx_hw_info_t *hwinfo, else { /* There are more GPUs than tMPI threads; we have to limit the number GPUs used. */ - md_print_warn(cr,fplog, + md_print_warn(cr, fplog, "NOTE: %d GPU%s were detected, but only %d PP thread-MPI thread%s can be started.\n" " %s can use one GPU per PP tread-MPI thread, so only %d GPU%s will be used.%s\n", ngpu, gpu_plural, npppn, th_or_proc_plural, @@ -308,14 +308,14 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, gmx_hw_info_t *hwinfo, gmx_fatal(FARGS, "Incorrect launch configuration: mismatching number of PP %s%s and GPUs%s.\n" "%s was started with %d PP %s%s%s, but you provided %d GPU%s.", - th_or_proc, btMPI ? "s" : "es" , pernode, + th_or_proc, btMPI ? "s" : "es", pernode, ShortProgram(), npppn, th_or_proc, th_or_proc_plural, pernode, ngpu, gpu_plural); } else { if (ngpu > npppn) { - md_print_warn(cr,fplog, + md_print_warn(cr, fplog, "NOTE: potentially sub-optimal launch configuration, %s started with less\n" " PP %s%s%s than GPU%s available.\n" " Each PP %s can use only one GPU, %d GPU%s%s will be used.\n", @@ -342,7 +342,7 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, gmx_hw_info_t *hwinfo, gmx_fatal(FARGS, "Incorrect launch configuration: mismatching number of PP %s%s and GPUs%s.\n" "%s was started with %d PP %s%s%s, but only %d GPU%s were detected.", - th_or_proc, btMPI ? "s" : "es" , pernode, + th_or_proc, btMPI ? "s" : "es", pernode, ShortProgram(), npppn, th_or_proc, th_or_proc_plural, pernode, ngpu, gpu_plural); } #ifdef GMX_MPI @@ -359,11 +359,11 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, gmx_hw_info_t *hwinfo, hwinfo->gpu_info.bDevShare = FALSE; if (hwinfo->gpu_info.bUserSet && (cr->rank_pp_intranode == 0)) { - int i, j, same_count; + int i, j, same_count; gmx_bool bSomeSame, bAllDifferent; - same_count = 0; /* number of GPUs shared among ranks */ - bSomeSame = FALSE; + same_count = 0; /* number of GPUs shared among ranks */ + bSomeSame = FALSE; bAllDifferent = TRUE; for (i = 0; i < ngpu - 1; i++) @@ -388,7 +388,7 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, gmx_hw_info_t *hwinfo, if (bSomeSame) { - md_print_warn(cr,fplog, + md_print_warn(cr, fplog, "NOTE: Potentially sub-optimal launch configuration: you assigned %s to\n" " multiple %s%s; this should be avoided as it can cause\n" " performance loss.\n", @@ -405,7 +405,7 @@ void gmx_check_hw_runconf_consistency(FILE *fplog, gmx_hw_info_t *hwinfo, */ static int get_nthreads_hw_avail(FILE *fplog, const t_commrec *cr) { - int ret = 0; + int ret = 0; #if ((defined(WIN32) || defined( _WIN32 ) || defined(WIN64) || defined( _WIN64 )) && !(defined (__CYGWIN__) || defined (__CYGWIN32__))) /* Windows */ @@ -455,12 +455,12 @@ void gmx_detect_hardware(FILE *fplog, gmx_hw_info_t *hwinfo, gmx_bool bForceUseGPU, gmx_bool bTryUseGPU, const char *gpu_id) { - int i; + int i; const char *env; - char sbuf[STRLEN], stmp[STRLEN]; + char sbuf[STRLEN], stmp[STRLEN]; gmx_hw_info_t *hw; - gmx_gpu_info_t gpuinfo_auto, gpuinfo_user; - gmx_bool bGPUBin; + gmx_gpu_info_t gpuinfo_auto, gpuinfo_user; + gmx_bool bGPUBin; assert(hwinfo); @@ -498,7 +498,7 @@ void gmx_detect_hardware(FILE *fplog, gmx_hw_info_t *hwinfo, } /* run the detection if the binary was compiled with GPU support */ - if (bGPUBin && getenv("GMX_DISABLE_GPU_DETECTION")==NULL) + if (bGPUBin && getenv("GMX_DISABLE_GPU_DETECTION") == NULL) { char detection_error[STRLEN]; @@ -524,7 +524,7 @@ void gmx_detect_hardware(FILE *fplog, gmx_hw_info_t *hwinfo, env = getenv("GMX_GPU_ID"); if (env != NULL && gpu_id != NULL) { - gmx_fatal(FARGS,"GMX_GPU_ID and -gpu_id can not be used at the same time"); + gmx_fatal(FARGS, "GMX_GPU_ID and -gpu_id can not be used at the same time"); } if (env == NULL) { @@ -535,7 +535,7 @@ void gmx_detect_hardware(FILE *fplog, gmx_hw_info_t *hwinfo, if (env != NULL) { int *gpuid, *checkres; - int nid, res; + int nid, res; snew(gpuid, max_gpu_ids_user); snew(checkres, max_gpu_ids_user); diff --git a/src/gromacs/gmxlib/gmx_fatal.c b/src/gromacs/gmxlib/gmx_fatal.c index f4131d6d15..a466a5e0d0 100644 --- a/src/gromacs/gmxlib/gmx_fatal.c +++ b/src/gromacs/gmxlib/gmx_fatal.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -60,14 +60,14 @@ #include "tmpi.h" #endif -static gmx_bool bDebug = FALSE; -static char *fatal_tmp_file = NULL; -static FILE *log_file = NULL; +static gmx_bool bDebug = FALSE; +static char *fatal_tmp_file = NULL; +static FILE *log_file = NULL; #ifdef GMX_THREAD_MPI -static tMPI_Thread_mutex_t debug_mutex=TMPI_THREAD_MUTEX_INITIALIZER; -static tMPI_Thread_mutex_t where_mutex=TMPI_THREAD_MUTEX_INITIALIZER; -static tMPI_Thread_mutex_t fatal_tmp_mutex=TMPI_THREAD_MUTEX_INITIALIZER; +static tMPI_Thread_mutex_t debug_mutex = TMPI_THREAD_MUTEX_INITIALIZER; +static tMPI_Thread_mutex_t where_mutex = TMPI_THREAD_MUTEX_INITIALIZER; +static tMPI_Thread_mutex_t fatal_tmp_mutex = TMPI_THREAD_MUTEX_INITIALIZER; #endif @@ -78,7 +78,7 @@ gmx_bool bDebugMode(void) #if 0 tMPI_Thread_mutex_lock(&debug_mutex); #endif - ret=bDebug; + ret = bDebug; /*#ifdef GMX_THREAD_MPI*/ #if 0 tMPI_Thread_mutex_unlock(&debug_mutex); @@ -88,105 +88,136 @@ gmx_bool bDebugMode(void) void gmx_fatal_set_log_file(FILE *fp) { - log_file = fp; + log_file = fp; } -void _where(const char *file,int line) +void _where(const char *file, int line) { - static gmx_bool bFirst = TRUE; - static int nskip = -1; - static int nwhere = 0; - FILE *fp; - char *temp; - - if ( bFirst ) { -#ifdef GMX_THREAD_MPI - tMPI_Thread_mutex_lock(&where_mutex); - if (bFirst) /* we repeat the check in the locked section because things - might have changed */ + static gmx_bool bFirst = TRUE; + static int nskip = -1; + static int nwhere = 0; + FILE *fp; + char *temp; + + if (bFirst) { +#ifdef GMX_THREAD_MPI + tMPI_Thread_mutex_lock(&where_mutex); + if (bFirst) /* we repeat the check in the locked section because things + might have changed */ + { #endif - if ((temp=getenv("WHERE")) != NULL) - nskip = strtol(temp, NULL, 10); + if ((temp = getenv("WHERE")) != NULL) + { + nskip = strtol(temp, NULL, 10); + } bFirst = FALSE; #ifdef GMX_THREAD_MPI } tMPI_Thread_mutex_unlock(&where_mutex); #endif - } + } - if (nskip >= 0) { - /* Skip the first n occasions, this allows to see where it goes wrong */ - if (nwhere >= nskip) { - if (log_file) - fp = log_file; - else - fp = stderr; - fprintf(fp,"WHERE %d, file %s - line %d\n",nwhere,file,line); + if (nskip >= 0) + { + /* Skip the first n occasions, this allows to see where it goes wrong */ + if (nwhere >= nskip) + { + if (log_file) + { + fp = log_file; + } + else + { + fp = stderr; + } + fprintf(fp, "WHERE %d, file %s - line %d\n", nwhere, file, line); + } + nwhere++; } - nwhere++; - } } -static void bputc(char *msg,int *len,char ch) +static void bputc(char *msg, int *len, char ch) { - msg[(*len)++]=ch; + msg[(*len)++] = ch; } -static void bputs(char *msg,int *len,const char *s,int fld) +static void bputs(char *msg, int *len, const char *s, int fld) { - for (fld-=(int)strlen(s); fld>0; fld--) - bputc(msg,len,' '); - while (*s) - bputc(msg,len,*(s++)); + for (fld -= (int)strlen(s); fld > 0; fld--) + { + bputc(msg, len, ' '); + } + while (*s) + { + bputc(msg, len, *(s++)); + } } -static void bputd(char *msg,int *len,int d) +static void bputd(char *msg, int *len, int d) { - if (d<10) bputc(msg,len,d+'0'); else bputc(msg,len,d-10+'a'); + if (d < 10) + { + bputc(msg, len, d+'0'); + } + else + { + bputc(msg, len, d-10+'a'); + } } -static void bputi(char *msg,int *len,int val,int radix,int fld,gmx_bool bNeg) +static void bputi(char *msg, int *len, int val, int radix, int fld, gmx_bool bNeg) { - int fmax=0; - - if (bNeg) - fmax=1; - - if (valfmax; fld--) - bputc(msg,len,' '); - if (bNeg) - bputc(msg,len,'-'); - bputd(msg,len,val); - } - else - { - if (bNeg) - bputc(msg,len,'-'); - bputi(msg,len,val/radix,radix,fld-1,FALSE); - bputd(msg,len,val%radix); + int fmax = 0; + + if (bNeg) + { + fmax = 1; + } + + if (val < radix) + { + for (fld--; fld > fmax; fld--) + { + bputc(msg, len, ' '); + } + if (bNeg) + { + bputc(msg, len, '-'); + } + bputd(msg, len, val); + } + else + { + if (bNeg) + { + bputc(msg, len, '-'); + } + bputi(msg, len, val/radix, radix, fld-1, FALSE); + bputd(msg, len, val%radix); } } static int getfld(const char **p) { - int fld; + int fld; - fld=0; - while (isdigit(**p)) fld=(fld*10)+((*((*p)++))-'0'); - return fld; + fld = 0; + while (isdigit(**p)) + { + fld = (fld*10)+((*((*p)++))-'0'); + } + return fld; } /*static void _halt(char *file,int line,char *reason) -{ - fprintf(stderr,"\nHALT in file %s line %d because:\n\t%s\n", - file,line,reason); - exit(1); -} -*/ + { + fprintf(stderr,"\nHALT in file %s line %d because:\n\t%s\n", + file,line,reason); + exit(1); + } + */ static int fatal_errno = 0; @@ -195,22 +226,22 @@ static void quit_gmx(const char *msg) #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&debug_mutex); #endif - if (fatal_errno == 0) + if (fatal_errno == 0) { if (log_file) { - fprintf(log_file,"%s\n",msg); + fprintf(log_file, "%s\n", msg); } - fprintf(stderr,"%s\n",msg); - /* we set it to no-zero because if this function is called, something + fprintf(stderr, "%s\n", msg); + /* we set it to no-zero because if this function is called, something has gone wrong */ - fatal_errno=255; + fatal_errno = 255; } - else + else { if (fatal_errno != -1) { - errno=fatal_errno; + errno = fatal_errno; } perror(msg); } @@ -224,13 +255,13 @@ static void quit_gmx(const char *msg) nnodes = gmx_node_num(); noderank = gmx_node_rank(); - if (nnodes > 1) + if (nnodes > 1) { - fprintf(stderr,"Error on node %d, will try to stop all the nodes\n", + fprintf(stderr, "Error on node %d, will try to stop all the nodes\n", noderank); } - gmx_abort(noderank,nnodes,-1); - } + gmx_abort(noderank, nnodes, -1); + } #endif if (debug) @@ -239,9 +270,9 @@ static void quit_gmx(const char *msg) } if (bDebugMode()) { - fprintf(stderr,"dump core (y/n):"); + fprintf(stderr, "dump core (y/n):"); fflush(stderr); - if (toupper(getc(stdin))!='N') + if (toupper(getc(stdin)) != 'N') { (void) abort(); } @@ -261,19 +292,23 @@ static void quit_gmx_noquit(const char *msg) #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&debug_mutex); #endif - if (!fatal_errno) + if (!fatal_errno) { - if (log_file) - fprintf(log_file,"%s\n",msg); - fprintf(stderr,"%s\n",msg); - /* we set it to no-zero because if this function is called, something + if (log_file) + { + fprintf(log_file, "%s\n", msg); + } + fprintf(stderr, "%s\n", msg); + /* we set it to no-zero because if this function is called, something has gone wrong */ - fatal_errno=255; + fatal_errno = 255; } - else + else { if (fatal_errno != -1) - errno=fatal_errno; + { + errno = fatal_errno; + } perror(msg); } @@ -284,11 +319,11 @@ static void quit_gmx_noquit(const char *msg) } if (bDebugMode()) { - fprintf(stderr,"dump core (y/n):"); + fprintf(stderr, "dump core (y/n):"); fflush(stderr); - if (toupper(getc(stdin))!='N') + if (toupper(getc(stdin)) != 'N') { - (void) abort(); + (void) abort(); } } #endif @@ -303,11 +338,15 @@ void _set_fatal_tmp_file(const char *fn, const char *file, int line) #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&fatal_tmp_mutex); #endif - if (fatal_tmp_file == NULL) - fatal_tmp_file = strdup(fn); - else - fprintf(stderr,"BUGWARNING: fatal_tmp_file already set at %s:%d", - file,line); + if (fatal_tmp_file == NULL) + { + fatal_tmp_file = strdup(fn); + } + else + { + fprintf(stderr, "BUGWARNING: fatal_tmp_file already set at %s:%d", + file, line); + } #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&fatal_tmp_mutex); #endif @@ -318,12 +357,16 @@ void _unset_fatal_tmp_file(const char *fn, const char *file, int line) #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&fatal_tmp_mutex); #endif - if (strcmp(fn,fatal_tmp_file) == 0) { - sfree(fatal_tmp_file); - fatal_tmp_file = NULL; - } else - fprintf(stderr,"BUGWARNING: file %s not set as fatal_tmp_file at %s:%d", - fn,file,line); + if (strcmp(fn, fatal_tmp_file) == 0) + { + sfree(fatal_tmp_file); + fatal_tmp_file = NULL; + } + else + { + fprintf(stderr, "BUGWARNING: file %s not set as fatal_tmp_file at %s:%d", + fn, file, line); + } #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&fatal_tmp_mutex); #endif @@ -334,124 +377,138 @@ static void clean_fatal_tmp_file() #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&fatal_tmp_mutex); #endif - if (fatal_tmp_file) { - fprintf(stderr,"Cleaning up temporary file %s\n",fatal_tmp_file); - remove(fatal_tmp_file); - sfree(fatal_tmp_file); - fatal_tmp_file = NULL; - } + if (fatal_tmp_file) + { + fprintf(stderr, "Cleaning up temporary file %s\n", fatal_tmp_file); + remove(fatal_tmp_file); + sfree(fatal_tmp_file); + fatal_tmp_file = NULL; + } #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&fatal_tmp_mutex); #endif } -static void parse_printf_args(const char *fmt,va_list *ap,char *msg) +static void parse_printf_args(const char *fmt, va_list *ap, char *msg) { int len; const char *p; - char cval,*sval; - char ibuf[64],ifmt[64]; - int index,ival,fld; + char cval, *sval; + char ibuf[64], ifmt[64]; + int index, ival, fld; double dval; - + len = 0; - for(p=fmt; *p; p++) + for (p = fmt; *p; p++) { - if (*p!='%') + if (*p != '%') { - bputc(msg,&len,*p); + bputc(msg, &len, *p); } else { p++; fld = getfld(&p); - switch(*p) { - case 'x': - ival = va_arg(*ap,int); - sprintf(ifmt,"0x%%%dx",fld); - sprintf(ibuf,ifmt,(unsigned int)ival); - for(index=0; (index<(int)strlen(ibuf)); index++) - bputc(msg,&len,ibuf[index]); - break; - case 'd': - ival = va_arg(*ap,int); - sprintf(ifmt,"%%%dd",fld); - sprintf(ibuf,ifmt,ival); - for(index=0; (index<(int)strlen(ibuf)); index++) - bputc(msg,&len,ibuf[index]); - break; - case 'u': - ival = va_arg(*ap,unsigned); - sprintf(ifmt,"%%%du",fld); - sprintf(ibuf,ifmt,ival); - for(index=0; (index<(int)strlen(ibuf)); index++) - bputc(msg,&len,ibuf[index]); - break; - case 'f': - dval = va_arg(*ap,double); - sprintf(ifmt,"%%%df",fld); - sprintf(ibuf,ifmt,dval); - for(index=0; (index<(int)strlen(ibuf)); index++) - bputc(msg,&len,ibuf[index]); - break; - case 'g': - dval = va_arg(*ap,double); - sprintf(ifmt,"%%%dg",fld); - sprintf(ibuf,ifmt,dval); - for(index=0; (index<(int)strlen(ibuf)); index++) - bputc(msg,&len,ibuf[index]); - break; - case 'c': - cval = (char) va_arg(*ap,int); /* char is promoted to int */ - bputc(msg,&len,cval); - break; - case 's': - sval = va_arg(*ap,char *); - if (sval == NULL) - sval = strdup("(null)"); - bputs(msg,&len,sval,fld); - break; - case '%': - bputc(msg,&len,*p); - break; - default: - break; + switch (*p) + { + case 'x': + ival = va_arg(*ap, int); + sprintf(ifmt, "0x%%%dx", fld); + sprintf(ibuf, ifmt, (unsigned int)ival); + for (index = 0; (index < (int)strlen(ibuf)); index++) + { + bputc(msg, &len, ibuf[index]); + } + break; + case 'd': + ival = va_arg(*ap, int); + sprintf(ifmt, "%%%dd", fld); + sprintf(ibuf, ifmt, ival); + for (index = 0; (index < (int)strlen(ibuf)); index++) + { + bputc(msg, &len, ibuf[index]); + } + break; + case 'u': + ival = va_arg(*ap, unsigned); + sprintf(ifmt, "%%%du", fld); + sprintf(ibuf, ifmt, ival); + for (index = 0; (index < (int)strlen(ibuf)); index++) + { + bputc(msg, &len, ibuf[index]); + } + break; + case 'f': + dval = va_arg(*ap, double); + sprintf(ifmt, "%%%df", fld); + sprintf(ibuf, ifmt, dval); + for (index = 0; (index < (int)strlen(ibuf)); index++) + { + bputc(msg, &len, ibuf[index]); + } + break; + case 'g': + dval = va_arg(*ap, double); + sprintf(ifmt, "%%%dg", fld); + sprintf(ibuf, ifmt, dval); + for (index = 0; (index < (int)strlen(ibuf)); index++) + { + bputc(msg, &len, ibuf[index]); + } + break; + case 'c': + cval = (char) va_arg(*ap, int); /* char is promoted to int */ + bputc(msg, &len, cval); + break; + case 's': + sval = va_arg(*ap, char *); + if (sval == NULL) + { + sval = strdup("(null)"); + } + bputs(msg, &len, sval, fld); + break; + case '%': + bputc(msg, &len, *p); + break; + default: + break; } } } - bputc(msg,&len,'\0'); + bputc(msg, &len, '\0'); } -void gmx_fatal(int f_errno,const char *file,int line,const char *fmt,...) +void gmx_fatal(int f_errno, const char *file, int line, const char *fmt, ...) { - va_list ap; - char msg[STRLEN]; - - va_start(ap,fmt); + va_list ap; + char msg[STRLEN]; + + va_start(ap, fmt); - clean_fatal_tmp_file(); + clean_fatal_tmp_file(); - parse_printf_args(fmt,&ap,msg); - - va_end(ap); + parse_printf_args(fmt, &ap, msg); + + va_end(ap); #ifdef GMX_THREAD_MPI - tMPI_Thread_mutex_lock(&debug_mutex); + tMPI_Thread_mutex_lock(&debug_mutex); #endif - fatal_errno = f_errno; + fatal_errno = f_errno; #ifdef GMX_THREAD_MPI - tMPI_Thread_mutex_unlock(&debug_mutex); + tMPI_Thread_mutex_unlock(&debug_mutex); #endif - _gmx_error("fatal",msg,file,line); + _gmx_error("fatal", msg, file, line); } -void gmx_fatal_collective(int f_errno,const char *file,int line, - const t_commrec *cr,gmx_domdec_t *dd, - const char *fmt,...) +void gmx_fatal_collective(int f_errno, const char *file, int line, + const t_commrec *cr, gmx_domdec_t *dd, + const char *fmt, ...) { gmx_bool bFinalize; va_list ap; @@ -463,14 +520,14 @@ void gmx_fatal_collective(int f_errno,const char *file,int line, bFinalize = TRUE; #ifdef GMX_MPI - /* Check if we are calling on all processes in MPI_COMM_WORLD */ + /* Check if we are calling on all processes in MPI_COMM_WORLD */ if (cr != NULL) { - MPI_Comm_compare(cr->mpi_comm_mysim,MPI_COMM_WORLD,&result); + MPI_Comm_compare(cr->mpi_comm_mysim, MPI_COMM_WORLD, &result); } else { - MPI_Comm_compare(dd->mpi_comm_all,MPI_COMM_WORLD,&result); + MPI_Comm_compare(dd->mpi_comm_all, MPI_COMM_WORLD, &result); } /* Any result except MPI_UNEQUAL allows us to call MPI_Finalize */ bFinalize = (result != MPI_UNEQUAL); @@ -479,20 +536,20 @@ void gmx_fatal_collective(int f_errno,const char *file,int line, if ((cr != NULL && MASTER(cr) ) || (dd != NULL && DDMASTER(dd))) { - va_start(ap,fmt); - + va_start(ap, fmt); + clean_fatal_tmp_file(); - - parse_printf_args(fmt,&ap,msg); - + + parse_printf_args(fmt, &ap, msg); + va_end(ap); - + #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&debug_mutex); #endif - + fatal_errno = f_errno; - + #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&debug_mutex); #endif @@ -503,7 +560,7 @@ void gmx_fatal_collective(int f_errno,const char *file,int line, set_gmx_error_handler(quit_gmx_noquit); } - _gmx_error("fatal",msg,file,line); + _gmx_error("fatal", msg, file, line); } #ifdef GMX_MPI @@ -514,8 +571,8 @@ void gmx_fatal_collective(int f_errno,const char *file,int line, * to use the return status on a non-master process. * The master process in cr and dd always has global rank 0. */ - MPI_Bcast(&fatal_errno,sizeof(fatal_errno),MPI_BYTE, - 0,MPI_COMM_WORLD); + MPI_Bcast(&fatal_errno, sizeof(fatal_errno), MPI_BYTE, + 0, MPI_COMM_WORLD); /* Finalize nicely instead of aborting */ MPI_Finalize(); @@ -532,29 +589,29 @@ void gmx_fatal_collective(int f_errno,const char *file,int line, exit(fatal_errno); } -void _invalid_case(const char *fn,int line) +void _invalid_case(const char *fn, int line) { - gmx_fatal(FARGS,"Invalid case in switch statement, file %s, line %d", - fn,line); + gmx_fatal(FARGS, "Invalid case in switch statement, file %s, line %d", + fn, line); } -void _unexpected_eof(const char *fn,int line,const char *srcfn,int srcline) +void _unexpected_eof(const char *fn, int line, const char *srcfn, int srcline) { - gmx_fatal(FARGS,"Unexpected end of file in file %s at line %d\n" - "(Source file %s, line %d)",fn,line,srcfn,srcline); + gmx_fatal(FARGS, "Unexpected end of file in file %s at line %d\n" + "(Source file %s, line %d)", fn, line, srcfn, srcline); } -/* +/* * These files are global variables in the gromacs preprocessor * Every routine in a file that includes gmx_fatal.h can write to these * debug channels. Depending on the debuglevel used * 0 to 3 of these filed are redirected to /dev/null * */ -FILE *debug=NULL; -gmx_bool gmx_debug_at=FALSE; +FILE *debug = NULL; +gmx_bool gmx_debug_at = FALSE; -void init_debug (const int dbglevel,const char *dbgfile) +void init_debug (const int dbglevel, const char *dbgfile) { #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&debug_mutex); @@ -562,10 +619,12 @@ void init_debug (const int dbglevel,const char *dbgfile) if (!bDebug) /* another thread hasn't already run this*/ { no_buffers(); - debug=gmx_fio_fopen(dbgfile,"w+"); + debug = gmx_fio_fopen(dbgfile, "w+"); bDebug = TRUE; if (dbglevel >= 2) + { gmx_debug_at = TRUE; + } } #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&debug_mutex); @@ -575,44 +634,46 @@ void init_debug (const int dbglevel,const char *dbgfile) #if (defined __sgi && defined USE_SGI_FPE) static void user_routine(unsigned us[5], int ii[2]) { - fprintf(stderr,"User routine us=(%u,%u,%u,%u,%u) ii=(%d,%d)\n", - us[0],us[1],us[2],us[3],us[4],ii[0],ii[1]); - fprintf(stderr,"Exception encountered! Dumping core\n"); - abort(); + fprintf(stderr, "User routine us=(%u,%u,%u,%u,%u) ii=(%d,%d)\n", + us[0], us[1], us[2], us[3], us[4], ii[0], ii[1]); + fprintf(stderr, "Exception encountered! Dumping core\n"); + abort(); } static void abort_routine(unsigned int **ii) { - fprintf(stderr,"Abort routine\n"); - abort(); + fprintf(stderr, "Abort routine\n"); + abort(); } static void handle_signals(int n) { - fprintf(stderr,"Handle signals: n = %d\n",n); - fprintf(stderr,"Dumping core\n"); - abort(); + fprintf(stderr, "Handle signals: n = %d\n", n); + fprintf(stderr, "Dumping core\n"); + abort(); } void doexceptions(void) { #include #include - int hs[] = { SIGILL, SIGFPE, SIGTRAP, SIGEMT, SIGSYS }; - - int onoff,en_mask,abort_action,i; + int hs[] = { SIGILL, SIGFPE, SIGTRAP, SIGEMT, SIGSYS }; + + int onoff, en_mask, abort_action, i; #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&debug_mutex); #endif - onoff = _DEBUG; - en_mask = _EN_UNDERFL | _EN_OVERFL | _EN_DIVZERO | - _EN_INVALID | _EN_INT_OVERFL; - abort_action = _ABORT_ON_ERROR; - handle_sigfpes(onoff,en_mask,user_routine,abort_action,abort_routine); - - for(i=0; (i= n_max)) { - if (warn_str != NULL) { - strcpy(buf,warn_str); - strcat(buf,"\n"); + char buf[1024]; + + if ((n < n_min) || (n >= n_max)) + { + if (warn_str != NULL) + { + strcpy(buf, warn_str); + strcat(buf, "\n"); + } + else + { + buf[0] = '\0'; + } + + sprintf(buf+strlen(buf), "Variable %s has value %d. It should have been " + "within [ %d .. %d ]\n", var, n, n_min, n_max); + + _gmx_error("range", buf, file, line); } - else - buf[0] = '\0'; - - sprintf(buf+strlen(buf),"Variable %s has value %d. It should have been " - "within [ %d .. %d ]\n",var,n,n_min,n_max); - - _gmx_error("range",buf,file,line); - } } -void gmx_warning(const char *fmt,...) +void gmx_warning(const char *fmt, ...) { va_list ap; char msg[STRLEN]; - va_start(ap,fmt); + va_start(ap, fmt); - parse_printf_args(fmt,&ap,msg); + parse_printf_args(fmt, &ap, msg); va_end(ap); - fprintf(stderr,"\nWARNING: %s\n\n",msg); + fprintf(stderr, "\nWARNING: %s\n\n", msg); } diff --git a/src/gromacs/gmxlib/gmx_omp.c b/src/gromacs/gmxlib/gmx_omp.c index a06c43d902..9dea548dc7 100644 --- a/src/gromacs/gmxlib/gmx_omp.c +++ b/src/gromacs/gmxlib/gmx_omp.c @@ -97,7 +97,7 @@ void gmx_omp_check_thread_affinity(FILE *fplog, const t_commrec *cr, gmx_hw_opt_t *hw_opt) { gmx_bool bKmpAffinitySet, bGompCpuAffinitySet; - char *kmp_env, *gomp_env; + char *kmp_env, *gomp_env; /* no need to worry if internal thread pinning is turned off */ if (hw_opt->thread_affinity == threadaffOFF) @@ -111,15 +111,15 @@ void gmx_omp_check_thread_affinity(FILE *fplog, const t_commrec *cr, * gcc supports. Even if this is not the case (e.g. Mac OS) the user * will only get a warning.*/ bGompCpuAffinitySet = FALSE; - gomp_env = NULL; + gomp_env = NULL; #if defined(__GNUC__) - gomp_env = getenv("GOMP_CPU_AFFINITY"); + gomp_env = getenv("GOMP_CPU_AFFINITY"); bGompCpuAffinitySet = (gomp_env != NULL); #endif /* __GNUC__ */ bKmpAffinitySet = FALSE; #if defined(__INTEL_COMPILER) - kmp_env = getenv("KMP_AFFINITY"); + kmp_env = getenv("KMP_AFFINITY"); bKmpAffinitySet = (kmp_env != NULL); /* disable Intel OpenMP affinity if neither KMP_AFFINITY nor @@ -134,7 +134,7 @@ void gmx_omp_check_thread_affinity(FILE *fplog, const t_commrec *cr, #else /* POSIX */ retval = setenv("KMP_AFFINITY", "disabled", 0); -#endif /* _MSC_VER */ +#endif /* _MSC_VER */ if (debug) { diff --git a/src/gromacs/gmxlib/gmx_omp_nthreads.c b/src/gromacs/gmxlib/gmx_omp_nthreads.c index b5a5a7ace2..f9d3947547 100644 --- a/src/gromacs/gmxlib/gmx_omp_nthreads.c +++ b/src/gromacs/gmxlib/gmx_omp_nthreads.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2010, The GROMACS development team, @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon */ @@ -55,10 +55,10 @@ * algorithmic module in mdrun. */ typedef struct { - int gnth; /**< Global num. of threads per PP or PP+PME process/tMPI thread. */ - int gnth_pme; /**< Global num. of threads per PME only process/tMPI thread. */ + int gnth; /**< Global num. of threads per PP or PP+PME process/tMPI thread. */ + int gnth_pme; /**< Global num. of threads per PME only process/tMPI thread. */ - int nth[emntNR]; /**< Number of threads for each module, indexed with module_nth_t */ + int nth[emntNR]; /**< Number of threads for each module, indexed with module_nth_t */ gmx_bool initialized; /**< TRUE if the module as been initialized. */ } omp_module_nthreads_t; @@ -111,9 +111,9 @@ static int pick_module_nthreads(FILE *fplog, int m, gmx_bool bFullOmpSupport, gmx_bool bSepPME) { - char *env; - int nth; - char sbuf[STRLEN]; + char *env; + int nth; + char sbuf[STRLEN]; gmx_bool bOMP; #ifdef GMX_OPENMP @@ -186,12 +186,12 @@ static int pick_module_nthreads(FILE *fplog, int m, return modth.nth[m] = nth; } -void gmx_omp_nthreads_read_env(int *nthreads_omp, +void gmx_omp_nthreads_read_env(int *nthreads_omp, gmx_bool bIsSimMaster) { - char *env; + char *env; gmx_bool bCommandLineSetNthreadsOMP = *nthreads_omp > 0; - char buffer[STRLEN]; + char buffer[STRLEN]; assert(nthreads_omp); @@ -199,15 +199,15 @@ void gmx_omp_nthreads_read_env(int *nthreads_omp, { int nt_omp; - sscanf(env,"%d",&nt_omp); + sscanf(env, "%d", &nt_omp); if (nt_omp <= 0) { - gmx_fatal(FARGS,"OMP_NUM_THREADS is invalid: '%s'",env); + gmx_fatal(FARGS, "OMP_NUM_THREADS is invalid: '%s'", env); } if (bCommandLineSetNthreadsOMP && nt_omp != *nthreads_omp) { - gmx_fatal(FARGS,"Environment variable OMP_NUM_THREADS (%d) and the number of threads requested on the command line (%d) have different values. Either omit one, or set them both to the same value.",nt_omp,*nthreads_omp); + gmx_fatal(FARGS, "Environment variable OMP_NUM_THREADS (%d) and the number of threads requested on the command line (%d) have different values. Either omit one, or set them both to the same value.", nt_omp, *nthreads_omp); } /* Setting the number of OpenMP threads. */ @@ -242,8 +242,8 @@ void gmx_omp_nthreads_init(FILE *fplog, t_commrec *cr, gmx_bool bThisNodePMEOnly, gmx_bool bFullOmpSupport) { - int nth, nth_pmeonly, gmx_maxth, nppn; - char *env; + int nth, nth_pmeonly, gmx_maxth, nppn; + char *env; gmx_bool bSepPME, bOMP; #ifdef GMX_OPENMP @@ -256,7 +256,7 @@ void gmx_omp_nthreads_init(FILE *fplog, t_commrec *cr, nppn = cr->nrank_intranode; bSepPME = ( (cr->duty & DUTY_PP) && !(cr->duty & DUTY_PME)) || - (!(cr->duty & DUTY_PP) && (cr->duty & DUTY_PME)); + (!(cr->duty & DUTY_PP) && (cr->duty & DUTY_PME)); #ifdef GMX_THREAD_MPI /* modth is shared among tMPI threads, so for thread safety do the @@ -374,7 +374,7 @@ void gmx_omp_nthreads_init(FILE *fplog, t_commrec *cr, gmx_omp_set_num_threads(modth.gnth_pme); } else -#endif /* GMX_THREAD_MPI */ +#endif /* GMX_THREAD_MPI */ { if (bFullOmpSupport) { @@ -401,22 +401,22 @@ void gmx_omp_nthreads_init(FILE *fplog, t_commrec *cr, if (bOMP) { #ifdef GMX_THREAD_MPI - const char *mpi_str="per tMPI thread"; + const char *mpi_str = "per tMPI thread"; #else - const char *mpi_str="per MPI process"; + const char *mpi_str = "per MPI process"; #endif /* for group scheme we print PME threads info only */ if (bFullOmpSupport) { md_print_info(cr, fplog, "Using %d OpenMP thread%s %s\n", - modth.gnth,modth.gnth > 1 ? "s" : "", + modth.gnth, modth.gnth > 1 ? "s" : "", cr->nnodes > 1 ? mpi_str : ""); } if (bSepPME && modth.gnth_pme != modth.gnth) { md_print_info(cr, fplog, "Using %d OpenMP thread%s %s for PME\n", - modth.gnth_pme,modth.gnth_pme > 1 ? "s" : "", + modth.gnth_pme, modth.gnth_pme > 1 ? "s" : "", cr->nnodes > 1 ? mpi_str : ""); } } diff --git a/src/gromacs/gmxlib/gmx_random.c b/src/gromacs/gmxlib/gmx_random.c index 524587ea03..6b4a8562ea 100644 --- a/src/gromacs/gmxlib/gmx_random.c +++ b/src/gromacs/gmxlib/gmx_random.c @@ -1,34 +1,34 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 4.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-2008, 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 - * + * * And Hey: * Groningen Machine for Chemical Simulation */ @@ -70,10 +70,10 @@ struct gmx_rng { - unsigned int mt[RNG_N]; - int mti; - int has_saved; - double gauss_saved; + unsigned int mt[RNG_N]; + int mti; + int has_saved; + double gauss_saved; }; @@ -81,67 +81,83 @@ struct gmx_rng { int gmx_rng_n(void) { - return RNG_N; + return RNG_N; } -gmx_rng_t +gmx_rng_t gmx_rng_init(unsigned int seed) { - struct gmx_rng *rng; - - if((rng=(struct gmx_rng *)malloc(sizeof(struct gmx_rng)))==NULL) - return NULL; - - rng->has_saved=0; /* no saved gaussian number yet */ - - rng->mt[0]= seed & 0xffffffffUL; - for (rng->mti=1; rng->mtimti++) { - rng->mt[rng->mti] = - (1812433253UL * (rng->mt[rng->mti-1] ^ - (rng->mt[rng->mti-1] >> 30)) + rng->mti); - /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ - /* In the previous versions, MSBs of the seed affect */ - /* only MSBs of the array mt[]. */ - /* 2002/01/09 modified by Makoto Matsumoto */ - rng->mt[rng->mti] &= 0xffffffffUL; - /* for >32 bit machines */ - } - return rng; + struct gmx_rng *rng; + + if ((rng = (struct gmx_rng *)malloc(sizeof(struct gmx_rng))) == NULL) + { + return NULL; + } + + rng->has_saved = 0; /* no saved gaussian number yet */ + + rng->mt[0] = seed & 0xffffffffUL; + for (rng->mti = 1; rng->mti < RNG_N; rng->mti++) + { + rng->mt[rng->mti] = + (1812433253UL * (rng->mt[rng->mti-1] ^ + (rng->mt[rng->mti-1] >> 30)) + rng->mti); + /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ + /* In the previous versions, MSBs of the seed affect */ + /* only MSBs of the array mt[]. */ + /* 2002/01/09 modified by Makoto Matsumoto */ + rng->mt[rng->mti] &= 0xffffffffUL; + /* for >32 bit machines */ + } + return rng; } -gmx_rng_t +gmx_rng_t gmx_rng_init_array(unsigned int seed[], int seed_length) { - int i, j, k; + int i, j, k; gmx_rng_t rng; - if((rng=gmx_rng_init(19650218UL))==NULL) - return NULL; - - i=1; j=0; - k = (RNG_N>seed_length ? RNG_N : seed_length); - for (; k; k--) { + if ((rng = gmx_rng_init(19650218UL)) == NULL) + { + return NULL; + } + + i = 1; j = 0; + k = (RNG_N > seed_length ? RNG_N : seed_length); + for (; k; k--) + { rng->mt[i] = (rng->mt[i] ^ ((rng->mt[i-1] ^ - (rng->mt[i-1] >> 30)) * 1664525UL)) - + seed[j] + j; /* non linear */ + (rng->mt[i-1] >> 30)) * 1664525UL)) + + seed[j] + j; /* non linear */ rng->mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; j++; - if (i>=RNG_N) { rng->mt[0] = rng->mt[RNG_N-1]; i=1; } - if (j>=seed_length) j=0; + if (i >= RNG_N) + { + rng->mt[0] = rng->mt[RNG_N-1]; i = 1; + } + if (j >= seed_length) + { + j = 0; + } } - for (k=RNG_N-1; k; k--) { - rng->mt[i] = (rng->mt[i] ^ ((rng->mt[i-1] ^ - (rng->mt[i-1] >> 30)) * - 1566083941UL)) - - i; /* non linear */ + for (k = RNG_N-1; k; k--) + { + rng->mt[i] = (rng->mt[i] ^ ((rng->mt[i-1] ^ + (rng->mt[i-1] >> 30)) * + 1566083941UL)) + - i; /* non linear */ rng->mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ i++; - if (i>=RNG_N) { rng->mt[0] = rng->mt[RNG_N-1]; i=1; } + if (i >= RNG_N) + { + rng->mt[0] = rng->mt[RNG_N-1]; i = 1; + } } - rng->mt[0] = 0x80000000UL; - /* MSB is 1; assuring non-zero initial array */ + rng->mt[0] = 0x80000000UL; + /* MSB is 1; assuring non-zero initial array */ return rng; } @@ -149,61 +165,68 @@ gmx_rng_init_array(unsigned int seed[], int seed_length) void gmx_rng_destroy(gmx_rng_t rng) { - if(rng) - free(rng); + if (rng) + { + free(rng); + } } void -gmx_rng_get_state(gmx_rng_t rng, unsigned int *mt,int *mti) +gmx_rng_get_state(gmx_rng_t rng, unsigned int *mt, int *mti) { - int i; + int i; - for(i=0; imt[i]; - } - *mti = rng->mti; + for (i = 0; i < RNG_N; i++) + { + mt[i] = rng->mt[i]; + } + *mti = rng->mti; } void -gmx_rng_set_state(gmx_rng_t rng, unsigned int *mt,int mti) +gmx_rng_set_state(gmx_rng_t rng, unsigned int *mt, int mti) { - int i; + int i; - for(i=0; imt[i] = mt[i]; - } - rng->mti = mti; + for (i = 0; i < RNG_N; i++) + { + rng->mt[i] = mt[i]; + } + rng->mti = mti; } unsigned int gmx_rng_make_seed(void) { - FILE *fp; - unsigned int data; - int ret; - long my_pid; + FILE *fp; + unsigned int data; + int ret; + long my_pid; #ifdef HAVE_UNISTD_H - fp=fopen("/dev/random","rb"); /* will return NULL if it is not present */ + fp = fopen("/dev/random", "rb"); /* will return NULL if it is not present */ #else - fp=NULL; + fp = NULL; #endif - if(fp!=NULL) { - ret=fread(&data,sizeof(unsigned int),1,fp); - fclose(fp); - } else { - /* No random device available, use time-of-day and process id */ + if (fp != NULL) + { + ret = fread(&data, sizeof(unsigned int), 1, fp); + fclose(fp); + } + else + { + /* No random device available, use time-of-day and process id */ #ifdef GMX_NATIVE_WINDOWS - my_pid = (long)_getpid(); + my_pid = (long)_getpid(); #else - my_pid = (long)getpid(); + my_pid = (long)getpid(); #endif - data=(unsigned int)(((long)time(NULL)+my_pid) % (long)1000000); - } - return data; + data = (unsigned int)(((long)time(NULL)+my_pid) % (long)1000000); + } + return data; } @@ -214,13 +237,13 @@ gmx_rng_make_seed(void) static void gmx_rng_update(gmx_rng_t rng) { - unsigned int lastx,x1,x2,y,*mt; - int mti,k; + unsigned int lastx, x1, x2, y, *mt; + int mti, k; const unsigned int mag01[2] = {0x0UL, RNG_MATRIX_A}; /* mag01[x] = x * MATRIX_A for x=0,1 */ /* update random numbers */ - mt = rng->mt; /* pointer to array - avoid repeated dereferencing */ + mt = rng->mt; /* pointer to array - avoid repeated dereferencing */ mti = rng->mti; x1 = mt[0]; @@ -266,7 +289,7 @@ gmx_rng_update(gmx_rng_t rng) y = (x1 & RNG_UPPER_MASK) | (x2 & RNG_LOWER_MASK); mt[k+3] = mt[k+(RNG_M-RNG_N)+3] ^ (y >> 1) ^ mag01[y & 0x1UL]; } - y = (x2 & RNG_UPPER_MASK) | (mt[0] & RNG_LOWER_MASK); + y = (x2 & RNG_UPPER_MASK) | (mt[0] & RNG_LOWER_MASK); mt[RNG_N-1] = mt[RNG_M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; rng->mti = 0; @@ -276,29 +299,34 @@ gmx_rng_update(gmx_rng_t rng) real gmx_rng_gaussian_real(gmx_rng_t rng) { - real x,y,r; - - if(rng->has_saved) { - rng->has_saved=0; - return rng->gauss_saved; - } else { - do { - x=2.0*gmx_rng_uniform_real(rng)-1.0; - y=2.0*gmx_rng_uniform_real(rng)-1.0; - r=x*x+y*y; - } while(r>1.0 || r==0.0); - - r=sqrt(-2.0*log(r)/r); - rng->gauss_saved=y*r; /* save second random number */ - rng->has_saved=1; - return x*r; /* return first random number */ - } + real x, y, r; + + if (rng->has_saved) + { + rng->has_saved = 0; + return rng->gauss_saved; + } + else + { + do + { + x = 2.0*gmx_rng_uniform_real(rng)-1.0; + y = 2.0*gmx_rng_uniform_real(rng)-1.0; + r = x*x+y*y; + } + while (r > 1.0 || r == 0.0); + + r = sqrt(-2.0*log(r)/r); + rng->gauss_saved = y*r; /* save second random number */ + rng->has_saved = 1; + return x*r; /* return first random number */ + } } -/* Return a random unsigned integer, i.e. 0..4294967295 +/* Return a random unsigned integer, i.e. 0..4294967295 * Provided in header file for performace reasons. * Unfortunately this function cannot be inlined, since * it needs to refer the internal-linkage gmx_rng_update(). @@ -306,19 +334,21 @@ gmx_rng_gaussian_real(gmx_rng_t rng) unsigned int gmx_rng_uniform_uint32(gmx_rng_t rng) { - unsigned int y; - - if(rng->mti==RNG_N) - gmx_rng_update(rng); - y=rng->mt[rng->mti++]; - - y ^= (y >> 11); - y ^= (y << 7) & 0x9d2c5680UL; - y ^= (y << 15) & 0xefc60000UL; - y ^= (y >> 18); - - return y; -} + unsigned int y; + + if (rng->mti == RNG_N) + { + gmx_rng_update(rng); + } + y = rng->mt[rng->mti++]; + + y ^= (y >> 11); + y ^= (y << 7) & 0x9d2c5680UL; + y ^= (y << 15) & 0xefc60000UL; + y ^= (y >> 18); + + return y; +} @@ -328,28 +358,30 @@ gmx_rng_uniform_uint32(gmx_rng_t rng) real gmx_rng_uniform_real(gmx_rng_t rng) { - if(sizeof(real)==sizeof(double)) - return ((double)gmx_rng_uniform_uint32(rng))*(1.0/4294967296.0); - else - return ((float)gmx_rng_uniform_uint32(rng))*(1.0/4294967423.0); - /* divided by the smallest number that will generate a - * single precision real number on 0<=x<1. - * This needs to be slightly larger than MAX_UNIT since - * we are limited to an accuracy of 1e-7. - */ + if (sizeof(real) == sizeof(double)) + { + return ((double)gmx_rng_uniform_uint32(rng))*(1.0/4294967296.0); + } + else + { + return ((float)gmx_rng_uniform_uint32(rng))*(1.0/4294967423.0); + } + /* divided by the smallest number that will generate a + * single precision real number on 0<=x<1. + * This needs to be slightly larger than MAX_UNIT since + * we are limited to an accuracy of 1e-7. + */ } -real +real gmx_rng_gaussian_table(gmx_rng_t rng) { - unsigned int i; - - i = gmx_rng_uniform_uint32(rng); - - /* The Gaussian table is a static constant in this file */ - return gaussian_table[i >> GAUSS_SHIFT]; -} + unsigned int i; + i = gmx_rng_uniform_uint32(rng); + /* The Gaussian table is a static constant in this file */ + return gaussian_table[i >> GAUSS_SHIFT]; +} diff --git a/src/gromacs/gmxlib/gmx_random_gausstable.h b/src/gromacs/gmxlib/gmx_random_gausstable.h index 8cfe0feaf7..7dcf9ee774 100644 --- a/src/gromacs/gmxlib/gmx_random_gausstable.h +++ b/src/gromacs/gmxlib/gmx_random_gausstable.h @@ -1,4103 +1,4103 @@ /* 14-bit table for fast gaussian lookup. - * To be included in gmx_random.c + * To be included in gmx_random.c */ -static const real -gaussian_table[16384] = { - -4.0255485e+00,-3.7595601e+00,-3.6167130e+00,-3.5255561e+00, - -3.4572146e+00,-3.4021609e+00,-3.3558927e+00,-3.3158946e+00, - -3.2806098e+00,-3.2490034e+00,-3.2203522e+00,-3.1941290e+00, - -3.1699378e+00,-3.1474738e+00,-3.1264958e+00,-3.1068115e+00, - -3.0882633e+00,-3.0707211e+00,-3.0540769e+00,-3.0382385e+00, - -3.0231280e+00,-3.0086782e+00,-2.9948308e+00,-2.9815352e+00, - -2.9687471e+00,-2.9564269e+00,-2.9445398e+00,-2.9330549e+00, - -2.9219446e+00,-2.9111838e+00,-2.9007499e+00,-2.8906226e+00, - -2.8807836e+00,-2.8712158e+00,-2.8619039e+00,-2.8528337e+00, - -2.8439925e+00,-2.8353682e+00,-2.8269496e+00,-2.8187268e+00, - -2.8106904e+00,-2.8028316e+00,-2.7951422e+00,-2.7876146e+00, - -2.7802417e+00,-2.7730169e+00,-2.7659342e+00,-2.7589874e+00, - -2.7521713e+00,-2.7454808e+00,-2.7389109e+00,-2.7324574e+00, - -2.7261155e+00,-2.7198815e+00,-2.7137513e+00,-2.7077217e+00, - -2.7017887e+00,-2.6959493e+00,-2.6902006e+00,-2.6845396e+00, - -2.6789629e+00,-2.6734686e+00,-2.6680539e+00,-2.6627162e+00, - -2.6574533e+00,-2.6522629e+00,-2.6471431e+00,-2.6420918e+00, - -2.6371069e+00,-2.6321869e+00,-2.6273296e+00,-2.6225336e+00, - -2.6177971e+00,-2.6131189e+00,-2.6084969e+00,-2.6039300e+00, - -2.5994170e+00,-2.5949562e+00,-2.5905464e+00,-2.5861864e+00, - -2.5818748e+00,-2.5776110e+00,-2.5733936e+00,-2.5692213e+00, - -2.5650933e+00,-2.5610085e+00,-2.5569661e+00,-2.5529649e+00, - -2.5490043e+00,-2.5450833e+00,-2.5412009e+00,-2.5373566e+00, - -2.5335493e+00,-2.5297785e+00,-2.5260432e+00,-2.5223429e+00, - -2.5186768e+00,-2.5150442e+00,-2.5114446e+00,-2.5078771e+00, - -2.5043414e+00,-2.5008366e+00,-2.4973624e+00,-2.4939179e+00, - -2.4905028e+00,-2.4871166e+00,-2.4837587e+00,-2.4804285e+00, - -2.4771256e+00,-2.4738493e+00,-2.4705997e+00,-2.4673758e+00, - -2.4641774e+00,-2.4610038e+00,-2.4578550e+00,-2.4547303e+00, - -2.4516294e+00,-2.4485519e+00,-2.4454975e+00,-2.4424658e+00, - -2.4394562e+00,-2.4364686e+00,-2.4335027e+00,-2.4305577e+00, - -2.4276340e+00,-2.4247308e+00,-2.4218478e+00,-2.4189849e+00, - -2.4161417e+00,-2.4133179e+00,-2.4105132e+00,-2.4077272e+00, - -2.4049599e+00,-2.4022110e+00,-2.3994799e+00,-2.3967667e+00, - -2.3940709e+00,-2.3913925e+00,-2.3887312e+00,-2.3860867e+00, - -2.3834586e+00,-2.3808472e+00,-2.3782516e+00,-2.3756721e+00, - -2.3731084e+00,-2.3705599e+00,-2.3680270e+00,-2.3655090e+00, - -2.3630061e+00,-2.3605177e+00,-2.3580439e+00,-2.3555846e+00, - -2.3531394e+00,-2.3507080e+00,-2.3482907e+00,-2.3458867e+00, - -2.3434966e+00,-2.3411195e+00,-2.3387556e+00,-2.3364048e+00, - -2.3340669e+00,-2.3317413e+00,-2.3294287e+00,-2.3271282e+00, - -2.3248401e+00,-2.3225641e+00,-2.3203001e+00,-2.3180478e+00, - -2.3158073e+00,-2.3135784e+00,-2.3113608e+00,-2.3091545e+00, - -2.3069596e+00,-2.3047755e+00,-2.3026025e+00,-2.3004403e+00, - -2.2982888e+00,-2.2961478e+00,-2.2940173e+00,-2.2918973e+00, - -2.2897875e+00,-2.2876878e+00,-2.2855980e+00,-2.2835183e+00, - -2.2814484e+00,-2.2793882e+00,-2.2773378e+00,-2.2752967e+00, - -2.2732651e+00,-2.2712429e+00,-2.2692299e+00,-2.2672260e+00, - -2.2652314e+00,-2.2632456e+00,-2.2612686e+00,-2.2593005e+00, - -2.2573411e+00,-2.2553902e+00,-2.2534480e+00,-2.2515142e+00, - -2.2495890e+00,-2.2476718e+00,-2.2457631e+00,-2.2438622e+00, - -2.2419696e+00,-2.2400849e+00,-2.2382083e+00,-2.2363393e+00, - -2.2344782e+00,-2.2326250e+00,-2.2307792e+00,-2.2289410e+00, - -2.2271104e+00,-2.2252872e+00,-2.2234712e+00,-2.2216625e+00, - -2.2198613e+00,-2.2180672e+00,-2.2162802e+00,-2.2145002e+00, - -2.2127271e+00,-2.2109611e+00,-2.2092018e+00,-2.2074494e+00, - -2.2057037e+00,-2.2039647e+00,-2.2022326e+00,-2.2005067e+00, - -2.1987877e+00,-2.1970749e+00,-2.1953685e+00,-2.1936686e+00, - -2.1919749e+00,-2.1902876e+00,-2.1886065e+00,-2.1869316e+00, - -2.1852627e+00,-2.1835999e+00,-2.1819429e+00,-2.1802921e+00, - -2.1786473e+00,-2.1770084e+00,-2.1753752e+00,-2.1737478e+00, - -2.1721261e+00,-2.1705101e+00,-2.1688998e+00,-2.1672950e+00, - -2.1656959e+00,-2.1641021e+00,-2.1625140e+00,-2.1609311e+00, - -2.1593540e+00,-2.1577818e+00,-2.1562152e+00,-2.1546538e+00, - -2.1530976e+00,-2.1515467e+00,-2.1500008e+00,-2.1484601e+00, - -2.1469245e+00,-2.1453941e+00,-2.1438684e+00,-2.1423478e+00, - -2.1408322e+00,-2.1393216e+00,-2.1378157e+00,-2.1363146e+00, - -2.1348183e+00,-2.1333268e+00,-2.1318402e+00,-2.1303580e+00, - -2.1288807e+00,-2.1274080e+00,-2.1259398e+00,-2.1244762e+00, - -2.1230171e+00,-2.1215627e+00,-2.1201127e+00,-2.1186669e+00, - -2.1172256e+00,-2.1157889e+00,-2.1143565e+00,-2.1129284e+00, - -2.1115043e+00,-2.1100848e+00,-2.1086695e+00,-2.1072583e+00, - -2.1058514e+00,-2.1044486e+00,-2.1030500e+00,-2.1016555e+00, - -2.1002650e+00,-2.0988786e+00,-2.0974960e+00,-2.0961177e+00, - -2.0947433e+00,-2.0933728e+00,-2.0920062e+00,-2.0906434e+00, - -2.0892847e+00,-2.0879297e+00,-2.0865786e+00,-2.0852313e+00, - -2.0838876e+00,-2.0825479e+00,-2.0812118e+00,-2.0798793e+00, - -2.0785506e+00,-2.0772257e+00,-2.0759041e+00,-2.0745864e+00, - -2.0732722e+00,-2.0719616e+00,-2.0706546e+00,-2.0693510e+00, - -2.0680509e+00,-2.0667543e+00,-2.0654614e+00,-2.0641716e+00, - -2.0628855e+00,-2.0616026e+00,-2.0603232e+00,-2.0590472e+00, - -2.0577743e+00,-2.0565050e+00,-2.0552390e+00,-2.0539761e+00, - -2.0527165e+00,-2.0514603e+00,-2.0502071e+00,-2.0489573e+00, - -2.0477107e+00,-2.0464671e+00,-2.0452268e+00,-2.0439897e+00, - -2.0427556e+00,-2.0415246e+00,-2.0402968e+00,-2.0390718e+00, - -2.0378501e+00,-2.0366313e+00,-2.0354156e+00,-2.0342031e+00, - -2.0329933e+00,-2.0317864e+00,-2.0305827e+00,-2.0293818e+00, - -2.0281839e+00,-2.0269887e+00,-2.0257967e+00,-2.0246074e+00, - -2.0234210e+00,-2.0222373e+00,-2.0210567e+00,-2.0198786e+00, - -2.0187035e+00,-2.0175312e+00,-2.0163615e+00,-2.0151947e+00, - -2.0140305e+00,-2.0128691e+00,-2.0117104e+00,-2.0105543e+00, - -2.0094011e+00,-2.0082505e+00,-2.0071025e+00,-2.0059571e+00, - -2.0048144e+00,-2.0036743e+00,-2.0025368e+00,-2.0014019e+00, - -2.0002694e+00,-1.9991397e+00,-1.9980124e+00,-1.9968877e+00, - -1.9957654e+00,-1.9946458e+00,-1.9935286e+00,-1.9924139e+00, - -1.9913017e+00,-1.9901918e+00,-1.9890845e+00,-1.9879795e+00, - -1.9868771e+00,-1.9857770e+00,-1.9846793e+00,-1.9835840e+00, - -1.9824911e+00,-1.9814006e+00,-1.9803123e+00,-1.9792265e+00, - -1.9781430e+00,-1.9770617e+00,-1.9759828e+00,-1.9749062e+00, - -1.9738319e+00,-1.9727598e+00,-1.9716901e+00,-1.9706224e+00, - -1.9695572e+00,-1.9684941e+00,-1.9674332e+00,-1.9663746e+00, - -1.9653181e+00,-1.9642639e+00,-1.9632118e+00,-1.9621619e+00, - -1.9611142e+00,-1.9600686e+00,-1.9590250e+00,-1.9579837e+00, - -1.9569446e+00,-1.9559075e+00,-1.9548724e+00,-1.9538395e+00, - -1.9528086e+00,-1.9517798e+00,-1.9507532e+00,-1.9497285e+00, - -1.9487059e+00,-1.9476854e+00,-1.9466668e+00,-1.9456502e+00, - -1.9446357e+00,-1.9436232e+00,-1.9426126e+00,-1.9416041e+00, - -1.9405975e+00,-1.9395928e+00,-1.9385902e+00,-1.9375895e+00, - -1.9365907e+00,-1.9355938e+00,-1.9345989e+00,-1.9336058e+00, - -1.9326147e+00,-1.9316255e+00,-1.9306381e+00,-1.9296527e+00, - -1.9286691e+00,-1.9276873e+00,-1.9267074e+00,-1.9257294e+00, - -1.9247532e+00,-1.9237788e+00,-1.9228063e+00,-1.9218355e+00, - -1.9208666e+00,-1.9198995e+00,-1.9189342e+00,-1.9179707e+00, - -1.9170089e+00,-1.9160489e+00,-1.9150907e+00,-1.9141341e+00, - -1.9131794e+00,-1.9122264e+00,-1.9112751e+00,-1.9103256e+00, - -1.9093778e+00,-1.9084318e+00,-1.9074874e+00,-1.9065447e+00, - -1.9056036e+00,-1.9046643e+00,-1.9037267e+00,-1.9027907e+00, - -1.9018564e+00,-1.9009237e+00,-1.8999927e+00,-1.8990633e+00, - -1.8981357e+00,-1.8972095e+00,-1.8962852e+00,-1.8953623e+00, - -1.8944410e+00,-1.8935214e+00,-1.8926034e+00,-1.8916869e+00, - -1.8907721e+00,-1.8898588e+00,-1.8889471e+00,-1.8880370e+00, - -1.8871284e+00,-1.8862214e+00,-1.8853159e+00,-1.8844121e+00, - -1.8835096e+00,-1.8826088e+00,-1.8817095e+00,-1.8808116e+00, - -1.8799154e+00,-1.8790206e+00,-1.8781272e+00,-1.8772354e+00, - -1.8763452e+00,-1.8754563e+00,-1.8745691e+00,-1.8736831e+00, - -1.8727987e+00,-1.8719158e+00,-1.8710344e+00,-1.8701543e+00, - -1.8692757e+00,-1.8683985e+00,-1.8675228e+00,-1.8666486e+00, - -1.8657757e+00,-1.8649043e+00,-1.8640343e+00,-1.8631657e+00, - -1.8622985e+00,-1.8614327e+00,-1.8605683e+00,-1.8597052e+00, - -1.8588436e+00,-1.8579834e+00,-1.8571244e+00,-1.8562670e+00, - -1.8554108e+00,-1.8545560e+00,-1.8537025e+00,-1.8528504e+00, - -1.8519996e+00,-1.8511503e+00,-1.8503022e+00,-1.8494554e+00, - -1.8486099e+00,-1.8477658e+00,-1.8469231e+00,-1.8460816e+00, - -1.8452414e+00,-1.8444026e+00,-1.8435649e+00,-1.8427286e+00, - -1.8418936e+00,-1.8410599e+00,-1.8402274e+00,-1.8393962e+00, - -1.8385663e+00,-1.8377377e+00,-1.8369104e+00,-1.8360841e+00, - -1.8352593e+00,-1.8344357e+00,-1.8336133e+00,-1.8327922e+00, - -1.8319722e+00,-1.8311535e+00,-1.8303361e+00,-1.8295199e+00, - -1.8287048e+00,-1.8278910e+00,-1.8270785e+00,-1.8262670e+00, - -1.8254569e+00,-1.8246478e+00,-1.8238400e+00,-1.8230335e+00, - -1.8222280e+00,-1.8214238e+00,-1.8206207e+00,-1.8198187e+00, - -1.8190180e+00,-1.8182185e+00,-1.8174200e+00,-1.8166227e+00, - -1.8158267e+00,-1.8150318e+00,-1.8142380e+00,-1.8134452e+00, - -1.8126537e+00,-1.8118633e+00,-1.8110740e+00,-1.8102859e+00, - -1.8094989e+00,-1.8087131e+00,-1.8079282e+00,-1.8071445e+00, - -1.8063620e+00,-1.8055806e+00,-1.8048003e+00,-1.8040210e+00, - -1.8032428e+00,-1.8024657e+00,-1.8016897e+00,-1.8009149e+00, - -1.8001410e+00,-1.7993683e+00,-1.7985966e+00,-1.7978261e+00, - -1.7970564e+00,-1.7962880e+00,-1.7955205e+00,-1.7947543e+00, - -1.7939889e+00,-1.7932247e+00,-1.7924615e+00,-1.7916993e+00, - -1.7909381e+00,-1.7901781e+00,-1.7894191e+00,-1.7886610e+00, - -1.7879040e+00,-1.7871480e+00,-1.7863930e+00,-1.7856392e+00, - -1.7848862e+00,-1.7841343e+00,-1.7833834e+00,-1.7826334e+00, - -1.7818846e+00,-1.7811366e+00,-1.7803898e+00,-1.7796438e+00, - -1.7788988e+00,-1.7781550e+00,-1.7774119e+00,-1.7766700e+00, - -1.7759290e+00,-1.7751889e+00,-1.7744499e+00,-1.7737118e+00, - -1.7729746e+00,-1.7722385e+00,-1.7715033e+00,-1.7707690e+00, - -1.7700357e+00,-1.7693034e+00,-1.7685720e+00,-1.7678416e+00, - -1.7671120e+00,-1.7663834e+00,-1.7656559e+00,-1.7649292e+00, - -1.7642033e+00,-1.7634785e+00,-1.7627546e+00,-1.7620316e+00, - -1.7613095e+00,-1.7605884e+00,-1.7598681e+00,-1.7591488e+00, - -1.7584304e+00,-1.7577128e+00,-1.7569963e+00,-1.7562805e+00, - -1.7555658e+00,-1.7548518e+00,-1.7541387e+00,-1.7534267e+00, - -1.7527153e+00,-1.7520050e+00,-1.7512956e+00,-1.7505870e+00, - -1.7498792e+00,-1.7491723e+00,-1.7484664e+00,-1.7477614e+00, - -1.7470571e+00,-1.7463537e+00,-1.7456512e+00,-1.7449496e+00, - -1.7442487e+00,-1.7435489e+00,-1.7428498e+00,-1.7421515e+00, - -1.7414541e+00,-1.7407576e+00,-1.7400620e+00,-1.7393671e+00, - -1.7386731e+00,-1.7379799e+00,-1.7372876e+00,-1.7365961e+00, - -1.7359054e+00,-1.7352155e+00,-1.7345265e+00,-1.7338383e+00, - -1.7331510e+00,-1.7324644e+00,-1.7317786e+00,-1.7310936e+00, - -1.7304096e+00,-1.7297263e+00,-1.7290437e+00,-1.7283621e+00, - -1.7276812e+00,-1.7270011e+00,-1.7263217e+00,-1.7256433e+00, - -1.7249656e+00,-1.7242886e+00,-1.7236124e+00,-1.7229371e+00, - -1.7222625e+00,-1.7215887e+00,-1.7209158e+00,-1.7202436e+00, - -1.7195721e+00,-1.7189014e+00,-1.7182316e+00,-1.7175624e+00, - -1.7168940e+00,-1.7162265e+00,-1.7155596e+00,-1.7148936e+00, - -1.7142283e+00,-1.7135637e+00,-1.7128999e+00,-1.7122369e+00, - -1.7115746e+00,-1.7109131e+00,-1.7102523e+00,-1.7095922e+00, - -1.7089329e+00,-1.7082744e+00,-1.7076166e+00,-1.7069595e+00, - -1.7063031e+00,-1.7056475e+00,-1.7049927e+00,-1.7043386e+00, - -1.7036850e+00,-1.7030324e+00,-1.7023804e+00,-1.7017292e+00, - -1.7010787e+00,-1.7004288e+00,-1.6997797e+00,-1.6991314e+00, - -1.6984837e+00,-1.6978368e+00,-1.6971905e+00,-1.6965450e+00, - -1.6959002e+00,-1.6952561e+00,-1.6946126e+00,-1.6939700e+00, - -1.6933279e+00,-1.6926867e+00,-1.6920460e+00,-1.6914060e+00, - -1.6907668e+00,-1.6901283e+00,-1.6894904e+00,-1.6888533e+00, - -1.6882168e+00,-1.6875809e+00,-1.6869458e+00,-1.6863114e+00, - -1.6856776e+00,-1.6850445e+00,-1.6844121e+00,-1.6837804e+00, - -1.6831493e+00,-1.6825190e+00,-1.6818892e+00,-1.6812601e+00, - -1.6806318e+00,-1.6800040e+00,-1.6793770e+00,-1.6787505e+00, - -1.6781248e+00,-1.6774997e+00,-1.6768752e+00,-1.6762514e+00, - -1.6756283e+00,-1.6750058e+00,-1.6743839e+00,-1.6737627e+00, - -1.6731422e+00,-1.6725223e+00,-1.6719030e+00,-1.6712843e+00, - -1.6706663e+00,-1.6700491e+00,-1.6694323e+00,-1.6688162e+00, - -1.6682007e+00,-1.6675860e+00,-1.6669718e+00,-1.6663582e+00, - -1.6657453e+00,-1.6651330e+00,-1.6645213e+00,-1.6639103e+00, - -1.6632998e+00,-1.6626899e+00,-1.6620808e+00,-1.6614722e+00, - -1.6608642e+00,-1.6602569e+00,-1.6596501e+00,-1.6590440e+00, - -1.6584384e+00,-1.6578336e+00,-1.6572292e+00,-1.6566255e+00, - -1.6560224e+00,-1.6554199e+00,-1.6548179e+00,-1.6542166e+00, - -1.6536160e+00,-1.6530159e+00,-1.6524163e+00,-1.6518174e+00, - -1.6512191e+00,-1.6506214e+00,-1.6500242e+00,-1.6494277e+00, - -1.6488316e+00,-1.6482363e+00,-1.6476414e+00,-1.6470473e+00, - -1.6464536e+00,-1.6458606e+00,-1.6452681e+00,-1.6446761e+00, - -1.6440848e+00,-1.6434940e+00,-1.6429038e+00,-1.6423142e+00, - -1.6417252e+00,-1.6411368e+00,-1.6405488e+00,-1.6399615e+00, - -1.6393747e+00,-1.6387885e+00,-1.6382028e+00,-1.6376177e+00, - -1.6370332e+00,-1.6364492e+00,-1.6358658e+00,-1.6352830e+00, - -1.6347007e+00,-1.6341189e+00,-1.6335378e+00,-1.6329571e+00, - -1.6323770e+00,-1.6317974e+00,-1.6312184e+00,-1.6306400e+00, - -1.6300621e+00,-1.6294848e+00,-1.6289079e+00,-1.6283317e+00, - -1.6277559e+00,-1.6271807e+00,-1.6266060e+00,-1.6260319e+00, - -1.6254584e+00,-1.6248852e+00,-1.6243128e+00,-1.6237408e+00, - -1.6231693e+00,-1.6225984e+00,-1.6220280e+00,-1.6214581e+00, - -1.6208887e+00,-1.6203200e+00,-1.6197516e+00,-1.6191839e+00, - -1.6186166e+00,-1.6180499e+00,-1.6174836e+00,-1.6169180e+00, - -1.6163528e+00,-1.6157881e+00,-1.6152240e+00,-1.6146603e+00, - -1.6140972e+00,-1.6135346e+00,-1.6129725e+00,-1.6124109e+00, - -1.6118498e+00,-1.6112893e+00,-1.6107291e+00,-1.6101696e+00, - -1.6096106e+00,-1.6090519e+00,-1.6084939e+00,-1.6079364e+00, - -1.6073793e+00,-1.6068227e+00,-1.6062666e+00,-1.6057111e+00, - -1.6051561e+00,-1.6046015e+00,-1.6040474e+00,-1.6034938e+00, - -1.6029407e+00,-1.6023880e+00,-1.6018360e+00,-1.6012843e+00, - -1.6007332e+00,-1.6001825e+00,-1.5996323e+00,-1.5990826e+00, - -1.5985334e+00,-1.5979847e+00,-1.5974364e+00,-1.5968887e+00, - -1.5963414e+00,-1.5957946e+00,-1.5952482e+00,-1.5947024e+00, - -1.5941570e+00,-1.5936121e+00,-1.5930676e+00,-1.5925237e+00, - -1.5919802e+00,-1.5914371e+00,-1.5908946e+00,-1.5903525e+00, - -1.5898108e+00,-1.5892698e+00,-1.5887290e+00,-1.5881888e+00, - -1.5876490e+00,-1.5871097e+00,-1.5865709e+00,-1.5860325e+00, - -1.5854946e+00,-1.5849571e+00,-1.5844201e+00,-1.5838836e+00, - -1.5833474e+00,-1.5828118e+00,-1.5822767e+00,-1.5817419e+00, - -1.5812076e+00,-1.5806738e+00,-1.5801405e+00,-1.5796075e+00, - -1.5790750e+00,-1.5785429e+00,-1.5780114e+00,-1.5774803e+00, - -1.5769496e+00,-1.5764194e+00,-1.5758895e+00,-1.5753602e+00, - -1.5748312e+00,-1.5743027e+00,-1.5737747e+00,-1.5732471e+00, - -1.5727199e+00,-1.5721931e+00,-1.5716668e+00,-1.5711410e+00, - -1.5706155e+00,-1.5700905e+00,-1.5695660e+00,-1.5690418e+00, - -1.5685182e+00,-1.5679950e+00,-1.5674721e+00,-1.5669496e+00, - -1.5664277e+00,-1.5659060e+00,-1.5653850e+00,-1.5648643e+00, - -1.5643439e+00,-1.5638241e+00,-1.5633047e+00,-1.5627856e+00, - -1.5622671e+00,-1.5617489e+00,-1.5612311e+00,-1.5607138e+00, - -1.5601968e+00,-1.5596803e+00,-1.5591642e+00,-1.5586486e+00, - -1.5581332e+00,-1.5576184e+00,-1.5571040e+00,-1.5565900e+00, - -1.5560763e+00,-1.5555631e+00,-1.5550504e+00,-1.5545379e+00, - -1.5540260e+00,-1.5535144e+00,-1.5530032e+00,-1.5524925e+00, - -1.5519822e+00,-1.5514722e+00,-1.5509626e+00,-1.5504534e+00, - -1.5499448e+00,-1.5494363e+00,-1.5489284e+00,-1.5484209e+00, - -1.5479138e+00,-1.5474070e+00,-1.5469006e+00,-1.5463947e+00, - -1.5458891e+00,-1.5453839e+00,-1.5448792e+00,-1.5443748e+00, - -1.5438708e+00,-1.5433673e+00,-1.5428641e+00,-1.5423613e+00, - -1.5418588e+00,-1.5413568e+00,-1.5408552e+00,-1.5403539e+00, - -1.5398530e+00,-1.5393525e+00,-1.5388525e+00,-1.5383527e+00, - -1.5378534e+00,-1.5373545e+00,-1.5368558e+00,-1.5363576e+00, - -1.5358598e+00,-1.5353625e+00,-1.5348654e+00,-1.5343688e+00, - -1.5338725e+00,-1.5333766e+00,-1.5328810e+00,-1.5323858e+00, - -1.5318911e+00,-1.5313966e+00,-1.5309026e+00,-1.5304090e+00, - -1.5299157e+00,-1.5294228e+00,-1.5289302e+00,-1.5284381e+00, - -1.5279462e+00,-1.5274549e+00,-1.5269638e+00,-1.5264730e+00, - -1.5259827e+00,-1.5254928e+00,-1.5250032e+00,-1.5245140e+00, - -1.5240251e+00,-1.5235366e+00,-1.5230485e+00,-1.5225607e+00, - -1.5220733e+00,-1.5215862e+00,-1.5210996e+00,-1.5206132e+00, - -1.5201272e+00,-1.5196416e+00,-1.5191563e+00,-1.5186715e+00, - -1.5181869e+00,-1.5177027e+00,-1.5172189e+00,-1.5167354e+00, - -1.5162523e+00,-1.5157695e+00,-1.5152872e+00,-1.5148051e+00, - -1.5143234e+00,-1.5138420e+00,-1.5133610e+00,-1.5128803e+00, - -1.5124000e+00,-1.5119201e+00,-1.5114404e+00,-1.5109612e+00, - -1.5104823e+00,-1.5100037e+00,-1.5095254e+00,-1.5090476e+00, - -1.5085701e+00,-1.5080929e+00,-1.5076160e+00,-1.5071396e+00, - -1.5066633e+00,-1.5061876e+00,-1.5057120e+00,-1.5052369e+00, - -1.5047621e+00,-1.5042876e+00,-1.5038135e+00,-1.5033398e+00, - -1.5028663e+00,-1.5023931e+00,-1.5019203e+00,-1.5014479e+00, - -1.5009758e+00,-1.5005040e+00,-1.5000327e+00,-1.4995615e+00, - -1.4990907e+00,-1.4986203e+00,-1.4981502e+00,-1.4976804e+00, - -1.4972110e+00,-1.4967418e+00,-1.4962730e+00,-1.4958045e+00, - -1.4953364e+00,-1.4948686e+00,-1.4944011e+00,-1.4939340e+00, - -1.4934672e+00,-1.4930006e+00,-1.4925345e+00,-1.4920686e+00, - -1.4916031e+00,-1.4911379e+00,-1.4906731e+00,-1.4902085e+00, - -1.4897442e+00,-1.4892803e+00,-1.4888167e+00,-1.4883534e+00, - -1.4878905e+00,-1.4874278e+00,-1.4869655e+00,-1.4865035e+00, - -1.4860418e+00,-1.4855804e+00,-1.4851193e+00,-1.4846586e+00, - -1.4841982e+00,-1.4837381e+00,-1.4832783e+00,-1.4828188e+00, - -1.4823596e+00,-1.4819008e+00,-1.4814422e+00,-1.4809840e+00, - -1.4805261e+00,-1.4800684e+00,-1.4796112e+00,-1.4791541e+00, - -1.4786974e+00,-1.4782411e+00,-1.4777850e+00,-1.4773293e+00, - -1.4768738e+00,-1.4764186e+00,-1.4759638e+00,-1.4755093e+00, - -1.4750550e+00,-1.4746010e+00,-1.4741474e+00,-1.4736941e+00, - -1.4732411e+00,-1.4727883e+00,-1.4723359e+00,-1.4718839e+00, - -1.4714320e+00,-1.4709805e+00,-1.4705293e+00,-1.4700783e+00, - -1.4696277e+00,-1.4691775e+00,-1.4687275e+00,-1.4682777e+00, - -1.4678283e+00,-1.4673791e+00,-1.4669303e+00,-1.4664818e+00, - -1.4660335e+00,-1.4655856e+00,-1.4651378e+00,-1.4646906e+00, - -1.4642434e+00,-1.4637966e+00,-1.4633502e+00,-1.4629040e+00, - -1.4624581e+00,-1.4620124e+00,-1.4615672e+00,-1.4611222e+00, - -1.4606774e+00,-1.4602329e+00,-1.4597887e+00,-1.4593449e+00, - -1.4589013e+00,-1.4584579e+00,-1.4580150e+00,-1.4575722e+00, - -1.4571297e+00,-1.4566876e+00,-1.4562457e+00,-1.4558041e+00, - -1.4553628e+00,-1.4549217e+00,-1.4544810e+00,-1.4540405e+00, - -1.4536004e+00,-1.4531605e+00,-1.4527209e+00,-1.4522815e+00, - -1.4518424e+00,-1.4514037e+00,-1.4509652e+00,-1.4505270e+00, - -1.4500890e+00,-1.4496514e+00,-1.4492140e+00,-1.4487768e+00, - -1.4483401e+00,-1.4479035e+00,-1.4474672e+00,-1.4470313e+00, - -1.4465954e+00,-1.4461601e+00,-1.4457248e+00,-1.4452900e+00, - -1.4448553e+00,-1.4444209e+00,-1.4439869e+00,-1.4435530e+00, - -1.4431195e+00,-1.4426862e+00,-1.4422532e+00,-1.4418205e+00, - -1.4413880e+00,-1.4409558e+00,-1.4405239e+00,-1.4400922e+00, - -1.4396608e+00,-1.4392297e+00,-1.4387989e+00,-1.4383683e+00, - -1.4379380e+00,-1.4375079e+00,-1.4370781e+00,-1.4366486e+00, - -1.4362193e+00,-1.4357903e+00,-1.4353616e+00,-1.4349332e+00, - -1.4345050e+00,-1.4340770e+00,-1.4336493e+00,-1.4332219e+00, - -1.4327947e+00,-1.4323678e+00,-1.4319413e+00,-1.4315149e+00, - -1.4310887e+00,-1.4306629e+00,-1.4302373e+00,-1.4298120e+00, - -1.4293869e+00,-1.4289621e+00,-1.4285375e+00,-1.4281132e+00, - -1.4276892e+00,-1.4272654e+00,-1.4268419e+00,-1.4264185e+00, - -1.4259956e+00,-1.4255728e+00,-1.4251503e+00,-1.4247280e+00, - -1.4243060e+00,-1.4238843e+00,-1.4234627e+00,-1.4230415e+00, - -1.4226205e+00,-1.4221997e+00,-1.4217793e+00,-1.4213591e+00, - -1.4209391e+00,-1.4205194e+00,-1.4200999e+00,-1.4196806e+00, - -1.4192616e+00,-1.4188429e+00,-1.4184244e+00,-1.4180062e+00, - -1.4175881e+00,-1.4171704e+00,-1.4167529e+00,-1.4163357e+00, - -1.4159187e+00,-1.4155020e+00,-1.4150854e+00,-1.4146692e+00, - -1.4142531e+00,-1.4138373e+00,-1.4134218e+00,-1.4130065e+00, - -1.4125915e+00,-1.4121766e+00,-1.4117621e+00,-1.4113477e+00, - -1.4109337e+00,-1.4105198e+00,-1.4101063e+00,-1.4096929e+00, - -1.4092798e+00,-1.4088670e+00,-1.4084543e+00,-1.4080420e+00, - -1.4076297e+00,-1.4072179e+00,-1.4068062e+00,-1.4063947e+00, - -1.4059836e+00,-1.4055727e+00,-1.4051619e+00,-1.4047514e+00, - -1.4043411e+00,-1.4039311e+00,-1.4035214e+00,-1.4031118e+00, - -1.4027026e+00,-1.4022934e+00,-1.4018846e+00,-1.4014760e+00, - -1.4010676e+00,-1.4006594e+00,-1.4002516e+00,-1.3998439e+00, - -1.3994365e+00,-1.3990293e+00,-1.3986223e+00,-1.3982155e+00, - -1.3978090e+00,-1.3974028e+00,-1.3969967e+00,-1.3965909e+00, - -1.3961853e+00,-1.3957800e+00,-1.3953749e+00,-1.3949699e+00, - -1.3945652e+00,-1.3941609e+00,-1.3937566e+00,-1.3933526e+00, - -1.3929489e+00,-1.3925453e+00,-1.3921421e+00,-1.3917389e+00, - -1.3913361e+00,-1.3909335e+00,-1.3905311e+00,-1.3901289e+00, - -1.3897269e+00,-1.3893251e+00,-1.3889236e+00,-1.3885224e+00, - -1.3881214e+00,-1.3877205e+00,-1.3873199e+00,-1.3869195e+00, - -1.3865193e+00,-1.3861194e+00,-1.3857197e+00,-1.3853202e+00, - -1.3849208e+00,-1.3845218e+00,-1.3841230e+00,-1.3837243e+00, - -1.3833259e+00,-1.3829278e+00,-1.3825299e+00,-1.3821321e+00, - -1.3817345e+00,-1.3813373e+00,-1.3809402e+00,-1.3805432e+00, - -1.3801466e+00,-1.3797501e+00,-1.3793540e+00,-1.3789580e+00, - -1.3785622e+00,-1.3781666e+00,-1.3777713e+00,-1.3773761e+00, - -1.3769811e+00,-1.3765864e+00,-1.3761920e+00,-1.3757976e+00, - -1.3754036e+00,-1.3750098e+00,-1.3746161e+00,-1.3742226e+00, - -1.3738295e+00,-1.3734365e+00,-1.3730437e+00,-1.3726511e+00, - -1.3722587e+00,-1.3718666e+00,-1.3714746e+00,-1.3710829e+00, - -1.3706913e+00,-1.3703001e+00,-1.3699089e+00,-1.3695180e+00, - -1.3691274e+00,-1.3687369e+00,-1.3683466e+00,-1.3679565e+00, - -1.3675667e+00,-1.3671770e+00,-1.3667876e+00,-1.3663983e+00, - -1.3660094e+00,-1.3656205e+00,-1.3652319e+00,-1.3648435e+00, - -1.3644553e+00,-1.3640673e+00,-1.3636795e+00,-1.3632919e+00, - -1.3629045e+00,-1.3625174e+00,-1.3621304e+00,-1.3617436e+00, - -1.3613571e+00,-1.3609707e+00,-1.3605845e+00,-1.3601986e+00, - -1.3598129e+00,-1.3594273e+00,-1.3590419e+00,-1.3586568e+00, - -1.3582718e+00,-1.3578871e+00,-1.3575026e+00,-1.3571182e+00, - -1.3567340e+00,-1.3563502e+00,-1.3559663e+00,-1.3555828e+00, - -1.3551995e+00,-1.3548163e+00,-1.3544334e+00,-1.3540506e+00, - -1.3536681e+00,-1.3532858e+00,-1.3529036e+00,-1.3525217e+00, - -1.3521399e+00,-1.3517584e+00,-1.3513770e+00,-1.3509958e+00, - -1.3506148e+00,-1.3502340e+00,-1.3498535e+00,-1.3494731e+00, - -1.3490928e+00,-1.3487129e+00,-1.3483331e+00,-1.3479534e+00, - -1.3475741e+00,-1.3471949e+00,-1.3468158e+00,-1.3464370e+00, - -1.3460584e+00,-1.3456799e+00,-1.3453016e+00,-1.3449236e+00, - -1.3445457e+00,-1.3441681e+00,-1.3437905e+00,-1.3434132e+00, - -1.3430362e+00,-1.3426592e+00,-1.3422825e+00,-1.3419061e+00, - -1.3415297e+00,-1.3411535e+00,-1.3407776e+00,-1.3404018e+00, - -1.3400263e+00,-1.3396509e+00,-1.3392756e+00,-1.3389006e+00, - -1.3385258e+00,-1.3381511e+00,-1.3377767e+00,-1.3374025e+00, - -1.3370284e+00,-1.3366544e+00,-1.3362808e+00,-1.3359072e+00, - -1.3355340e+00,-1.3351607e+00,-1.3347878e+00,-1.3344151e+00, - -1.3340424e+00,-1.3336700e+00,-1.3332978e+00,-1.3329258e+00, - -1.3325540e+00,-1.3321823e+00,-1.3318108e+00,-1.3314395e+00, - -1.3310684e+00,-1.3306974e+00,-1.3303267e+00,-1.3299562e+00, - -1.3295858e+00,-1.3292155e+00,-1.3288456e+00,-1.3284757e+00, - -1.3281060e+00,-1.3277366e+00,-1.3273673e+00,-1.3269982e+00, - -1.3266293e+00,-1.3262606e+00,-1.3258920e+00,-1.3255236e+00, - -1.3251554e+00,-1.3247874e+00,-1.3244195e+00,-1.3240519e+00, - -1.3236843e+00,-1.3233171e+00,-1.3229499e+00,-1.3225830e+00, - -1.3222162e+00,-1.3218495e+00,-1.3214831e+00,-1.3211168e+00, - -1.3207508e+00,-1.3203849e+00,-1.3200191e+00,-1.3196536e+00, - -1.3192883e+00,-1.3189231e+00,-1.3185581e+00,-1.3181932e+00, - -1.3178285e+00,-1.3174641e+00,-1.3170998e+00,-1.3167356e+00, - -1.3163717e+00,-1.3160079e+00,-1.3156443e+00,-1.3152809e+00, - -1.3149176e+00,-1.3145545e+00,-1.3141916e+00,-1.3138288e+00, - -1.3134663e+00,-1.3131039e+00,-1.3127416e+00,-1.3123796e+00, - -1.3120177e+00,-1.3116560e+00,-1.3112944e+00,-1.3109331e+00, - -1.3105719e+00,-1.3102108e+00,-1.3098500e+00,-1.3094894e+00, - -1.3091288e+00,-1.3087685e+00,-1.3084083e+00,-1.3080482e+00, - -1.3076885e+00,-1.3073288e+00,-1.3069693e+00,-1.3066100e+00, - -1.3062508e+00,-1.3058918e+00,-1.3055329e+00,-1.3051744e+00, - -1.3048158e+00,-1.3044575e+00,-1.3040993e+00,-1.3037413e+00, - -1.3033836e+00,-1.3030258e+00,-1.3026685e+00,-1.3023111e+00, - -1.3019539e+00,-1.3015970e+00,-1.3012401e+00,-1.3008835e+00, - -1.3005270e+00,-1.3001707e+00,-1.2998145e+00,-1.2994585e+00, - -1.2991027e+00,-1.2987471e+00,-1.2983915e+00,-1.2980362e+00, - -1.2976810e+00,-1.2973260e+00,-1.2969712e+00,-1.2966164e+00, - -1.2962619e+00,-1.2959076e+00,-1.2955534e+00,-1.2951994e+00, - -1.2948455e+00,-1.2944918e+00,-1.2941382e+00,-1.2937849e+00, - -1.2934316e+00,-1.2930785e+00,-1.2927257e+00,-1.2923729e+00, - -1.2920203e+00,-1.2916679e+00,-1.2913157e+00,-1.2909635e+00, - -1.2906116e+00,-1.2902598e+00,-1.2899083e+00,-1.2895567e+00, - -1.2892054e+00,-1.2888544e+00,-1.2885034e+00,-1.2881526e+00, - -1.2878019e+00,-1.2874514e+00,-1.2871010e+00,-1.2867508e+00, - -1.2864008e+00,-1.2860509e+00,-1.2857012e+00,-1.2853516e+00, - -1.2850022e+00,-1.2846529e+00,-1.2843039e+00,-1.2839550e+00, - -1.2836062e+00,-1.2832576e+00,-1.2829090e+00,-1.2825608e+00, - -1.2822126e+00,-1.2818646e+00,-1.2815168e+00,-1.2811691e+00, - -1.2808216e+00,-1.2804742e+00,-1.2801269e+00,-1.2797799e+00, - -1.2794330e+00,-1.2790862e+00,-1.2787396e+00,-1.2783931e+00, - -1.2780468e+00,-1.2777007e+00,-1.2773547e+00,-1.2770089e+00, - -1.2766632e+00,-1.2763176e+00,-1.2759722e+00,-1.2756270e+00, - -1.2752819e+00,-1.2749370e+00,-1.2745922e+00,-1.2742475e+00, - -1.2739031e+00,-1.2735587e+00,-1.2732146e+00,-1.2728705e+00, - -1.2725267e+00,-1.2721829e+00,-1.2718394e+00,-1.2714961e+00, - -1.2711527e+00,-1.2708097e+00,-1.2704667e+00,-1.2701238e+00, - -1.2697811e+00,-1.2694386e+00,-1.2690963e+00,-1.2687540e+00, - -1.2684120e+00,-1.2680700e+00,-1.2677282e+00,-1.2673866e+00, - -1.2670451e+00,-1.2667037e+00,-1.2663625e+00,-1.2660215e+00, - -1.2656807e+00,-1.2653399e+00,-1.2649993e+00,-1.2646588e+00, - -1.2643185e+00,-1.2639784e+00,-1.2636384e+00,-1.2632985e+00, - -1.2629588e+00,-1.2626191e+00,-1.2622797e+00,-1.2619405e+00, - -1.2616013e+00,-1.2612623e+00,-1.2609235e+00,-1.2605847e+00, - -1.2602462e+00,-1.2599077e+00,-1.2595695e+00,-1.2592313e+00, - -1.2588934e+00,-1.2585555e+00,-1.2582178e+00,-1.2578802e+00, - -1.2575428e+00,-1.2572056e+00,-1.2568685e+00,-1.2565315e+00, - -1.2561946e+00,-1.2558579e+00,-1.2555214e+00,-1.2551850e+00, - -1.2548487e+00,-1.2545125e+00,-1.2541766e+00,-1.2538407e+00, - -1.2535050e+00,-1.2531694e+00,-1.2528341e+00,-1.2524987e+00, - -1.2521636e+00,-1.2518286e+00,-1.2514937e+00,-1.2511591e+00, - -1.2508245e+00,-1.2504900e+00,-1.2501557e+00,-1.2498215e+00, - -1.2494875e+00,-1.2491536e+00,-1.2488198e+00,-1.2484863e+00, - -1.2481529e+00,-1.2478195e+00,-1.2474864e+00,-1.2471533e+00, - -1.2468203e+00,-1.2464876e+00,-1.2461549e+00,-1.2458224e+00, - -1.2454901e+00,-1.2451578e+00,-1.2448257e+00,-1.2444938e+00, - -1.2441620e+00,-1.2438303e+00,-1.2434988e+00,-1.2431674e+00, - -1.2428361e+00,-1.2425050e+00,-1.2421740e+00,-1.2418431e+00, - -1.2415124e+00,-1.2411819e+00,-1.2408514e+00,-1.2405211e+00, - -1.2401909e+00,-1.2398609e+00,-1.2395309e+00,-1.2392012e+00, - -1.2388716e+00,-1.2385421e+00,-1.2382127e+00,-1.2378834e+00, - -1.2375543e+00,-1.2372254e+00,-1.2368965e+00,-1.2365679e+00, - -1.2362393e+00,-1.2359109e+00,-1.2355826e+00,-1.2352544e+00, - -1.2349263e+00,-1.2345985e+00,-1.2342707e+00,-1.2339431e+00, - -1.2336155e+00,-1.2332882e+00,-1.2329609e+00,-1.2326338e+00, - -1.2323068e+00,-1.2319801e+00,-1.2316533e+00,-1.2313267e+00, - -1.2310003e+00,-1.2306740e+00,-1.2303478e+00,-1.2300217e+00, - -1.2296958e+00,-1.2293700e+00,-1.2290443e+00,-1.2287189e+00, - -1.2283934e+00,-1.2280681e+00,-1.2277430e+00,-1.2274179e+00, - -1.2270931e+00,-1.2267684e+00,-1.2264438e+00,-1.2261193e+00, - -1.2257949e+00,-1.2254707e+00,-1.2251465e+00,-1.2248225e+00, - -1.2244986e+00,-1.2241750e+00,-1.2238513e+00,-1.2235279e+00, - -1.2232046e+00,-1.2228813e+00,-1.2225583e+00,-1.2222353e+00, - -1.2219125e+00,-1.2215898e+00,-1.2212672e+00,-1.2209448e+00, - -1.2206224e+00,-1.2203002e+00,-1.2199782e+00,-1.2196562e+00, - -1.2193345e+00,-1.2190127e+00,-1.2186912e+00,-1.2183697e+00, - -1.2180485e+00,-1.2177273e+00,-1.2174062e+00,-1.2170852e+00, - -1.2167645e+00,-1.2164438e+00,-1.2161232e+00,-1.2158028e+00, - -1.2154825e+00,-1.2151623e+00,-1.2148422e+00,-1.2145222e+00, - -1.2142025e+00,-1.2138828e+00,-1.2135632e+00,-1.2132438e+00, - -1.2129245e+00,-1.2126052e+00,-1.2122862e+00,-1.2119672e+00, - -1.2116485e+00,-1.2113298e+00,-1.2110112e+00,-1.2106928e+00, - -1.2103744e+00,-1.2100562e+00,-1.2097381e+00,-1.2094202e+00, - -1.2091023e+00,-1.2087846e+00,-1.2084670e+00,-1.2081496e+00, - -1.2078322e+00,-1.2075150e+00,-1.2071979e+00,-1.2068808e+00, - -1.2065639e+00,-1.2062472e+00,-1.2059306e+00,-1.2056141e+00, - -1.2052977e+00,-1.2049814e+00,-1.2046653e+00,-1.2043493e+00, - -1.2040334e+00,-1.2037176e+00,-1.2034019e+00,-1.2030865e+00, - -1.2027711e+00,-1.2024558e+00,-1.2021406e+00,-1.2018255e+00, - -1.2015105e+00,-1.2011957e+00,-1.2008810e+00,-1.2005664e+00, - -1.2002519e+00,-1.1999376e+00,-1.1996233e+00,-1.1993092e+00, - -1.1989952e+00,-1.1986814e+00,-1.1983676e+00,-1.1980540e+00, - -1.1977404e+00,-1.1974270e+00,-1.1971138e+00,-1.1968006e+00, - -1.1964875e+00,-1.1961746e+00,-1.1958618e+00,-1.1955491e+00, - -1.1952366e+00,-1.1949241e+00,-1.1946117e+00,-1.1942995e+00, - -1.1939874e+00,-1.1936754e+00,-1.1933634e+00,-1.1930517e+00, - -1.1927401e+00,-1.1924285e+00,-1.1921171e+00,-1.1918058e+00, - -1.1914946e+00,-1.1911836e+00,-1.1908726e+00,-1.1905618e+00, - -1.1902510e+00,-1.1899403e+00,-1.1896299e+00,-1.1893195e+00, - -1.1890092e+00,-1.1886991e+00,-1.1883891e+00,-1.1880791e+00, - -1.1877693e+00,-1.1874596e+00,-1.1871500e+00,-1.1868405e+00, - -1.1865312e+00,-1.1862220e+00,-1.1859128e+00,-1.1856037e+00, - -1.1852949e+00,-1.1849861e+00,-1.1846774e+00,-1.1843688e+00, - -1.1840603e+00,-1.1837521e+00,-1.1834438e+00,-1.1831357e+00, - -1.1828277e+00,-1.1825198e+00,-1.1822120e+00,-1.1819043e+00, - -1.1815968e+00,-1.1812893e+00,-1.1809820e+00,-1.1806748e+00, - -1.1803677e+00,-1.1800607e+00,-1.1797538e+00,-1.1794471e+00, - -1.1791403e+00,-1.1788338e+00,-1.1785274e+00,-1.1782210e+00, - -1.1779149e+00,-1.1776087e+00,-1.1773027e+00,-1.1769968e+00, - -1.1766911e+00,-1.1763854e+00,-1.1760798e+00,-1.1757743e+00, - -1.1754690e+00,-1.1751637e+00,-1.1748587e+00,-1.1745536e+00, - -1.1742487e+00,-1.1739439e+00,-1.1736393e+00,-1.1733347e+00, - -1.1730303e+00,-1.1727258e+00,-1.1724216e+00,-1.1721175e+00, - -1.1718134e+00,-1.1715095e+00,-1.1712056e+00,-1.1709020e+00, - -1.1705984e+00,-1.1702949e+00,-1.1699915e+00,-1.1696882e+00, - -1.1693851e+00,-1.1690819e+00,-1.1687790e+00,-1.1684762e+00, - -1.1681734e+00,-1.1678708e+00,-1.1675682e+00,-1.1672659e+00, - -1.1669636e+00,-1.1666613e+00,-1.1663592e+00,-1.1660572e+00, - -1.1657554e+00,-1.1654536e+00,-1.1651518e+00,-1.1648504e+00, - -1.1645489e+00,-1.1642475e+00,-1.1639463e+00,-1.1636450e+00, - -1.1633440e+00,-1.1630431e+00,-1.1627423e+00,-1.1624415e+00, - -1.1621410e+00,-1.1618404e+00,-1.1615400e+00,-1.1612397e+00, - -1.1609395e+00,-1.1606394e+00,-1.1603394e+00,-1.1600395e+00, - -1.1597397e+00,-1.1594400e+00,-1.1591405e+00,-1.1588410e+00, - -1.1585417e+00,-1.1582423e+00,-1.1579432e+00,-1.1576442e+00, - -1.1573452e+00,-1.1570463e+00,-1.1567476e+00,-1.1564490e+00, - -1.1561505e+00,-1.1558520e+00,-1.1555537e+00,-1.1552554e+00, - -1.1549573e+00,-1.1546593e+00,-1.1543614e+00,-1.1540636e+00, - -1.1537658e+00,-1.1534683e+00,-1.1531707e+00,-1.1528733e+00, - -1.1525760e+00,-1.1522788e+00,-1.1519816e+00,-1.1516846e+00, - -1.1513877e+00,-1.1510910e+00,-1.1507943e+00,-1.1504977e+00, - -1.1502011e+00,-1.1499047e+00,-1.1496085e+00,-1.1493123e+00, - -1.1490161e+00,-1.1487201e+00,-1.1484243e+00,-1.1481285e+00, - -1.1478328e+00,-1.1475372e+00,-1.1472417e+00,-1.1469463e+00, - -1.1466510e+00,-1.1463559e+00,-1.1460607e+00,-1.1457658e+00, - -1.1454709e+00,-1.1451761e+00,-1.1448814e+00,-1.1445868e+00, - -1.1442922e+00,-1.1439979e+00,-1.1437036e+00,-1.1434094e+00, - -1.1431153e+00,-1.1428213e+00,-1.1425273e+00,-1.1422336e+00, - -1.1419399e+00,-1.1416463e+00,-1.1413528e+00,-1.1410594e+00, - -1.1407660e+00,-1.1404729e+00,-1.1401798e+00,-1.1398867e+00, - -1.1395938e+00,-1.1393009e+00,-1.1390083e+00,-1.1387156e+00, - -1.1384231e+00,-1.1381307e+00,-1.1378384e+00,-1.1375461e+00, - -1.1372540e+00,-1.1369619e+00,-1.1366700e+00,-1.1363782e+00, - -1.1360863e+00,-1.1357948e+00,-1.1355032e+00,-1.1352117e+00, - -1.1349204e+00,-1.1346291e+00,-1.1343379e+00,-1.1340468e+00, - -1.1337558e+00,-1.1334649e+00,-1.1331742e+00,-1.1328834e+00, - -1.1325929e+00,-1.1323024e+00,-1.1320120e+00,-1.1317216e+00, - -1.1314315e+00,-1.1311413e+00,-1.1308513e+00,-1.1305614e+00, - -1.1302716e+00,-1.1299818e+00,-1.1296922e+00,-1.1294026e+00, - -1.1291132e+00,-1.1288238e+00,-1.1285346e+00,-1.1282454e+00, - -1.1279563e+00,-1.1276673e+00,-1.1273785e+00,-1.1270896e+00, - -1.1268009e+00,-1.1265123e+00,-1.1262238e+00,-1.1259354e+00, - -1.1256471e+00,-1.1253588e+00,-1.1250707e+00,-1.1247827e+00, - -1.1244947e+00,-1.1242068e+00,-1.1239190e+00,-1.1236314e+00, - -1.1233438e+00,-1.1230563e+00,-1.1227689e+00,-1.1224816e+00, - -1.1221944e+00,-1.1219074e+00,-1.1216203e+00,-1.1213334e+00, - -1.1210465e+00,-1.1207597e+00,-1.1204731e+00,-1.1201866e+00, - -1.1199001e+00,-1.1196136e+00,-1.1193274e+00,-1.1190412e+00, - -1.1187551e+00,-1.1184691e+00,-1.1181831e+00,-1.1178974e+00, - -1.1176116e+00,-1.1173259e+00,-1.1170404e+00,-1.1167549e+00, - -1.1164695e+00,-1.1161842e+00,-1.1158991e+00,-1.1156139e+00, - -1.1153290e+00,-1.1150440e+00,-1.1147592e+00,-1.1144745e+00, - -1.1141899e+00,-1.1139053e+00,-1.1136208e+00,-1.1133364e+00, - -1.1130521e+00,-1.1127679e+00,-1.1124839e+00,-1.1121998e+00, - -1.1119158e+00,-1.1116320e+00,-1.1113483e+00,-1.1110647e+00, - -1.1107811e+00,-1.1104976e+00,-1.1102142e+00,-1.1099309e+00, - -1.1096476e+00,-1.1093645e+00,-1.1090815e+00,-1.1087985e+00, - -1.1085157e+00,-1.1082330e+00,-1.1079502e+00,-1.1076677e+00, - -1.1073852e+00,-1.1071028e+00,-1.1068205e+00,-1.1065382e+00, - -1.1062560e+00,-1.1059740e+00,-1.1056920e+00,-1.1054101e+00, - -1.1051283e+00,-1.1048466e+00,-1.1045649e+00,-1.1042835e+00, - -1.1040020e+00,-1.1037205e+00,-1.1034393e+00,-1.1031581e+00, - -1.1028770e+00,-1.1025960e+00,-1.1023151e+00,-1.1020342e+00, - -1.1017535e+00,-1.1014729e+00,-1.1011922e+00,-1.1009117e+00, - -1.1006314e+00,-1.1003511e+00,-1.1000708e+00,-1.0997907e+00, - -1.0995106e+00,-1.0992306e+00,-1.0989507e+00,-1.0986710e+00, - -1.0983912e+00,-1.0981116e+00,-1.0978321e+00,-1.0975525e+00, - -1.0972732e+00,-1.0969939e+00,-1.0967147e+00,-1.0964357e+00, - -1.0961566e+00,-1.0958776e+00,-1.0955988e+00,-1.0953200e+00, - -1.0950413e+00,-1.0947627e+00,-1.0944842e+00,-1.0942057e+00, - -1.0939274e+00,-1.0936491e+00,-1.0933709e+00,-1.0930929e+00, - -1.0928148e+00,-1.0925369e+00,-1.0922590e+00,-1.0919813e+00, - -1.0917037e+00,-1.0914260e+00,-1.0911485e+00,-1.0908711e+00, - -1.0905938e+00,-1.0903165e+00,-1.0900394e+00,-1.0897623e+00, - -1.0894853e+00,-1.0892084e+00,-1.0889316e+00,-1.0886548e+00, - -1.0883781e+00,-1.0881015e+00,-1.0878251e+00,-1.0875486e+00, - -1.0872723e+00,-1.0869960e+00,-1.0867199e+00,-1.0864438e+00, - -1.0861677e+00,-1.0858918e+00,-1.0856160e+00,-1.0853403e+00, - -1.0850645e+00,-1.0847889e+00,-1.0845134e+00,-1.0842381e+00, - -1.0839627e+00,-1.0836874e+00,-1.0834122e+00,-1.0831372e+00, - -1.0828621e+00,-1.0825871e+00,-1.0823123e+00,-1.0820376e+00, - -1.0817629e+00,-1.0814883e+00,-1.0812137e+00,-1.0809393e+00, - -1.0806649e+00,-1.0803907e+00,-1.0801164e+00,-1.0798423e+00, - -1.0795683e+00,-1.0792943e+00,-1.0790205e+00,-1.0787467e+00, - -1.0784730e+00,-1.0781993e+00,-1.0779257e+00,-1.0776522e+00, - -1.0773789e+00,-1.0771055e+00,-1.0768323e+00,-1.0765592e+00, - -1.0762861e+00,-1.0760131e+00,-1.0757402e+00,-1.0754673e+00, - -1.0751946e+00,-1.0749220e+00,-1.0746493e+00,-1.0743768e+00, - -1.0741044e+00,-1.0738320e+00,-1.0735598e+00,-1.0732876e+00, - -1.0730155e+00,-1.0727434e+00,-1.0724715e+00,-1.0721996e+00, - -1.0719278e+00,-1.0716561e+00,-1.0713844e+00,-1.0711130e+00, - -1.0708414e+00,-1.0705701e+00,-1.0702987e+00,-1.0700275e+00, - -1.0697563e+00,-1.0694852e+00,-1.0692142e+00,-1.0689433e+00, - -1.0686724e+00,-1.0684017e+00,-1.0681310e+00,-1.0678604e+00, - -1.0675899e+00,-1.0673194e+00,-1.0670490e+00,-1.0667787e+00, - -1.0665085e+00,-1.0662383e+00,-1.0659683e+00,-1.0656983e+00, - -1.0654284e+00,-1.0651585e+00,-1.0648887e+00,-1.0646191e+00, - -1.0643495e+00,-1.0640800e+00,-1.0638105e+00,-1.0635412e+00, - -1.0632719e+00,-1.0630026e+00,-1.0627335e+00,-1.0624644e+00, - -1.0621954e+00,-1.0619265e+00,-1.0616577e+00,-1.0613890e+00, - -1.0611203e+00,-1.0608517e+00,-1.0605831e+00,-1.0603147e+00, - -1.0600463e+00,-1.0597780e+00,-1.0595098e+00,-1.0592417e+00, - -1.0589736e+00,-1.0587056e+00,-1.0584377e+00,-1.0581698e+00, - -1.0579021e+00,-1.0576344e+00,-1.0573667e+00,-1.0570992e+00, - -1.0568317e+00,-1.0565643e+00,-1.0562971e+00,-1.0560298e+00, - -1.0557626e+00,-1.0554956e+00,-1.0552286e+00,-1.0549617e+00, - -1.0546948e+00,-1.0544280e+00,-1.0541613e+00,-1.0538946e+00, - -1.0536281e+00,-1.0533617e+00,-1.0530952e+00,-1.0528289e+00, - -1.0525626e+00,-1.0522964e+00,-1.0520303e+00,-1.0517642e+00, - -1.0514983e+00,-1.0512325e+00,-1.0509666e+00,-1.0507009e+00, - -1.0504352e+00,-1.0501696e+00,-1.0499041e+00,-1.0496386e+00, - -1.0493733e+00,-1.0491080e+00,-1.0488428e+00,-1.0485777e+00, - -1.0483125e+00,-1.0480475e+00,-1.0477827e+00,-1.0475178e+00, - -1.0472530e+00,-1.0469882e+00,-1.0467236e+00,-1.0464591e+00, - -1.0461946e+00,-1.0459301e+00,-1.0456659e+00,-1.0454016e+00, - -1.0451374e+00,-1.0448732e+00,-1.0446092e+00,-1.0443453e+00, - -1.0440813e+00,-1.0438175e+00,-1.0435537e+00,-1.0432900e+00, - -1.0430264e+00,-1.0427629e+00,-1.0424994e+00,-1.0422361e+00, - -1.0419728e+00,-1.0417095e+00,-1.0414463e+00,-1.0411832e+00, - -1.0409201e+00,-1.0406572e+00,-1.0403943e+00,-1.0401314e+00, - -1.0398687e+00,-1.0396061e+00,-1.0393435e+00,-1.0390810e+00, - -1.0388185e+00,-1.0385561e+00,-1.0382938e+00,-1.0380316e+00, - -1.0377693e+00,-1.0375073e+00,-1.0372453e+00,-1.0369833e+00, - -1.0367213e+00,-1.0364596e+00,-1.0361978e+00,-1.0359361e+00, - -1.0356746e+00,-1.0354130e+00,-1.0351515e+00,-1.0348902e+00, - -1.0346289e+00,-1.0343676e+00,-1.0341064e+00,-1.0338453e+00, - -1.0335842e+00,-1.0333233e+00,-1.0330623e+00,-1.0328015e+00, - -1.0325408e+00,-1.0322801e+00,-1.0320195e+00,-1.0317589e+00, - -1.0314984e+00,-1.0312381e+00,-1.0309777e+00,-1.0307175e+00, - -1.0304573e+00,-1.0301971e+00,-1.0299370e+00,-1.0296770e+00, - -1.0294172e+00,-1.0291573e+00,-1.0288975e+00,-1.0286378e+00, - -1.0283781e+00,-1.0281186e+00,-1.0278591e+00,-1.0275997e+00, - -1.0273403e+00,-1.0270810e+00,-1.0268217e+00,-1.0265626e+00, - -1.0263035e+00,-1.0260445e+00,-1.0257856e+00,-1.0255266e+00, - -1.0252678e+00,-1.0250092e+00,-1.0247505e+00,-1.0244918e+00, - -1.0242333e+00,-1.0239748e+00,-1.0237164e+00,-1.0234581e+00, - -1.0231998e+00,-1.0229416e+00,-1.0226835e+00,-1.0224254e+00, - -1.0221674e+00,-1.0219095e+00,-1.0216516e+00,-1.0213939e+00, - -1.0211362e+00,-1.0208784e+00,-1.0206209e+00,-1.0203633e+00, - -1.0201060e+00,-1.0198486e+00,-1.0195912e+00,-1.0193340e+00, - -1.0190768e+00,-1.0188197e+00,-1.0185627e+00,-1.0183057e+00, - -1.0180488e+00,-1.0177919e+00,-1.0175351e+00,-1.0172784e+00, - -1.0170218e+00,-1.0167652e+00,-1.0165087e+00,-1.0162523e+00, - -1.0159959e+00,-1.0157396e+00,-1.0154834e+00,-1.0152272e+00, - -1.0149710e+00,-1.0147150e+00,-1.0144590e+00,-1.0142031e+00, - -1.0139472e+00,-1.0136915e+00,-1.0134358e+00,-1.0131801e+00, - -1.0129246e+00,-1.0126691e+00,-1.0124136e+00,-1.0121583e+00, - -1.0119029e+00,-1.0116477e+00,-1.0113925e+00,-1.0111374e+00, - -1.0108824e+00,-1.0106274e+00,-1.0103724e+00,-1.0101175e+00, - -1.0098628e+00,-1.0096080e+00,-1.0093534e+00,-1.0090988e+00, - -1.0088443e+00,-1.0085899e+00,-1.0083355e+00,-1.0080811e+00, - -1.0078268e+00,-1.0075727e+00,-1.0073185e+00,-1.0070645e+00, - -1.0068104e+00,-1.0065565e+00,-1.0063026e+00,-1.0060488e+00, - -1.0057951e+00,-1.0055413e+00,-1.0052878e+00,-1.0050342e+00, - -1.0047808e+00,-1.0045273e+00,-1.0042740e+00,-1.0040207e+00, - -1.0037675e+00,-1.0035143e+00,-1.0032612e+00,-1.0030081e+00, - -1.0027552e+00,-1.0025022e+00,-1.0022494e+00,-1.0019966e+00, - -1.0017439e+00,-1.0014913e+00,-1.0012387e+00,-1.0009862e+00, - -1.0007337e+00,-1.0004814e+00,-1.0002290e+00,-9.9997669e-01, - -9.9972451e-01,-9.9947238e-01,-9.9922031e-01,-9.9896824e-01, - -9.9871629e-01,-9.9846447e-01,-9.9821264e-01,-9.9796087e-01, - -9.9770916e-01,-9.9745750e-01,-9.9720597e-01,-9.9695444e-01, - -9.9670297e-01,-9.9645162e-01,-9.9620032e-01,-9.9594903e-01, - -9.9569786e-01,-9.9544674e-01,-9.9519563e-01,-9.9494463e-01, - -9.9469370e-01,-9.9444282e-01,-9.9419200e-01,-9.9394125e-01, - -9.9369055e-01,-9.9343991e-01,-9.9318939e-01,-9.9293888e-01, - -9.9268842e-01,-9.9243802e-01,-9.9218774e-01,-9.9193746e-01, - -9.9168730e-01,-9.9143714e-01,-9.9118710e-01,-9.9093705e-01, - -9.9068713e-01,-9.9043721e-01,-9.9018741e-01,-9.8993766e-01, - -9.8968798e-01,-9.8943830e-01,-9.8918873e-01,-9.8893923e-01, - -9.8868978e-01,-9.8844039e-01,-9.8819107e-01,-9.8794180e-01, - -9.8769259e-01,-9.8744345e-01,-9.8719436e-01,-9.8694533e-01, - -9.8669636e-01,-9.8644745e-01,-9.8619866e-01,-9.8594987e-01, - -9.8570114e-01,-9.8545247e-01,-9.8520392e-01,-9.8495537e-01, - -9.8470688e-01,-9.8445845e-01,-9.8421013e-01,-9.8396182e-01, - -9.8371363e-01,-9.8346543e-01,-9.8321730e-01,-9.8296928e-01, - -9.8272127e-01,-9.8247337e-01,-9.8222548e-01,-9.8197770e-01, - -9.8172992e-01,-9.8148227e-01,-9.8123461e-01,-9.8098707e-01, - -9.8073953e-01,-9.8049212e-01,-9.8024470e-01,-9.7999740e-01, - -9.7975016e-01,-9.7950292e-01,-9.7925580e-01,-9.7900867e-01, - -9.7876167e-01,-9.7851467e-01,-9.7826779e-01,-9.7802097e-01, - -9.7777414e-01,-9.7752744e-01,-9.7728074e-01,-9.7703415e-01, - -9.7678757e-01,-9.7654110e-01,-9.7629470e-01,-9.7604829e-01, - -9.7580200e-01,-9.7555572e-01,-9.7530955e-01,-9.7506338e-01, - -9.7481734e-01,-9.7457129e-01,-9.7432536e-01,-9.7407943e-01, - -9.7383362e-01,-9.7358781e-01,-9.7334212e-01,-9.7309643e-01, - -9.7285086e-01,-9.7260529e-01,-9.7235978e-01,-9.7211438e-01, - -9.7186899e-01,-9.7162366e-01,-9.7137845e-01,-9.7113323e-01, - -9.7088808e-01,-9.7064304e-01,-9.7039801e-01,-9.7015303e-01, - -9.6990812e-01,-9.6966326e-01,-9.6941847e-01,-9.6917379e-01, - -9.6892911e-01,-9.6868449e-01,-9.6843994e-01,-9.6819544e-01, - -9.6795100e-01,-9.6770662e-01,-9.6746230e-01,-9.6721798e-01, - -9.6697378e-01,-9.6672964e-01,-9.6648556e-01,-9.6624154e-01, - -9.6599752e-01,-9.6575361e-01,-9.6550977e-01,-9.6526593e-01, - -9.6502221e-01,-9.6477848e-01,-9.6453488e-01,-9.6429127e-01, - -9.6404779e-01,-9.6380430e-01,-9.6356088e-01,-9.6331757e-01, - -9.6307427e-01,-9.6283102e-01,-9.6258783e-01,-9.6234471e-01, - -9.6210164e-01,-9.6185863e-01,-9.6161568e-01,-9.6137279e-01, - -9.6112996e-01,-9.6088719e-01,-9.6064448e-01,-9.6040183e-01, - -9.6015918e-01,-9.5991665e-01,-9.5967412e-01,-9.5943171e-01, - -9.5918930e-01,-9.5894700e-01,-9.5870471e-01,-9.5846248e-01, - -9.5822036e-01,-9.5797825e-01,-9.5773619e-01,-9.5749420e-01, - -9.5725226e-01,-9.5701039e-01,-9.5676857e-01,-9.5652682e-01, - -9.5628506e-01,-9.5604342e-01,-9.5580184e-01,-9.5556027e-01, - -9.5531881e-01,-9.5507735e-01,-9.5483601e-01,-9.5459467e-01, - -9.5435339e-01,-9.5411217e-01,-9.5387101e-01,-9.5362991e-01, - -9.5338887e-01,-9.5314789e-01,-9.5290697e-01,-9.5266610e-01, - -9.5242524e-01,-9.5218450e-01,-9.5194381e-01,-9.5170313e-01, - -9.5146251e-01,-9.5122200e-01,-9.5098150e-01,-9.5074105e-01, - -9.5050067e-01,-9.5026034e-01,-9.5002007e-01,-9.4977987e-01, - -9.4953972e-01,-9.4929957e-01,-9.4905955e-01,-9.4881952e-01, - -9.4857961e-01,-9.4833970e-01,-9.4809985e-01,-9.4786006e-01, - -9.4762039e-01,-9.4738066e-01,-9.4714105e-01,-9.4690150e-01, - -9.4666201e-01,-9.4642258e-01,-9.4618315e-01,-9.4594383e-01, - -9.4570452e-01,-9.4546527e-01,-9.4522607e-01,-9.4498694e-01, - -9.4474787e-01,-9.4450885e-01,-9.4426990e-01,-9.4403100e-01, - -9.4379210e-01,-9.4355333e-01,-9.4331455e-01,-9.4307590e-01, - -9.4283724e-01,-9.4259864e-01,-9.4236010e-01,-9.4212162e-01, - -9.4188321e-01,-9.4164485e-01,-9.4140649e-01,-9.4116825e-01, - -9.4093001e-01,-9.4069183e-01,-9.4045377e-01,-9.4021571e-01, - -9.3997771e-01,-9.3973976e-01,-9.3950182e-01,-9.3926400e-01, - -9.3902624e-01,-9.3878847e-01,-9.3855077e-01,-9.3831319e-01, - -9.3807560e-01,-9.3783808e-01,-9.3760061e-01,-9.3736315e-01, - -9.3712580e-01,-9.3688852e-01,-9.3665123e-01,-9.3641400e-01, - -9.3617690e-01,-9.3593979e-01,-9.3570274e-01,-9.3546569e-01, - -9.3522877e-01,-9.3499190e-01,-9.3475503e-01,-9.3451828e-01, - -9.3428153e-01,-9.3404484e-01,-9.3380821e-01,-9.3357164e-01, - -9.3333513e-01,-9.3309861e-01,-9.3286222e-01,-9.3262583e-01, - -9.3238950e-01,-9.3215328e-01,-9.3191707e-01,-9.3168086e-01, - -9.3144476e-01,-9.3120873e-01,-9.3097270e-01,-9.3073678e-01, - -9.3050086e-01,-9.3026501e-01,-9.3002921e-01,-9.2979348e-01, - -9.2955780e-01,-9.2932212e-01,-9.2908657e-01,-9.2885101e-01, - -9.2861551e-01,-9.2838007e-01,-9.2814469e-01,-9.2790937e-01, - -9.2767406e-01,-9.2743886e-01,-9.2720366e-01,-9.2696851e-01, - -9.2673343e-01,-9.2649841e-01,-9.2626345e-01,-9.2602855e-01, - -9.2579365e-01,-9.2555881e-01,-9.2532408e-01,-9.2508936e-01, - -9.2485470e-01,-9.2462003e-01,-9.2438549e-01,-9.2415094e-01, - -9.2391652e-01,-9.2368209e-01,-9.2344773e-01,-9.2321342e-01, - -9.2297918e-01,-9.2274493e-01,-9.2251080e-01,-9.2227668e-01, - -9.2204261e-01,-9.2180860e-01,-9.2157465e-01,-9.2134070e-01, - -9.2110687e-01,-9.2087305e-01,-9.2063934e-01,-9.2040563e-01, - -9.2017192e-01,-9.1993833e-01,-9.1970479e-01,-9.1947126e-01, - -9.1923779e-01,-9.1900444e-01,-9.1877103e-01,-9.1853774e-01, - -9.1830450e-01,-9.1807127e-01,-9.1783816e-01,-9.1760504e-01, - -9.1737199e-01,-9.1713893e-01,-9.1690600e-01,-9.1667312e-01, - -9.1644025e-01,-9.1620743e-01,-9.1597468e-01,-9.1574198e-01, - -9.1550928e-01,-9.1527671e-01,-9.1504413e-01,-9.1481161e-01, - -9.1457915e-01,-9.1434675e-01,-9.1411442e-01,-9.1388208e-01, - -9.1364980e-01,-9.1341758e-01,-9.1318542e-01,-9.1295332e-01, - -9.1272128e-01,-9.1248924e-01,-9.1225725e-01,-9.1202533e-01, - -9.1179347e-01,-9.1156167e-01,-9.1132987e-01,-9.1109818e-01, - -9.1086650e-01,-9.1063488e-01,-9.1040331e-01,-9.1017175e-01, - -9.0994030e-01,-9.0970886e-01,-9.0947747e-01,-9.0924615e-01, - -9.0901482e-01,-9.0878361e-01,-9.0855241e-01,-9.0832126e-01, - -9.0809017e-01,-9.0785915e-01,-9.0762818e-01,-9.0739721e-01, - -9.0716630e-01,-9.0693545e-01,-9.0670466e-01,-9.0647393e-01, - -9.0624321e-01,-9.0601259e-01,-9.0578198e-01,-9.0555137e-01, - -9.0532088e-01,-9.0509045e-01,-9.0486002e-01,-9.0462965e-01, - -9.0439934e-01,-9.0416908e-01,-9.0393883e-01,-9.0370864e-01, - -9.0347856e-01,-9.0324843e-01,-9.0301841e-01,-9.0278846e-01, - -9.0255851e-01,-9.0232861e-01,-9.0209877e-01,-9.0186900e-01, - -9.0163922e-01,-9.0140957e-01,-9.0117991e-01,-9.0095031e-01, - -9.0072072e-01,-9.0049124e-01,-9.0026176e-01,-9.0003234e-01, - -8.9980298e-01,-8.9957368e-01,-8.9934438e-01,-8.9911520e-01, - -8.9888602e-01,-8.9865690e-01,-8.9842778e-01,-8.9819878e-01, - -8.9796978e-01,-8.9774084e-01,-8.9751196e-01,-8.9728308e-01, - -8.9705431e-01,-8.9682555e-01,-8.9659685e-01,-8.9636821e-01, - -8.9613956e-01,-8.9591098e-01,-8.9568251e-01,-8.9545399e-01, - -8.9522558e-01,-8.9499724e-01,-8.9476889e-01,-8.9454061e-01, - -8.9431238e-01,-8.9408416e-01,-8.9385605e-01,-8.9362794e-01, - -8.9339989e-01,-8.9317185e-01,-8.9294392e-01,-8.9271599e-01, - -8.9248812e-01,-8.9226031e-01,-8.9203256e-01,-8.9180481e-01, - -8.9157712e-01,-8.9134949e-01,-8.9112192e-01,-8.9089435e-01, - -8.9066684e-01,-8.9043945e-01,-8.9021200e-01,-8.8998467e-01, - -8.8975734e-01,-8.8953006e-01,-8.8930285e-01,-8.8907570e-01, - -8.8884854e-01,-8.8862145e-01,-8.8839442e-01,-8.8816744e-01, - -8.8794053e-01,-8.8771361e-01,-8.8748676e-01,-8.8725996e-01, - -8.8703316e-01,-8.8680649e-01,-8.8657981e-01,-8.8635319e-01, - -8.8612658e-01,-8.8590008e-01,-8.8567358e-01,-8.8544714e-01, - -8.8522071e-01,-8.8499439e-01,-8.8476807e-01,-8.8454181e-01, - -8.8431555e-01,-8.8408941e-01,-8.8386327e-01,-8.8363719e-01, - -8.8341117e-01,-8.8318515e-01,-8.8295925e-01,-8.8273335e-01, - -8.8250744e-01,-8.8228166e-01,-8.8205588e-01,-8.8183016e-01, - -8.8160449e-01,-8.8137889e-01,-8.8115329e-01,-8.8092774e-01, - -8.8070226e-01,-8.8047677e-01,-8.8025135e-01,-8.8002604e-01, - -8.7980068e-01,-8.7957543e-01,-8.7935019e-01,-8.7912500e-01, - -8.7889987e-01,-8.7867481e-01,-8.7844974e-01,-8.7822473e-01, - -8.7799978e-01,-8.7777483e-01,-8.7754995e-01,-8.7732512e-01, - -8.7710035e-01,-8.7687564e-01,-8.7665093e-01,-8.7642628e-01, - -8.7620169e-01,-8.7597710e-01,-8.7575257e-01,-8.7552810e-01, - -8.7530369e-01,-8.7507927e-01,-8.7485492e-01,-8.7463063e-01, - -8.7440640e-01,-8.7418216e-01,-8.7395799e-01,-8.7373388e-01, - -8.7350982e-01,-8.7328577e-01,-8.7306178e-01,-8.7283784e-01, - -8.7261397e-01,-8.7239009e-01,-8.7216628e-01,-8.7194252e-01, - -8.7171876e-01,-8.7149507e-01,-8.7127143e-01,-8.7104785e-01, - -8.7082428e-01,-8.7060076e-01,-8.7037730e-01,-8.7015390e-01, - -8.6993051e-01,-8.6970717e-01,-8.6948389e-01,-8.6926061e-01, - -8.6903745e-01,-8.6881423e-01,-8.6859113e-01,-8.6836809e-01, - -8.6814505e-01,-8.6792201e-01,-8.6769909e-01,-8.6747617e-01, - -8.6725330e-01,-8.6703050e-01,-8.6680776e-01,-8.6658502e-01, - -8.6636233e-01,-8.6613965e-01,-8.6591709e-01,-8.6569452e-01, - -8.6547196e-01,-8.6524951e-01,-8.6502707e-01,-8.6480469e-01, - -8.6458236e-01,-8.6436003e-01,-8.6413777e-01,-8.6391556e-01, - -8.6369336e-01,-8.6347127e-01,-8.6324918e-01,-8.6302710e-01, - -8.6280513e-01,-8.6258316e-01,-8.6236125e-01,-8.6213934e-01, - -8.6191750e-01,-8.6169571e-01,-8.6147398e-01,-8.6125225e-01, - -8.6103058e-01,-8.6080897e-01,-8.6058742e-01,-8.6036587e-01, - -8.6014438e-01,-8.5992289e-01,-8.5970151e-01,-8.5948014e-01, - -8.5925877e-01,-8.5903752e-01,-8.5881627e-01,-8.5859507e-01, - -8.5837388e-01,-8.5815281e-01,-8.5793167e-01,-8.5771066e-01, - -8.5748965e-01,-8.5726875e-01,-8.5704780e-01,-8.5682696e-01, - -8.5660613e-01,-8.5638535e-01,-8.5616457e-01,-8.5594392e-01, - -8.5572326e-01,-8.5550261e-01,-8.5528207e-01,-8.5506153e-01, - -8.5484105e-01,-8.5462058e-01,-8.5440016e-01,-8.5417980e-01, - -8.5395950e-01,-8.5373920e-01,-8.5351896e-01,-8.5329872e-01, - -8.5307860e-01,-8.5285848e-01,-8.5263836e-01,-8.5241836e-01, - -8.5219836e-01,-8.5197842e-01,-8.5175848e-01,-8.5153860e-01, - -8.5131878e-01,-8.5109901e-01,-8.5087925e-01,-8.5065955e-01, - -8.5043991e-01,-8.5022026e-01,-8.5000068e-01,-8.4978116e-01, - -8.4956163e-01,-8.4934217e-01,-8.4912276e-01,-8.4890336e-01, - -8.4868401e-01,-8.4846473e-01,-8.4824550e-01,-8.4802628e-01, - -8.4780711e-01,-8.4758794e-01,-8.4736884e-01,-8.4714979e-01, - -8.4693080e-01,-8.4671181e-01,-8.4649289e-01,-8.4627402e-01, - -8.4605515e-01,-8.4583634e-01,-8.4561759e-01,-8.4539884e-01, - -8.4518015e-01,-8.4496152e-01,-8.4474289e-01,-8.4452432e-01, - -8.4430581e-01,-8.4408730e-01,-8.4386891e-01,-8.4365046e-01, - -8.4343213e-01,-8.4321380e-01,-8.4299552e-01,-8.4277725e-01, - -8.4255904e-01,-8.4234089e-01,-8.4212279e-01,-8.4190470e-01, - -8.4168661e-01,-8.4146863e-01,-8.4125066e-01,-8.4103274e-01, - -8.4081483e-01,-8.4059703e-01,-8.4037918e-01,-8.4016144e-01, - -8.3994371e-01,-8.3972603e-01,-8.3950841e-01,-8.3929080e-01, - -8.3907324e-01,-8.3885568e-01,-8.3863819e-01,-8.3842075e-01, - -8.3820337e-01,-8.3798599e-01,-8.3776867e-01,-8.3755136e-01, - -8.3733410e-01,-8.3711690e-01,-8.3689976e-01,-8.3668262e-01, - -8.3646554e-01,-8.3624846e-01,-8.3603144e-01,-8.3581448e-01, - -8.3559757e-01,-8.3538067e-01,-8.3516377e-01,-8.3494699e-01, - -8.3473021e-01,-8.3451349e-01,-8.3429676e-01,-8.3408010e-01, - -8.3386350e-01,-8.3364689e-01,-8.3343035e-01,-8.3321387e-01, - -8.3299738e-01,-8.3278096e-01,-8.3256459e-01,-8.3234823e-01, - -8.3213192e-01,-8.3191568e-01,-8.3169943e-01,-8.3148324e-01, - -8.3126712e-01,-8.3105099e-01,-8.3083493e-01,-8.3061886e-01, - -8.3040285e-01,-8.3018690e-01,-8.2997102e-01,-8.2975513e-01, - -8.2953930e-01,-8.2932347e-01,-8.2910770e-01,-8.2889199e-01, - -8.2867628e-01,-8.2846063e-01,-8.2824504e-01,-8.2802945e-01, - -8.2781392e-01,-8.2759845e-01,-8.2738298e-01,-8.2716757e-01, - -8.2695216e-01,-8.2673687e-01,-8.2652152e-01,-8.2630628e-01, - -8.2609105e-01,-8.2587588e-01,-8.2566071e-01,-8.2544559e-01, - -8.2523054e-01,-8.2501549e-01,-8.2480049e-01,-8.2458556e-01, - -8.2437062e-01,-8.2415575e-01,-8.2394087e-01,-8.2372606e-01, - -8.2351130e-01,-8.2329661e-01,-8.2308191e-01,-8.2286721e-01, - -8.2265264e-01,-8.2243806e-01,-8.2222348e-01,-8.2200897e-01, - -8.2179451e-01,-8.2158011e-01,-8.2136571e-01,-8.2115138e-01, - -8.2093704e-01,-8.2072276e-01,-8.2050854e-01,-8.2029432e-01, - -8.2008016e-01,-8.1986606e-01,-8.1965196e-01,-8.1943792e-01, - -8.1922388e-01,-8.1900990e-01,-8.1879598e-01,-8.1858206e-01, - -8.1836820e-01,-8.1815439e-01,-8.1794059e-01,-8.1772685e-01, - -8.1751311e-01,-8.1729943e-01,-8.1708580e-01,-8.1687218e-01, - -8.1665862e-01,-8.1644511e-01,-8.1623161e-01,-8.1601816e-01, - -8.1580472e-01,-8.1559139e-01,-8.1537801e-01,-8.1516474e-01, - -8.1495148e-01,-8.1473821e-01,-8.1452501e-01,-8.1431186e-01, - -8.1409878e-01,-8.1388569e-01,-8.1367260e-01,-8.1345963e-01, - -8.1324667e-01,-8.1303370e-01,-8.1282079e-01,-8.1260794e-01, - -8.1239510e-01,-8.1218231e-01,-8.1196958e-01,-8.1175685e-01, - -8.1154418e-01,-8.1133157e-01,-8.1111896e-01,-8.1090641e-01, - -8.1069386e-01,-8.1048137e-01,-8.1026888e-01,-8.1005645e-01, - -8.0984408e-01,-8.0963176e-01,-8.0941945e-01,-8.0920714e-01, - -8.0899495e-01,-8.0878270e-01,-8.0857056e-01,-8.0835843e-01, - -8.0814636e-01,-8.0793428e-01,-8.0772227e-01,-8.0751026e-01, - -8.0729830e-01,-8.0708641e-01,-8.0687451e-01,-8.0666268e-01, - -8.0645090e-01,-8.0623913e-01,-8.0602741e-01,-8.0581570e-01, - -8.0560404e-01,-8.0539244e-01,-8.0518085e-01,-8.0496931e-01, - -8.0475777e-01,-8.0454630e-01,-8.0433488e-01,-8.0412346e-01, - -8.0391210e-01,-8.0370075e-01,-8.0348945e-01,-8.0327821e-01, - -8.0306697e-01,-8.0285579e-01,-8.0264461e-01,-8.0243349e-01, - -8.0222243e-01,-8.0201137e-01,-8.0180037e-01,-8.0158937e-01, - -8.0137843e-01,-8.0116755e-01,-8.0095667e-01,-8.0074584e-01, - -8.0053502e-01,-8.0032426e-01,-8.0011356e-01,-7.9990286e-01, - -7.9969221e-01,-7.9948157e-01,-7.9927099e-01,-7.9906040e-01, - -7.9884994e-01,-7.9863942e-01,-7.9842901e-01,-7.9821861e-01, - -7.9800820e-01,-7.9779786e-01,-7.9758757e-01,-7.9737729e-01, - -7.9716706e-01,-7.9695690e-01,-7.9674673e-01,-7.9653656e-01, - -7.9632652e-01,-7.9611647e-01,-7.9590642e-01,-7.9569644e-01, - -7.9548651e-01,-7.9527658e-01,-7.9506671e-01,-7.9485685e-01, - -7.9464704e-01,-7.9443729e-01,-7.9422754e-01,-7.9401779e-01, - -7.9380816e-01,-7.9359853e-01,-7.9338890e-01,-7.9317933e-01, - -7.9296982e-01,-7.9276031e-01,-7.9255086e-01,-7.9234141e-01, - -7.9213202e-01,-7.9192269e-01,-7.9171336e-01,-7.9150409e-01, - -7.9129481e-01,-7.9108560e-01,-7.9087639e-01,-7.9066724e-01, - -7.9045814e-01,-7.9024905e-01,-7.9004002e-01,-7.8983098e-01, - -7.8962201e-01,-7.8941309e-01,-7.8920418e-01,-7.8899533e-01, - -7.8878647e-01,-7.8857768e-01,-7.8836888e-01,-7.8816015e-01, - -7.8795147e-01,-7.8774279e-01,-7.8753418e-01,-7.8732556e-01, - -7.8711700e-01,-7.8690845e-01,-7.8669995e-01,-7.8649151e-01, - -7.8628308e-01,-7.8607470e-01,-7.8586632e-01,-7.8565800e-01, - -7.8544968e-01,-7.8524148e-01,-7.8503323e-01,-7.8482503e-01, - -7.8461689e-01,-7.8440875e-01,-7.8420067e-01,-7.8399265e-01, - -7.8378463e-01,-7.8357661e-01,-7.8336865e-01,-7.8316075e-01, - -7.8295285e-01,-7.8274500e-01,-7.8253722e-01,-7.8232944e-01, - -7.8212166e-01,-7.8191394e-01,-7.8170627e-01,-7.8149861e-01, - -7.8129101e-01,-7.8108346e-01,-7.8087592e-01,-7.8066838e-01, - -7.8046089e-01,-7.8025347e-01,-7.8004605e-01,-7.7983868e-01, - -7.7963132e-01,-7.7942401e-01,-7.7921671e-01,-7.7900952e-01, - -7.7880228e-01,-7.7859509e-01,-7.7838796e-01,-7.7818084e-01, - -7.7797377e-01,-7.7776670e-01,-7.7755970e-01,-7.7735275e-01, - -7.7714580e-01,-7.7693892e-01,-7.7673203e-01,-7.7652514e-01, - -7.7631837e-01,-7.7611160e-01,-7.7590483e-01,-7.7569813e-01, - -7.7549142e-01,-7.7528483e-01,-7.7507818e-01,-7.7487159e-01, - -7.7466506e-01,-7.7445853e-01,-7.7425206e-01,-7.7404565e-01, - -7.7383924e-01,-7.7363282e-01,-7.7342647e-01,-7.7322018e-01, - -7.7301389e-01,-7.7280766e-01,-7.7260143e-01,-7.7239525e-01, - -7.7218908e-01,-7.7198297e-01,-7.7177691e-01,-7.7157086e-01, - -7.7136481e-01,-7.7115881e-01,-7.7095288e-01,-7.7074695e-01, - -7.7054107e-01,-7.7033520e-01,-7.7012938e-01,-7.6992357e-01, - -7.6971781e-01,-7.6951212e-01,-7.6930642e-01,-7.6910079e-01, - -7.6889515e-01,-7.6868951e-01,-7.6848400e-01,-7.6827842e-01, - -7.6807296e-01,-7.6786751e-01,-7.6766205e-01,-7.6745665e-01, - -7.6725125e-01,-7.6704592e-01,-7.6684064e-01,-7.6663536e-01, - -7.6643014e-01,-7.6622492e-01,-7.6601976e-01,-7.6581460e-01, - -7.6560950e-01,-7.6540440e-01,-7.6519936e-01,-7.6499438e-01, - -7.6478940e-01,-7.6458442e-01,-7.6437950e-01,-7.6417464e-01, - -7.6396978e-01,-7.6376498e-01,-7.6356018e-01,-7.6335543e-01, - -7.6315069e-01,-7.6294601e-01,-7.6274133e-01,-7.6253670e-01, - -7.6233208e-01,-7.6212752e-01,-7.6192302e-01,-7.6171851e-01, - -7.6151401e-01,-7.6130962e-01,-7.6110518e-01,-7.6090080e-01, - -7.6069647e-01,-7.6049215e-01,-7.6028788e-01,-7.6008362e-01, - -7.5987941e-01,-7.5967526e-01,-7.5947106e-01,-7.5926697e-01, - -7.5906289e-01,-7.5885880e-01,-7.5865477e-01,-7.5845081e-01, - -7.5824684e-01,-7.5804293e-01,-7.5783902e-01,-7.5763512e-01, - -7.5743133e-01,-7.5722748e-01,-7.5702375e-01,-7.5681996e-01, - -7.5661629e-01,-7.5641263e-01,-7.5620896e-01,-7.5600535e-01, - -7.5580174e-01,-7.5559819e-01,-7.5539470e-01,-7.5519121e-01, - -7.5498772e-01,-7.5478429e-01,-7.5458091e-01,-7.5437754e-01, - -7.5417417e-01,-7.5397086e-01,-7.5376761e-01,-7.5356436e-01, - -7.5336117e-01,-7.5315797e-01,-7.5295484e-01,-7.5275171e-01, - -7.5254864e-01,-7.5234556e-01,-7.5214255e-01,-7.5193954e-01, - -7.5173658e-01,-7.5153369e-01,-7.5133079e-01,-7.5112790e-01, - -7.5092506e-01,-7.5072223e-01,-7.5051945e-01,-7.5031674e-01, - -7.5011402e-01,-7.4991131e-01,-7.4970865e-01,-7.4950606e-01, - -7.4930346e-01,-7.4910092e-01,-7.4889839e-01,-7.4869585e-01, - -7.4849343e-01,-7.4829096e-01,-7.4808854e-01,-7.4788618e-01, - -7.4768382e-01,-7.4748152e-01,-7.4727923e-01,-7.4707699e-01, - -7.4687475e-01,-7.4667257e-01,-7.4647039e-01,-7.4626827e-01, - -7.4606615e-01,-7.4586409e-01,-7.4566203e-01,-7.4546003e-01, - -7.4525809e-01,-7.4505609e-01,-7.4485421e-01,-7.4465233e-01, - -7.4445045e-01,-7.4424863e-01,-7.4404681e-01,-7.4384505e-01, - -7.4364334e-01,-7.4344164e-01,-7.4323994e-01,-7.4303830e-01, - -7.4283665e-01,-7.4263507e-01,-7.4243355e-01,-7.4223202e-01, - -7.4203050e-01,-7.4182904e-01,-7.4162763e-01,-7.4142623e-01, - -7.4122483e-01,-7.4102348e-01,-7.4082220e-01,-7.4062091e-01, - -7.4041963e-01,-7.4021840e-01,-7.4001724e-01,-7.3981607e-01, - -7.3961490e-01,-7.3941380e-01,-7.3921275e-01,-7.3901170e-01, - -7.3881066e-01,-7.3860967e-01,-7.3840874e-01,-7.3820782e-01, - -7.3800689e-01,-7.3780602e-01,-7.3760521e-01,-7.3740441e-01, - -7.3720360e-01,-7.3700285e-01,-7.3680216e-01,-7.3660147e-01, - -7.3640078e-01,-7.3620015e-01,-7.3599958e-01,-7.3579901e-01, - -7.3559844e-01,-7.3539793e-01,-7.3519748e-01,-7.3499703e-01, - -7.3479658e-01,-7.3459619e-01,-7.3439586e-01,-7.3419553e-01, - -7.3399520e-01,-7.3379493e-01,-7.3359466e-01,-7.3339444e-01, - -7.3319429e-01,-7.3299414e-01,-7.3279399e-01,-7.3259389e-01, - -7.3239380e-01,-7.3219377e-01,-7.3199379e-01,-7.3179382e-01, - -7.3159385e-01,-7.3139393e-01,-7.3119402e-01,-7.3099416e-01, - -7.3079431e-01,-7.3059452e-01,-7.3039472e-01,-7.3019499e-01, - -7.2999531e-01,-7.2979558e-01,-7.2959596e-01,-7.2939628e-01, - -7.2919673e-01,-7.2899711e-01,-7.2879755e-01,-7.2859806e-01, - -7.2839856e-01,-7.2819912e-01,-7.2799969e-01,-7.2780031e-01, - -7.2760093e-01,-7.2740161e-01,-7.2720230e-01,-7.2700298e-01, - -7.2680372e-01,-7.2660452e-01,-7.2640532e-01,-7.2620612e-01, - -7.2600698e-01,-7.2580791e-01,-7.2560883e-01,-7.2540975e-01, - -7.2521073e-01,-7.2501177e-01,-7.2481281e-01,-7.2461385e-01, - -7.2441494e-01,-7.2421604e-01,-7.2401720e-01,-7.2381836e-01, - -7.2361958e-01,-7.2342080e-01,-7.2322208e-01,-7.2302336e-01, - -7.2282469e-01,-7.2262603e-01,-7.2242743e-01,-7.2222883e-01, - -7.2203022e-01,-7.2183174e-01,-7.2163320e-01,-7.2143471e-01, - -7.2123629e-01,-7.2103786e-01,-7.2083944e-01,-7.2064108e-01, - -7.2044271e-01,-7.2024441e-01,-7.2004616e-01,-7.1984792e-01, - -7.1964967e-01,-7.1945149e-01,-7.1925330e-01,-7.1905518e-01, - -7.1885705e-01,-7.1865898e-01,-7.1846092e-01,-7.1826285e-01, - -7.1806484e-01,-7.1786690e-01,-7.1766895e-01,-7.1747106e-01, - -7.1727318e-01,-7.1707529e-01,-7.1687746e-01,-7.1667963e-01, - -7.1648186e-01,-7.1628416e-01,-7.1608639e-01,-7.1588874e-01, - -7.1569109e-01,-7.1549344e-01,-7.1529579e-01,-7.1509826e-01, - -7.1490067e-01,-7.1470314e-01,-7.1450567e-01,-7.1430820e-01, - -7.1411073e-01,-7.1391332e-01,-7.1371597e-01,-7.1351862e-01, - -7.1332127e-01,-7.1312398e-01,-7.1292669e-01,-7.1272945e-01, - -7.1253222e-01,-7.1233505e-01,-7.1213788e-01,-7.1194077e-01, - -7.1174365e-01,-7.1154654e-01,-7.1134949e-01,-7.1115249e-01, - -7.1095550e-01,-7.1075851e-01,-7.1056157e-01,-7.1036464e-01, - -7.1016777e-01,-7.0997089e-01,-7.0977408e-01,-7.0957726e-01, - -7.0938051e-01,-7.0918375e-01,-7.0898706e-01,-7.0879036e-01, - -7.0859367e-01,-7.0839703e-01,-7.0820040e-01,-7.0800382e-01, - -7.0780730e-01,-7.0761073e-01,-7.0741427e-01,-7.0721775e-01, - -7.0702136e-01,-7.0682490e-01,-7.0662850e-01,-7.0643216e-01, - -7.0623583e-01,-7.0603949e-01,-7.0584321e-01,-7.0564693e-01, - -7.0545071e-01,-7.0525450e-01,-7.0505834e-01,-7.0486218e-01, - -7.0466608e-01,-7.0446998e-01,-7.0427394e-01,-7.0407790e-01, - -7.0388186e-01,-7.0368588e-01,-7.0348990e-01,-7.0329398e-01, - -7.0309806e-01,-7.0290220e-01,-7.0270634e-01,-7.0251054e-01, - -7.0231473e-01,-7.0211893e-01,-7.0192319e-01,-7.0172751e-01, - -7.0153183e-01,-7.0133615e-01,-7.0114052e-01,-7.0094490e-01, - -7.0074934e-01,-7.0055377e-01,-7.0035821e-01,-7.0016271e-01, - -6.9996727e-01,-6.9977182e-01,-6.9957638e-01,-6.9938099e-01, - -6.9918561e-01,-6.9899029e-01,-6.9879496e-01,-6.9859970e-01, - -6.9840443e-01,-6.9820917e-01,-6.9801396e-01,-6.9781876e-01, - -6.9762361e-01,-6.9742852e-01,-6.9723338e-01,-6.9703835e-01, - -6.9684327e-01,-6.9664824e-01,-6.9645327e-01,-6.9625831e-01, - -6.9606334e-01,-6.9586843e-01,-6.9567353e-01,-6.9547868e-01, - -6.9528383e-01,-6.9508904e-01,-6.9489425e-01,-6.9469947e-01, - -6.9450474e-01,-6.9431007e-01,-6.9411534e-01,-6.9392073e-01, - -6.9372606e-01,-6.9353145e-01,-6.9333690e-01,-6.9314235e-01, - -6.9294786e-01,-6.9275331e-01,-6.9255888e-01,-6.9236445e-01, - -6.9217002e-01,-6.9197559e-01,-6.9178128e-01,-6.9158691e-01, - -6.9139260e-01,-6.9119835e-01,-6.9100404e-01,-6.9080985e-01, - -6.9061559e-01,-6.9042146e-01,-6.9022727e-01,-6.9003314e-01, - -6.8983907e-01,-6.8964499e-01,-6.8945092e-01,-6.8925691e-01, - -6.8906289e-01,-6.8886894e-01,-6.8867499e-01,-6.8848103e-01, - -6.8828714e-01,-6.8809330e-01,-6.8789941e-01,-6.8770564e-01, - -6.8751180e-01,-6.8731803e-01,-6.8712431e-01,-6.8693060e-01, - -6.8673688e-01,-6.8654323e-01,-6.8634963e-01,-6.8615597e-01, - -6.8596238e-01,-6.8576884e-01,-6.8557531e-01,-6.8538177e-01, - -6.8518829e-01,-6.8499488e-01,-6.8480140e-01,-6.8460798e-01, - -6.8441463e-01,-6.8422127e-01,-6.8402797e-01,-6.8383461e-01, - -6.8364137e-01,-6.8344808e-01,-6.8325490e-01,-6.8306166e-01, - -6.8286848e-01,-6.8267536e-01,-6.8248224e-01,-6.8228912e-01, - -6.8209606e-01,-6.8190300e-01,-6.8170995e-01,-6.8151695e-01, - -6.8132401e-01,-6.8113106e-01,-6.8093812e-01,-6.8074524e-01, - -6.8055236e-01,-6.8035948e-01,-6.8016666e-01,-6.7997390e-01, - -6.7978114e-01,-6.7958838e-01,-6.7939562e-01,-6.7920297e-01, - -6.7901027e-01,-6.7881763e-01,-6.7862499e-01,-6.7843240e-01, - -6.7823982e-01,-6.7804730e-01,-6.7785478e-01,-6.7766231e-01, - -6.7746985e-01,-6.7727739e-01,-6.7708498e-01,-6.7689258e-01, - -6.7670017e-01,-6.7650783e-01,-6.7631555e-01,-6.7612326e-01, - -6.7593098e-01,-6.7573875e-01,-6.7554653e-01,-6.7535430e-01, - -6.7516214e-01,-6.7496997e-01,-6.7477787e-01,-6.7458576e-01, - -6.7439371e-01,-6.7420167e-01,-6.7400968e-01,-6.7381763e-01, - -6.7362571e-01,-6.7343372e-01,-6.7324179e-01,-6.7304993e-01, - -6.7285806e-01,-6.7266619e-01,-6.7247438e-01,-6.7228258e-01, - -6.7209083e-01,-6.7189908e-01,-6.7170733e-01,-6.7151564e-01, - -6.7132396e-01,-6.7113233e-01,-6.7094070e-01,-6.7074913e-01, - -6.7055756e-01,-6.7036599e-01,-6.7017448e-01,-6.6998297e-01, - -6.6979146e-01,-6.6960001e-01,-6.6940862e-01,-6.6921723e-01, - -6.6902584e-01,-6.6883445e-01,-6.6864312e-01,-6.6845185e-01, - -6.6826057e-01,-6.6806930e-01,-6.6787809e-01,-6.6768688e-01, - -6.6749567e-01,-6.6730452e-01,-6.6711336e-01,-6.6692227e-01, - -6.6673118e-01,-6.6654015e-01,-6.6634911e-01,-6.6615808e-01, - -6.6596711e-01,-6.6577613e-01,-6.6558522e-01,-6.6539431e-01, - -6.6520339e-01,-6.6501254e-01,-6.6482168e-01,-6.6463089e-01, - -6.6444010e-01,-6.6424930e-01,-6.6405857e-01,-6.6386783e-01, - -6.6367716e-01,-6.6348648e-01,-6.6329581e-01,-6.6310519e-01, - -6.6291457e-01,-6.6272402e-01,-6.6253346e-01,-6.6234291e-01, - -6.6215241e-01,-6.6196197e-01,-6.6177148e-01,-6.6158104e-01, - -6.6139066e-01,-6.6120028e-01,-6.6100991e-01,-6.6081959e-01, - -6.6062927e-01,-6.6043895e-01,-6.6024870e-01,-6.6005844e-01, - -6.5986824e-01,-6.5967804e-01,-6.5948790e-01,-6.5929776e-01, - -6.5910763e-01,-6.5891755e-01,-6.5872747e-01,-6.5853739e-01, - -6.5834737e-01,-6.5815735e-01,-6.5796739e-01,-6.5777743e-01, - -6.5758753e-01,-6.5739763e-01,-6.5720773e-01,-6.5701783e-01, - -6.5682805e-01,-6.5663821e-01,-6.5644842e-01,-6.5625864e-01, - -6.5606892e-01,-6.5587920e-01,-6.5568948e-01,-6.5549982e-01, - -6.5531015e-01,-6.5512055e-01,-6.5493095e-01,-6.5474141e-01, - -6.5455180e-01,-6.5436232e-01,-6.5417278e-01,-6.5398329e-01, - -6.5379387e-01,-6.5360439e-01,-6.5341502e-01,-6.5322560e-01, - -6.5303624e-01,-6.5284693e-01,-6.5265757e-01,-6.5246826e-01, - -6.5227902e-01,-6.5208977e-01,-6.5190053e-01,-6.5171134e-01, - -6.5152216e-01,-6.5133303e-01,-6.5114385e-01,-6.5095478e-01, - -6.5076566e-01,-6.5057659e-01,-6.5038759e-01,-6.5019858e-01, - -6.5000957e-01,-6.4982063e-01,-6.4963168e-01,-6.4944273e-01, - -6.4925385e-01,-6.4906496e-01,-6.4887613e-01,-6.4868730e-01, - -6.4849848e-01,-6.4830971e-01,-6.4812094e-01,-6.4793217e-01, - -6.4774346e-01,-6.4755476e-01,-6.4736611e-01,-6.4717746e-01, - -6.4698887e-01,-6.4680022e-01,-6.4661169e-01,-6.4642310e-01, - -6.4623457e-01,-6.4604610e-01,-6.4585757e-01,-6.4566916e-01, - -6.4548069e-01,-6.4529228e-01,-6.4510387e-01,-6.4491552e-01, - -6.4472717e-01,-6.4453882e-01,-6.4435053e-01,-6.4416224e-01, - -6.4397401e-01,-6.4378577e-01,-6.4359754e-01,-6.4340937e-01, - -6.4322120e-01,-6.4303309e-01,-6.4284497e-01,-6.4265686e-01, - -6.4246881e-01,-6.4228076e-01,-6.4209270e-01,-6.4190471e-01, - -6.4171672e-01,-6.4152879e-01,-6.4134085e-01,-6.4115292e-01, - -6.4096504e-01,-6.4077717e-01,-6.4058930e-01,-6.4040148e-01, - -6.4021367e-01,-6.4002591e-01,-6.3983816e-01,-6.3965040e-01, - -6.3946271e-01,-6.3927501e-01,-6.3908732e-01,-6.3889968e-01, - -6.3871205e-01,-6.3852447e-01,-6.3833690e-01,-6.3814932e-01, - -6.3796180e-01,-6.3777429e-01,-6.3758683e-01,-6.3739938e-01, - -6.3721192e-01,-6.3702452e-01,-6.3683712e-01,-6.3664973e-01, - -6.3646239e-01,-6.3627505e-01,-6.3608772e-01,-6.3590044e-01, - -6.3571316e-01,-6.3552594e-01,-6.3533872e-01,-6.3515151e-01, - -6.3496435e-01,-6.3477719e-01,-6.3459009e-01,-6.3440299e-01, - -6.3421589e-01,-6.3402879e-01,-6.3384175e-01,-6.3365477e-01, - -6.3346779e-01,-6.3328081e-01,-6.3309383e-01,-6.3290691e-01, - -6.3271999e-01,-6.3253313e-01,-6.3234627e-01,-6.3215941e-01, - -6.3197261e-01,-6.3178581e-01,-6.3159901e-01,-6.3141227e-01, - -6.3122553e-01,-6.3103884e-01,-6.3085216e-01,-6.3066548e-01, - -6.3047886e-01,-6.3029224e-01,-6.3010561e-01,-6.2991905e-01, - -6.2973249e-01,-6.2954593e-01,-6.2935942e-01,-6.2917292e-01, - -6.2898648e-01,-6.2880003e-01,-6.2861359e-01,-6.2842721e-01, - -6.2824082e-01,-6.2805444e-01,-6.2786812e-01,-6.2768179e-01, - -6.2749553e-01,-6.2730926e-01,-6.2712300e-01,-6.2693679e-01, - -6.2675059e-01,-6.2656438e-01,-6.2637824e-01,-6.2619209e-01, - -6.2600595e-01,-6.2581986e-01,-6.2563378e-01,-6.2544775e-01, - -6.2526166e-01,-6.2507570e-01,-6.2488967e-01,-6.2470371e-01, - -6.2451780e-01,-6.2433183e-01,-6.2414593e-01,-6.2396008e-01, - -6.2377423e-01,-6.2358838e-01,-6.2340254e-01,-6.2321675e-01, - -6.2303096e-01,-6.2284523e-01,-6.2265950e-01,-6.2247378e-01, - -6.2228811e-01,-6.2210244e-01,-6.2191677e-01,-6.2173116e-01, - -6.2154555e-01,-6.2136000e-01,-6.2117440e-01,-6.2098891e-01, - -6.2080336e-01,-6.2061787e-01,-6.2043238e-01,-6.2024695e-01, - -6.2006152e-01,-6.1987609e-01,-6.1969072e-01,-6.1950535e-01, - -6.1931998e-01,-6.1913466e-01,-6.1894935e-01,-6.1876410e-01, - -6.1857885e-01,-6.1839360e-01,-6.1820835e-01,-6.1802316e-01, - -6.1783803e-01,-6.1765283e-01,-6.1746770e-01,-6.1728263e-01, - -6.1709750e-01,-6.1691242e-01,-6.1672741e-01,-6.1654234e-01, - -6.1635733e-01,-6.1617237e-01,-6.1598742e-01,-6.1580247e-01, - -6.1561751e-01,-6.1543262e-01,-6.1524773e-01,-6.1506289e-01, - -6.1487806e-01,-6.1469322e-01,-6.1450845e-01,-6.1432368e-01, - -6.1413890e-01,-6.1395419e-01,-6.1376947e-01,-6.1358476e-01, - -6.1340010e-01,-6.1321545e-01,-6.1303085e-01,-6.1284620e-01, - -6.1266160e-01,-6.1247706e-01,-6.1229253e-01,-6.1210799e-01, - -6.1192352e-01,-6.1173898e-01,-6.1155456e-01,-6.1137009e-01, - -6.1118567e-01,-6.1100125e-01,-6.1081690e-01,-6.1063254e-01, - -6.1044818e-01,-6.1026388e-01,-6.1007959e-01,-6.0989529e-01, - -6.0971105e-01,-6.0952681e-01,-6.0934263e-01,-6.0915840e-01, - -6.0897428e-01,-6.0879010e-01,-6.0860598e-01,-6.0842186e-01, - -6.0823774e-01,-6.0805368e-01,-6.0786963e-01,-6.0768563e-01, - -6.0750163e-01,-6.0731763e-01,-6.0713369e-01,-6.0694975e-01, - -6.0676581e-01,-6.0658187e-01,-6.0639799e-01,-6.0621417e-01, - -6.0603029e-01,-6.0584646e-01,-6.0566270e-01,-6.0547888e-01, - -6.0529512e-01,-6.0511142e-01,-6.0492766e-01,-6.0474396e-01, - -6.0456032e-01,-6.0437661e-01,-6.0419297e-01,-6.0400939e-01, - -6.0382581e-01,-6.0364223e-01,-6.0345864e-01,-6.0327512e-01, - -6.0309160e-01,-6.0290807e-01,-6.0272461e-01,-6.0254115e-01, - -6.0235775e-01,-6.0217434e-01,-6.0199094e-01,-6.0180753e-01, - -6.0162419e-01,-6.0144085e-01,-6.0125756e-01,-6.0107428e-01, - -6.0089099e-01,-6.0070771e-01,-6.0052449e-01,-6.0034126e-01, - -6.0015810e-01,-5.9997493e-01,-5.9979177e-01,-5.9960866e-01, - -5.9942549e-01,-5.9924245e-01,-5.9905934e-01,-5.9887630e-01, - -5.9869325e-01,-5.9851027e-01,-5.9832728e-01,-5.9814429e-01, - -5.9796137e-01,-5.9777844e-01,-5.9759551e-01,-5.9741259e-01, - -5.9722972e-01,-5.9704691e-01,-5.9686404e-01,-5.9668124e-01, - -5.9649843e-01,-5.9631568e-01,-5.9613293e-01,-5.9595019e-01, - -5.9576750e-01,-5.9558481e-01,-5.9540212e-01,-5.9521949e-01, - -5.9503686e-01,-5.9485424e-01,-5.9467161e-01,-5.9448904e-01, - -5.9430653e-01,-5.9412396e-01,-5.9394145e-01,-5.9375894e-01, - -5.9357649e-01,-5.9339404e-01,-5.9321159e-01,-5.9302920e-01, - -5.9284681e-01,-5.9266442e-01,-5.9248203e-01,-5.9229970e-01, - -5.9211743e-01,-5.9193510e-01,-5.9175283e-01,-5.9157056e-01, - -5.9138834e-01,-5.9120613e-01,-5.9102392e-01,-5.9084171e-01, - -5.9065956e-01,-5.9047747e-01,-5.9029531e-01,-5.9011322e-01, - -5.8993113e-01,-5.8974910e-01,-5.8956701e-01,-5.8938503e-01, - -5.8920300e-01,-5.8902103e-01,-5.8883905e-01,-5.8865714e-01, - -5.8847517e-01,-5.8829331e-01,-5.8811140e-01,-5.8792955e-01, - -5.8774769e-01,-5.8756584e-01,-5.8738405e-01,-5.8720225e-01, - -5.8702052e-01,-5.8683872e-01,-5.8665699e-01,-5.8647531e-01, - -5.8629364e-01,-5.8611196e-01,-5.8593029e-01,-5.8574867e-01, - -5.8556706e-01,-5.8538544e-01,-5.8520389e-01,-5.8502233e-01, - -5.8484077e-01,-5.8465928e-01,-5.8447778e-01,-5.8429629e-01, - -5.8411479e-01,-5.8393335e-01,-5.8375198e-01,-5.8357054e-01, - -5.8338916e-01,-5.8320779e-01,-5.8302647e-01,-5.8284515e-01, - -5.8266383e-01,-5.8248252e-01,-5.8230126e-01,-5.8212000e-01, - -5.8193880e-01,-5.8175761e-01,-5.8157641e-01,-5.8139521e-01, - -5.8121407e-01,-5.8103293e-01,-5.8085179e-01,-5.8067071e-01, - -5.8048964e-01,-5.8030856e-01,-5.8012754e-01,-5.7994652e-01, - -5.7976550e-01,-5.7958454e-01,-5.7940358e-01,-5.7922262e-01, - -5.7904172e-01,-5.7886082e-01,-5.7867992e-01,-5.7849902e-01, - -5.7831818e-01,-5.7813734e-01,-5.7795656e-01,-5.7777578e-01, - -5.7759500e-01,-5.7741421e-01,-5.7723349e-01,-5.7705277e-01, - -5.7687205e-01,-5.7669139e-01,-5.7651073e-01,-5.7633007e-01, - -5.7614946e-01,-5.7596886e-01,-5.7578826e-01,-5.7560772e-01, - -5.7542717e-01,-5.7524663e-01,-5.7506609e-01,-5.7488561e-01, - -5.7470512e-01,-5.7452470e-01,-5.7434428e-01,-5.7416385e-01, - -5.7398343e-01,-5.7380307e-01,-5.7362270e-01,-5.7344234e-01, - -5.7326204e-01,-5.7308173e-01,-5.7290143e-01,-5.7272118e-01, - -5.7254094e-01,-5.7236069e-01,-5.7218051e-01,-5.7200027e-01, - -5.7182014e-01,-5.7163996e-01,-5.7145983e-01,-5.7127970e-01, - -5.7109958e-01,-5.7091951e-01,-5.7073945e-01,-5.7055938e-01, - -5.7037938e-01,-5.7019937e-01,-5.7001936e-01,-5.6983942e-01, - -5.6965947e-01,-5.6947953e-01,-5.6929958e-01,-5.6911969e-01, - -5.6893981e-01,-5.6875998e-01,-5.6858015e-01,-5.6840032e-01, - -5.6822050e-01,-5.6804073e-01,-5.6786096e-01,-5.6768119e-01, - -5.6750149e-01,-5.6732172e-01,-5.6714207e-01,-5.6696236e-01, - -5.6678271e-01,-5.6660306e-01,-5.6642348e-01,-5.6624383e-01, - -5.6606424e-01,-5.6588471e-01,-5.6570512e-01,-5.6552559e-01, - -5.6534612e-01,-5.6516659e-01,-5.6498712e-01,-5.6480765e-01, - -5.6462824e-01,-5.6444883e-01,-5.6426942e-01,-5.6409001e-01, - -5.6391066e-01,-5.6373131e-01,-5.6355196e-01,-5.6337267e-01, - -5.6319338e-01,-5.6301409e-01,-5.6283480e-01,-5.6265557e-01, - -5.6247634e-01,-5.6229717e-01,-5.6211799e-01,-5.6193882e-01, - -5.6175965e-01,-5.6158054e-01,-5.6140143e-01,-5.6122231e-01, - -5.6104320e-01,-5.6086415e-01,-5.6068510e-01,-5.6050611e-01, - -5.6032711e-01,-5.6014812e-01,-5.5996913e-01,-5.5979019e-01, - -5.5961126e-01,-5.5943233e-01,-5.5925345e-01,-5.5907458e-01, - -5.5889571e-01,-5.5871683e-01,-5.5853802e-01,-5.5835921e-01, - -5.5818039e-01,-5.5800164e-01,-5.5782288e-01,-5.5764413e-01, - -5.5746543e-01,-5.5728674e-01,-5.5710804e-01,-5.5692935e-01, - -5.5675071e-01,-5.5657208e-01,-5.5639350e-01,-5.5621487e-01, - -5.5603629e-01,-5.5585772e-01,-5.5567920e-01,-5.5550069e-01, - -5.5532217e-01,-5.5514365e-01,-5.5496520e-01,-5.5478674e-01, - -5.5460835e-01,-5.5442989e-01,-5.5425149e-01,-5.5407310e-01, - -5.5389476e-01,-5.5371642e-01,-5.5353808e-01,-5.5335975e-01, - -5.5318147e-01,-5.5300319e-01,-5.5282491e-01,-5.5264670e-01, - -5.5246848e-01,-5.5229026e-01,-5.5211204e-01,-5.5193388e-01, - -5.5175573e-01,-5.5157757e-01,-5.5139947e-01,-5.5122137e-01, - -5.5104327e-01,-5.5086523e-01,-5.5068713e-01,-5.5050915e-01, - -5.5033112e-01,-5.5015314e-01,-5.4997516e-01,-5.4979718e-01, - -5.4961920e-01,-5.4944128e-01,-5.4926342e-01,-5.4908550e-01, - -5.4890764e-01,-5.4872978e-01,-5.4855192e-01,-5.4837412e-01, - -5.4819632e-01,-5.4801852e-01,-5.4784071e-01,-5.4766297e-01, - -5.4748523e-01,-5.4730749e-01,-5.4712981e-01,-5.4695213e-01, - -5.4677445e-01,-5.4659683e-01,-5.4641914e-01,-5.4624158e-01, - -5.4606396e-01,-5.4588640e-01,-5.4570884e-01,-5.4553127e-01, - -5.4535371e-01,-5.4517621e-01,-5.4499871e-01,-5.4482126e-01, - -5.4464376e-01,-5.4446632e-01,-5.4428893e-01,-5.4411149e-01, - -5.4393411e-01,-5.4375672e-01,-5.4357940e-01,-5.4340202e-01, - -5.4322469e-01,-5.4304737e-01,-5.4287010e-01,-5.4269284e-01, - -5.4251558e-01,-5.4233831e-01,-5.4216111e-01,-5.4198390e-01, - -5.4180670e-01,-5.4162955e-01,-5.4145241e-01,-5.4127526e-01, - -5.4109812e-01,-5.4092103e-01,-5.4074395e-01,-5.4056686e-01, - -5.4038984e-01,-5.4021281e-01,-5.4003578e-01,-5.3985876e-01, - -5.3968179e-01,-5.3950483e-01,-5.3932786e-01,-5.3915095e-01, - -5.3897399e-01,-5.3879714e-01,-5.3862023e-01,-5.3844339e-01, - -5.3826654e-01,-5.3808969e-01,-5.3791285e-01,-5.3773606e-01, - -5.3755927e-01,-5.3738254e-01,-5.3720576e-01,-5.3702903e-01, - -5.3685230e-01,-5.3667563e-01,-5.3649896e-01,-5.3632230e-01, - -5.3614563e-01,-5.3596902e-01,-5.3579235e-01,-5.3561580e-01, - -5.3543919e-01,-5.3526264e-01,-5.3508610e-01,-5.3490955e-01, - -5.3473306e-01,-5.3455651e-01,-5.3438008e-01,-5.3420359e-01, - -5.3402716e-01,-5.3385073e-01,-5.3367430e-01,-5.3349787e-01, - -5.3332150e-01,-5.3314513e-01,-5.3296882e-01,-5.3279245e-01, - -5.3261614e-01,-5.3243983e-01,-5.3226358e-01,-5.3208733e-01, - -5.3191108e-01,-5.3173482e-01,-5.3155863e-01,-5.3138238e-01, - -5.3120625e-01,-5.3103006e-01,-5.3085393e-01,-5.3067780e-01, - -5.3050166e-01,-5.3032553e-01,-5.3014946e-01,-5.2997339e-01, - -5.2979738e-01,-5.2962130e-01,-5.2944529e-01,-5.2926928e-01, - -5.2909333e-01,-5.2891731e-01,-5.2874136e-01,-5.2856547e-01, - -5.2838951e-01,-5.2821362e-01,-5.2803773e-01,-5.2786183e-01, - -5.2768600e-01,-5.2751017e-01,-5.2733433e-01,-5.2715856e-01, - -5.2698272e-01,-5.2680695e-01,-5.2663124e-01,-5.2645546e-01, - -5.2627975e-01,-5.2610403e-01,-5.2592838e-01,-5.2575266e-01, - -5.2557701e-01,-5.2540135e-01,-5.2522576e-01,-5.2505010e-01, - -5.2487451e-01,-5.2469897e-01,-5.2452338e-01,-5.2434784e-01, - -5.2417231e-01,-5.2399683e-01,-5.2382129e-01,-5.2364582e-01, - -5.2347034e-01,-5.2329493e-01,-5.2311945e-01,-5.2294403e-01, - -5.2276868e-01,-5.2259326e-01,-5.2241790e-01,-5.2224255e-01, - -5.2206719e-01,-5.2189189e-01,-5.2171659e-01,-5.2154130e-01, - -5.2136600e-01,-5.2119076e-01,-5.2101552e-01,-5.2084029e-01, - -5.2066511e-01,-5.2048987e-01,-5.2031469e-01,-5.2013958e-01, - -5.1996440e-01,-5.1978928e-01,-5.1961416e-01,-5.1943904e-01, - -5.1926398e-01,-5.1908892e-01,-5.1891387e-01,-5.1873887e-01, - -5.1856381e-01,-5.1838881e-01,-5.1821381e-01,-5.1803887e-01, - -5.1786393e-01,-5.1768899e-01,-5.1751405e-01,-5.1733917e-01, - -5.1716423e-01,-5.1698935e-01,-5.1681453e-01,-5.1663965e-01, - -5.1646483e-01,-5.1629001e-01,-5.1611525e-01,-5.1594043e-01, - -5.1576567e-01,-5.1559097e-01,-5.1541620e-01,-5.1524150e-01, - -5.1506680e-01,-5.1489210e-01,-5.1471746e-01,-5.1454276e-01, - -5.1436812e-01,-5.1419353e-01,-5.1401889e-01,-5.1384431e-01, - -5.1366973e-01,-5.1349521e-01,-5.1332062e-01,-5.1314610e-01, - -5.1297158e-01,-5.1279712e-01,-5.1262259e-01,-5.1244813e-01, - -5.1227367e-01,-5.1209927e-01,-5.1192486e-01,-5.1175046e-01, - -5.1157606e-01,-5.1140165e-01,-5.1122731e-01,-5.1105297e-01, - -5.1087862e-01,-5.1070434e-01,-5.1053005e-01,-5.1035577e-01, - -5.1018149e-01,-5.1000726e-01,-5.0983304e-01,-5.0965881e-01, - -5.0948459e-01,-5.0931042e-01,-5.0913620e-01,-5.0896209e-01, - -5.0878793e-01,-5.0861382e-01,-5.0843972e-01,-5.0826561e-01, - -5.0809151e-01,-5.0791746e-01,-5.0774342e-01,-5.0756937e-01, - -5.0739533e-01,-5.0722134e-01,-5.0704736e-01,-5.0687337e-01, - -5.0669944e-01,-5.0652552e-01,-5.0635159e-01,-5.0617766e-01, - -5.0600374e-01,-5.0582987e-01,-5.0565600e-01,-5.0548220e-01, - -5.0530833e-01,-5.0513452e-01,-5.0496072e-01,-5.0478691e-01, - -5.0461316e-01,-5.0443941e-01,-5.0426567e-01,-5.0409192e-01, - -5.0391823e-01,-5.0374454e-01,-5.0357085e-01,-5.0339717e-01, - -5.0322354e-01,-5.0304991e-01,-5.0287628e-01,-5.0270265e-01, - -5.0252908e-01,-5.0235552e-01,-5.0218195e-01,-5.0200838e-01, - -5.0183487e-01,-5.0166136e-01,-5.0148785e-01,-5.0131434e-01, - -5.0114089e-01,-5.0096744e-01,-5.0079399e-01,-5.0062054e-01, - -5.0044715e-01,-5.0027376e-01,-5.0010037e-01,-4.9992701e-01, - -4.9975368e-01,-4.9958032e-01,-4.9940702e-01,-4.9923372e-01, - -4.9906042e-01,-4.9888715e-01,-4.9871388e-01,-4.9854064e-01, - -4.9836743e-01,-4.9819419e-01,-4.9802101e-01,-4.9784783e-01, - -4.9767464e-01,-4.9750149e-01,-4.9732834e-01,-4.9715522e-01, - -4.9698213e-01,-4.9680904e-01,-4.9663594e-01,-4.9646288e-01, - -4.9628982e-01,-4.9611679e-01,-4.9594378e-01,-4.9577075e-01, - -4.9559778e-01,-4.9542481e-01,-4.9525183e-01,-4.9507889e-01, - -4.9490595e-01,-4.9473304e-01,-4.9456015e-01,-4.9438724e-01, - -4.9421439e-01,-4.9404153e-01,-4.9386868e-01,-4.9369586e-01, - -4.9352303e-01,-4.9335024e-01,-4.9317744e-01,-4.9300468e-01, - -4.9283192e-01,-4.9265918e-01,-4.9248648e-01,-4.9231374e-01, - -4.9214107e-01,-4.9196836e-01,-4.9179572e-01,-4.9162304e-01, - -4.9145043e-01,-4.9127778e-01,-4.9110520e-01,-4.9093258e-01, - -4.9076003e-01,-4.9058744e-01,-4.9041489e-01,-4.9024236e-01, - -4.9006984e-01,-4.8989734e-01,-4.8972484e-01,-4.8955238e-01, - -4.8937991e-01,-4.8920748e-01,-4.8903504e-01,-4.8886260e-01, - -4.8869020e-01,-4.8851782e-01,-4.8834544e-01,-4.8817310e-01, - -4.8800075e-01,-4.8782840e-01,-4.8765609e-01,-4.8748380e-01, - -4.8731151e-01,-4.8713923e-01,-4.8696697e-01,-4.8679471e-01, - -4.8662248e-01,-4.8645028e-01,-4.8627809e-01,-4.8610589e-01, - -4.8593372e-01,-4.8576155e-01,-4.8558941e-01,-4.8541728e-01, - -4.8524517e-01,-4.8507306e-01,-4.8490098e-01,-4.8472890e-01, - -4.8455685e-01,-4.8438480e-01,-4.8421279e-01,-4.8404077e-01, - -4.8386878e-01,-4.8369679e-01,-4.8352480e-01,-4.8335287e-01, - -4.8318091e-01,-4.8300898e-01,-4.8283708e-01,-4.8266518e-01, - -4.8249328e-01,-4.8232141e-01,-4.8214954e-01,-4.8197770e-01, - -4.8180589e-01,-4.8163408e-01,-4.8146227e-01,-4.8129049e-01, - -4.8111871e-01,-4.8094696e-01,-4.8077521e-01,-4.8060349e-01, - -4.8043177e-01,-4.8026007e-01,-4.8008838e-01,-4.7991669e-01, - -4.7974506e-01,-4.7957340e-01,-4.7940177e-01,-4.7923017e-01, - -4.7905856e-01,-4.7888696e-01,-4.7871539e-01,-4.7854382e-01, - -4.7837228e-01,-4.7820076e-01,-4.7802925e-01,-4.7785774e-01, - -4.7768626e-01,-4.7751477e-01,-4.7734332e-01,-4.7717187e-01, - -4.7700042e-01,-4.7682902e-01,-4.7665760e-01,-4.7648621e-01, - -4.7631484e-01,-4.7614348e-01,-4.7597212e-01,-4.7580078e-01, - -4.7562948e-01,-4.7545815e-01,-4.7528687e-01,-4.7511560e-01, - -4.7494432e-01,-4.7477308e-01,-4.7460184e-01,-4.7443059e-01, - -4.7425941e-01,-4.7408819e-01,-4.7391701e-01,-4.7374585e-01, - -4.7357470e-01,-4.7340354e-01,-4.7323242e-01,-4.7306132e-01, - -4.7289023e-01,-4.7271913e-01,-4.7254807e-01,-4.7237700e-01, - -4.7220597e-01,-4.7203493e-01,-4.7186393e-01,-4.7169292e-01, - -4.7152191e-01,-4.7135094e-01,-4.7117999e-01,-4.7100905e-01, - -4.7083810e-01,-4.7066718e-01,-4.7049630e-01,-4.7032538e-01, - -4.7015452e-01,-4.6998364e-01,-4.6981281e-01,-4.6964195e-01, - -4.6947113e-01,-4.6930033e-01,-4.6912953e-01,-4.6895874e-01, - -4.6878797e-01,-4.6861723e-01,-4.6844649e-01,-4.6827576e-01, - -4.6810505e-01,-4.6793434e-01,-4.6776366e-01,-4.6759298e-01, - -4.6742234e-01,-4.6725169e-01,-4.6708104e-01,-4.6691042e-01, - -4.6673983e-01,-4.6656922e-01,-4.6639866e-01,-4.6622810e-01, - -4.6605754e-01,-4.6588701e-01,-4.6571648e-01,-4.6554595e-01, - -4.6537545e-01,-4.6520498e-01,-4.6503451e-01,-4.6486405e-01, - -4.6469361e-01,-4.6452320e-01,-4.6435279e-01,-4.6418238e-01, - -4.6401197e-01,-4.6384162e-01,-4.6367124e-01,-4.6350089e-01, - -4.6333057e-01,-4.6316025e-01,-4.6298993e-01,-4.6281964e-01, - -4.6264935e-01,-4.6247908e-01,-4.6230882e-01,-4.6213859e-01, - -4.6196836e-01,-4.6179816e-01,-4.6162796e-01,-4.6145776e-01, - -4.6128759e-01,-4.6111742e-01,-4.6094728e-01,-4.6077716e-01, - -4.6060702e-01,-4.6043691e-01,-4.6026683e-01,-4.6009675e-01, - -4.5992669e-01,-4.5975661e-01,-4.5958659e-01,-4.5941657e-01, - -4.5924655e-01,-4.5907655e-01,-4.5890656e-01,-4.5873657e-01, - -4.5856661e-01,-4.5839667e-01,-4.5822674e-01,-4.5805681e-01, - -4.5788690e-01,-4.5771700e-01,-4.5754713e-01,-4.5737725e-01, - -4.5720741e-01,-4.5703757e-01,-4.5686772e-01,-4.5669791e-01, - -4.5652813e-01,-4.5635834e-01,-4.5618856e-01,-4.5601878e-01, - -4.5584905e-01,-4.5567930e-01,-4.5550957e-01,-4.5533988e-01, - -4.5517018e-01,-4.5500049e-01,-4.5483083e-01,-4.5466116e-01, - -4.5449153e-01,-4.5432189e-01,-4.5415226e-01,-4.5398265e-01, - -4.5381308e-01,-4.5364347e-01,-4.5347393e-01,-4.5330435e-01, - -4.5313483e-01,-4.5296529e-01,-4.5279577e-01,-4.5262629e-01, - -4.5245680e-01,-4.5228732e-01,-4.5211786e-01,-4.5194840e-01, - -4.5177898e-01,-4.5160955e-01,-4.5144013e-01,-4.5127073e-01, - -4.5110136e-01,-4.5093197e-01,-4.5076263e-01,-4.5059326e-01, - -4.5042393e-01,-4.5025462e-01,-4.5008531e-01,-4.4991601e-01, - -4.4974673e-01,-4.4957748e-01,-4.4940820e-01,-4.4923896e-01, - -4.4906974e-01,-4.4890052e-01,-4.4873130e-01,-4.4856212e-01, - -4.4839296e-01,-4.4822377e-01,-4.4805464e-01,-4.4788548e-01, - -4.4771636e-01,-4.4754726e-01,-4.4737816e-01,-4.4720906e-01, - -4.4703999e-01,-4.4687092e-01,-4.4670185e-01,-4.4653282e-01, - -4.4636381e-01,-4.4619480e-01,-4.4602579e-01,-4.4585681e-01, - -4.4568783e-01,-4.4551888e-01,-4.4534993e-01,-4.4518098e-01, - -4.4501206e-01,-4.4484314e-01,-4.4467425e-01,-4.4450536e-01, - -4.4433650e-01,-4.4416764e-01,-4.4399878e-01,-4.4382995e-01, - -4.4366112e-01,-4.4349232e-01,-4.4332352e-01,-4.4315475e-01, - -4.4298598e-01,-4.4281721e-01,-4.4264847e-01,-4.4247973e-01, - -4.4231102e-01,-4.4214231e-01,-4.4197360e-01,-4.4180492e-01, - -4.4163626e-01,-4.4146761e-01,-4.4129896e-01,-4.4113031e-01, - -4.4096169e-01,-4.4079310e-01,-4.4062451e-01,-4.4045591e-01, - -4.4028735e-01,-4.4011879e-01,-4.3995023e-01,-4.3978170e-01, - -4.3961319e-01,-4.3944469e-01,-4.3927619e-01,-4.3910772e-01, - -4.3893924e-01,-4.3877077e-01,-4.3860233e-01,-4.3843389e-01, - -4.3826547e-01,-4.3809706e-01,-4.3792868e-01,-4.3776029e-01, - -4.3759191e-01,-4.3742356e-01,-4.3725520e-01,-4.3708688e-01, - -4.3691856e-01,-4.3675026e-01,-4.3658197e-01,-4.3641368e-01, - -4.3624541e-01,-4.3607715e-01,-4.3590888e-01,-4.3574065e-01, - -4.3557245e-01,-4.3540421e-01,-4.3523604e-01,-4.3506783e-01, - -4.3489966e-01,-4.3473151e-01,-4.3456337e-01,-4.3439522e-01, - -4.3422711e-01,-4.3405899e-01,-4.3389088e-01,-4.3372279e-01, - -4.3355474e-01,-4.3338665e-01,-4.3321860e-01,-4.3305057e-01, - -4.3288255e-01,-4.3271452e-01,-4.3254653e-01,-4.3237853e-01, - -4.3221056e-01,-4.3204260e-01,-4.3187466e-01,-4.3170670e-01, - -4.3153879e-01,-4.3137085e-01,-4.3120295e-01,-4.3103507e-01, - -4.3086720e-01,-4.3069932e-01,-4.3053147e-01,-4.3036363e-01, - -4.3019578e-01,-4.3002796e-01,-4.2986017e-01,-4.2969236e-01, - -4.2952460e-01,-4.2935681e-01,-4.2918906e-01,-4.2902130e-01, - -4.2885357e-01,-4.2868584e-01,-4.2851815e-01,-4.2835045e-01, - -4.2818275e-01,-4.2801508e-01,-4.2784742e-01,-4.2767978e-01, - -4.2751214e-01,-4.2734450e-01,-4.2717689e-01,-4.2700928e-01, - -4.2684171e-01,-4.2667413e-01,-4.2650655e-01,-4.2633900e-01, - -4.2617145e-01,-4.2600393e-01,-4.2583641e-01,-4.2566890e-01, - -4.2550141e-01,-4.2533392e-01,-4.2516646e-01,-4.2499900e-01, - -4.2483154e-01,-4.2466411e-01,-4.2449671e-01,-4.2432928e-01, - -4.2416188e-01,-4.2399451e-01,-4.2382711e-01,-4.2365977e-01, - -4.2349240e-01,-4.2332506e-01,-4.2315775e-01,-4.2299041e-01, - -4.2282313e-01,-4.2265582e-01,-4.2248854e-01,-4.2232129e-01, - -4.2215401e-01,-4.2198679e-01,-4.2181954e-01,-4.2165232e-01, - -4.2148513e-01,-4.2131791e-01,-4.2115071e-01,-4.2098355e-01, - -4.2081639e-01,-4.2064923e-01,-4.2048210e-01,-4.2031497e-01, - -4.2014787e-01,-4.1998076e-01,-4.1981366e-01,-4.1964659e-01, - -4.1947952e-01,-4.1931245e-01,-4.1914541e-01,-4.1897836e-01, - -4.1881135e-01,-4.1864434e-01,-4.1847736e-01,-4.1831037e-01, - -4.1814339e-01,-4.1797641e-01,-4.1780946e-01,-4.1764253e-01, - -4.1747561e-01,-4.1730869e-01,-4.1714177e-01,-4.1697487e-01, - -4.1680801e-01,-4.1664115e-01,-4.1647428e-01,-4.1630742e-01, - -4.1614059e-01,-4.1597375e-01,-4.1580695e-01,-4.1564015e-01, - -4.1547337e-01,-4.1530660e-01,-4.1513982e-01,-4.1497305e-01, - -4.1480631e-01,-4.1463959e-01,-4.1447288e-01,-4.1430616e-01, - -4.1413945e-01,-4.1397277e-01,-4.1380611e-01,-4.1363943e-01, - -4.1347280e-01,-4.1330615e-01,-4.1313952e-01,-4.1297290e-01, - -4.1280630e-01,-4.1263971e-01,-4.1247311e-01,-4.1230655e-01, - -4.1213998e-01,-4.1197345e-01,-4.1180691e-01,-4.1164038e-01, - -4.1147387e-01,-4.1130736e-01,-4.1114089e-01,-4.1097438e-01, - -4.1080794e-01,-4.1064146e-01,-4.1047502e-01,-4.1030860e-01, - -4.1014215e-01,-4.0997577e-01,-4.0980935e-01,-4.0964296e-01, - -4.0947658e-01,-4.0931022e-01,-4.0914387e-01,-4.0897754e-01, - -4.0881118e-01,-4.0864488e-01,-4.0847856e-01,-4.0831226e-01, - -4.0814599e-01,-4.0797970e-01,-4.0781343e-01,-4.0764719e-01, - -4.0748096e-01,-4.0731472e-01,-4.0714851e-01,-4.0698227e-01, - -4.0681610e-01,-4.0664992e-01,-4.0648374e-01,-4.0631756e-01, - -4.0615141e-01,-4.0598527e-01,-4.0581915e-01,-4.0565303e-01, - -4.0548691e-01,-4.0532082e-01,-4.0515473e-01,-4.0498868e-01, - -4.0482262e-01,-4.0465656e-01,-4.0449050e-01,-4.0432447e-01, - -4.0415847e-01,-4.0399247e-01,-4.0382648e-01,-4.0366048e-01, - -4.0349451e-01,-4.0332854e-01,-4.0316260e-01,-4.0299666e-01, - -4.0283072e-01,-4.0266481e-01,-4.0249890e-01,-4.0233302e-01, - -4.0216711e-01,-4.0200126e-01,-4.0183538e-01,-4.0166953e-01, - -4.0150368e-01,-4.0133786e-01,-4.0117204e-01,-4.0100625e-01, - -4.0084043e-01,-4.0067467e-01,-4.0050888e-01,-4.0034312e-01, - -4.0017736e-01,-4.0001163e-01,-3.9984590e-01,-3.9968017e-01, - -3.9951447e-01,-3.9934877e-01,-3.9918309e-01,-3.9901742e-01, - -3.9885175e-01,-3.9868611e-01,-3.9852047e-01,-3.9835483e-01, - -3.9818922e-01,-3.9802361e-01,-3.9785799e-01,-3.9769241e-01, - -3.9752683e-01,-3.9736128e-01,-3.9719570e-01,-3.9703017e-01, - -3.9686462e-01,-3.9669910e-01,-3.9653361e-01,-3.9636809e-01, - -3.9620259e-01,-3.9603713e-01,-3.9587167e-01,-3.9570621e-01, - -3.9554074e-01,-3.9537531e-01,-3.9520991e-01,-3.9504448e-01, - -3.9487907e-01,-3.9471370e-01,-3.9454830e-01,-3.9438292e-01, - -3.9421758e-01,-3.9405224e-01,-3.9388689e-01,-3.9372155e-01, - -3.9355624e-01,-3.9339092e-01,-3.9322564e-01,-3.9306036e-01, - -3.9289507e-01,-3.9272982e-01,-3.9256456e-01,-3.9239931e-01, - -3.9223409e-01,-3.9206886e-01,-3.9190367e-01,-3.9173847e-01, - -3.9157328e-01,-3.9140809e-01,-3.9124292e-01,-3.9107779e-01, - -3.9091262e-01,-3.9074749e-01,-3.9058238e-01,-3.9041725e-01, - -3.9025214e-01,-3.9008707e-01,-3.8992199e-01,-3.8975692e-01, - -3.8959184e-01,-3.8942680e-01,-3.8926175e-01,-3.8909674e-01, - -3.8893172e-01,-3.8876671e-01,-3.8860172e-01,-3.8843673e-01, - -3.8827175e-01,-3.8810679e-01,-3.8794184e-01,-3.8777688e-01, - -3.8761196e-01,-3.8744703e-01,-3.8728210e-01,-3.8711721e-01, - -3.8695231e-01,-3.8678744e-01,-3.8662258e-01,-3.8645771e-01, - -3.8629287e-01,-3.8612801e-01,-3.8596320e-01,-3.8579836e-01, - -3.8563356e-01,-3.8546878e-01,-3.8530397e-01,-3.8513920e-01, - -3.8497445e-01,-3.8480970e-01,-3.8464496e-01,-3.8448021e-01, - -3.8431549e-01,-3.8415077e-01,-3.8398609e-01,-3.8382137e-01, - -3.8365671e-01,-3.8349202e-01,-3.8332736e-01,-3.8316271e-01, - -3.8299808e-01,-3.8283345e-01,-3.8266882e-01,-3.8250422e-01, - -3.8233963e-01,-3.8217503e-01,-3.8201046e-01,-3.8184589e-01, - -3.8168132e-01,-3.8151678e-01,-3.8135225e-01,-3.8118771e-01, - -3.8102320e-01,-3.8085869e-01,-3.8069418e-01,-3.8052970e-01, - -3.8036522e-01,-3.8020077e-01,-3.8003632e-01,-3.7987188e-01, - -3.7970743e-01,-3.7954301e-01,-3.7937859e-01,-3.7921420e-01, - -3.7904981e-01,-3.7888542e-01,-3.7872106e-01,-3.7855670e-01, - -3.7839234e-01,-3.7822798e-01,-3.7806365e-01,-3.7789935e-01, - -3.7773502e-01,-3.7757072e-01,-3.7740645e-01,-3.7724215e-01, - -3.7707788e-01,-3.7691364e-01,-3.7674937e-01,-3.7658513e-01, - -3.7642092e-01,-3.7625667e-01,-3.7609249e-01,-3.7592828e-01, - -3.7576410e-01,-3.7559992e-01,-3.7543574e-01,-3.7527159e-01, - -3.7510744e-01,-3.7494329e-01,-3.7477916e-01,-3.7461504e-01, - -3.7445095e-01,-3.7428683e-01,-3.7412277e-01,-3.7395868e-01, - -3.7379462e-01,-3.7363055e-01,-3.7346649e-01,-3.7330246e-01, - -3.7313843e-01,-3.7297443e-01,-3.7281042e-01,-3.7264642e-01, - -3.7248242e-01,-3.7231845e-01,-3.7215447e-01,-3.7199053e-01, - -3.7182659e-01,-3.7166265e-01,-3.7149870e-01,-3.7133479e-01, - -3.7117088e-01,-3.7100700e-01,-3.7084311e-01,-3.7067923e-01, - -3.7051535e-01,-3.7035149e-01,-3.7018764e-01,-3.7002382e-01, - -3.6985999e-01,-3.6969617e-01,-3.6953235e-01,-3.6936855e-01, - -3.6920476e-01,-3.6904100e-01,-3.6887723e-01,-3.6871347e-01, - -3.6854970e-01,-3.6838597e-01,-3.6822224e-01,-3.6805853e-01, - -3.6789483e-01,-3.6773112e-01,-3.6756742e-01,-3.6740375e-01, - -3.6724007e-01,-3.6707643e-01,-3.6691278e-01,-3.6674914e-01, - -3.6658549e-01,-3.6642188e-01,-3.6625826e-01,-3.6609468e-01, - -3.6593106e-01,-3.6576751e-01,-3.6560392e-01,-3.6544037e-01, - -3.6527681e-01,-3.6511326e-01,-3.6494973e-01,-3.6478621e-01, - -3.6462271e-01,-3.6445919e-01,-3.6429569e-01,-3.6413223e-01, - -3.6396876e-01,-3.6380529e-01,-3.6364183e-01,-3.6347839e-01, - -3.6331496e-01,-3.6315152e-01,-3.6298811e-01,-3.6282471e-01, - -3.6266130e-01,-3.6249793e-01,-3.6233455e-01,-3.6217117e-01, - -3.6200783e-01,-3.6184445e-01,-3.6168113e-01,-3.6151779e-01, - -3.6135447e-01,-3.6119115e-01,-3.6102787e-01,-3.6086458e-01, - -3.6070129e-01,-3.6053804e-01,-3.6037478e-01,-3.6021152e-01, - -3.6004826e-01,-3.5988504e-01,-3.5972181e-01,-3.5955861e-01, - -3.5939538e-01,-3.5923222e-01,-3.5906902e-01,-3.5890585e-01, - -3.5874268e-01,-3.5857952e-01,-3.5841638e-01,-3.5825324e-01, - -3.5809010e-01,-3.5792699e-01,-3.5776389e-01,-3.5760078e-01, - -3.5743770e-01,-3.5727462e-01,-3.5711154e-01,-3.5694849e-01, - -3.5678545e-01,-3.5662240e-01,-3.5645935e-01,-3.5629633e-01, - -3.5613331e-01,-3.5597032e-01,-3.5580733e-01,-3.5564435e-01, - -3.5548136e-01,-3.5531840e-01,-3.5515544e-01,-3.5499248e-01, - -3.5482955e-01,-3.5466662e-01,-3.5450372e-01,-3.5434079e-01, - -3.5417789e-01,-3.5401499e-01,-3.5385212e-01,-3.5368925e-01, - -3.5352638e-01,-3.5336354e-01,-3.5320070e-01,-3.5303786e-01, - -3.5287502e-01,-3.5271221e-01,-3.5254940e-01,-3.5238662e-01, - -3.5222381e-01,-3.5206103e-01,-3.5189828e-01,-3.5173550e-01, - -3.5157275e-01,-3.5141003e-01,-3.5124728e-01,-3.5108456e-01, - -3.5092187e-01,-3.5075915e-01,-3.5059646e-01,-3.5043377e-01, - -3.5027111e-01,-3.5010841e-01,-3.4994578e-01,-3.4978312e-01, - -3.4962049e-01,-3.4945786e-01,-3.4929523e-01,-3.4913263e-01, - -3.4897003e-01,-3.4880742e-01,-3.4864485e-01,-3.4848228e-01, - -3.4831971e-01,-3.4815714e-01,-3.4799460e-01,-3.4783205e-01, - -3.4766954e-01,-3.4750700e-01,-3.4734452e-01,-3.4718201e-01, - -3.4701952e-01,-3.4685704e-01,-3.4669456e-01,-3.4653208e-01, - -3.4636962e-01,-3.4620720e-01,-3.4604475e-01,-3.4588233e-01, - -3.4571990e-01,-3.4555748e-01,-3.4539509e-01,-3.4523270e-01, - -3.4507033e-01,-3.4490794e-01,-3.4474558e-01,-3.4458324e-01, - -3.4442088e-01,-3.4425855e-01,-3.4409621e-01,-3.4393391e-01, - -3.4377158e-01,-3.4360930e-01,-3.4344700e-01,-3.4328473e-01, - -3.4312245e-01,-3.4296018e-01,-3.4279794e-01,-3.4263566e-01, - -3.4247345e-01,-3.4231120e-01,-3.4214899e-01,-3.4198678e-01, - -3.4182459e-01,-3.4166238e-01,-3.4150019e-01,-3.4133804e-01, - -3.4117585e-01,-3.4101370e-01,-3.4085155e-01,-3.4068942e-01, - -3.4052730e-01,-3.4036517e-01,-3.4020305e-01,-3.4004095e-01, - -3.3987886e-01,-3.3971679e-01,-3.3955470e-01,-3.3939263e-01, - -3.3923057e-01,-3.3906853e-01,-3.3890650e-01,-3.3874446e-01, - -3.3858243e-01,-3.3842042e-01,-3.3825842e-01,-3.3809641e-01, - -3.3793443e-01,-3.3777246e-01,-3.3761048e-01,-3.3744854e-01, - -3.3728656e-01,-3.3712465e-01,-3.3696270e-01,-3.3680078e-01, - -3.3663887e-01,-3.3647695e-01,-3.3631504e-01,-3.3615315e-01, - -3.3599129e-01,-3.3582941e-01,-3.3566755e-01,-3.3550569e-01, - -3.3534384e-01,-3.3518201e-01,-3.3502018e-01,-3.3485836e-01, - -3.3469656e-01,-3.3453473e-01,-3.3437297e-01,-3.3421117e-01, - -3.3404940e-01,-3.3388764e-01,-3.3372587e-01,-3.3356413e-01, - -3.3340237e-01,-3.3324066e-01,-3.3307892e-01,-3.3291721e-01, - -3.3275551e-01,-3.3259380e-01,-3.3243212e-01,-3.3227044e-01, - -3.3210877e-01,-3.3194712e-01,-3.3178544e-01,-3.3162379e-01, - -3.3146217e-01,-3.3130056e-01,-3.3113891e-01,-3.3097732e-01, - -3.3081570e-01,-3.3065411e-01,-3.3049253e-01,-3.3033097e-01, - -3.3016938e-01,-3.3000782e-01,-3.2984629e-01,-3.2968473e-01, - -3.2952321e-01,-3.2936168e-01,-3.2920018e-01,-3.2903865e-01, - -3.2887715e-01,-3.2871568e-01,-3.2855418e-01,-3.2839271e-01, - -3.2823125e-01,-3.2806981e-01,-3.2790837e-01,-3.2774693e-01, - -3.2758549e-01,-3.2742405e-01,-3.2726264e-01,-3.2710126e-01, - -3.2693985e-01,-3.2677847e-01,-3.2661709e-01,-3.2645571e-01, - -3.2629436e-01,-3.2613301e-01,-3.2597166e-01,-3.2581031e-01, - -3.2564899e-01,-3.2548767e-01,-3.2532635e-01,-3.2516506e-01, - -3.2500377e-01,-3.2484248e-01,-3.2468119e-01,-3.2451993e-01, - -3.2435867e-01,-3.2419741e-01,-3.2403618e-01,-3.2387495e-01, - -3.2371372e-01,-3.2355249e-01,-3.2339129e-01,-3.2323009e-01, - -3.2306889e-01,-3.2290772e-01,-3.2274655e-01,-3.2258537e-01, - -3.2242420e-01,-3.2226306e-01,-3.2210192e-01,-3.2194078e-01, - -3.2177964e-01,-3.2161853e-01,-3.2145742e-01,-3.2129633e-01, - -3.2113522e-01,-3.2097414e-01,-3.2081306e-01,-3.2065201e-01, - -3.2049096e-01,-3.2032990e-01,-3.2016885e-01,-3.2000783e-01, - -3.1984678e-01,-3.1968579e-01,-3.1952477e-01,-3.1936377e-01, - -3.1920278e-01,-3.1904179e-01,-3.1888083e-01,-3.1871983e-01, - -3.1855887e-01,-3.1839794e-01,-3.1823698e-01,-3.1807604e-01, - -3.1791514e-01,-3.1775421e-01,-3.1759331e-01,-3.1743240e-01, - -3.1727150e-01,-3.1711063e-01,-3.1694973e-01,-3.1678888e-01, - -3.1662801e-01,-3.1646717e-01,-3.1630632e-01,-3.1614548e-01, - -3.1598464e-01,-3.1582382e-01,-3.1566301e-01,-3.1550223e-01, - -3.1534141e-01,-3.1518063e-01,-3.1501985e-01,-3.1485909e-01, - -3.1469831e-01,-3.1453755e-01,-3.1437680e-01,-3.1421608e-01, - -3.1405535e-01,-3.1389463e-01,-3.1373391e-01,-3.1357321e-01, - -3.1341252e-01,-3.1325182e-01,-3.1309113e-01,-3.1293046e-01, - -3.1276980e-01,-3.1260914e-01,-3.1244847e-01,-3.1228784e-01, - -3.1212720e-01,-3.1196660e-01,-3.1180596e-01,-3.1164536e-01, - -3.1148475e-01,-3.1132415e-01,-3.1116357e-01,-3.1100300e-01, - -3.1084242e-01,-3.1068188e-01,-3.1052130e-01,-3.1036076e-01, - -3.1020024e-01,-3.1003970e-01,-3.0987918e-01,-3.0971867e-01, - -3.0955815e-01,-3.0939767e-01,-3.0923718e-01,-3.0907670e-01, - -3.0891621e-01,-3.0875576e-01,-3.0859530e-01,-3.0843484e-01, - -3.0827442e-01,-3.0811396e-01,-3.0795354e-01,-3.0779314e-01, - -3.0763271e-01,-3.0747232e-01,-3.0731192e-01,-3.0715156e-01, - -3.0699116e-01,-3.0683079e-01,-3.0667043e-01,-3.0651006e-01, - -3.0634972e-01,-3.0618939e-01,-3.0602905e-01,-3.0586874e-01, - -3.0570841e-01,-3.0554810e-01,-3.0538782e-01,-3.0522752e-01, - -3.0506724e-01,-3.0490696e-01,-3.0474669e-01,-3.0458644e-01, - -3.0442619e-01,-3.0426595e-01,-3.0410570e-01,-3.0394548e-01, - -3.0378526e-01,-3.0362505e-01,-3.0346483e-01,-3.0330464e-01, - -3.0314445e-01,-3.0298427e-01,-3.0282408e-01,-3.0266392e-01, - -3.0250376e-01,-3.0234361e-01,-3.0218348e-01,-3.0202332e-01, - -3.0186319e-01,-3.0170310e-01,-3.0154297e-01,-3.0138287e-01, - -3.0122277e-01,-3.0106267e-01,-3.0090261e-01,-3.0074254e-01, - -3.0058247e-01,-3.0042240e-01,-3.0026236e-01,-3.0010229e-01, - -2.9994226e-01,-2.9978225e-01,-2.9962221e-01,-2.9946220e-01, - -2.9930219e-01,-2.9914221e-01,-2.9898220e-01,-2.9882222e-01, - -2.9866228e-01,-2.9850230e-01,-2.9834235e-01,-2.9818240e-01, - -2.9802245e-01,-2.9786250e-01,-2.9770258e-01,-2.9754266e-01, - -2.9738274e-01,-2.9722282e-01,-2.9706293e-01,-2.9690304e-01, - -2.9674315e-01,-2.9658329e-01,-2.9642344e-01,-2.9626358e-01, - -2.9610372e-01,-2.9594386e-01,-2.9578403e-01,-2.9562420e-01, - -2.9546437e-01,-2.9530457e-01,-2.9514477e-01,-2.9498497e-01, - -2.9482517e-01,-2.9466537e-01,-2.9450560e-01,-2.9434583e-01, - -2.9418609e-01,-2.9402632e-01,-2.9386657e-01,-2.9370683e-01, - -2.9354709e-01,-2.9338738e-01,-2.9322764e-01,-2.9306796e-01, - -2.9290825e-01,-2.9274854e-01,-2.9258886e-01,-2.9242918e-01, - -2.9226950e-01,-2.9210985e-01,-2.9195020e-01,-2.9179054e-01, - -2.9163089e-01,-2.9147127e-01,-2.9131162e-01,-2.9115203e-01, - -2.9099241e-01,-2.9083279e-01,-2.9067320e-01,-2.9051360e-01, - -2.9035401e-01,-2.9019445e-01,-2.9003489e-01,-2.8987533e-01, - -2.8971577e-01,-2.8955624e-01,-2.8939667e-01,-2.8923714e-01, - -2.8907764e-01,-2.8891811e-01,-2.8875861e-01,-2.8859910e-01, - -2.8843960e-01,-2.8828013e-01,-2.8812063e-01,-2.8796116e-01, - -2.8780171e-01,-2.8764224e-01,-2.8748280e-01,-2.8732336e-01, - -2.8716391e-01,-2.8700447e-01,-2.8684506e-01,-2.8668565e-01, - -2.8652623e-01,-2.8636685e-01,-2.8620744e-01,-2.8604805e-01, - -2.8588867e-01,-2.8572932e-01,-2.8556997e-01,-2.8541058e-01, - -2.8525126e-01,-2.8509191e-01,-2.8493258e-01,-2.8477323e-01, - -2.8461394e-01,-2.8445461e-01,-2.8429532e-01,-2.8413600e-01, - -2.8397670e-01,-2.8381744e-01,-2.8365815e-01,-2.8349888e-01, - -2.8333962e-01,-2.8318036e-01,-2.8302112e-01,-2.8286189e-01, - -2.8270265e-01,-2.8254342e-01,-2.8238422e-01,-2.8222498e-01, - -2.8206578e-01,-2.8190657e-01,-2.8174740e-01,-2.8158823e-01, - -2.8142905e-01,-2.8126988e-01,-2.8111070e-01,-2.8095156e-01, - -2.8079242e-01,-2.8063327e-01,-2.8047413e-01,-2.8031501e-01, - -2.8015590e-01,-2.7999678e-01,-2.7983767e-01,-2.7967858e-01, - -2.7951947e-01,-2.7936038e-01,-2.7920133e-01,-2.7904224e-01, - -2.7888319e-01,-2.7872413e-01,-2.7856508e-01,-2.7840602e-01, - -2.7824700e-01,-2.7808797e-01,-2.7792895e-01,-2.7776995e-01, - -2.7761093e-01,-2.7745193e-01,-2.7729294e-01,-2.7713397e-01, - -2.7697498e-01,-2.7681601e-01,-2.7665704e-01,-2.7649808e-01, - -2.7633914e-01,-2.7618021e-01,-2.7602127e-01,-2.7586234e-01, - -2.7570340e-01,-2.7554449e-01,-2.7538559e-01,-2.7522668e-01, - -2.7506778e-01,-2.7490890e-01,-2.7475002e-01,-2.7459115e-01, - -2.7443227e-01,-2.7427343e-01,-2.7411455e-01,-2.7395570e-01, - -2.7379689e-01,-2.7363804e-01,-2.7347922e-01,-2.7332041e-01, - -2.7316159e-01,-2.7300277e-01,-2.7284399e-01,-2.7268520e-01, - -2.7252641e-01,-2.7236763e-01,-2.7220887e-01,-2.7205011e-01, - -2.7189136e-01,-2.7173260e-01,-2.7157384e-01,-2.7141511e-01, - -2.7125639e-01,-2.7109766e-01,-2.7093893e-01,-2.7078024e-01, - -2.7062154e-01,-2.7046284e-01,-2.7030414e-01,-2.7014548e-01, - -2.6998681e-01,-2.6982814e-01,-2.6966947e-01,-2.6951081e-01, - -2.6935217e-01,-2.6919353e-01,-2.6903489e-01,-2.6887625e-01, - -2.6871765e-01,-2.6855904e-01,-2.6840043e-01,-2.6824182e-01, - -2.6808321e-01,-2.6792464e-01,-2.6776606e-01,-2.6760748e-01, - -2.6744893e-01,-2.6729035e-01,-2.6713181e-01,-2.6697326e-01, - -2.6681474e-01,-2.6665619e-01,-2.6649767e-01,-2.6633915e-01, - -2.6618063e-01,-2.6602212e-01,-2.6586363e-01,-2.6570514e-01, - -2.6554665e-01,-2.6538816e-01,-2.6522970e-01,-2.6507124e-01, - -2.6491278e-01,-2.6475433e-01,-2.6459587e-01,-2.6443744e-01, - -2.6427901e-01,-2.6412058e-01,-2.6396215e-01,-2.6380375e-01, - -2.6364532e-01,-2.6348692e-01,-2.6332855e-01,-2.6317015e-01, - -2.6301178e-01,-2.6285341e-01,-2.6269504e-01,-2.6253667e-01, - -2.6237831e-01,-2.6221997e-01,-2.6206163e-01,-2.6190329e-01, - -2.6174498e-01,-2.6158664e-01,-2.6142833e-01,-2.6127002e-01, - -2.6111174e-01,-2.6095343e-01,-2.6079515e-01,-2.6063687e-01, - -2.6047859e-01,-2.6032031e-01,-2.6016206e-01,-2.6000381e-01, - -2.5984555e-01,-2.5968730e-01,-2.5952908e-01,-2.5937083e-01, - -2.5921261e-01,-2.5905439e-01,-2.5889620e-01,-2.5873798e-01, - -2.5857979e-01,-2.5842160e-01,-2.5826341e-01,-2.5810525e-01, - -2.5794709e-01,-2.5778890e-01,-2.5763074e-01,-2.5747260e-01, - -2.5731444e-01,-2.5715631e-01,-2.5699818e-01,-2.5684005e-01, - -2.5668195e-01,-2.5652382e-01,-2.5636572e-01,-2.5620762e-01, - -2.5604951e-01,-2.5589144e-01,-2.5573334e-01,-2.5557527e-01, - -2.5541720e-01,-2.5525916e-01,-2.5510108e-01,-2.5494304e-01, - -2.5478500e-01,-2.5462696e-01,-2.5446895e-01,-2.5431091e-01, - -2.5415289e-01,-2.5399488e-01,-2.5383687e-01,-2.5367889e-01, - -2.5352088e-01,-2.5336289e-01,-2.5320491e-01,-2.5304696e-01, - -2.5288898e-01,-2.5273103e-01,-2.5257307e-01,-2.5241512e-01, - -2.5225717e-01,-2.5209925e-01,-2.5194132e-01,-2.5178340e-01, - -2.5162548e-01,-2.5146756e-01,-2.5130966e-01,-2.5115177e-01, - -2.5099388e-01,-2.5083598e-01,-2.5067809e-01,-2.5052023e-01, - -2.5036237e-01,-2.5020450e-01,-2.5004664e-01,-2.4988881e-01, - -2.4973096e-01,-2.4957313e-01,-2.4941529e-01,-2.4925748e-01, - -2.4909966e-01,-2.4894185e-01,-2.4878405e-01,-2.4862625e-01, - -2.4846846e-01,-2.4831067e-01,-2.4815290e-01,-2.4799512e-01, - -2.4783735e-01,-2.4767959e-01,-2.4752183e-01,-2.4736409e-01, - -2.4720635e-01,-2.4704860e-01,-2.4689087e-01,-2.4673316e-01, - -2.4657543e-01,-2.4641773e-01,-2.4626002e-01,-2.4610232e-01, - -2.4594462e-01,-2.4578694e-01,-2.4562925e-01,-2.4547158e-01, - -2.4531391e-01,-2.4515624e-01,-2.4499859e-01,-2.4484095e-01, - -2.4468330e-01,-2.4452566e-01,-2.4436803e-01,-2.4421041e-01, - -2.4405278e-01,-2.4389517e-01,-2.4373756e-01,-2.4357995e-01, - -2.4342236e-01,-2.4326476e-01,-2.4310718e-01,-2.4294960e-01, - -2.4279204e-01,-2.4263448e-01,-2.4247691e-01,-2.4231936e-01, - -2.4216181e-01,-2.4200428e-01,-2.4184673e-01,-2.4168921e-01, - -2.4153168e-01,-2.4137416e-01,-2.4121664e-01,-2.4105914e-01, - -2.4090165e-01,-2.4074414e-01,-2.4058667e-01,-2.4042918e-01, - -2.4027170e-01,-2.4011423e-01,-2.3995677e-01,-2.3979931e-01, - -2.3964186e-01,-2.3948441e-01,-2.3932697e-01,-2.3916954e-01, - -2.3901211e-01,-2.3885469e-01,-2.3869728e-01,-2.3853986e-01, - -2.3838246e-01,-2.3822506e-01,-2.3806766e-01,-2.3791027e-01, - -2.3775290e-01,-2.3759551e-01,-2.3743816e-01,-2.3728079e-01, - -2.3712343e-01,-2.3696607e-01,-2.3680873e-01,-2.3665139e-01, - -2.3649406e-01,-2.3633672e-01,-2.3617941e-01,-2.3602208e-01, - -2.3586477e-01,-2.3570748e-01,-2.3555018e-01,-2.3539288e-01, - -2.3523560e-01,-2.3507832e-01,-2.3492104e-01,-2.3476377e-01, - -2.3460650e-01,-2.3444925e-01,-2.3429200e-01,-2.3413475e-01, - -2.3397751e-01,-2.3382027e-01,-2.3366304e-01,-2.3350582e-01, - -2.3334859e-01,-2.3319139e-01,-2.3303418e-01,-2.3287699e-01, - -2.3271978e-01,-2.3256260e-01,-2.3240541e-01,-2.3224823e-01, - -2.3209107e-01,-2.3193389e-01,-2.3177674e-01,-2.3161958e-01, - -2.3146243e-01,-2.3130529e-01,-2.3114815e-01,-2.3099102e-01, - -2.3083389e-01,-2.3067677e-01,-2.3051965e-01,-2.3036255e-01, - -2.3020545e-01,-2.3004834e-01,-2.2989126e-01,-2.2973417e-01, - -2.2957709e-01,-2.2942002e-01,-2.2926295e-01,-2.2910587e-01, - -2.2894882e-01,-2.2879177e-01,-2.2863473e-01,-2.2847769e-01, - -2.2832064e-01,-2.2816361e-01,-2.2800660e-01,-2.2784957e-01, - -2.2769256e-01,-2.2753556e-01,-2.2737855e-01,-2.2722156e-01, - -2.2706456e-01,-2.2690758e-01,-2.2675060e-01,-2.2659363e-01, - -2.2643666e-01,-2.2627969e-01,-2.2612274e-01,-2.2596578e-01, - -2.2580884e-01,-2.2565190e-01,-2.2549497e-01,-2.2533804e-01, - -2.2518112e-01,-2.2502419e-01,-2.2486728e-01,-2.2471038e-01, - -2.2455348e-01,-2.2439659e-01,-2.2423969e-01,-2.2408280e-01, - -2.2392592e-01,-2.2376905e-01,-2.2361219e-01,-2.2345532e-01, - -2.2329846e-01,-2.2314161e-01,-2.2298476e-01,-2.2282793e-01, - -2.2267109e-01,-2.2251426e-01,-2.2235744e-01,-2.2220062e-01, - -2.2204380e-01,-2.2188699e-01,-2.2173019e-01,-2.2157340e-01, - -2.2141661e-01,-2.2125982e-01,-2.2110303e-01,-2.2094625e-01, - -2.2078949e-01,-2.2063272e-01,-2.2047597e-01,-2.2031921e-01, - -2.2016247e-01,-2.2000572e-01,-2.1984898e-01,-2.1969225e-01, - -2.1953553e-01,-2.1937880e-01,-2.1922208e-01,-2.1906538e-01, - -2.1890867e-01,-2.1875197e-01,-2.1859528e-01,-2.1843858e-01, - -2.1828191e-01,-2.1812522e-01,-2.1796855e-01,-2.1781188e-01, - -2.1765523e-01,-2.1749857e-01,-2.1734191e-01,-2.1718527e-01, - -2.1702863e-01,-2.1687199e-01,-2.1671537e-01,-2.1655874e-01, - -2.1640211e-01,-2.1624550e-01,-2.1608889e-01,-2.1593229e-01, - -2.1577568e-01,-2.1561910e-01,-2.1546251e-01,-2.1530592e-01, - -2.1514934e-01,-2.1499278e-01,-2.1483621e-01,-2.1467964e-01, - -2.1452309e-01,-2.1436654e-01,-2.1420999e-01,-2.1405345e-01, - -2.1389692e-01,-2.1374039e-01,-2.1358387e-01,-2.1342735e-01, - -2.1327083e-01,-2.1311432e-01,-2.1295781e-01,-2.1280132e-01, - -2.1264483e-01,-2.1248834e-01,-2.1233186e-01,-2.1217538e-01, - -2.1201891e-01,-2.1186243e-01,-2.1170597e-01,-2.1154952e-01, - -2.1139307e-01,-2.1123663e-01,-2.1108018e-01,-2.1092375e-01, - -2.1076731e-01,-2.1061088e-01,-2.1045446e-01,-2.1029805e-01, - -2.1014164e-01,-2.0998523e-01,-2.0982882e-01,-2.0967244e-01, - -2.0951605e-01,-2.0935966e-01,-2.0920329e-01,-2.0904690e-01, - -2.0889054e-01,-2.0873417e-01,-2.0857781e-01,-2.0842145e-01, - -2.0826511e-01,-2.0810877e-01,-2.0795242e-01,-2.0779610e-01, - -2.0763977e-01,-2.0748344e-01,-2.0732713e-01,-2.0717081e-01, - -2.0701450e-01,-2.0685819e-01,-2.0670189e-01,-2.0654561e-01, - -2.0638931e-01,-2.0623302e-01,-2.0607676e-01,-2.0592047e-01, - -2.0576420e-01,-2.0560795e-01,-2.0545170e-01,-2.0529544e-01, - -2.0513919e-01,-2.0498295e-01,-2.0482671e-01,-2.0467047e-01, - -2.0451425e-01,-2.0435803e-01,-2.0420180e-01,-2.0404559e-01, - -2.0388938e-01,-2.0373318e-01,-2.0357698e-01,-2.0342079e-01, - -2.0326459e-01,-2.0310842e-01,-2.0295224e-01,-2.0279607e-01, - -2.0263989e-01,-2.0248373e-01,-2.0232758e-01,-2.0217142e-01, - -2.0201527e-01,-2.0185913e-01,-2.0170298e-01,-2.0154685e-01, - -2.0139073e-01,-2.0123459e-01,-2.0107847e-01,-2.0092237e-01, - -2.0076625e-01,-2.0061015e-01,-2.0045406e-01,-2.0029795e-01, - -2.0014186e-01,-1.9998579e-01,-1.9982970e-01,-1.9967362e-01, - -1.9951756e-01,-1.9936149e-01,-1.9920543e-01,-1.9904937e-01, - -1.9889332e-01,-1.9873728e-01,-1.9858123e-01,-1.9842520e-01, - -1.9826917e-01,-1.9811314e-01,-1.9795711e-01,-1.9780110e-01, - -1.9764508e-01,-1.9748908e-01,-1.9733308e-01,-1.9717708e-01, - -1.9702108e-01,-1.9686510e-01,-1.9670911e-01,-1.9655314e-01, - -1.9639716e-01,-1.9624120e-01,-1.9608523e-01,-1.9592927e-01, - -1.9577332e-01,-1.9561736e-01,-1.9546142e-01,-1.9530548e-01, - -1.9514954e-01,-1.9499362e-01,-1.9483769e-01,-1.9468176e-01, - -1.9452584e-01,-1.9436993e-01,-1.9421403e-01,-1.9405812e-01, - -1.9390222e-01,-1.9374633e-01,-1.9359045e-01,-1.9343455e-01, - -1.9327869e-01,-1.9312280e-01,-1.9296694e-01,-1.9281107e-01, - -1.9265521e-01,-1.9249935e-01,-1.9234350e-01,-1.9218765e-01, - -1.9203182e-01,-1.9187598e-01,-1.9172014e-01,-1.9156432e-01, - -1.9140849e-01,-1.9125268e-01,-1.9109686e-01,-1.9094105e-01, - -1.9078524e-01,-1.9062945e-01,-1.9047365e-01,-1.9031785e-01, - -1.9016208e-01,-1.9000629e-01,-1.8985051e-01,-1.8969475e-01, - -1.8953897e-01,-1.8938321e-01,-1.8922745e-01,-1.8907170e-01, - -1.8891595e-01,-1.8876021e-01,-1.8860446e-01,-1.8844873e-01, - -1.8829300e-01,-1.8813728e-01,-1.8798155e-01,-1.8782583e-01, - -1.8767013e-01,-1.8751441e-01,-1.8735871e-01,-1.8720300e-01, - -1.8704732e-01,-1.8689163e-01,-1.8673594e-01,-1.8658026e-01, - -1.8642458e-01,-1.8626891e-01,-1.8611324e-01,-1.8595758e-01, - -1.8580192e-01,-1.8564627e-01,-1.8549062e-01,-1.8533497e-01, - -1.8517934e-01,-1.8502370e-01,-1.8486807e-01,-1.8471244e-01, - -1.8455681e-01,-1.8440120e-01,-1.8424559e-01,-1.8408997e-01, - -1.8393438e-01,-1.8377876e-01,-1.8362318e-01,-1.8346758e-01, - -1.8331200e-01,-1.8315642e-01,-1.8300083e-01,-1.8284526e-01, - -1.8268970e-01,-1.8253413e-01,-1.8237856e-01,-1.8222301e-01, - -1.8206745e-01,-1.8191192e-01,-1.8175636e-01,-1.8160082e-01, - -1.8144530e-01,-1.8128976e-01,-1.8113424e-01,-1.8097872e-01, - -1.8082321e-01,-1.8066770e-01,-1.8051219e-01,-1.8035668e-01, - -1.8020119e-01,-1.8004569e-01,-1.7989020e-01,-1.7973471e-01, - -1.7957923e-01,-1.7942375e-01,-1.7926829e-01,-1.7911281e-01, - -1.7895734e-01,-1.7880189e-01,-1.7864643e-01,-1.7849098e-01, - -1.7833553e-01,-1.7818010e-01,-1.7802465e-01,-1.7786922e-01, - -1.7771380e-01,-1.7755836e-01,-1.7740294e-01,-1.7724752e-01, - -1.7709212e-01,-1.7693670e-01,-1.7678130e-01,-1.7662591e-01, - -1.7647050e-01,-1.7631511e-01,-1.7615972e-01,-1.7600435e-01, - -1.7584896e-01,-1.7569359e-01,-1.7553823e-01,-1.7538285e-01, - -1.7522749e-01,-1.7507213e-01,-1.7491679e-01,-1.7476144e-01, - -1.7460610e-01,-1.7445076e-01,-1.7429541e-01,-1.7414008e-01, - -1.7398475e-01,-1.7382944e-01,-1.7367411e-01,-1.7351879e-01, - -1.7336349e-01,-1.7320818e-01,-1.7305288e-01,-1.7289758e-01, - -1.7274229e-01,-1.7258699e-01,-1.7243171e-01,-1.7227642e-01, - -1.7212115e-01,-1.7196588e-01,-1.7181061e-01,-1.7165534e-01, - -1.7150009e-01,-1.7134482e-01,-1.7118958e-01,-1.7103432e-01, - -1.7087908e-01,-1.7072384e-01,-1.7056860e-01,-1.7041337e-01, - -1.7025813e-01,-1.7010292e-01,-1.6994770e-01,-1.6979249e-01, - -1.6963726e-01,-1.6948207e-01,-1.6932686e-01,-1.6917166e-01, - -1.6901647e-01,-1.6886127e-01,-1.6870609e-01,-1.6855091e-01, - -1.6839573e-01,-1.6824055e-01,-1.6808538e-01,-1.6793022e-01, - -1.6777505e-01,-1.6761988e-01,-1.6746473e-01,-1.6730958e-01, - -1.6715443e-01,-1.6699930e-01,-1.6684416e-01,-1.6668902e-01, - -1.6653389e-01,-1.6637877e-01,-1.6622365e-01,-1.6606852e-01, - -1.6591340e-01,-1.6575830e-01,-1.6560319e-01,-1.6544808e-01, - -1.6529299e-01,-1.6513789e-01,-1.6498280e-01,-1.6482772e-01, - -1.6467263e-01,-1.6451755e-01,-1.6436248e-01,-1.6420740e-01, - -1.6405234e-01,-1.6389728e-01,-1.6374221e-01,-1.6358717e-01, - -1.6343211e-01,-1.6327706e-01,-1.6312201e-01,-1.6296698e-01, - -1.6281195e-01,-1.6265692e-01,-1.6250189e-01,-1.6234685e-01, - -1.6219184e-01,-1.6203682e-01,-1.6188180e-01,-1.6172680e-01, - -1.6157180e-01,-1.6141680e-01,-1.6126180e-01,-1.6110681e-01, - -1.6095182e-01,-1.6079684e-01,-1.6064185e-01,-1.6048688e-01, - -1.6033190e-01,-1.6017693e-01,-1.6002196e-01,-1.5986700e-01, - -1.5971205e-01,-1.5955709e-01,-1.5940215e-01,-1.5924719e-01, - -1.5909225e-01,-1.5893732e-01,-1.5878238e-01,-1.5862745e-01, - -1.5847252e-01,-1.5831760e-01,-1.5816268e-01,-1.5800776e-01, - -1.5785284e-01,-1.5769795e-01,-1.5754303e-01,-1.5738814e-01, - -1.5723324e-01,-1.5707834e-01,-1.5692346e-01,-1.5676856e-01, - -1.5661368e-01,-1.5645881e-01,-1.5630393e-01,-1.5614906e-01, - -1.5599419e-01,-1.5583932e-01,-1.5568447e-01,-1.5552962e-01, - -1.5537477e-01,-1.5521991e-01,-1.5506507e-01,-1.5491022e-01, - -1.5475538e-01,-1.5460056e-01,-1.5444572e-01,-1.5429090e-01, - -1.5413608e-01,-1.5398125e-01,-1.5382645e-01,-1.5367164e-01, - -1.5351683e-01,-1.5336202e-01,-1.5320723e-01,-1.5305242e-01, - -1.5289763e-01,-1.5274285e-01,-1.5258805e-01,-1.5243328e-01, - -1.5227850e-01,-1.5212372e-01,-1.5196896e-01,-1.5181418e-01, - -1.5165941e-01,-1.5150465e-01,-1.5134990e-01,-1.5119515e-01, - -1.5104041e-01,-1.5088566e-01,-1.5073091e-01,-1.5057617e-01, - -1.5042144e-01,-1.5026671e-01,-1.5011197e-01,-1.4995725e-01, - -1.4980254e-01,-1.4964782e-01,-1.4949310e-01,-1.4933839e-01, - -1.4918369e-01,-1.4902899e-01,-1.4887428e-01,-1.4871959e-01, - -1.4856490e-01,-1.4841022e-01,-1.4825553e-01,-1.4810084e-01, - -1.4794616e-01,-1.4779149e-01,-1.4763682e-01,-1.4748216e-01, - -1.4732748e-01,-1.4717282e-01,-1.4701818e-01,-1.4686352e-01, - -1.4670888e-01,-1.4655423e-01,-1.4639959e-01,-1.4624494e-01, - -1.4609031e-01,-1.4593567e-01,-1.4578104e-01,-1.4562643e-01, - -1.4547180e-01,-1.4531718e-01,-1.4516257e-01,-1.4500795e-01, - -1.4485335e-01,-1.4469874e-01,-1.4454414e-01,-1.4438954e-01, - -1.4423496e-01,-1.4408036e-01,-1.4392577e-01,-1.4377119e-01, - -1.4361662e-01,-1.4346203e-01,-1.4330746e-01,-1.4315289e-01, - -1.4299832e-01,-1.4284377e-01,-1.4268920e-01,-1.4253464e-01, - -1.4238009e-01,-1.4222555e-01,-1.4207099e-01,-1.4191645e-01, - -1.4176191e-01,-1.4160737e-01,-1.4145285e-01,-1.4129832e-01, - -1.4114380e-01,-1.4098927e-01,-1.4083475e-01,-1.4068024e-01, - -1.4052573e-01,-1.4037122e-01,-1.4021671e-01,-1.4006221e-01, - -1.3990770e-01,-1.3975321e-01,-1.3959873e-01,-1.3944423e-01, - -1.3928975e-01,-1.3913527e-01,-1.3898079e-01,-1.3882631e-01, - -1.3867185e-01,-1.3851736e-01,-1.3836290e-01,-1.3820843e-01, - -1.3805398e-01,-1.3789953e-01,-1.3774507e-01,-1.3759063e-01, - -1.3743618e-01,-1.3728173e-01,-1.3712730e-01,-1.3697286e-01, - -1.3681842e-01,-1.3666400e-01,-1.3650957e-01,-1.3635515e-01, - -1.3620073e-01,-1.3604632e-01,-1.3589190e-01,-1.3573749e-01, - -1.3558309e-01,-1.3542868e-01,-1.3527428e-01,-1.3511989e-01, - -1.3496549e-01,-1.3481110e-01,-1.3465671e-01,-1.3450232e-01, - -1.3434795e-01,-1.3419357e-01,-1.3403919e-01,-1.3388482e-01, - -1.3373046e-01,-1.3357610e-01,-1.3342173e-01,-1.3326737e-01, - -1.3311301e-01,-1.3295867e-01,-1.3280430e-01,-1.3264996e-01, - -1.3249563e-01,-1.3234128e-01,-1.3218695e-01,-1.3203262e-01, - -1.3187829e-01,-1.3172396e-01,-1.3156962e-01,-1.3141531e-01, - -1.3126099e-01,-1.3110667e-01,-1.3095237e-01,-1.3079806e-01, - -1.3064376e-01,-1.3048945e-01,-1.3033515e-01,-1.3018085e-01, - -1.3002656e-01,-1.2987228e-01,-1.2971799e-01,-1.2956370e-01, - -1.2940942e-01,-1.2925515e-01,-1.2910087e-01,-1.2894660e-01, - -1.2879233e-01,-1.2863807e-01,-1.2848380e-01,-1.2832955e-01, - -1.2817529e-01,-1.2802103e-01,-1.2786679e-01,-1.2771255e-01, - -1.2755829e-01,-1.2740405e-01,-1.2724982e-01,-1.2709558e-01, - -1.2694135e-01,-1.2678713e-01,-1.2663290e-01,-1.2647867e-01, - -1.2632446e-01,-1.2617023e-01,-1.2601602e-01,-1.2586181e-01, - -1.2570761e-01,-1.2555340e-01,-1.2539920e-01,-1.2524500e-01, - -1.2509081e-01,-1.2493662e-01,-1.2478243e-01,-1.2462824e-01, - -1.2447406e-01,-1.2431987e-01,-1.2416570e-01,-1.2401152e-01, - -1.2385735e-01,-1.2370318e-01,-1.2354901e-01,-1.2339485e-01, - -1.2324069e-01,-1.2308653e-01,-1.2293238e-01,-1.2277823e-01, - -1.2262408e-01,-1.2246993e-01,-1.2231579e-01,-1.2216165e-01, - -1.2200751e-01,-1.2185338e-01,-1.2169925e-01,-1.2154512e-01, - -1.2139100e-01,-1.2123688e-01,-1.2108275e-01,-1.2092864e-01, - -1.2077452e-01,-1.2062041e-01,-1.2046631e-01,-1.2031220e-01, - -1.2015810e-01,-1.2000400e-01,-1.1984990e-01,-1.1969581e-01, - -1.1954172e-01,-1.1938763e-01,-1.1923354e-01,-1.1907946e-01, - -1.1892538e-01,-1.1877131e-01,-1.1861723e-01,-1.1846316e-01, - -1.1830909e-01,-1.1815502e-01,-1.1800096e-01,-1.1784691e-01, - -1.1769284e-01,-1.1753879e-01,-1.1738474e-01,-1.1723069e-01, - -1.1707664e-01,-1.1692260e-01,-1.1676856e-01,-1.1661452e-01, - -1.1646049e-01,-1.1630645e-01,-1.1615243e-01,-1.1599840e-01, - -1.1584438e-01,-1.1569036e-01,-1.1553634e-01,-1.1538232e-01, - -1.1522831e-01,-1.1507430e-01,-1.1492029e-01,-1.1476628e-01, - -1.1461229e-01,-1.1445829e-01,-1.1430429e-01,-1.1415029e-01, - -1.1399630e-01,-1.1384232e-01,-1.1368833e-01,-1.1353435e-01, - -1.1338037e-01,-1.1322639e-01,-1.1307242e-01,-1.1291844e-01, - -1.1276447e-01,-1.1261050e-01,-1.1245654e-01,-1.1230258e-01, - -1.1214862e-01,-1.1199466e-01,-1.1184071e-01,-1.1168676e-01, - -1.1153281e-01,-1.1137886e-01,-1.1122492e-01,-1.1107098e-01, - -1.1091705e-01,-1.1076311e-01,-1.1060917e-01,-1.1045524e-01, - -1.1030132e-01,-1.1014739e-01,-1.0999347e-01,-1.0983955e-01, - -1.0968564e-01,-1.0953172e-01,-1.0937781e-01,-1.0922390e-01, - -1.0907000e-01,-1.0891609e-01,-1.0876219e-01,-1.0860829e-01, - -1.0845440e-01,-1.0830050e-01,-1.0814661e-01,-1.0799272e-01, - -1.0783884e-01,-1.0768496e-01,-1.0753107e-01,-1.0737719e-01, - -1.0722332e-01,-1.0706945e-01,-1.0691557e-01,-1.0676171e-01, - -1.0660784e-01,-1.0645398e-01,-1.0630012e-01,-1.0614626e-01, - -1.0599241e-01,-1.0583855e-01,-1.0568470e-01,-1.0553085e-01, - -1.0537700e-01,-1.0522316e-01,-1.0506932e-01,-1.0491548e-01, - -1.0476165e-01,-1.0460781e-01,-1.0445399e-01,-1.0430016e-01, - -1.0414633e-01,-1.0399251e-01,-1.0383869e-01,-1.0368487e-01, - -1.0353106e-01,-1.0337724e-01,-1.0322343e-01,-1.0306962e-01, - -1.0291582e-01,-1.0276201e-01,-1.0260821e-01,-1.0245441e-01, - -1.0230061e-01,-1.0214682e-01,-1.0199303e-01,-1.0183924e-01, - -1.0168546e-01,-1.0153167e-01,-1.0137789e-01,-1.0122411e-01, - -1.0107033e-01,-1.0091656e-01,-1.0076278e-01,-1.0060901e-01, - -1.0045525e-01,-1.0030148e-01,-1.0014772e-01,-9.9993959e-02, - -9.9840201e-02,-9.9686444e-02,-9.9532694e-02,-9.9378943e-02, - -9.9225193e-02,-9.9071443e-02,-9.8917700e-02,-9.8763958e-02, - -9.8610222e-02,-9.8456487e-02,-9.8302752e-02,-9.8149016e-02, - -9.7995289e-02,-9.7841561e-02,-9.7687833e-02,-9.7534113e-02, - -9.7380392e-02,-9.7226672e-02,-9.7072959e-02,-9.6919239e-02, - -9.6765533e-02,-9.6611820e-02,-9.6458115e-02,-9.6304409e-02, - -9.6150704e-02,-9.5997006e-02,-9.5843308e-02,-9.5689617e-02, - -9.5535919e-02,-9.5382228e-02,-9.5228538e-02,-9.5074855e-02, - -9.4921172e-02,-9.4767489e-02,-9.4613805e-02,-9.4460130e-02, - -9.4306454e-02,-9.4152778e-02,-9.3999110e-02,-9.3845442e-02, - -9.3691774e-02,-9.3538113e-02,-9.3384452e-02,-9.3230791e-02, - -9.3077131e-02,-9.2923477e-02,-9.2769824e-02,-9.2616171e-02, - -9.2462525e-02,-9.2308879e-02,-9.2155233e-02,-9.2001587e-02, - -9.1847949e-02,-9.1694310e-02,-9.1540672e-02,-9.1387041e-02, - -9.1233410e-02,-9.1079779e-02,-9.0926155e-02,-9.0772524e-02, - -9.0618901e-02,-9.0465285e-02,-9.0311661e-02,-9.0158045e-02, - -9.0004437e-02,-8.9850821e-02,-8.9697212e-02,-8.9543603e-02, - -8.9389995e-02,-8.9236394e-02,-8.9082792e-02,-8.8929191e-02, - -8.8775598e-02,-8.8621996e-02,-8.8468403e-02,-8.8314816e-02, - -8.8161223e-02,-8.8007636e-02,-8.7854050e-02,-8.7700471e-02, - -8.7546885e-02,-8.7393306e-02,-8.7239735e-02,-8.7086156e-02, - -8.6932585e-02,-8.6779013e-02,-8.6625449e-02,-8.6471878e-02, - -8.6318314e-02,-8.6164750e-02,-8.6011194e-02,-8.5857637e-02, - -8.5704081e-02,-8.5550524e-02,-8.5396968e-02,-8.5243419e-02, - -8.5089870e-02,-8.4936328e-02,-8.4782779e-02,-8.4629238e-02, - -8.4475696e-02,-8.4322162e-02,-8.4168628e-02,-8.4015094e-02, - -8.3861560e-02,-8.3708026e-02,-8.3554499e-02,-8.3400972e-02, - -8.3247446e-02,-8.3093926e-02,-8.2940407e-02,-8.2786888e-02, - -8.2633369e-02,-8.2479857e-02,-8.2326345e-02,-8.2172833e-02, - -8.2019322e-02,-8.1865817e-02,-8.1712313e-02,-8.1558809e-02, - -8.1405304e-02,-8.1251808e-02,-8.1098311e-02,-8.0944814e-02, - -8.0791324e-02,-8.0637828e-02,-8.0484338e-02,-8.0330849e-02, - -8.0177367e-02,-8.0023885e-02,-7.9870403e-02,-7.9716921e-02, - -7.9563439e-02,-7.9409964e-02,-7.9256490e-02,-7.9103015e-02, - -7.8949548e-02,-7.8796074e-02,-7.8642607e-02,-7.8489147e-02, - -7.8335680e-02,-7.8182220e-02,-7.8028761e-02,-7.7875301e-02, - -7.7721842e-02,-7.7568389e-02,-7.7414937e-02,-7.7261485e-02, - -7.7108040e-02,-7.6954588e-02,-7.6801144e-02,-7.6647706e-02, - -7.6494262e-02,-7.6340824e-02,-7.6187387e-02,-7.6033950e-02, - -7.5880513e-02,-7.5727083e-02,-7.5573653e-02,-7.5420223e-02, - -7.5266793e-02,-7.5113371e-02,-7.4959941e-02,-7.4806519e-02, - -7.4653104e-02,-7.4499682e-02,-7.4346267e-02,-7.4192852e-02, - -7.4039437e-02,-7.3886029e-02,-7.3732615e-02,-7.3579207e-02, - -7.3425800e-02,-7.3272400e-02,-7.3118992e-02,-7.2965592e-02, - -7.2812192e-02,-7.2658800e-02,-7.2505400e-02,-7.2352007e-02, - -7.2198614e-02,-7.2045222e-02,-7.1891837e-02,-7.1738444e-02, - -7.1585059e-02,-7.1431674e-02,-7.1278296e-02,-7.1124911e-02, - -7.0971534e-02,-7.0818156e-02,-7.0664778e-02,-7.0511408e-02, - -7.0358038e-02,-7.0204668e-02,-7.0051298e-02,-6.9897927e-02, - -6.9744565e-02,-6.9591194e-02,-6.9437832e-02,-6.9284476e-02, - -6.9131114e-02,-6.8977758e-02,-6.8824403e-02,-6.8671048e-02, - -6.8517692e-02,-6.8364345e-02,-6.8210997e-02,-6.8057649e-02, - -6.7904301e-02,-6.7750953e-02,-6.7597613e-02,-6.7444272e-02, - -6.7290932e-02,-6.7137592e-02,-6.6984251e-02,-6.6830918e-02, - -6.6677585e-02,-6.6524252e-02,-6.6370919e-02,-6.6217594e-02, - -6.6064268e-02,-6.5910943e-02,-6.5757617e-02,-6.5604292e-02, - -6.5450974e-02,-6.5297648e-02,-6.5144330e-02,-6.4991020e-02, - -6.4837702e-02,-6.4684391e-02,-6.4531073e-02,-6.4377762e-02, - -6.4224459e-02,-6.4071149e-02,-6.3917845e-02,-6.3764535e-02, - -6.3611232e-02,-6.3457936e-02,-6.3304633e-02,-6.3151337e-02, - -6.2998042e-02,-6.2844746e-02,-6.2691450e-02,-6.2538154e-02, - -6.2384866e-02,-6.2231574e-02,-6.2078286e-02,-6.1925001e-02, - -6.1771713e-02,-6.1618429e-02,-6.1465148e-02,-6.1311867e-02, - -6.1158586e-02,-6.1005309e-02,-6.0852032e-02,-6.0698759e-02, - -6.0545482e-02,-6.0392212e-02,-6.0238939e-02,-6.0085669e-02, - -5.9932403e-02,-5.9779137e-02,-5.9625871e-02,-5.9472606e-02, - -5.9319343e-02,-5.9166081e-02,-5.9012823e-02,-5.8859564e-02, - -5.8706306e-02,-5.8553051e-02,-5.8399796e-02,-5.8246545e-02, - -5.8093295e-02,-5.7940044e-02,-5.7786793e-02,-5.7633545e-02, - -5.7480302e-02,-5.7327054e-02,-5.7173811e-02,-5.7020571e-02, - -5.6867331e-02,-5.6714091e-02,-5.6560852e-02,-5.6407616e-02, - -5.6254379e-02,-5.6101147e-02,-5.5947915e-02,-5.5794682e-02, - -5.5641454e-02,-5.5488225e-02,-5.5334996e-02,-5.5181768e-02, - -5.5028547e-02,-5.4875322e-02,-5.4722100e-02,-5.4568879e-02, - -5.4415658e-02,-5.4262441e-02,-5.4109223e-02,-5.3956006e-02, - -5.3802792e-02,-5.3649578e-02,-5.3496365e-02,-5.3343154e-02, - -5.3189944e-02,-5.3036738e-02,-5.2883528e-02,-5.2730326e-02, - -5.2577119e-02,-5.2423917e-02,-5.2270714e-02,-5.2117512e-02, - -5.1964313e-02,-5.1811114e-02,-5.1657919e-02,-5.1504720e-02, - -5.1351525e-02,-5.1198334e-02,-5.1045138e-02,-5.0891947e-02, - -5.0738759e-02,-5.0585568e-02,-5.0432380e-02,-5.0279196e-02, - -5.0126009e-02,-4.9972825e-02,-4.9819645e-02,-4.9666461e-02, - -4.9513280e-02,-4.9360100e-02,-4.9206924e-02,-4.9053743e-02, - -4.8900571e-02,-4.8747394e-02,-4.8594221e-02,-4.8441049e-02, - -4.8287876e-02,-4.8134707e-02,-4.7981538e-02,-4.7828369e-02, - -4.7675204e-02,-4.7522034e-02,-4.7368873e-02,-4.7215708e-02, - -4.7062546e-02,-4.6909384e-02,-4.6756223e-02,-4.6603065e-02, - -4.6449907e-02,-4.6296749e-02,-4.6143591e-02,-4.5990437e-02, - -4.5837283e-02,-4.5684133e-02,-4.5530979e-02,-4.5377828e-02, - -4.5224681e-02,-4.5071531e-02,-4.4918384e-02,-4.4765238e-02, - -4.4612091e-02,-4.4458948e-02,-4.4305805e-02,-4.4152662e-02, - -4.3999523e-02,-4.3846380e-02,-4.3693241e-02,-4.3540105e-02, - -4.3386966e-02,-4.3233830e-02,-4.3080695e-02,-4.2927563e-02, - -4.2774428e-02,-4.2621296e-02,-4.2468168e-02,-4.2315036e-02, - -4.2161908e-02,-4.2008780e-02,-4.1855652e-02,-4.1702528e-02, - -4.1549399e-02,-4.1396279e-02,-4.1243155e-02,-4.1090030e-02, - -4.0936910e-02,-4.0783789e-02,-4.0630672e-02,-4.0477552e-02, - -4.0324435e-02,-4.0171318e-02,-4.0018205e-02,-3.9865088e-02, - -3.9711975e-02,-3.9558861e-02,-3.9405752e-02,-3.9252639e-02, - -3.9099529e-02,-3.8946420e-02,-3.8793314e-02,-3.8640205e-02, - -3.8487099e-02,-3.8333993e-02,-3.8180891e-02,-3.8027786e-02, - -3.7874684e-02,-3.7721582e-02,-3.7568480e-02,-3.7415382e-02, - -3.7262283e-02,-3.7109185e-02,-3.6956087e-02,-3.6802988e-02, - -3.6649894e-02,-3.6496799e-02,-3.6343705e-02,-3.6190614e-02, - -3.6037520e-02,-3.5884429e-02,-3.5731338e-02,-3.5578247e-02, - -3.5425160e-02,-3.5272073e-02,-3.5118986e-02,-3.4965899e-02, - -3.4812812e-02,-3.4659728e-02,-3.4506645e-02,-3.4353562e-02, - -3.4200478e-02,-3.4047395e-02,-3.3894315e-02,-3.3741236e-02, - -3.3588156e-02,-3.3435080e-02,-3.3282001e-02,-3.3128925e-02, - -3.2975849e-02,-3.2822773e-02,-3.2669697e-02,-3.2516625e-02, - -3.2363553e-02,-3.2210480e-02,-3.2057408e-02,-3.1904336e-02, - -3.1751268e-02,-3.1598199e-02,-3.1445131e-02,-3.1292062e-02, - -3.1138994e-02,-3.0985929e-02,-3.0832862e-02,-3.0679798e-02, - -3.0526733e-02,-3.0373670e-02,-3.0220607e-02,-3.0067546e-02, - -2.9914485e-02,-2.9761424e-02,-2.9608363e-02,-2.9455304e-02, - -2.9302247e-02,-2.9149190e-02,-2.8996132e-02,-2.8843075e-02, - -2.8690020e-02,-2.8536964e-02,-2.8383911e-02,-2.8230855e-02, - -2.8077804e-02,-2.7924750e-02,-2.7771698e-02,-2.7618648e-02, - -2.7465597e-02,-2.7312547e-02,-2.7159499e-02,-2.7006449e-02, - -2.6853401e-02,-2.6700355e-02,-2.6547307e-02,-2.6394261e-02, - -2.6241217e-02,-2.6088171e-02,-2.5935126e-02,-2.5782084e-02, - -2.5629040e-02,-2.5475997e-02,-2.5322957e-02,-2.5169915e-02, - -2.5016874e-02,-2.4863834e-02,-2.4710795e-02,-2.4557756e-02, - -2.4404718e-02,-2.4251681e-02,-2.4098642e-02,-2.3945605e-02, - -2.3792570e-02,-2.3639536e-02,-2.3486501e-02,-2.3333466e-02, - -2.3180431e-02,-2.3027398e-02,-2.2874366e-02,-2.2721333e-02, - -2.2568302e-02,-2.2415271e-02,-2.2262240e-02,-2.2109210e-02, - -2.1956179e-02,-2.1803152e-02,-2.1650122e-02,-2.1497095e-02, - -2.1344068e-02,-2.1191040e-02,-2.1038013e-02,-2.0884987e-02, - -2.0731961e-02,-2.0578936e-02,-2.0425912e-02,-2.0272888e-02, - -2.0119864e-02,-1.9966841e-02,-1.9813819e-02,-1.9660797e-02, - -1.9507775e-02,-1.9354753e-02,-1.9201731e-02,-1.9048711e-02, - -1.8895691e-02,-1.8742671e-02,-1.8589653e-02,-1.8436635e-02, - -1.8283617e-02,-1.8130599e-02,-1.7977580e-02,-1.7824564e-02, - -1.7671548e-02,-1.7518532e-02,-1.7365515e-02,-1.7212501e-02, - -1.7059484e-02,-1.6906470e-02,-1.6753457e-02,-1.6600443e-02, - -1.6447430e-02,-1.6294416e-02,-1.6141403e-02,-1.5988393e-02, - -1.5835380e-02,-1.5682369e-02,-1.5529358e-02,-1.5376347e-02, - -1.5223336e-02,-1.5070327e-02,-1.4917317e-02,-1.4764308e-02, - -1.4611298e-02,-1.4458290e-02,-1.4305281e-02,-1.4152274e-02, - -1.3999267e-02,-1.3846259e-02,-1.3693252e-02,-1.3540246e-02, - -1.3387239e-02,-1.3234233e-02,-1.3081227e-02,-1.2928222e-02, - -1.2775217e-02,-1.2622212e-02,-1.2469208e-02,-1.2316204e-02, - -1.2163199e-02,-1.2010196e-02,-1.1857193e-02,-1.1704190e-02, - -1.1551186e-02,-1.1398184e-02,-1.1245182e-02,-1.1092179e-02, - -1.0939178e-02,-1.0786177e-02,-1.0633175e-02,-1.0480175e-02, - -1.0327173e-02,-1.0174173e-02,-1.0021173e-02,-9.8681729e-03, - -9.7151734e-03,-9.5621739e-03,-9.4091743e-03,-9.2561757e-03, - -9.1031762e-03,-8.9501776e-03,-8.7971790e-03,-8.6441813e-03, - -8.4911827e-03,-8.3381850e-03,-8.1851874e-03,-8.0321897e-03, - -7.8791929e-03,-7.7261953e-03,-7.5731985e-03,-7.4202018e-03, - -7.2672050e-03,-7.1142088e-03,-6.9612125e-03,-6.8082167e-03, - -6.6552204e-03,-6.5022251e-03,-6.3492293e-03,-6.1962339e-03, - -6.0432386e-03,-5.8902432e-03,-5.7372483e-03,-5.5842535e-03, - -5.4312586e-03,-5.2782642e-03,-5.1252693e-03,-4.9722749e-03, - -4.8192809e-03,-4.6662865e-03,-4.5132926e-03,-4.3602986e-03, - -4.2073047e-03,-4.0543112e-03,-3.9013172e-03,-3.7483238e-03, - -3.5953303e-03,-3.4423368e-03,-3.2893436e-03,-3.1363503e-03, - -2.9833571e-03,-2.8303640e-03,-2.6773710e-03,-2.5243780e-03, - -2.3713852e-03,-2.2183922e-03,-2.0653994e-03,-1.9124068e-03, - -1.7594141e-03,-1.6064214e-03,-1.4534288e-03,-1.3004362e-03, - -1.1474437e-03,-9.9445111e-04,-8.4145856e-04,-6.8846607e-04, - -5.3547358e-04,-3.8248114e-04,-2.2948868e-04,-7.6496224e-05, - 7.6496224e-05, 2.2948868e-04, 3.8248114e-04, 5.3547358e-04, - 6.8846607e-04, 8.4145856e-04, 9.9445111e-04, 1.1474437e-03, - 1.3004362e-03, 1.4534288e-03, 1.6064214e-03, 1.7594141e-03, - 1.9124068e-03, 2.0653994e-03, 2.2183922e-03, 2.3713852e-03, - 2.5243780e-03, 2.6773710e-03, 2.8303640e-03, 2.9833571e-03, - 3.1363503e-03, 3.2893436e-03, 3.4423368e-03, 3.5953303e-03, - 3.7483238e-03, 3.9013172e-03, 4.0543112e-03, 4.2073047e-03, - 4.3602986e-03, 4.5132926e-03, 4.6662865e-03, 4.8192809e-03, - 4.9722749e-03, 5.1252693e-03, 5.2782642e-03, 5.4312586e-03, - 5.5842535e-03, 5.7372483e-03, 5.8902432e-03, 6.0432386e-03, - 6.1962339e-03, 6.3492293e-03, 6.5022251e-03, 6.6552204e-03, - 6.8082167e-03, 6.9612125e-03, 7.1142088e-03, 7.2672050e-03, - 7.4202018e-03, 7.5731985e-03, 7.7261953e-03, 7.8791929e-03, - 8.0321897e-03, 8.1851874e-03, 8.3381850e-03, 8.4911827e-03, - 8.6441813e-03, 8.7971790e-03, 8.9501776e-03, 9.1031762e-03, - 9.2561757e-03, 9.4091743e-03, 9.5621739e-03, 9.7151734e-03, - 9.8681729e-03, 1.0021173e-02, 1.0174173e-02, 1.0327173e-02, - 1.0480175e-02, 1.0633175e-02, 1.0786177e-02, 1.0939178e-02, - 1.1092179e-02, 1.1245182e-02, 1.1398184e-02, 1.1551186e-02, - 1.1704190e-02, 1.1857193e-02, 1.2010196e-02, 1.2163199e-02, - 1.2316204e-02, 1.2469208e-02, 1.2622212e-02, 1.2775217e-02, - 1.2928222e-02, 1.3081227e-02, 1.3234233e-02, 1.3387239e-02, - 1.3540246e-02, 1.3693252e-02, 1.3846259e-02, 1.3999267e-02, - 1.4152274e-02, 1.4305281e-02, 1.4458290e-02, 1.4611298e-02, - 1.4764308e-02, 1.4917317e-02, 1.5070327e-02, 1.5223336e-02, - 1.5376347e-02, 1.5529358e-02, 1.5682369e-02, 1.5835380e-02, - 1.5988393e-02, 1.6141403e-02, 1.6294416e-02, 1.6447430e-02, - 1.6600443e-02, 1.6753457e-02, 1.6906470e-02, 1.7059484e-02, - 1.7212501e-02, 1.7365515e-02, 1.7518532e-02, 1.7671548e-02, - 1.7824564e-02, 1.7977580e-02, 1.8130599e-02, 1.8283617e-02, - 1.8436635e-02, 1.8589653e-02, 1.8742671e-02, 1.8895691e-02, - 1.9048711e-02, 1.9201731e-02, 1.9354753e-02, 1.9507775e-02, - 1.9660797e-02, 1.9813819e-02, 1.9966841e-02, 2.0119864e-02, - 2.0272888e-02, 2.0425912e-02, 2.0578936e-02, 2.0731961e-02, - 2.0884987e-02, 2.1038013e-02, 2.1191040e-02, 2.1344068e-02, - 2.1497095e-02, 2.1650122e-02, 2.1803152e-02, 2.1956179e-02, - 2.2109210e-02, 2.2262240e-02, 2.2415271e-02, 2.2568302e-02, - 2.2721333e-02, 2.2874366e-02, 2.3027398e-02, 2.3180431e-02, - 2.3333466e-02, 2.3486501e-02, 2.3639536e-02, 2.3792570e-02, - 2.3945605e-02, 2.4098642e-02, 2.4251681e-02, 2.4404718e-02, - 2.4557756e-02, 2.4710795e-02, 2.4863834e-02, 2.5016874e-02, - 2.5169915e-02, 2.5322957e-02, 2.5475997e-02, 2.5629040e-02, - 2.5782084e-02, 2.5935126e-02, 2.6088171e-02, 2.6241217e-02, - 2.6394261e-02, 2.6547307e-02, 2.6700355e-02, 2.6853401e-02, - 2.7006449e-02, 2.7159499e-02, 2.7312547e-02, 2.7465597e-02, - 2.7618648e-02, 2.7771698e-02, 2.7924750e-02, 2.8077804e-02, - 2.8230855e-02, 2.8383911e-02, 2.8536964e-02, 2.8690020e-02, - 2.8843075e-02, 2.8996132e-02, 2.9149190e-02, 2.9302247e-02, - 2.9455304e-02, 2.9608363e-02, 2.9761424e-02, 2.9914485e-02, - 3.0067546e-02, 3.0220607e-02, 3.0373670e-02, 3.0526733e-02, - 3.0679798e-02, 3.0832862e-02, 3.0985929e-02, 3.1138994e-02, - 3.1292062e-02, 3.1445131e-02, 3.1598199e-02, 3.1751268e-02, - 3.1904336e-02, 3.2057408e-02, 3.2210480e-02, 3.2363553e-02, - 3.2516625e-02, 3.2669697e-02, 3.2822773e-02, 3.2975849e-02, - 3.3128925e-02, 3.3282001e-02, 3.3435080e-02, 3.3588156e-02, - 3.3741236e-02, 3.3894315e-02, 3.4047395e-02, 3.4200478e-02, - 3.4353562e-02, 3.4506645e-02, 3.4659728e-02, 3.4812812e-02, - 3.4965899e-02, 3.5118986e-02, 3.5272073e-02, 3.5425160e-02, - 3.5578247e-02, 3.5731338e-02, 3.5884429e-02, 3.6037520e-02, - 3.6190614e-02, 3.6343705e-02, 3.6496799e-02, 3.6649894e-02, - 3.6802988e-02, 3.6956087e-02, 3.7109185e-02, 3.7262283e-02, - 3.7415382e-02, 3.7568480e-02, 3.7721582e-02, 3.7874684e-02, - 3.8027786e-02, 3.8180891e-02, 3.8333993e-02, 3.8487099e-02, - 3.8640205e-02, 3.8793314e-02, 3.8946420e-02, 3.9099529e-02, - 3.9252639e-02, 3.9405752e-02, 3.9558861e-02, 3.9711975e-02, - 3.9865088e-02, 4.0018205e-02, 4.0171318e-02, 4.0324435e-02, - 4.0477552e-02, 4.0630672e-02, 4.0783789e-02, 4.0936910e-02, - 4.1090030e-02, 4.1243155e-02, 4.1396279e-02, 4.1549399e-02, - 4.1702528e-02, 4.1855652e-02, 4.2008780e-02, 4.2161908e-02, - 4.2315036e-02, 4.2468168e-02, 4.2621296e-02, 4.2774428e-02, - 4.2927563e-02, 4.3080695e-02, 4.3233830e-02, 4.3386966e-02, - 4.3540105e-02, 4.3693241e-02, 4.3846380e-02, 4.3999523e-02, - 4.4152662e-02, 4.4305805e-02, 4.4458948e-02, 4.4612091e-02, - 4.4765238e-02, 4.4918384e-02, 4.5071531e-02, 4.5224681e-02, - 4.5377828e-02, 4.5530979e-02, 4.5684133e-02, 4.5837283e-02, - 4.5990437e-02, 4.6143591e-02, 4.6296749e-02, 4.6449907e-02, - 4.6603065e-02, 4.6756223e-02, 4.6909384e-02, 4.7062546e-02, - 4.7215708e-02, 4.7368873e-02, 4.7522034e-02, 4.7675204e-02, - 4.7828369e-02, 4.7981538e-02, 4.8134707e-02, 4.8287876e-02, - 4.8441049e-02, 4.8594221e-02, 4.8747394e-02, 4.8900571e-02, - 4.9053743e-02, 4.9206924e-02, 4.9360100e-02, 4.9513280e-02, - 4.9666461e-02, 4.9819645e-02, 4.9972825e-02, 5.0126009e-02, - 5.0279196e-02, 5.0432380e-02, 5.0585568e-02, 5.0738759e-02, - 5.0891947e-02, 5.1045138e-02, 5.1198334e-02, 5.1351525e-02, - 5.1504720e-02, 5.1657919e-02, 5.1811114e-02, 5.1964313e-02, - 5.2117512e-02, 5.2270714e-02, 5.2423917e-02, 5.2577119e-02, - 5.2730326e-02, 5.2883528e-02, 5.3036738e-02, 5.3189944e-02, - 5.3343154e-02, 5.3496365e-02, 5.3649578e-02, 5.3802792e-02, - 5.3956006e-02, 5.4109223e-02, 5.4262441e-02, 5.4415658e-02, - 5.4568879e-02, 5.4722100e-02, 5.4875322e-02, 5.5028547e-02, - 5.5181768e-02, 5.5334996e-02, 5.5488225e-02, 5.5641454e-02, - 5.5794682e-02, 5.5947915e-02, 5.6101147e-02, 5.6254379e-02, - 5.6407616e-02, 5.6560852e-02, 5.6714091e-02, 5.6867331e-02, - 5.7020571e-02, 5.7173811e-02, 5.7327054e-02, 5.7480302e-02, - 5.7633545e-02, 5.7786793e-02, 5.7940044e-02, 5.8093295e-02, - 5.8246545e-02, 5.8399796e-02, 5.8553051e-02, 5.8706306e-02, - 5.8859564e-02, 5.9012823e-02, 5.9166081e-02, 5.9319343e-02, - 5.9472606e-02, 5.9625871e-02, 5.9779137e-02, 5.9932403e-02, - 6.0085669e-02, 6.0238939e-02, 6.0392212e-02, 6.0545482e-02, - 6.0698759e-02, 6.0852032e-02, 6.1005309e-02, 6.1158586e-02, - 6.1311867e-02, 6.1465148e-02, 6.1618429e-02, 6.1771713e-02, - 6.1925001e-02, 6.2078286e-02, 6.2231574e-02, 6.2384866e-02, - 6.2538154e-02, 6.2691450e-02, 6.2844746e-02, 6.2998042e-02, - 6.3151337e-02, 6.3304633e-02, 6.3457936e-02, 6.3611232e-02, - 6.3764535e-02, 6.3917845e-02, 6.4071149e-02, 6.4224459e-02, - 6.4377762e-02, 6.4531073e-02, 6.4684391e-02, 6.4837702e-02, - 6.4991020e-02, 6.5144330e-02, 6.5297648e-02, 6.5450974e-02, - 6.5604292e-02, 6.5757617e-02, 6.5910943e-02, 6.6064268e-02, - 6.6217594e-02, 6.6370919e-02, 6.6524252e-02, 6.6677585e-02, - 6.6830918e-02, 6.6984251e-02, 6.7137592e-02, 6.7290932e-02, - 6.7444272e-02, 6.7597613e-02, 6.7750953e-02, 6.7904301e-02, - 6.8057649e-02, 6.8210997e-02, 6.8364345e-02, 6.8517692e-02, - 6.8671048e-02, 6.8824403e-02, 6.8977758e-02, 6.9131114e-02, - 6.9284476e-02, 6.9437832e-02, 6.9591194e-02, 6.9744565e-02, - 6.9897927e-02, 7.0051298e-02, 7.0204668e-02, 7.0358038e-02, - 7.0511408e-02, 7.0664778e-02, 7.0818156e-02, 7.0971534e-02, - 7.1124911e-02, 7.1278296e-02, 7.1431674e-02, 7.1585059e-02, - 7.1738444e-02, 7.1891837e-02, 7.2045222e-02, 7.2198614e-02, - 7.2352007e-02, 7.2505400e-02, 7.2658800e-02, 7.2812192e-02, - 7.2965592e-02, 7.3118992e-02, 7.3272400e-02, 7.3425800e-02, - 7.3579207e-02, 7.3732615e-02, 7.3886029e-02, 7.4039437e-02, - 7.4192852e-02, 7.4346267e-02, 7.4499682e-02, 7.4653104e-02, - 7.4806519e-02, 7.4959941e-02, 7.5113371e-02, 7.5266793e-02, - 7.5420223e-02, 7.5573653e-02, 7.5727083e-02, 7.5880513e-02, - 7.6033950e-02, 7.6187387e-02, 7.6340824e-02, 7.6494262e-02, - 7.6647706e-02, 7.6801144e-02, 7.6954588e-02, 7.7108040e-02, - 7.7261485e-02, 7.7414937e-02, 7.7568389e-02, 7.7721842e-02, - 7.7875301e-02, 7.8028761e-02, 7.8182220e-02, 7.8335680e-02, - 7.8489147e-02, 7.8642607e-02, 7.8796074e-02, 7.8949548e-02, - 7.9103015e-02, 7.9256490e-02, 7.9409964e-02, 7.9563439e-02, - 7.9716921e-02, 7.9870403e-02, 8.0023885e-02, 8.0177367e-02, - 8.0330849e-02, 8.0484338e-02, 8.0637828e-02, 8.0791324e-02, - 8.0944814e-02, 8.1098311e-02, 8.1251808e-02, 8.1405304e-02, - 8.1558809e-02, 8.1712313e-02, 8.1865817e-02, 8.2019322e-02, - 8.2172833e-02, 8.2326345e-02, 8.2479857e-02, 8.2633369e-02, - 8.2786888e-02, 8.2940407e-02, 8.3093926e-02, 8.3247446e-02, - 8.3400972e-02, 8.3554499e-02, 8.3708026e-02, 8.3861560e-02, - 8.4015094e-02, 8.4168628e-02, 8.4322162e-02, 8.4475696e-02, - 8.4629238e-02, 8.4782779e-02, 8.4936328e-02, 8.5089870e-02, - 8.5243419e-02, 8.5396968e-02, 8.5550524e-02, 8.5704081e-02, - 8.5857637e-02, 8.6011194e-02, 8.6164750e-02, 8.6318314e-02, - 8.6471878e-02, 8.6625449e-02, 8.6779013e-02, 8.6932585e-02, - 8.7086156e-02, 8.7239735e-02, 8.7393306e-02, 8.7546885e-02, - 8.7700471e-02, 8.7854050e-02, 8.8007636e-02, 8.8161223e-02, - 8.8314816e-02, 8.8468403e-02, 8.8621996e-02, 8.8775598e-02, - 8.8929191e-02, 8.9082792e-02, 8.9236394e-02, 8.9389995e-02, - 8.9543603e-02, 8.9697212e-02, 8.9850821e-02, 9.0004437e-02, - 9.0158045e-02, 9.0311661e-02, 9.0465285e-02, 9.0618901e-02, - 9.0772524e-02, 9.0926155e-02, 9.1079779e-02, 9.1233410e-02, - 9.1387041e-02, 9.1540672e-02, 9.1694310e-02, 9.1847949e-02, - 9.2001587e-02, 9.2155233e-02, 9.2308879e-02, 9.2462525e-02, - 9.2616171e-02, 9.2769824e-02, 9.2923477e-02, 9.3077131e-02, - 9.3230791e-02, 9.3384452e-02, 9.3538113e-02, 9.3691774e-02, - 9.3845442e-02, 9.3999110e-02, 9.4152778e-02, 9.4306454e-02, - 9.4460130e-02, 9.4613805e-02, 9.4767489e-02, 9.4921172e-02, - 9.5074855e-02, 9.5228538e-02, 9.5382228e-02, 9.5535919e-02, - 9.5689617e-02, 9.5843308e-02, 9.5997006e-02, 9.6150704e-02, - 9.6304409e-02, 9.6458115e-02, 9.6611820e-02, 9.6765533e-02, - 9.6919239e-02, 9.7072959e-02, 9.7226672e-02, 9.7380392e-02, - 9.7534113e-02, 9.7687833e-02, 9.7841561e-02, 9.7995289e-02, - 9.8149016e-02, 9.8302752e-02, 9.8456487e-02, 9.8610222e-02, - 9.8763958e-02, 9.8917700e-02, 9.9071443e-02, 9.9225193e-02, - 9.9378943e-02, 9.9532694e-02, 9.9686444e-02, 9.9840201e-02, - 9.9993959e-02, 1.0014772e-01, 1.0030148e-01, 1.0045525e-01, - 1.0060901e-01, 1.0076278e-01, 1.0091656e-01, 1.0107033e-01, - 1.0122411e-01, 1.0137789e-01, 1.0153167e-01, 1.0168546e-01, - 1.0183924e-01, 1.0199303e-01, 1.0214682e-01, 1.0230061e-01, - 1.0245441e-01, 1.0260821e-01, 1.0276201e-01, 1.0291582e-01, - 1.0306962e-01, 1.0322343e-01, 1.0337724e-01, 1.0353106e-01, - 1.0368487e-01, 1.0383869e-01, 1.0399251e-01, 1.0414633e-01, - 1.0430016e-01, 1.0445399e-01, 1.0460781e-01, 1.0476165e-01, - 1.0491548e-01, 1.0506932e-01, 1.0522316e-01, 1.0537700e-01, - 1.0553085e-01, 1.0568470e-01, 1.0583855e-01, 1.0599241e-01, - 1.0614626e-01, 1.0630012e-01, 1.0645398e-01, 1.0660784e-01, - 1.0676171e-01, 1.0691557e-01, 1.0706945e-01, 1.0722332e-01, - 1.0737719e-01, 1.0753107e-01, 1.0768496e-01, 1.0783884e-01, - 1.0799272e-01, 1.0814661e-01, 1.0830050e-01, 1.0845440e-01, - 1.0860829e-01, 1.0876219e-01, 1.0891609e-01, 1.0907000e-01, - 1.0922390e-01, 1.0937781e-01, 1.0953172e-01, 1.0968564e-01, - 1.0983955e-01, 1.0999347e-01, 1.1014739e-01, 1.1030132e-01, - 1.1045524e-01, 1.1060917e-01, 1.1076311e-01, 1.1091705e-01, - 1.1107098e-01, 1.1122492e-01, 1.1137886e-01, 1.1153281e-01, - 1.1168676e-01, 1.1184071e-01, 1.1199466e-01, 1.1214862e-01, - 1.1230258e-01, 1.1245654e-01, 1.1261050e-01, 1.1276447e-01, - 1.1291844e-01, 1.1307242e-01, 1.1322639e-01, 1.1338037e-01, - 1.1353435e-01, 1.1368833e-01, 1.1384232e-01, 1.1399630e-01, - 1.1415029e-01, 1.1430429e-01, 1.1445829e-01, 1.1461229e-01, - 1.1476628e-01, 1.1492029e-01, 1.1507430e-01, 1.1522831e-01, - 1.1538232e-01, 1.1553634e-01, 1.1569036e-01, 1.1584438e-01, - 1.1599840e-01, 1.1615243e-01, 1.1630645e-01, 1.1646049e-01, - 1.1661452e-01, 1.1676856e-01, 1.1692260e-01, 1.1707664e-01, - 1.1723069e-01, 1.1738474e-01, 1.1753879e-01, 1.1769284e-01, - 1.1784691e-01, 1.1800096e-01, 1.1815502e-01, 1.1830909e-01, - 1.1846316e-01, 1.1861723e-01, 1.1877131e-01, 1.1892538e-01, - 1.1907946e-01, 1.1923354e-01, 1.1938763e-01, 1.1954172e-01, - 1.1969581e-01, 1.1984990e-01, 1.2000400e-01, 1.2015810e-01, - 1.2031220e-01, 1.2046631e-01, 1.2062041e-01, 1.2077452e-01, - 1.2092864e-01, 1.2108275e-01, 1.2123688e-01, 1.2139100e-01, - 1.2154512e-01, 1.2169925e-01, 1.2185338e-01, 1.2200751e-01, - 1.2216165e-01, 1.2231579e-01, 1.2246993e-01, 1.2262408e-01, - 1.2277823e-01, 1.2293238e-01, 1.2308653e-01, 1.2324069e-01, - 1.2339485e-01, 1.2354901e-01, 1.2370318e-01, 1.2385735e-01, - 1.2401152e-01, 1.2416570e-01, 1.2431987e-01, 1.2447406e-01, - 1.2462824e-01, 1.2478243e-01, 1.2493662e-01, 1.2509081e-01, - 1.2524500e-01, 1.2539920e-01, 1.2555340e-01, 1.2570761e-01, - 1.2586181e-01, 1.2601602e-01, 1.2617023e-01, 1.2632446e-01, - 1.2647867e-01, 1.2663290e-01, 1.2678713e-01, 1.2694135e-01, - 1.2709558e-01, 1.2724982e-01, 1.2740405e-01, 1.2755829e-01, - 1.2771255e-01, 1.2786679e-01, 1.2802103e-01, 1.2817529e-01, - 1.2832955e-01, 1.2848380e-01, 1.2863807e-01, 1.2879233e-01, - 1.2894660e-01, 1.2910087e-01, 1.2925515e-01, 1.2940942e-01, - 1.2956370e-01, 1.2971799e-01, 1.2987228e-01, 1.3002656e-01, - 1.3018085e-01, 1.3033515e-01, 1.3048945e-01, 1.3064376e-01, - 1.3079806e-01, 1.3095237e-01, 1.3110667e-01, 1.3126099e-01, - 1.3141531e-01, 1.3156962e-01, 1.3172396e-01, 1.3187829e-01, - 1.3203262e-01, 1.3218695e-01, 1.3234128e-01, 1.3249563e-01, - 1.3264996e-01, 1.3280430e-01, 1.3295867e-01, 1.3311301e-01, - 1.3326737e-01, 1.3342173e-01, 1.3357610e-01, 1.3373046e-01, - 1.3388482e-01, 1.3403919e-01, 1.3419357e-01, 1.3434795e-01, - 1.3450232e-01, 1.3465671e-01, 1.3481110e-01, 1.3496549e-01, - 1.3511989e-01, 1.3527428e-01, 1.3542868e-01, 1.3558309e-01, - 1.3573749e-01, 1.3589190e-01, 1.3604632e-01, 1.3620073e-01, - 1.3635515e-01, 1.3650957e-01, 1.3666400e-01, 1.3681842e-01, - 1.3697286e-01, 1.3712730e-01, 1.3728173e-01, 1.3743618e-01, - 1.3759063e-01, 1.3774507e-01, 1.3789953e-01, 1.3805398e-01, - 1.3820843e-01, 1.3836290e-01, 1.3851736e-01, 1.3867185e-01, - 1.3882631e-01, 1.3898079e-01, 1.3913527e-01, 1.3928975e-01, - 1.3944423e-01, 1.3959873e-01, 1.3975321e-01, 1.3990770e-01, - 1.4006221e-01, 1.4021671e-01, 1.4037122e-01, 1.4052573e-01, - 1.4068024e-01, 1.4083475e-01, 1.4098927e-01, 1.4114380e-01, - 1.4129832e-01, 1.4145285e-01, 1.4160737e-01, 1.4176191e-01, - 1.4191645e-01, 1.4207099e-01, 1.4222555e-01, 1.4238009e-01, - 1.4253464e-01, 1.4268920e-01, 1.4284377e-01, 1.4299832e-01, - 1.4315289e-01, 1.4330746e-01, 1.4346203e-01, 1.4361662e-01, - 1.4377119e-01, 1.4392577e-01, 1.4408036e-01, 1.4423496e-01, - 1.4438954e-01, 1.4454414e-01, 1.4469874e-01, 1.4485335e-01, - 1.4500795e-01, 1.4516257e-01, 1.4531718e-01, 1.4547180e-01, - 1.4562643e-01, 1.4578104e-01, 1.4593567e-01, 1.4609031e-01, - 1.4624494e-01, 1.4639959e-01, 1.4655423e-01, 1.4670888e-01, - 1.4686352e-01, 1.4701818e-01, 1.4717282e-01, 1.4732748e-01, - 1.4748216e-01, 1.4763682e-01, 1.4779149e-01, 1.4794616e-01, - 1.4810084e-01, 1.4825553e-01, 1.4841022e-01, 1.4856490e-01, - 1.4871959e-01, 1.4887428e-01, 1.4902899e-01, 1.4918369e-01, - 1.4933839e-01, 1.4949310e-01, 1.4964782e-01, 1.4980254e-01, - 1.4995725e-01, 1.5011197e-01, 1.5026671e-01, 1.5042144e-01, - 1.5057617e-01, 1.5073091e-01, 1.5088566e-01, 1.5104041e-01, - 1.5119515e-01, 1.5134990e-01, 1.5150465e-01, 1.5165941e-01, - 1.5181418e-01, 1.5196896e-01, 1.5212372e-01, 1.5227850e-01, - 1.5243328e-01, 1.5258805e-01, 1.5274285e-01, 1.5289763e-01, - 1.5305242e-01, 1.5320723e-01, 1.5336202e-01, 1.5351683e-01, - 1.5367164e-01, 1.5382645e-01, 1.5398125e-01, 1.5413608e-01, - 1.5429090e-01, 1.5444572e-01, 1.5460056e-01, 1.5475538e-01, - 1.5491022e-01, 1.5506507e-01, 1.5521991e-01, 1.5537477e-01, - 1.5552962e-01, 1.5568447e-01, 1.5583932e-01, 1.5599419e-01, - 1.5614906e-01, 1.5630393e-01, 1.5645881e-01, 1.5661368e-01, - 1.5676856e-01, 1.5692346e-01, 1.5707834e-01, 1.5723324e-01, - 1.5738814e-01, 1.5754303e-01, 1.5769795e-01, 1.5785284e-01, - 1.5800776e-01, 1.5816268e-01, 1.5831760e-01, 1.5847252e-01, - 1.5862745e-01, 1.5878238e-01, 1.5893732e-01, 1.5909225e-01, - 1.5924719e-01, 1.5940215e-01, 1.5955709e-01, 1.5971205e-01, - 1.5986700e-01, 1.6002196e-01, 1.6017693e-01, 1.6033190e-01, - 1.6048688e-01, 1.6064185e-01, 1.6079684e-01, 1.6095182e-01, - 1.6110681e-01, 1.6126180e-01, 1.6141680e-01, 1.6157180e-01, - 1.6172680e-01, 1.6188180e-01, 1.6203682e-01, 1.6219184e-01, - 1.6234685e-01, 1.6250189e-01, 1.6265692e-01, 1.6281195e-01, - 1.6296698e-01, 1.6312201e-01, 1.6327706e-01, 1.6343211e-01, - 1.6358717e-01, 1.6374221e-01, 1.6389728e-01, 1.6405234e-01, - 1.6420740e-01, 1.6436248e-01, 1.6451755e-01, 1.6467263e-01, - 1.6482772e-01, 1.6498280e-01, 1.6513789e-01, 1.6529299e-01, - 1.6544808e-01, 1.6560319e-01, 1.6575830e-01, 1.6591340e-01, - 1.6606852e-01, 1.6622365e-01, 1.6637877e-01, 1.6653389e-01, - 1.6668902e-01, 1.6684416e-01, 1.6699930e-01, 1.6715443e-01, - 1.6730958e-01, 1.6746473e-01, 1.6761988e-01, 1.6777505e-01, - 1.6793022e-01, 1.6808538e-01, 1.6824055e-01, 1.6839573e-01, - 1.6855091e-01, 1.6870609e-01, 1.6886127e-01, 1.6901647e-01, - 1.6917166e-01, 1.6932686e-01, 1.6948207e-01, 1.6963726e-01, - 1.6979249e-01, 1.6994770e-01, 1.7010292e-01, 1.7025813e-01, - 1.7041337e-01, 1.7056860e-01, 1.7072384e-01, 1.7087908e-01, - 1.7103432e-01, 1.7118958e-01, 1.7134482e-01, 1.7150009e-01, - 1.7165534e-01, 1.7181061e-01, 1.7196588e-01, 1.7212115e-01, - 1.7227642e-01, 1.7243171e-01, 1.7258699e-01, 1.7274229e-01, - 1.7289758e-01, 1.7305288e-01, 1.7320818e-01, 1.7336349e-01, - 1.7351879e-01, 1.7367411e-01, 1.7382944e-01, 1.7398475e-01, - 1.7414008e-01, 1.7429541e-01, 1.7445076e-01, 1.7460610e-01, - 1.7476144e-01, 1.7491679e-01, 1.7507213e-01, 1.7522749e-01, - 1.7538285e-01, 1.7553823e-01, 1.7569359e-01, 1.7584896e-01, - 1.7600435e-01, 1.7615972e-01, 1.7631511e-01, 1.7647050e-01, - 1.7662591e-01, 1.7678130e-01, 1.7693670e-01, 1.7709212e-01, - 1.7724752e-01, 1.7740294e-01, 1.7755836e-01, 1.7771380e-01, - 1.7786922e-01, 1.7802465e-01, 1.7818010e-01, 1.7833553e-01, - 1.7849098e-01, 1.7864643e-01, 1.7880189e-01, 1.7895734e-01, - 1.7911281e-01, 1.7926829e-01, 1.7942375e-01, 1.7957923e-01, - 1.7973471e-01, 1.7989020e-01, 1.8004569e-01, 1.8020119e-01, - 1.8035668e-01, 1.8051219e-01, 1.8066770e-01, 1.8082321e-01, - 1.8097872e-01, 1.8113424e-01, 1.8128976e-01, 1.8144530e-01, - 1.8160082e-01, 1.8175636e-01, 1.8191192e-01, 1.8206745e-01, - 1.8222301e-01, 1.8237856e-01, 1.8253413e-01, 1.8268970e-01, - 1.8284526e-01, 1.8300083e-01, 1.8315642e-01, 1.8331200e-01, - 1.8346758e-01, 1.8362318e-01, 1.8377876e-01, 1.8393438e-01, - 1.8408997e-01, 1.8424559e-01, 1.8440120e-01, 1.8455681e-01, - 1.8471244e-01, 1.8486807e-01, 1.8502370e-01, 1.8517934e-01, - 1.8533497e-01, 1.8549062e-01, 1.8564627e-01, 1.8580192e-01, - 1.8595758e-01, 1.8611324e-01, 1.8626891e-01, 1.8642458e-01, - 1.8658026e-01, 1.8673594e-01, 1.8689163e-01, 1.8704732e-01, - 1.8720300e-01, 1.8735871e-01, 1.8751441e-01, 1.8767013e-01, - 1.8782583e-01, 1.8798155e-01, 1.8813728e-01, 1.8829300e-01, - 1.8844873e-01, 1.8860446e-01, 1.8876021e-01, 1.8891595e-01, - 1.8907170e-01, 1.8922745e-01, 1.8938321e-01, 1.8953897e-01, - 1.8969475e-01, 1.8985051e-01, 1.9000629e-01, 1.9016208e-01, - 1.9031785e-01, 1.9047365e-01, 1.9062945e-01, 1.9078524e-01, - 1.9094105e-01, 1.9109686e-01, 1.9125268e-01, 1.9140849e-01, - 1.9156432e-01, 1.9172014e-01, 1.9187598e-01, 1.9203182e-01, - 1.9218765e-01, 1.9234350e-01, 1.9249935e-01, 1.9265521e-01, - 1.9281107e-01, 1.9296694e-01, 1.9312280e-01, 1.9327869e-01, - 1.9343455e-01, 1.9359045e-01, 1.9374633e-01, 1.9390222e-01, - 1.9405812e-01, 1.9421403e-01, 1.9436993e-01, 1.9452584e-01, - 1.9468176e-01, 1.9483769e-01, 1.9499362e-01, 1.9514954e-01, - 1.9530548e-01, 1.9546142e-01, 1.9561736e-01, 1.9577332e-01, - 1.9592927e-01, 1.9608523e-01, 1.9624120e-01, 1.9639716e-01, - 1.9655314e-01, 1.9670911e-01, 1.9686510e-01, 1.9702108e-01, - 1.9717708e-01, 1.9733308e-01, 1.9748908e-01, 1.9764508e-01, - 1.9780110e-01, 1.9795711e-01, 1.9811314e-01, 1.9826917e-01, - 1.9842520e-01, 1.9858123e-01, 1.9873728e-01, 1.9889332e-01, - 1.9904937e-01, 1.9920543e-01, 1.9936149e-01, 1.9951756e-01, - 1.9967362e-01, 1.9982970e-01, 1.9998579e-01, 2.0014186e-01, - 2.0029795e-01, 2.0045406e-01, 2.0061015e-01, 2.0076625e-01, - 2.0092237e-01, 2.0107847e-01, 2.0123459e-01, 2.0139073e-01, - 2.0154685e-01, 2.0170298e-01, 2.0185913e-01, 2.0201527e-01, - 2.0217142e-01, 2.0232758e-01, 2.0248373e-01, 2.0263989e-01, - 2.0279607e-01, 2.0295224e-01, 2.0310842e-01, 2.0326459e-01, - 2.0342079e-01, 2.0357698e-01, 2.0373318e-01, 2.0388938e-01, - 2.0404559e-01, 2.0420180e-01, 2.0435803e-01, 2.0451425e-01, - 2.0467047e-01, 2.0482671e-01, 2.0498295e-01, 2.0513919e-01, - 2.0529544e-01, 2.0545170e-01, 2.0560795e-01, 2.0576420e-01, - 2.0592047e-01, 2.0607676e-01, 2.0623302e-01, 2.0638931e-01, - 2.0654561e-01, 2.0670189e-01, 2.0685819e-01, 2.0701450e-01, - 2.0717081e-01, 2.0732713e-01, 2.0748344e-01, 2.0763977e-01, - 2.0779610e-01, 2.0795242e-01, 2.0810877e-01, 2.0826511e-01, - 2.0842145e-01, 2.0857781e-01, 2.0873417e-01, 2.0889054e-01, - 2.0904690e-01, 2.0920329e-01, 2.0935966e-01, 2.0951605e-01, - 2.0967244e-01, 2.0982882e-01, 2.0998523e-01, 2.1014164e-01, - 2.1029805e-01, 2.1045446e-01, 2.1061088e-01, 2.1076731e-01, - 2.1092375e-01, 2.1108018e-01, 2.1123663e-01, 2.1139307e-01, - 2.1154952e-01, 2.1170597e-01, 2.1186243e-01, 2.1201891e-01, - 2.1217538e-01, 2.1233186e-01, 2.1248834e-01, 2.1264483e-01, - 2.1280132e-01, 2.1295781e-01, 2.1311432e-01, 2.1327083e-01, - 2.1342735e-01, 2.1358387e-01, 2.1374039e-01, 2.1389692e-01, - 2.1405345e-01, 2.1420999e-01, 2.1436654e-01, 2.1452309e-01, - 2.1467964e-01, 2.1483621e-01, 2.1499278e-01, 2.1514934e-01, - 2.1530592e-01, 2.1546251e-01, 2.1561910e-01, 2.1577568e-01, - 2.1593229e-01, 2.1608889e-01, 2.1624550e-01, 2.1640211e-01, - 2.1655874e-01, 2.1671537e-01, 2.1687199e-01, 2.1702863e-01, - 2.1718527e-01, 2.1734191e-01, 2.1749857e-01, 2.1765523e-01, - 2.1781188e-01, 2.1796855e-01, 2.1812522e-01, 2.1828191e-01, - 2.1843858e-01, 2.1859528e-01, 2.1875197e-01, 2.1890867e-01, - 2.1906538e-01, 2.1922208e-01, 2.1937880e-01, 2.1953553e-01, - 2.1969225e-01, 2.1984898e-01, 2.2000572e-01, 2.2016247e-01, - 2.2031921e-01, 2.2047597e-01, 2.2063272e-01, 2.2078949e-01, - 2.2094625e-01, 2.2110303e-01, 2.2125982e-01, 2.2141661e-01, - 2.2157340e-01, 2.2173019e-01, 2.2188699e-01, 2.2204380e-01, - 2.2220062e-01, 2.2235744e-01, 2.2251426e-01, 2.2267109e-01, - 2.2282793e-01, 2.2298476e-01, 2.2314161e-01, 2.2329846e-01, - 2.2345532e-01, 2.2361219e-01, 2.2376905e-01, 2.2392592e-01, - 2.2408280e-01, 2.2423969e-01, 2.2439659e-01, 2.2455348e-01, - 2.2471038e-01, 2.2486728e-01, 2.2502419e-01, 2.2518112e-01, - 2.2533804e-01, 2.2549497e-01, 2.2565190e-01, 2.2580884e-01, - 2.2596578e-01, 2.2612274e-01, 2.2627969e-01, 2.2643666e-01, - 2.2659363e-01, 2.2675060e-01, 2.2690758e-01, 2.2706456e-01, - 2.2722156e-01, 2.2737855e-01, 2.2753556e-01, 2.2769256e-01, - 2.2784957e-01, 2.2800660e-01, 2.2816361e-01, 2.2832064e-01, - 2.2847769e-01, 2.2863473e-01, 2.2879177e-01, 2.2894882e-01, - 2.2910587e-01, 2.2926295e-01, 2.2942002e-01, 2.2957709e-01, - 2.2973417e-01, 2.2989126e-01, 2.3004834e-01, 2.3020545e-01, - 2.3036255e-01, 2.3051965e-01, 2.3067677e-01, 2.3083389e-01, - 2.3099102e-01, 2.3114815e-01, 2.3130529e-01, 2.3146243e-01, - 2.3161958e-01, 2.3177674e-01, 2.3193389e-01, 2.3209107e-01, - 2.3224823e-01, 2.3240541e-01, 2.3256260e-01, 2.3271978e-01, - 2.3287699e-01, 2.3303418e-01, 2.3319139e-01, 2.3334859e-01, - 2.3350582e-01, 2.3366304e-01, 2.3382027e-01, 2.3397751e-01, - 2.3413475e-01, 2.3429200e-01, 2.3444925e-01, 2.3460650e-01, - 2.3476377e-01, 2.3492104e-01, 2.3507832e-01, 2.3523560e-01, - 2.3539288e-01, 2.3555018e-01, 2.3570748e-01, 2.3586477e-01, - 2.3602208e-01, 2.3617941e-01, 2.3633672e-01, 2.3649406e-01, - 2.3665139e-01, 2.3680873e-01, 2.3696607e-01, 2.3712343e-01, - 2.3728079e-01, 2.3743816e-01, 2.3759551e-01, 2.3775290e-01, - 2.3791027e-01, 2.3806766e-01, 2.3822506e-01, 2.3838246e-01, - 2.3853986e-01, 2.3869728e-01, 2.3885469e-01, 2.3901211e-01, - 2.3916954e-01, 2.3932697e-01, 2.3948441e-01, 2.3964186e-01, - 2.3979931e-01, 2.3995677e-01, 2.4011423e-01, 2.4027170e-01, - 2.4042918e-01, 2.4058667e-01, 2.4074414e-01, 2.4090165e-01, - 2.4105914e-01, 2.4121664e-01, 2.4137416e-01, 2.4153168e-01, - 2.4168921e-01, 2.4184673e-01, 2.4200428e-01, 2.4216181e-01, - 2.4231936e-01, 2.4247691e-01, 2.4263448e-01, 2.4279204e-01, - 2.4294960e-01, 2.4310718e-01, 2.4326476e-01, 2.4342236e-01, - 2.4357995e-01, 2.4373756e-01, 2.4389517e-01, 2.4405278e-01, - 2.4421041e-01, 2.4436803e-01, 2.4452566e-01, 2.4468330e-01, - 2.4484095e-01, 2.4499859e-01, 2.4515624e-01, 2.4531391e-01, - 2.4547158e-01, 2.4562925e-01, 2.4578694e-01, 2.4594462e-01, - 2.4610232e-01, 2.4626002e-01, 2.4641773e-01, 2.4657543e-01, - 2.4673316e-01, 2.4689087e-01, 2.4704860e-01, 2.4720635e-01, - 2.4736409e-01, 2.4752183e-01, 2.4767959e-01, 2.4783735e-01, - 2.4799512e-01, 2.4815290e-01, 2.4831067e-01, 2.4846846e-01, - 2.4862625e-01, 2.4878405e-01, 2.4894185e-01, 2.4909966e-01, - 2.4925748e-01, 2.4941529e-01, 2.4957313e-01, 2.4973096e-01, - 2.4988881e-01, 2.5004664e-01, 2.5020450e-01, 2.5036237e-01, - 2.5052023e-01, 2.5067809e-01, 2.5083598e-01, 2.5099388e-01, - 2.5115177e-01, 2.5130966e-01, 2.5146756e-01, 2.5162548e-01, - 2.5178340e-01, 2.5194132e-01, 2.5209925e-01, 2.5225717e-01, - 2.5241512e-01, 2.5257307e-01, 2.5273103e-01, 2.5288898e-01, - 2.5304696e-01, 2.5320491e-01, 2.5336289e-01, 2.5352088e-01, - 2.5367889e-01, 2.5383687e-01, 2.5399488e-01, 2.5415289e-01, - 2.5431091e-01, 2.5446895e-01, 2.5462696e-01, 2.5478500e-01, - 2.5494304e-01, 2.5510108e-01, 2.5525916e-01, 2.5541720e-01, - 2.5557527e-01, 2.5573334e-01, 2.5589144e-01, 2.5604951e-01, - 2.5620762e-01, 2.5636572e-01, 2.5652382e-01, 2.5668195e-01, - 2.5684005e-01, 2.5699818e-01, 2.5715631e-01, 2.5731444e-01, - 2.5747260e-01, 2.5763074e-01, 2.5778890e-01, 2.5794709e-01, - 2.5810525e-01, 2.5826341e-01, 2.5842160e-01, 2.5857979e-01, - 2.5873798e-01, 2.5889620e-01, 2.5905439e-01, 2.5921261e-01, - 2.5937083e-01, 2.5952908e-01, 2.5968730e-01, 2.5984555e-01, - 2.6000381e-01, 2.6016206e-01, 2.6032031e-01, 2.6047859e-01, - 2.6063687e-01, 2.6079515e-01, 2.6095343e-01, 2.6111174e-01, - 2.6127002e-01, 2.6142833e-01, 2.6158664e-01, 2.6174498e-01, - 2.6190329e-01, 2.6206163e-01, 2.6221997e-01, 2.6237831e-01, - 2.6253667e-01, 2.6269504e-01, 2.6285341e-01, 2.6301178e-01, - 2.6317015e-01, 2.6332855e-01, 2.6348692e-01, 2.6364532e-01, - 2.6380375e-01, 2.6396215e-01, 2.6412058e-01, 2.6427901e-01, - 2.6443744e-01, 2.6459587e-01, 2.6475433e-01, 2.6491278e-01, - 2.6507124e-01, 2.6522970e-01, 2.6538816e-01, 2.6554665e-01, - 2.6570514e-01, 2.6586363e-01, 2.6602212e-01, 2.6618063e-01, - 2.6633915e-01, 2.6649767e-01, 2.6665619e-01, 2.6681474e-01, - 2.6697326e-01, 2.6713181e-01, 2.6729035e-01, 2.6744893e-01, - 2.6760748e-01, 2.6776606e-01, 2.6792464e-01, 2.6808321e-01, - 2.6824182e-01, 2.6840043e-01, 2.6855904e-01, 2.6871765e-01, - 2.6887625e-01, 2.6903489e-01, 2.6919353e-01, 2.6935217e-01, - 2.6951081e-01, 2.6966947e-01, 2.6982814e-01, 2.6998681e-01, - 2.7014548e-01, 2.7030414e-01, 2.7046284e-01, 2.7062154e-01, - 2.7078024e-01, 2.7093893e-01, 2.7109766e-01, 2.7125639e-01, - 2.7141511e-01, 2.7157384e-01, 2.7173260e-01, 2.7189136e-01, - 2.7205011e-01, 2.7220887e-01, 2.7236763e-01, 2.7252641e-01, - 2.7268520e-01, 2.7284399e-01, 2.7300277e-01, 2.7316159e-01, - 2.7332041e-01, 2.7347922e-01, 2.7363804e-01, 2.7379689e-01, - 2.7395570e-01, 2.7411455e-01, 2.7427343e-01, 2.7443227e-01, - 2.7459115e-01, 2.7475002e-01, 2.7490890e-01, 2.7506778e-01, - 2.7522668e-01, 2.7538559e-01, 2.7554449e-01, 2.7570340e-01, - 2.7586234e-01, 2.7602127e-01, 2.7618021e-01, 2.7633914e-01, - 2.7649808e-01, 2.7665704e-01, 2.7681601e-01, 2.7697498e-01, - 2.7713397e-01, 2.7729294e-01, 2.7745193e-01, 2.7761093e-01, - 2.7776995e-01, 2.7792895e-01, 2.7808797e-01, 2.7824700e-01, - 2.7840602e-01, 2.7856508e-01, 2.7872413e-01, 2.7888319e-01, - 2.7904224e-01, 2.7920133e-01, 2.7936038e-01, 2.7951947e-01, - 2.7967858e-01, 2.7983767e-01, 2.7999678e-01, 2.8015590e-01, - 2.8031501e-01, 2.8047413e-01, 2.8063327e-01, 2.8079242e-01, - 2.8095156e-01, 2.8111070e-01, 2.8126988e-01, 2.8142905e-01, - 2.8158823e-01, 2.8174740e-01, 2.8190657e-01, 2.8206578e-01, - 2.8222498e-01, 2.8238422e-01, 2.8254342e-01, 2.8270265e-01, - 2.8286189e-01, 2.8302112e-01, 2.8318036e-01, 2.8333962e-01, - 2.8349888e-01, 2.8365815e-01, 2.8381744e-01, 2.8397670e-01, - 2.8413600e-01, 2.8429532e-01, 2.8445461e-01, 2.8461394e-01, - 2.8477323e-01, 2.8493258e-01, 2.8509191e-01, 2.8525126e-01, - 2.8541058e-01, 2.8556997e-01, 2.8572932e-01, 2.8588867e-01, - 2.8604805e-01, 2.8620744e-01, 2.8636685e-01, 2.8652623e-01, - 2.8668565e-01, 2.8684506e-01, 2.8700447e-01, 2.8716391e-01, - 2.8732336e-01, 2.8748280e-01, 2.8764224e-01, 2.8780171e-01, - 2.8796116e-01, 2.8812063e-01, 2.8828013e-01, 2.8843960e-01, - 2.8859910e-01, 2.8875861e-01, 2.8891811e-01, 2.8907764e-01, - 2.8923714e-01, 2.8939667e-01, 2.8955624e-01, 2.8971577e-01, - 2.8987533e-01, 2.9003489e-01, 2.9019445e-01, 2.9035401e-01, - 2.9051360e-01, 2.9067320e-01, 2.9083279e-01, 2.9099241e-01, - 2.9115203e-01, 2.9131162e-01, 2.9147127e-01, 2.9163089e-01, - 2.9179054e-01, 2.9195020e-01, 2.9210985e-01, 2.9226950e-01, - 2.9242918e-01, 2.9258886e-01, 2.9274854e-01, 2.9290825e-01, - 2.9306796e-01, 2.9322764e-01, 2.9338738e-01, 2.9354709e-01, - 2.9370683e-01, 2.9386657e-01, 2.9402632e-01, 2.9418609e-01, - 2.9434583e-01, 2.9450560e-01, 2.9466537e-01, 2.9482517e-01, - 2.9498497e-01, 2.9514477e-01, 2.9530457e-01, 2.9546437e-01, - 2.9562420e-01, 2.9578403e-01, 2.9594386e-01, 2.9610372e-01, - 2.9626358e-01, 2.9642344e-01, 2.9658329e-01, 2.9674315e-01, - 2.9690304e-01, 2.9706293e-01, 2.9722282e-01, 2.9738274e-01, - 2.9754266e-01, 2.9770258e-01, 2.9786250e-01, 2.9802245e-01, - 2.9818240e-01, 2.9834235e-01, 2.9850230e-01, 2.9866228e-01, - 2.9882222e-01, 2.9898220e-01, 2.9914221e-01, 2.9930219e-01, - 2.9946220e-01, 2.9962221e-01, 2.9978225e-01, 2.9994226e-01, - 3.0010229e-01, 3.0026236e-01, 3.0042240e-01, 3.0058247e-01, - 3.0074254e-01, 3.0090261e-01, 3.0106267e-01, 3.0122277e-01, - 3.0138287e-01, 3.0154297e-01, 3.0170310e-01, 3.0186319e-01, - 3.0202332e-01, 3.0218348e-01, 3.0234361e-01, 3.0250376e-01, - 3.0266392e-01, 3.0282408e-01, 3.0298427e-01, 3.0314445e-01, - 3.0330464e-01, 3.0346483e-01, 3.0362505e-01, 3.0378526e-01, - 3.0394548e-01, 3.0410570e-01, 3.0426595e-01, 3.0442619e-01, - 3.0458644e-01, 3.0474669e-01, 3.0490696e-01, 3.0506724e-01, - 3.0522752e-01, 3.0538782e-01, 3.0554810e-01, 3.0570841e-01, - 3.0586874e-01, 3.0602905e-01, 3.0618939e-01, 3.0634972e-01, - 3.0651006e-01, 3.0667043e-01, 3.0683079e-01, 3.0699116e-01, - 3.0715156e-01, 3.0731192e-01, 3.0747232e-01, 3.0763271e-01, - 3.0779314e-01, 3.0795354e-01, 3.0811396e-01, 3.0827442e-01, - 3.0843484e-01, 3.0859530e-01, 3.0875576e-01, 3.0891621e-01, - 3.0907670e-01, 3.0923718e-01, 3.0939767e-01, 3.0955815e-01, - 3.0971867e-01, 3.0987918e-01, 3.1003970e-01, 3.1020024e-01, - 3.1036076e-01, 3.1052130e-01, 3.1068188e-01, 3.1084242e-01, - 3.1100300e-01, 3.1116357e-01, 3.1132415e-01, 3.1148475e-01, - 3.1164536e-01, 3.1180596e-01, 3.1196660e-01, 3.1212720e-01, - 3.1228784e-01, 3.1244847e-01, 3.1260914e-01, 3.1276980e-01, - 3.1293046e-01, 3.1309113e-01, 3.1325182e-01, 3.1341252e-01, - 3.1357321e-01, 3.1373391e-01, 3.1389463e-01, 3.1405535e-01, - 3.1421608e-01, 3.1437680e-01, 3.1453755e-01, 3.1469831e-01, - 3.1485909e-01, 3.1501985e-01, 3.1518063e-01, 3.1534141e-01, - 3.1550223e-01, 3.1566301e-01, 3.1582382e-01, 3.1598464e-01, - 3.1614548e-01, 3.1630632e-01, 3.1646717e-01, 3.1662801e-01, - 3.1678888e-01, 3.1694973e-01, 3.1711063e-01, 3.1727150e-01, - 3.1743240e-01, 3.1759331e-01, 3.1775421e-01, 3.1791514e-01, - 3.1807604e-01, 3.1823698e-01, 3.1839794e-01, 3.1855887e-01, - 3.1871983e-01, 3.1888083e-01, 3.1904179e-01, 3.1920278e-01, - 3.1936377e-01, 3.1952477e-01, 3.1968579e-01, 3.1984678e-01, - 3.2000783e-01, 3.2016885e-01, 3.2032990e-01, 3.2049096e-01, - 3.2065201e-01, 3.2081306e-01, 3.2097414e-01, 3.2113522e-01, - 3.2129633e-01, 3.2145742e-01, 3.2161853e-01, 3.2177964e-01, - 3.2194078e-01, 3.2210192e-01, 3.2226306e-01, 3.2242420e-01, - 3.2258537e-01, 3.2274655e-01, 3.2290772e-01, 3.2306889e-01, - 3.2323009e-01, 3.2339129e-01, 3.2355249e-01, 3.2371372e-01, - 3.2387495e-01, 3.2403618e-01, 3.2419741e-01, 3.2435867e-01, - 3.2451993e-01, 3.2468119e-01, 3.2484248e-01, 3.2500377e-01, - 3.2516506e-01, 3.2532635e-01, 3.2548767e-01, 3.2564899e-01, - 3.2581031e-01, 3.2597166e-01, 3.2613301e-01, 3.2629436e-01, - 3.2645571e-01, 3.2661709e-01, 3.2677847e-01, 3.2693985e-01, - 3.2710126e-01, 3.2726264e-01, 3.2742405e-01, 3.2758549e-01, - 3.2774693e-01, 3.2790837e-01, 3.2806981e-01, 3.2823125e-01, - 3.2839271e-01, 3.2855418e-01, 3.2871568e-01, 3.2887715e-01, - 3.2903865e-01, 3.2920018e-01, 3.2936168e-01, 3.2952321e-01, - 3.2968473e-01, 3.2984629e-01, 3.3000782e-01, 3.3016938e-01, - 3.3033097e-01, 3.3049253e-01, 3.3065411e-01, 3.3081570e-01, - 3.3097732e-01, 3.3113891e-01, 3.3130056e-01, 3.3146217e-01, - 3.3162379e-01, 3.3178544e-01, 3.3194712e-01, 3.3210877e-01, - 3.3227044e-01, 3.3243212e-01, 3.3259380e-01, 3.3275551e-01, - 3.3291721e-01, 3.3307892e-01, 3.3324066e-01, 3.3340237e-01, - 3.3356413e-01, 3.3372587e-01, 3.3388764e-01, 3.3404940e-01, - 3.3421117e-01, 3.3437297e-01, 3.3453473e-01, 3.3469656e-01, - 3.3485836e-01, 3.3502018e-01, 3.3518201e-01, 3.3534384e-01, - 3.3550569e-01, 3.3566755e-01, 3.3582941e-01, 3.3599129e-01, - 3.3615315e-01, 3.3631504e-01, 3.3647695e-01, 3.3663887e-01, - 3.3680078e-01, 3.3696270e-01, 3.3712465e-01, 3.3728656e-01, - 3.3744854e-01, 3.3761048e-01, 3.3777246e-01, 3.3793443e-01, - 3.3809641e-01, 3.3825842e-01, 3.3842042e-01, 3.3858243e-01, - 3.3874446e-01, 3.3890650e-01, 3.3906853e-01, 3.3923057e-01, - 3.3939263e-01, 3.3955470e-01, 3.3971679e-01, 3.3987886e-01, - 3.4004095e-01, 3.4020305e-01, 3.4036517e-01, 3.4052730e-01, - 3.4068942e-01, 3.4085155e-01, 3.4101370e-01, 3.4117585e-01, - 3.4133804e-01, 3.4150019e-01, 3.4166238e-01, 3.4182459e-01, - 3.4198678e-01, 3.4214899e-01, 3.4231120e-01, 3.4247345e-01, - 3.4263566e-01, 3.4279794e-01, 3.4296018e-01, 3.4312245e-01, - 3.4328473e-01, 3.4344700e-01, 3.4360930e-01, 3.4377158e-01, - 3.4393391e-01, 3.4409621e-01, 3.4425855e-01, 3.4442088e-01, - 3.4458324e-01, 3.4474558e-01, 3.4490794e-01, 3.4507033e-01, - 3.4523270e-01, 3.4539509e-01, 3.4555748e-01, 3.4571990e-01, - 3.4588233e-01, 3.4604475e-01, 3.4620720e-01, 3.4636962e-01, - 3.4653208e-01, 3.4669456e-01, 3.4685704e-01, 3.4701952e-01, - 3.4718201e-01, 3.4734452e-01, 3.4750700e-01, 3.4766954e-01, - 3.4783205e-01, 3.4799460e-01, 3.4815714e-01, 3.4831971e-01, - 3.4848228e-01, 3.4864485e-01, 3.4880742e-01, 3.4897003e-01, - 3.4913263e-01, 3.4929523e-01, 3.4945786e-01, 3.4962049e-01, - 3.4978312e-01, 3.4994578e-01, 3.5010841e-01, 3.5027111e-01, - 3.5043377e-01, 3.5059646e-01, 3.5075915e-01, 3.5092187e-01, - 3.5108456e-01, 3.5124728e-01, 3.5141003e-01, 3.5157275e-01, - 3.5173550e-01, 3.5189828e-01, 3.5206103e-01, 3.5222381e-01, - 3.5238662e-01, 3.5254940e-01, 3.5271221e-01, 3.5287502e-01, - 3.5303786e-01, 3.5320070e-01, 3.5336354e-01, 3.5352638e-01, - 3.5368925e-01, 3.5385212e-01, 3.5401499e-01, 3.5417789e-01, - 3.5434079e-01, 3.5450372e-01, 3.5466662e-01, 3.5482955e-01, - 3.5499248e-01, 3.5515544e-01, 3.5531840e-01, 3.5548136e-01, - 3.5564435e-01, 3.5580733e-01, 3.5597032e-01, 3.5613331e-01, - 3.5629633e-01, 3.5645935e-01, 3.5662240e-01, 3.5678545e-01, - 3.5694849e-01, 3.5711154e-01, 3.5727462e-01, 3.5743770e-01, - 3.5760078e-01, 3.5776389e-01, 3.5792699e-01, 3.5809010e-01, - 3.5825324e-01, 3.5841638e-01, 3.5857952e-01, 3.5874268e-01, - 3.5890585e-01, 3.5906902e-01, 3.5923222e-01, 3.5939538e-01, - 3.5955861e-01, 3.5972181e-01, 3.5988504e-01, 3.6004826e-01, - 3.6021152e-01, 3.6037478e-01, 3.6053804e-01, 3.6070129e-01, - 3.6086458e-01, 3.6102787e-01, 3.6119115e-01, 3.6135447e-01, - 3.6151779e-01, 3.6168113e-01, 3.6184445e-01, 3.6200783e-01, - 3.6217117e-01, 3.6233455e-01, 3.6249793e-01, 3.6266130e-01, - 3.6282471e-01, 3.6298811e-01, 3.6315152e-01, 3.6331496e-01, - 3.6347839e-01, 3.6364183e-01, 3.6380529e-01, 3.6396876e-01, - 3.6413223e-01, 3.6429569e-01, 3.6445919e-01, 3.6462271e-01, - 3.6478621e-01, 3.6494973e-01, 3.6511326e-01, 3.6527681e-01, - 3.6544037e-01, 3.6560392e-01, 3.6576751e-01, 3.6593106e-01, - 3.6609468e-01, 3.6625826e-01, 3.6642188e-01, 3.6658549e-01, - 3.6674914e-01, 3.6691278e-01, 3.6707643e-01, 3.6724007e-01, - 3.6740375e-01, 3.6756742e-01, 3.6773112e-01, 3.6789483e-01, - 3.6805853e-01, 3.6822224e-01, 3.6838597e-01, 3.6854970e-01, - 3.6871347e-01, 3.6887723e-01, 3.6904100e-01, 3.6920476e-01, - 3.6936855e-01, 3.6953235e-01, 3.6969617e-01, 3.6985999e-01, - 3.7002382e-01, 3.7018764e-01, 3.7035149e-01, 3.7051535e-01, - 3.7067923e-01, 3.7084311e-01, 3.7100700e-01, 3.7117088e-01, - 3.7133479e-01, 3.7149870e-01, 3.7166265e-01, 3.7182659e-01, - 3.7199053e-01, 3.7215447e-01, 3.7231845e-01, 3.7248242e-01, - 3.7264642e-01, 3.7281042e-01, 3.7297443e-01, 3.7313843e-01, - 3.7330246e-01, 3.7346649e-01, 3.7363055e-01, 3.7379462e-01, - 3.7395868e-01, 3.7412277e-01, 3.7428683e-01, 3.7445095e-01, - 3.7461504e-01, 3.7477916e-01, 3.7494329e-01, 3.7510744e-01, - 3.7527159e-01, 3.7543574e-01, 3.7559992e-01, 3.7576410e-01, - 3.7592828e-01, 3.7609249e-01, 3.7625667e-01, 3.7642092e-01, - 3.7658513e-01, 3.7674937e-01, 3.7691364e-01, 3.7707788e-01, - 3.7724215e-01, 3.7740645e-01, 3.7757072e-01, 3.7773502e-01, - 3.7789935e-01, 3.7806365e-01, 3.7822798e-01, 3.7839234e-01, - 3.7855670e-01, 3.7872106e-01, 3.7888542e-01, 3.7904981e-01, - 3.7921420e-01, 3.7937859e-01, 3.7954301e-01, 3.7970743e-01, - 3.7987188e-01, 3.8003632e-01, 3.8020077e-01, 3.8036522e-01, - 3.8052970e-01, 3.8069418e-01, 3.8085869e-01, 3.8102320e-01, - 3.8118771e-01, 3.8135225e-01, 3.8151678e-01, 3.8168132e-01, - 3.8184589e-01, 3.8201046e-01, 3.8217503e-01, 3.8233963e-01, - 3.8250422e-01, 3.8266882e-01, 3.8283345e-01, 3.8299808e-01, - 3.8316271e-01, 3.8332736e-01, 3.8349202e-01, 3.8365671e-01, - 3.8382137e-01, 3.8398609e-01, 3.8415077e-01, 3.8431549e-01, - 3.8448021e-01, 3.8464496e-01, 3.8480970e-01, 3.8497445e-01, - 3.8513920e-01, 3.8530397e-01, 3.8546878e-01, 3.8563356e-01, - 3.8579836e-01, 3.8596320e-01, 3.8612801e-01, 3.8629287e-01, - 3.8645771e-01, 3.8662258e-01, 3.8678744e-01, 3.8695231e-01, - 3.8711721e-01, 3.8728210e-01, 3.8744703e-01, 3.8761196e-01, - 3.8777688e-01, 3.8794184e-01, 3.8810679e-01, 3.8827175e-01, - 3.8843673e-01, 3.8860172e-01, 3.8876671e-01, 3.8893172e-01, - 3.8909674e-01, 3.8926175e-01, 3.8942680e-01, 3.8959184e-01, - 3.8975692e-01, 3.8992199e-01, 3.9008707e-01, 3.9025214e-01, - 3.9041725e-01, 3.9058238e-01, 3.9074749e-01, 3.9091262e-01, - 3.9107779e-01, 3.9124292e-01, 3.9140809e-01, 3.9157328e-01, - 3.9173847e-01, 3.9190367e-01, 3.9206886e-01, 3.9223409e-01, - 3.9239931e-01, 3.9256456e-01, 3.9272982e-01, 3.9289507e-01, - 3.9306036e-01, 3.9322564e-01, 3.9339092e-01, 3.9355624e-01, - 3.9372155e-01, 3.9388689e-01, 3.9405224e-01, 3.9421758e-01, - 3.9438292e-01, 3.9454830e-01, 3.9471370e-01, 3.9487907e-01, - 3.9504448e-01, 3.9520991e-01, 3.9537531e-01, 3.9554074e-01, - 3.9570621e-01, 3.9587167e-01, 3.9603713e-01, 3.9620259e-01, - 3.9636809e-01, 3.9653361e-01, 3.9669910e-01, 3.9686462e-01, - 3.9703017e-01, 3.9719570e-01, 3.9736128e-01, 3.9752683e-01, - 3.9769241e-01, 3.9785799e-01, 3.9802361e-01, 3.9818922e-01, - 3.9835483e-01, 3.9852047e-01, 3.9868611e-01, 3.9885175e-01, - 3.9901742e-01, 3.9918309e-01, 3.9934877e-01, 3.9951447e-01, - 3.9968017e-01, 3.9984590e-01, 4.0001163e-01, 4.0017736e-01, - 4.0034312e-01, 4.0050888e-01, 4.0067467e-01, 4.0084043e-01, - 4.0100625e-01, 4.0117204e-01, 4.0133786e-01, 4.0150368e-01, - 4.0166953e-01, 4.0183538e-01, 4.0200126e-01, 4.0216711e-01, - 4.0233302e-01, 4.0249890e-01, 4.0266481e-01, 4.0283072e-01, - 4.0299666e-01, 4.0316260e-01, 4.0332854e-01, 4.0349451e-01, - 4.0366048e-01, 4.0382648e-01, 4.0399247e-01, 4.0415847e-01, - 4.0432447e-01, 4.0449050e-01, 4.0465656e-01, 4.0482262e-01, - 4.0498868e-01, 4.0515473e-01, 4.0532082e-01, 4.0548691e-01, - 4.0565303e-01, 4.0581915e-01, 4.0598527e-01, 4.0615141e-01, - 4.0631756e-01, 4.0648374e-01, 4.0664992e-01, 4.0681610e-01, - 4.0698227e-01, 4.0714851e-01, 4.0731472e-01, 4.0748096e-01, - 4.0764719e-01, 4.0781343e-01, 4.0797970e-01, 4.0814599e-01, - 4.0831226e-01, 4.0847856e-01, 4.0864488e-01, 4.0881118e-01, - 4.0897754e-01, 4.0914387e-01, 4.0931022e-01, 4.0947658e-01, - 4.0964296e-01, 4.0980935e-01, 4.0997577e-01, 4.1014215e-01, - 4.1030860e-01, 4.1047502e-01, 4.1064146e-01, 4.1080794e-01, - 4.1097438e-01, 4.1114089e-01, 4.1130736e-01, 4.1147387e-01, - 4.1164038e-01, 4.1180691e-01, 4.1197345e-01, 4.1213998e-01, - 4.1230655e-01, 4.1247311e-01, 4.1263971e-01, 4.1280630e-01, - 4.1297290e-01, 4.1313952e-01, 4.1330615e-01, 4.1347280e-01, - 4.1363943e-01, 4.1380611e-01, 4.1397277e-01, 4.1413945e-01, - 4.1430616e-01, 4.1447288e-01, 4.1463959e-01, 4.1480631e-01, - 4.1497305e-01, 4.1513982e-01, 4.1530660e-01, 4.1547337e-01, - 4.1564015e-01, 4.1580695e-01, 4.1597375e-01, 4.1614059e-01, - 4.1630742e-01, 4.1647428e-01, 4.1664115e-01, 4.1680801e-01, - 4.1697487e-01, 4.1714177e-01, 4.1730869e-01, 4.1747561e-01, - 4.1764253e-01, 4.1780946e-01, 4.1797641e-01, 4.1814339e-01, - 4.1831037e-01, 4.1847736e-01, 4.1864434e-01, 4.1881135e-01, - 4.1897836e-01, 4.1914541e-01, 4.1931245e-01, 4.1947952e-01, - 4.1964659e-01, 4.1981366e-01, 4.1998076e-01, 4.2014787e-01, - 4.2031497e-01, 4.2048210e-01, 4.2064923e-01, 4.2081639e-01, - 4.2098355e-01, 4.2115071e-01, 4.2131791e-01, 4.2148513e-01, - 4.2165232e-01, 4.2181954e-01, 4.2198679e-01, 4.2215401e-01, - 4.2232129e-01, 4.2248854e-01, 4.2265582e-01, 4.2282313e-01, - 4.2299041e-01, 4.2315775e-01, 4.2332506e-01, 4.2349240e-01, - 4.2365977e-01, 4.2382711e-01, 4.2399451e-01, 4.2416188e-01, - 4.2432928e-01, 4.2449671e-01, 4.2466411e-01, 4.2483154e-01, - 4.2499900e-01, 4.2516646e-01, 4.2533392e-01, 4.2550141e-01, - 4.2566890e-01, 4.2583641e-01, 4.2600393e-01, 4.2617145e-01, - 4.2633900e-01, 4.2650655e-01, 4.2667413e-01, 4.2684171e-01, - 4.2700928e-01, 4.2717689e-01, 4.2734450e-01, 4.2751214e-01, - 4.2767978e-01, 4.2784742e-01, 4.2801508e-01, 4.2818275e-01, - 4.2835045e-01, 4.2851815e-01, 4.2868584e-01, 4.2885357e-01, - 4.2902130e-01, 4.2918906e-01, 4.2935681e-01, 4.2952460e-01, - 4.2969236e-01, 4.2986017e-01, 4.3002796e-01, 4.3019578e-01, - 4.3036363e-01, 4.3053147e-01, 4.3069932e-01, 4.3086720e-01, - 4.3103507e-01, 4.3120295e-01, 4.3137085e-01, 4.3153879e-01, - 4.3170670e-01, 4.3187466e-01, 4.3204260e-01, 4.3221056e-01, - 4.3237853e-01, 4.3254653e-01, 4.3271452e-01, 4.3288255e-01, - 4.3305057e-01, 4.3321860e-01, 4.3338665e-01, 4.3355474e-01, - 4.3372279e-01, 4.3389088e-01, 4.3405899e-01, 4.3422711e-01, - 4.3439522e-01, 4.3456337e-01, 4.3473151e-01, 4.3489966e-01, - 4.3506783e-01, 4.3523604e-01, 4.3540421e-01, 4.3557245e-01, - 4.3574065e-01, 4.3590888e-01, 4.3607715e-01, 4.3624541e-01, - 4.3641368e-01, 4.3658197e-01, 4.3675026e-01, 4.3691856e-01, - 4.3708688e-01, 4.3725520e-01, 4.3742356e-01, 4.3759191e-01, - 4.3776029e-01, 4.3792868e-01, 4.3809706e-01, 4.3826547e-01, - 4.3843389e-01, 4.3860233e-01, 4.3877077e-01, 4.3893924e-01, - 4.3910772e-01, 4.3927619e-01, 4.3944469e-01, 4.3961319e-01, - 4.3978170e-01, 4.3995023e-01, 4.4011879e-01, 4.4028735e-01, - 4.4045591e-01, 4.4062451e-01, 4.4079310e-01, 4.4096169e-01, - 4.4113031e-01, 4.4129896e-01, 4.4146761e-01, 4.4163626e-01, - 4.4180492e-01, 4.4197360e-01, 4.4214231e-01, 4.4231102e-01, - 4.4247973e-01, 4.4264847e-01, 4.4281721e-01, 4.4298598e-01, - 4.4315475e-01, 4.4332352e-01, 4.4349232e-01, 4.4366112e-01, - 4.4382995e-01, 4.4399878e-01, 4.4416764e-01, 4.4433650e-01, - 4.4450536e-01, 4.4467425e-01, 4.4484314e-01, 4.4501206e-01, - 4.4518098e-01, 4.4534993e-01, 4.4551888e-01, 4.4568783e-01, - 4.4585681e-01, 4.4602579e-01, 4.4619480e-01, 4.4636381e-01, - 4.4653282e-01, 4.4670185e-01, 4.4687092e-01, 4.4703999e-01, - 4.4720906e-01, 4.4737816e-01, 4.4754726e-01, 4.4771636e-01, - 4.4788548e-01, 4.4805464e-01, 4.4822377e-01, 4.4839296e-01, - 4.4856212e-01, 4.4873130e-01, 4.4890052e-01, 4.4906974e-01, - 4.4923896e-01, 4.4940820e-01, 4.4957748e-01, 4.4974673e-01, - 4.4991601e-01, 4.5008531e-01, 4.5025462e-01, 4.5042393e-01, - 4.5059326e-01, 4.5076263e-01, 4.5093197e-01, 4.5110136e-01, - 4.5127073e-01, 4.5144013e-01, 4.5160955e-01, 4.5177898e-01, - 4.5194840e-01, 4.5211786e-01, 4.5228732e-01, 4.5245680e-01, - 4.5262629e-01, 4.5279577e-01, 4.5296529e-01, 4.5313483e-01, - 4.5330435e-01, 4.5347393e-01, 4.5364347e-01, 4.5381308e-01, - 4.5398265e-01, 4.5415226e-01, 4.5432189e-01, 4.5449153e-01, - 4.5466116e-01, 4.5483083e-01, 4.5500049e-01, 4.5517018e-01, - 4.5533988e-01, 4.5550957e-01, 4.5567930e-01, 4.5584905e-01, - 4.5601878e-01, 4.5618856e-01, 4.5635834e-01, 4.5652813e-01, - 4.5669791e-01, 4.5686772e-01, 4.5703757e-01, 4.5720741e-01, - 4.5737725e-01, 4.5754713e-01, 4.5771700e-01, 4.5788690e-01, - 4.5805681e-01, 4.5822674e-01, 4.5839667e-01, 4.5856661e-01, - 4.5873657e-01, 4.5890656e-01, 4.5907655e-01, 4.5924655e-01, - 4.5941657e-01, 4.5958659e-01, 4.5975661e-01, 4.5992669e-01, - 4.6009675e-01, 4.6026683e-01, 4.6043691e-01, 4.6060702e-01, - 4.6077716e-01, 4.6094728e-01, 4.6111742e-01, 4.6128759e-01, - 4.6145776e-01, 4.6162796e-01, 4.6179816e-01, 4.6196836e-01, - 4.6213859e-01, 4.6230882e-01, 4.6247908e-01, 4.6264935e-01, - 4.6281964e-01, 4.6298993e-01, 4.6316025e-01, 4.6333057e-01, - 4.6350089e-01, 4.6367124e-01, 4.6384162e-01, 4.6401197e-01, - 4.6418238e-01, 4.6435279e-01, 4.6452320e-01, 4.6469361e-01, - 4.6486405e-01, 4.6503451e-01, 4.6520498e-01, 4.6537545e-01, - 4.6554595e-01, 4.6571648e-01, 4.6588701e-01, 4.6605754e-01, - 4.6622810e-01, 4.6639866e-01, 4.6656922e-01, 4.6673983e-01, - 4.6691042e-01, 4.6708104e-01, 4.6725169e-01, 4.6742234e-01, - 4.6759298e-01, 4.6776366e-01, 4.6793434e-01, 4.6810505e-01, - 4.6827576e-01, 4.6844649e-01, 4.6861723e-01, 4.6878797e-01, - 4.6895874e-01, 4.6912953e-01, 4.6930033e-01, 4.6947113e-01, - 4.6964195e-01, 4.6981281e-01, 4.6998364e-01, 4.7015452e-01, - 4.7032538e-01, 4.7049630e-01, 4.7066718e-01, 4.7083810e-01, - 4.7100905e-01, 4.7117999e-01, 4.7135094e-01, 4.7152191e-01, - 4.7169292e-01, 4.7186393e-01, 4.7203493e-01, 4.7220597e-01, - 4.7237700e-01, 4.7254807e-01, 4.7271913e-01, 4.7289023e-01, - 4.7306132e-01, 4.7323242e-01, 4.7340354e-01, 4.7357470e-01, - 4.7374585e-01, 4.7391701e-01, 4.7408819e-01, 4.7425941e-01, - 4.7443059e-01, 4.7460184e-01, 4.7477308e-01, 4.7494432e-01, - 4.7511560e-01, 4.7528687e-01, 4.7545815e-01, 4.7562948e-01, - 4.7580078e-01, 4.7597212e-01, 4.7614348e-01, 4.7631484e-01, - 4.7648621e-01, 4.7665760e-01, 4.7682902e-01, 4.7700042e-01, - 4.7717187e-01, 4.7734332e-01, 4.7751477e-01, 4.7768626e-01, - 4.7785774e-01, 4.7802925e-01, 4.7820076e-01, 4.7837228e-01, - 4.7854382e-01, 4.7871539e-01, 4.7888696e-01, 4.7905856e-01, - 4.7923017e-01, 4.7940177e-01, 4.7957340e-01, 4.7974506e-01, - 4.7991669e-01, 4.8008838e-01, 4.8026007e-01, 4.8043177e-01, - 4.8060349e-01, 4.8077521e-01, 4.8094696e-01, 4.8111871e-01, - 4.8129049e-01, 4.8146227e-01, 4.8163408e-01, 4.8180589e-01, - 4.8197770e-01, 4.8214954e-01, 4.8232141e-01, 4.8249328e-01, - 4.8266518e-01, 4.8283708e-01, 4.8300898e-01, 4.8318091e-01, - 4.8335287e-01, 4.8352480e-01, 4.8369679e-01, 4.8386878e-01, - 4.8404077e-01, 4.8421279e-01, 4.8438480e-01, 4.8455685e-01, - 4.8472890e-01, 4.8490098e-01, 4.8507306e-01, 4.8524517e-01, - 4.8541728e-01, 4.8558941e-01, 4.8576155e-01, 4.8593372e-01, - 4.8610589e-01, 4.8627809e-01, 4.8645028e-01, 4.8662248e-01, - 4.8679471e-01, 4.8696697e-01, 4.8713923e-01, 4.8731151e-01, - 4.8748380e-01, 4.8765609e-01, 4.8782840e-01, 4.8800075e-01, - 4.8817310e-01, 4.8834544e-01, 4.8851782e-01, 4.8869020e-01, - 4.8886260e-01, 4.8903504e-01, 4.8920748e-01, 4.8937991e-01, - 4.8955238e-01, 4.8972484e-01, 4.8989734e-01, 4.9006984e-01, - 4.9024236e-01, 4.9041489e-01, 4.9058744e-01, 4.9076003e-01, - 4.9093258e-01, 4.9110520e-01, 4.9127778e-01, 4.9145043e-01, - 4.9162304e-01, 4.9179572e-01, 4.9196836e-01, 4.9214107e-01, - 4.9231374e-01, 4.9248648e-01, 4.9265918e-01, 4.9283192e-01, - 4.9300468e-01, 4.9317744e-01, 4.9335024e-01, 4.9352303e-01, - 4.9369586e-01, 4.9386868e-01, 4.9404153e-01, 4.9421439e-01, - 4.9438724e-01, 4.9456015e-01, 4.9473304e-01, 4.9490595e-01, - 4.9507889e-01, 4.9525183e-01, 4.9542481e-01, 4.9559778e-01, - 4.9577075e-01, 4.9594378e-01, 4.9611679e-01, 4.9628982e-01, - 4.9646288e-01, 4.9663594e-01, 4.9680904e-01, 4.9698213e-01, - 4.9715522e-01, 4.9732834e-01, 4.9750149e-01, 4.9767464e-01, - 4.9784783e-01, 4.9802101e-01, 4.9819419e-01, 4.9836743e-01, - 4.9854064e-01, 4.9871388e-01, 4.9888715e-01, 4.9906042e-01, - 4.9923372e-01, 4.9940702e-01, 4.9958032e-01, 4.9975368e-01, - 4.9992701e-01, 5.0010037e-01, 5.0027376e-01, 5.0044715e-01, - 5.0062054e-01, 5.0079399e-01, 5.0096744e-01, 5.0114089e-01, - 5.0131434e-01, 5.0148785e-01, 5.0166136e-01, 5.0183487e-01, - 5.0200838e-01, 5.0218195e-01, 5.0235552e-01, 5.0252908e-01, - 5.0270265e-01, 5.0287628e-01, 5.0304991e-01, 5.0322354e-01, - 5.0339717e-01, 5.0357085e-01, 5.0374454e-01, 5.0391823e-01, - 5.0409192e-01, 5.0426567e-01, 5.0443941e-01, 5.0461316e-01, - 5.0478691e-01, 5.0496072e-01, 5.0513452e-01, 5.0530833e-01, - 5.0548220e-01, 5.0565600e-01, 5.0582987e-01, 5.0600374e-01, - 5.0617766e-01, 5.0635159e-01, 5.0652552e-01, 5.0669944e-01, - 5.0687337e-01, 5.0704736e-01, 5.0722134e-01, 5.0739533e-01, - 5.0756937e-01, 5.0774342e-01, 5.0791746e-01, 5.0809151e-01, - 5.0826561e-01, 5.0843972e-01, 5.0861382e-01, 5.0878793e-01, - 5.0896209e-01, 5.0913620e-01, 5.0931042e-01, 5.0948459e-01, - 5.0965881e-01, 5.0983304e-01, 5.1000726e-01, 5.1018149e-01, - 5.1035577e-01, 5.1053005e-01, 5.1070434e-01, 5.1087862e-01, - 5.1105297e-01, 5.1122731e-01, 5.1140165e-01, 5.1157606e-01, - 5.1175046e-01, 5.1192486e-01, 5.1209927e-01, 5.1227367e-01, - 5.1244813e-01, 5.1262259e-01, 5.1279712e-01, 5.1297158e-01, - 5.1314610e-01, 5.1332062e-01, 5.1349521e-01, 5.1366973e-01, - 5.1384431e-01, 5.1401889e-01, 5.1419353e-01, 5.1436812e-01, - 5.1454276e-01, 5.1471746e-01, 5.1489210e-01, 5.1506680e-01, - 5.1524150e-01, 5.1541620e-01, 5.1559097e-01, 5.1576567e-01, - 5.1594043e-01, 5.1611525e-01, 5.1629001e-01, 5.1646483e-01, - 5.1663965e-01, 5.1681453e-01, 5.1698935e-01, 5.1716423e-01, - 5.1733917e-01, 5.1751405e-01, 5.1768899e-01, 5.1786393e-01, - 5.1803887e-01, 5.1821381e-01, 5.1838881e-01, 5.1856381e-01, - 5.1873887e-01, 5.1891387e-01, 5.1908892e-01, 5.1926398e-01, - 5.1943904e-01, 5.1961416e-01, 5.1978928e-01, 5.1996440e-01, - 5.2013958e-01, 5.2031469e-01, 5.2048987e-01, 5.2066511e-01, - 5.2084029e-01, 5.2101552e-01, 5.2119076e-01, 5.2136600e-01, - 5.2154130e-01, 5.2171659e-01, 5.2189189e-01, 5.2206719e-01, - 5.2224255e-01, 5.2241790e-01, 5.2259326e-01, 5.2276868e-01, - 5.2294403e-01, 5.2311945e-01, 5.2329493e-01, 5.2347034e-01, - 5.2364582e-01, 5.2382129e-01, 5.2399683e-01, 5.2417231e-01, - 5.2434784e-01, 5.2452338e-01, 5.2469897e-01, 5.2487451e-01, - 5.2505010e-01, 5.2522576e-01, 5.2540135e-01, 5.2557701e-01, - 5.2575266e-01, 5.2592838e-01, 5.2610403e-01, 5.2627975e-01, - 5.2645546e-01, 5.2663124e-01, 5.2680695e-01, 5.2698272e-01, - 5.2715856e-01, 5.2733433e-01, 5.2751017e-01, 5.2768600e-01, - 5.2786183e-01, 5.2803773e-01, 5.2821362e-01, 5.2838951e-01, - 5.2856547e-01, 5.2874136e-01, 5.2891731e-01, 5.2909333e-01, - 5.2926928e-01, 5.2944529e-01, 5.2962130e-01, 5.2979738e-01, - 5.2997339e-01, 5.3014946e-01, 5.3032553e-01, 5.3050166e-01, - 5.3067780e-01, 5.3085393e-01, 5.3103006e-01, 5.3120625e-01, - 5.3138238e-01, 5.3155863e-01, 5.3173482e-01, 5.3191108e-01, - 5.3208733e-01, 5.3226358e-01, 5.3243983e-01, 5.3261614e-01, - 5.3279245e-01, 5.3296882e-01, 5.3314513e-01, 5.3332150e-01, - 5.3349787e-01, 5.3367430e-01, 5.3385073e-01, 5.3402716e-01, - 5.3420359e-01, 5.3438008e-01, 5.3455651e-01, 5.3473306e-01, - 5.3490955e-01, 5.3508610e-01, 5.3526264e-01, 5.3543919e-01, - 5.3561580e-01, 5.3579235e-01, 5.3596902e-01, 5.3614563e-01, - 5.3632230e-01, 5.3649896e-01, 5.3667563e-01, 5.3685230e-01, - 5.3702903e-01, 5.3720576e-01, 5.3738254e-01, 5.3755927e-01, - 5.3773606e-01, 5.3791285e-01, 5.3808969e-01, 5.3826654e-01, - 5.3844339e-01, 5.3862023e-01, 5.3879714e-01, 5.3897399e-01, - 5.3915095e-01, 5.3932786e-01, 5.3950483e-01, 5.3968179e-01, - 5.3985876e-01, 5.4003578e-01, 5.4021281e-01, 5.4038984e-01, - 5.4056686e-01, 5.4074395e-01, 5.4092103e-01, 5.4109812e-01, - 5.4127526e-01, 5.4145241e-01, 5.4162955e-01, 5.4180670e-01, - 5.4198390e-01, 5.4216111e-01, 5.4233831e-01, 5.4251558e-01, - 5.4269284e-01, 5.4287010e-01, 5.4304737e-01, 5.4322469e-01, - 5.4340202e-01, 5.4357940e-01, 5.4375672e-01, 5.4393411e-01, - 5.4411149e-01, 5.4428893e-01, 5.4446632e-01, 5.4464376e-01, - 5.4482126e-01, 5.4499871e-01, 5.4517621e-01, 5.4535371e-01, - 5.4553127e-01, 5.4570884e-01, 5.4588640e-01, 5.4606396e-01, - 5.4624158e-01, 5.4641914e-01, 5.4659683e-01, 5.4677445e-01, - 5.4695213e-01, 5.4712981e-01, 5.4730749e-01, 5.4748523e-01, - 5.4766297e-01, 5.4784071e-01, 5.4801852e-01, 5.4819632e-01, - 5.4837412e-01, 5.4855192e-01, 5.4872978e-01, 5.4890764e-01, - 5.4908550e-01, 5.4926342e-01, 5.4944128e-01, 5.4961920e-01, - 5.4979718e-01, 5.4997516e-01, 5.5015314e-01, 5.5033112e-01, - 5.5050915e-01, 5.5068713e-01, 5.5086523e-01, 5.5104327e-01, - 5.5122137e-01, 5.5139947e-01, 5.5157757e-01, 5.5175573e-01, - 5.5193388e-01, 5.5211204e-01, 5.5229026e-01, 5.5246848e-01, - 5.5264670e-01, 5.5282491e-01, 5.5300319e-01, 5.5318147e-01, - 5.5335975e-01, 5.5353808e-01, 5.5371642e-01, 5.5389476e-01, - 5.5407310e-01, 5.5425149e-01, 5.5442989e-01, 5.5460835e-01, - 5.5478674e-01, 5.5496520e-01, 5.5514365e-01, 5.5532217e-01, - 5.5550069e-01, 5.5567920e-01, 5.5585772e-01, 5.5603629e-01, - 5.5621487e-01, 5.5639350e-01, 5.5657208e-01, 5.5675071e-01, - 5.5692935e-01, 5.5710804e-01, 5.5728674e-01, 5.5746543e-01, - 5.5764413e-01, 5.5782288e-01, 5.5800164e-01, 5.5818039e-01, - 5.5835921e-01, 5.5853802e-01, 5.5871683e-01, 5.5889571e-01, - 5.5907458e-01, 5.5925345e-01, 5.5943233e-01, 5.5961126e-01, - 5.5979019e-01, 5.5996913e-01, 5.6014812e-01, 5.6032711e-01, - 5.6050611e-01, 5.6068510e-01, 5.6086415e-01, 5.6104320e-01, - 5.6122231e-01, 5.6140143e-01, 5.6158054e-01, 5.6175965e-01, - 5.6193882e-01, 5.6211799e-01, 5.6229717e-01, 5.6247634e-01, - 5.6265557e-01, 5.6283480e-01, 5.6301409e-01, 5.6319338e-01, - 5.6337267e-01, 5.6355196e-01, 5.6373131e-01, 5.6391066e-01, - 5.6409001e-01, 5.6426942e-01, 5.6444883e-01, 5.6462824e-01, - 5.6480765e-01, 5.6498712e-01, 5.6516659e-01, 5.6534612e-01, - 5.6552559e-01, 5.6570512e-01, 5.6588471e-01, 5.6606424e-01, - 5.6624383e-01, 5.6642348e-01, 5.6660306e-01, 5.6678271e-01, - 5.6696236e-01, 5.6714207e-01, 5.6732172e-01, 5.6750149e-01, - 5.6768119e-01, 5.6786096e-01, 5.6804073e-01, 5.6822050e-01, - 5.6840032e-01, 5.6858015e-01, 5.6875998e-01, 5.6893981e-01, - 5.6911969e-01, 5.6929958e-01, 5.6947953e-01, 5.6965947e-01, - 5.6983942e-01, 5.7001936e-01, 5.7019937e-01, 5.7037938e-01, - 5.7055938e-01, 5.7073945e-01, 5.7091951e-01, 5.7109958e-01, - 5.7127970e-01, 5.7145983e-01, 5.7163996e-01, 5.7182014e-01, - 5.7200027e-01, 5.7218051e-01, 5.7236069e-01, 5.7254094e-01, - 5.7272118e-01, 5.7290143e-01, 5.7308173e-01, 5.7326204e-01, - 5.7344234e-01, 5.7362270e-01, 5.7380307e-01, 5.7398343e-01, - 5.7416385e-01, 5.7434428e-01, 5.7452470e-01, 5.7470512e-01, - 5.7488561e-01, 5.7506609e-01, 5.7524663e-01, 5.7542717e-01, - 5.7560772e-01, 5.7578826e-01, 5.7596886e-01, 5.7614946e-01, - 5.7633007e-01, 5.7651073e-01, 5.7669139e-01, 5.7687205e-01, - 5.7705277e-01, 5.7723349e-01, 5.7741421e-01, 5.7759500e-01, - 5.7777578e-01, 5.7795656e-01, 5.7813734e-01, 5.7831818e-01, - 5.7849902e-01, 5.7867992e-01, 5.7886082e-01, 5.7904172e-01, - 5.7922262e-01, 5.7940358e-01, 5.7958454e-01, 5.7976550e-01, - 5.7994652e-01, 5.8012754e-01, 5.8030856e-01, 5.8048964e-01, - 5.8067071e-01, 5.8085179e-01, 5.8103293e-01, 5.8121407e-01, - 5.8139521e-01, 5.8157641e-01, 5.8175761e-01, 5.8193880e-01, - 5.8212000e-01, 5.8230126e-01, 5.8248252e-01, 5.8266383e-01, - 5.8284515e-01, 5.8302647e-01, 5.8320779e-01, 5.8338916e-01, - 5.8357054e-01, 5.8375198e-01, 5.8393335e-01, 5.8411479e-01, - 5.8429629e-01, 5.8447778e-01, 5.8465928e-01, 5.8484077e-01, - 5.8502233e-01, 5.8520389e-01, 5.8538544e-01, 5.8556706e-01, - 5.8574867e-01, 5.8593029e-01, 5.8611196e-01, 5.8629364e-01, - 5.8647531e-01, 5.8665699e-01, 5.8683872e-01, 5.8702052e-01, - 5.8720225e-01, 5.8738405e-01, 5.8756584e-01, 5.8774769e-01, - 5.8792955e-01, 5.8811140e-01, 5.8829331e-01, 5.8847517e-01, - 5.8865714e-01, 5.8883905e-01, 5.8902103e-01, 5.8920300e-01, - 5.8938503e-01, 5.8956701e-01, 5.8974910e-01, 5.8993113e-01, - 5.9011322e-01, 5.9029531e-01, 5.9047747e-01, 5.9065956e-01, - 5.9084171e-01, 5.9102392e-01, 5.9120613e-01, 5.9138834e-01, - 5.9157056e-01, 5.9175283e-01, 5.9193510e-01, 5.9211743e-01, - 5.9229970e-01, 5.9248203e-01, 5.9266442e-01, 5.9284681e-01, - 5.9302920e-01, 5.9321159e-01, 5.9339404e-01, 5.9357649e-01, - 5.9375894e-01, 5.9394145e-01, 5.9412396e-01, 5.9430653e-01, - 5.9448904e-01, 5.9467161e-01, 5.9485424e-01, 5.9503686e-01, - 5.9521949e-01, 5.9540212e-01, 5.9558481e-01, 5.9576750e-01, - 5.9595019e-01, 5.9613293e-01, 5.9631568e-01, 5.9649843e-01, - 5.9668124e-01, 5.9686404e-01, 5.9704691e-01, 5.9722972e-01, - 5.9741259e-01, 5.9759551e-01, 5.9777844e-01, 5.9796137e-01, - 5.9814429e-01, 5.9832728e-01, 5.9851027e-01, 5.9869325e-01, - 5.9887630e-01, 5.9905934e-01, 5.9924245e-01, 5.9942549e-01, - 5.9960866e-01, 5.9979177e-01, 5.9997493e-01, 6.0015810e-01, - 6.0034126e-01, 6.0052449e-01, 6.0070771e-01, 6.0089099e-01, - 6.0107428e-01, 6.0125756e-01, 6.0144085e-01, 6.0162419e-01, - 6.0180753e-01, 6.0199094e-01, 6.0217434e-01, 6.0235775e-01, - 6.0254115e-01, 6.0272461e-01, 6.0290807e-01, 6.0309160e-01, - 6.0327512e-01, 6.0345864e-01, 6.0364223e-01, 6.0382581e-01, - 6.0400939e-01, 6.0419297e-01, 6.0437661e-01, 6.0456032e-01, - 6.0474396e-01, 6.0492766e-01, 6.0511142e-01, 6.0529512e-01, - 6.0547888e-01, 6.0566270e-01, 6.0584646e-01, 6.0603029e-01, - 6.0621417e-01, 6.0639799e-01, 6.0658187e-01, 6.0676581e-01, - 6.0694975e-01, 6.0713369e-01, 6.0731763e-01, 6.0750163e-01, - 6.0768563e-01, 6.0786963e-01, 6.0805368e-01, 6.0823774e-01, - 6.0842186e-01, 6.0860598e-01, 6.0879010e-01, 6.0897428e-01, - 6.0915840e-01, 6.0934263e-01, 6.0952681e-01, 6.0971105e-01, - 6.0989529e-01, 6.1007959e-01, 6.1026388e-01, 6.1044818e-01, - 6.1063254e-01, 6.1081690e-01, 6.1100125e-01, 6.1118567e-01, - 6.1137009e-01, 6.1155456e-01, 6.1173898e-01, 6.1192352e-01, - 6.1210799e-01, 6.1229253e-01, 6.1247706e-01, 6.1266160e-01, - 6.1284620e-01, 6.1303085e-01, 6.1321545e-01, 6.1340010e-01, - 6.1358476e-01, 6.1376947e-01, 6.1395419e-01, 6.1413890e-01, - 6.1432368e-01, 6.1450845e-01, 6.1469322e-01, 6.1487806e-01, - 6.1506289e-01, 6.1524773e-01, 6.1543262e-01, 6.1561751e-01, - 6.1580247e-01, 6.1598742e-01, 6.1617237e-01, 6.1635733e-01, - 6.1654234e-01, 6.1672741e-01, 6.1691242e-01, 6.1709750e-01, - 6.1728263e-01, 6.1746770e-01, 6.1765283e-01, 6.1783803e-01, - 6.1802316e-01, 6.1820835e-01, 6.1839360e-01, 6.1857885e-01, - 6.1876410e-01, 6.1894935e-01, 6.1913466e-01, 6.1931998e-01, - 6.1950535e-01, 6.1969072e-01, 6.1987609e-01, 6.2006152e-01, - 6.2024695e-01, 6.2043238e-01, 6.2061787e-01, 6.2080336e-01, - 6.2098891e-01, 6.2117440e-01, 6.2136000e-01, 6.2154555e-01, - 6.2173116e-01, 6.2191677e-01, 6.2210244e-01, 6.2228811e-01, - 6.2247378e-01, 6.2265950e-01, 6.2284523e-01, 6.2303096e-01, - 6.2321675e-01, 6.2340254e-01, 6.2358838e-01, 6.2377423e-01, - 6.2396008e-01, 6.2414593e-01, 6.2433183e-01, 6.2451780e-01, - 6.2470371e-01, 6.2488967e-01, 6.2507570e-01, 6.2526166e-01, - 6.2544775e-01, 6.2563378e-01, 6.2581986e-01, 6.2600595e-01, - 6.2619209e-01, 6.2637824e-01, 6.2656438e-01, 6.2675059e-01, - 6.2693679e-01, 6.2712300e-01, 6.2730926e-01, 6.2749553e-01, - 6.2768179e-01, 6.2786812e-01, 6.2805444e-01, 6.2824082e-01, - 6.2842721e-01, 6.2861359e-01, 6.2880003e-01, 6.2898648e-01, - 6.2917292e-01, 6.2935942e-01, 6.2954593e-01, 6.2973249e-01, - 6.2991905e-01, 6.3010561e-01, 6.3029224e-01, 6.3047886e-01, - 6.3066548e-01, 6.3085216e-01, 6.3103884e-01, 6.3122553e-01, - 6.3141227e-01, 6.3159901e-01, 6.3178581e-01, 6.3197261e-01, - 6.3215941e-01, 6.3234627e-01, 6.3253313e-01, 6.3271999e-01, - 6.3290691e-01, 6.3309383e-01, 6.3328081e-01, 6.3346779e-01, - 6.3365477e-01, 6.3384175e-01, 6.3402879e-01, 6.3421589e-01, - 6.3440299e-01, 6.3459009e-01, 6.3477719e-01, 6.3496435e-01, - 6.3515151e-01, 6.3533872e-01, 6.3552594e-01, 6.3571316e-01, - 6.3590044e-01, 6.3608772e-01, 6.3627505e-01, 6.3646239e-01, - 6.3664973e-01, 6.3683712e-01, 6.3702452e-01, 6.3721192e-01, - 6.3739938e-01, 6.3758683e-01, 6.3777429e-01, 6.3796180e-01, - 6.3814932e-01, 6.3833690e-01, 6.3852447e-01, 6.3871205e-01, - 6.3889968e-01, 6.3908732e-01, 6.3927501e-01, 6.3946271e-01, - 6.3965040e-01, 6.3983816e-01, 6.4002591e-01, 6.4021367e-01, - 6.4040148e-01, 6.4058930e-01, 6.4077717e-01, 6.4096504e-01, - 6.4115292e-01, 6.4134085e-01, 6.4152879e-01, 6.4171672e-01, - 6.4190471e-01, 6.4209270e-01, 6.4228076e-01, 6.4246881e-01, - 6.4265686e-01, 6.4284497e-01, 6.4303309e-01, 6.4322120e-01, - 6.4340937e-01, 6.4359754e-01, 6.4378577e-01, 6.4397401e-01, - 6.4416224e-01, 6.4435053e-01, 6.4453882e-01, 6.4472717e-01, - 6.4491552e-01, 6.4510387e-01, 6.4529228e-01, 6.4548069e-01, - 6.4566916e-01, 6.4585757e-01, 6.4604610e-01, 6.4623457e-01, - 6.4642310e-01, 6.4661169e-01, 6.4680022e-01, 6.4698887e-01, - 6.4717746e-01, 6.4736611e-01, 6.4755476e-01, 6.4774346e-01, - 6.4793217e-01, 6.4812094e-01, 6.4830971e-01, 6.4849848e-01, - 6.4868730e-01, 6.4887613e-01, 6.4906496e-01, 6.4925385e-01, - 6.4944273e-01, 6.4963168e-01, 6.4982063e-01, 6.5000957e-01, - 6.5019858e-01, 6.5038759e-01, 6.5057659e-01, 6.5076566e-01, - 6.5095478e-01, 6.5114385e-01, 6.5133303e-01, 6.5152216e-01, - 6.5171134e-01, 6.5190053e-01, 6.5208977e-01, 6.5227902e-01, - 6.5246826e-01, 6.5265757e-01, 6.5284693e-01, 6.5303624e-01, - 6.5322560e-01, 6.5341502e-01, 6.5360439e-01, 6.5379387e-01, - 6.5398329e-01, 6.5417278e-01, 6.5436232e-01, 6.5455180e-01, - 6.5474141e-01, 6.5493095e-01, 6.5512055e-01, 6.5531015e-01, - 6.5549982e-01, 6.5568948e-01, 6.5587920e-01, 6.5606892e-01, - 6.5625864e-01, 6.5644842e-01, 6.5663821e-01, 6.5682805e-01, - 6.5701783e-01, 6.5720773e-01, 6.5739763e-01, 6.5758753e-01, - 6.5777743e-01, 6.5796739e-01, 6.5815735e-01, 6.5834737e-01, - 6.5853739e-01, 6.5872747e-01, 6.5891755e-01, 6.5910763e-01, - 6.5929776e-01, 6.5948790e-01, 6.5967804e-01, 6.5986824e-01, - 6.6005844e-01, 6.6024870e-01, 6.6043895e-01, 6.6062927e-01, - 6.6081959e-01, 6.6100991e-01, 6.6120028e-01, 6.6139066e-01, - 6.6158104e-01, 6.6177148e-01, 6.6196197e-01, 6.6215241e-01, - 6.6234291e-01, 6.6253346e-01, 6.6272402e-01, 6.6291457e-01, - 6.6310519e-01, 6.6329581e-01, 6.6348648e-01, 6.6367716e-01, - 6.6386783e-01, 6.6405857e-01, 6.6424930e-01, 6.6444010e-01, - 6.6463089e-01, 6.6482168e-01, 6.6501254e-01, 6.6520339e-01, - 6.6539431e-01, 6.6558522e-01, 6.6577613e-01, 6.6596711e-01, - 6.6615808e-01, 6.6634911e-01, 6.6654015e-01, 6.6673118e-01, - 6.6692227e-01, 6.6711336e-01, 6.6730452e-01, 6.6749567e-01, - 6.6768688e-01, 6.6787809e-01, 6.6806930e-01, 6.6826057e-01, - 6.6845185e-01, 6.6864312e-01, 6.6883445e-01, 6.6902584e-01, - 6.6921723e-01, 6.6940862e-01, 6.6960001e-01, 6.6979146e-01, - 6.6998297e-01, 6.7017448e-01, 6.7036599e-01, 6.7055756e-01, - 6.7074913e-01, 6.7094070e-01, 6.7113233e-01, 6.7132396e-01, - 6.7151564e-01, 6.7170733e-01, 6.7189908e-01, 6.7209083e-01, - 6.7228258e-01, 6.7247438e-01, 6.7266619e-01, 6.7285806e-01, - 6.7304993e-01, 6.7324179e-01, 6.7343372e-01, 6.7362571e-01, - 6.7381763e-01, 6.7400968e-01, 6.7420167e-01, 6.7439371e-01, - 6.7458576e-01, 6.7477787e-01, 6.7496997e-01, 6.7516214e-01, - 6.7535430e-01, 6.7554653e-01, 6.7573875e-01, 6.7593098e-01, - 6.7612326e-01, 6.7631555e-01, 6.7650783e-01, 6.7670017e-01, - 6.7689258e-01, 6.7708498e-01, 6.7727739e-01, 6.7746985e-01, - 6.7766231e-01, 6.7785478e-01, 6.7804730e-01, 6.7823982e-01, - 6.7843240e-01, 6.7862499e-01, 6.7881763e-01, 6.7901027e-01, - 6.7920297e-01, 6.7939562e-01, 6.7958838e-01, 6.7978114e-01, - 6.7997390e-01, 6.8016666e-01, 6.8035948e-01, 6.8055236e-01, - 6.8074524e-01, 6.8093812e-01, 6.8113106e-01, 6.8132401e-01, - 6.8151695e-01, 6.8170995e-01, 6.8190300e-01, 6.8209606e-01, - 6.8228912e-01, 6.8248224e-01, 6.8267536e-01, 6.8286848e-01, - 6.8306166e-01, 6.8325490e-01, 6.8344808e-01, 6.8364137e-01, - 6.8383461e-01, 6.8402797e-01, 6.8422127e-01, 6.8441463e-01, - 6.8460798e-01, 6.8480140e-01, 6.8499488e-01, 6.8518829e-01, - 6.8538177e-01, 6.8557531e-01, 6.8576884e-01, 6.8596238e-01, - 6.8615597e-01, 6.8634963e-01, 6.8654323e-01, 6.8673688e-01, - 6.8693060e-01, 6.8712431e-01, 6.8731803e-01, 6.8751180e-01, - 6.8770564e-01, 6.8789941e-01, 6.8809330e-01, 6.8828714e-01, - 6.8848103e-01, 6.8867499e-01, 6.8886894e-01, 6.8906289e-01, - 6.8925691e-01, 6.8945092e-01, 6.8964499e-01, 6.8983907e-01, - 6.9003314e-01, 6.9022727e-01, 6.9042146e-01, 6.9061559e-01, - 6.9080985e-01, 6.9100404e-01, 6.9119835e-01, 6.9139260e-01, - 6.9158691e-01, 6.9178128e-01, 6.9197559e-01, 6.9217002e-01, - 6.9236445e-01, 6.9255888e-01, 6.9275331e-01, 6.9294786e-01, - 6.9314235e-01, 6.9333690e-01, 6.9353145e-01, 6.9372606e-01, - 6.9392073e-01, 6.9411534e-01, 6.9431007e-01, 6.9450474e-01, - 6.9469947e-01, 6.9489425e-01, 6.9508904e-01, 6.9528383e-01, - 6.9547868e-01, 6.9567353e-01, 6.9586843e-01, 6.9606334e-01, - 6.9625831e-01, 6.9645327e-01, 6.9664824e-01, 6.9684327e-01, - 6.9703835e-01, 6.9723338e-01, 6.9742852e-01, 6.9762361e-01, - 6.9781876e-01, 6.9801396e-01, 6.9820917e-01, 6.9840443e-01, - 6.9859970e-01, 6.9879496e-01, 6.9899029e-01, 6.9918561e-01, - 6.9938099e-01, 6.9957638e-01, 6.9977182e-01, 6.9996727e-01, - 7.0016271e-01, 7.0035821e-01, 7.0055377e-01, 7.0074934e-01, - 7.0094490e-01, 7.0114052e-01, 7.0133615e-01, 7.0153183e-01, - 7.0172751e-01, 7.0192319e-01, 7.0211893e-01, 7.0231473e-01, - 7.0251054e-01, 7.0270634e-01, 7.0290220e-01, 7.0309806e-01, - 7.0329398e-01, 7.0348990e-01, 7.0368588e-01, 7.0388186e-01, - 7.0407790e-01, 7.0427394e-01, 7.0446998e-01, 7.0466608e-01, - 7.0486218e-01, 7.0505834e-01, 7.0525450e-01, 7.0545071e-01, - 7.0564693e-01, 7.0584321e-01, 7.0603949e-01, 7.0623583e-01, - 7.0643216e-01, 7.0662850e-01, 7.0682490e-01, 7.0702136e-01, - 7.0721775e-01, 7.0741427e-01, 7.0761073e-01, 7.0780730e-01, - 7.0800382e-01, 7.0820040e-01, 7.0839703e-01, 7.0859367e-01, - 7.0879036e-01, 7.0898706e-01, 7.0918375e-01, 7.0938051e-01, - 7.0957726e-01, 7.0977408e-01, 7.0997089e-01, 7.1016777e-01, - 7.1036464e-01, 7.1056157e-01, 7.1075851e-01, 7.1095550e-01, - 7.1115249e-01, 7.1134949e-01, 7.1154654e-01, 7.1174365e-01, - 7.1194077e-01, 7.1213788e-01, 7.1233505e-01, 7.1253222e-01, - 7.1272945e-01, 7.1292669e-01, 7.1312398e-01, 7.1332127e-01, - 7.1351862e-01, 7.1371597e-01, 7.1391332e-01, 7.1411073e-01, - 7.1430820e-01, 7.1450567e-01, 7.1470314e-01, 7.1490067e-01, - 7.1509826e-01, 7.1529579e-01, 7.1549344e-01, 7.1569109e-01, - 7.1588874e-01, 7.1608639e-01, 7.1628416e-01, 7.1648186e-01, - 7.1667963e-01, 7.1687746e-01, 7.1707529e-01, 7.1727318e-01, - 7.1747106e-01, 7.1766895e-01, 7.1786690e-01, 7.1806484e-01, - 7.1826285e-01, 7.1846092e-01, 7.1865898e-01, 7.1885705e-01, - 7.1905518e-01, 7.1925330e-01, 7.1945149e-01, 7.1964967e-01, - 7.1984792e-01, 7.2004616e-01, 7.2024441e-01, 7.2044271e-01, - 7.2064108e-01, 7.2083944e-01, 7.2103786e-01, 7.2123629e-01, - 7.2143471e-01, 7.2163320e-01, 7.2183174e-01, 7.2203022e-01, - 7.2222883e-01, 7.2242743e-01, 7.2262603e-01, 7.2282469e-01, - 7.2302336e-01, 7.2322208e-01, 7.2342080e-01, 7.2361958e-01, - 7.2381836e-01, 7.2401720e-01, 7.2421604e-01, 7.2441494e-01, - 7.2461385e-01, 7.2481281e-01, 7.2501177e-01, 7.2521073e-01, - 7.2540975e-01, 7.2560883e-01, 7.2580791e-01, 7.2600698e-01, - 7.2620612e-01, 7.2640532e-01, 7.2660452e-01, 7.2680372e-01, - 7.2700298e-01, 7.2720230e-01, 7.2740161e-01, 7.2760093e-01, - 7.2780031e-01, 7.2799969e-01, 7.2819912e-01, 7.2839856e-01, - 7.2859806e-01, 7.2879755e-01, 7.2899711e-01, 7.2919673e-01, - 7.2939628e-01, 7.2959596e-01, 7.2979558e-01, 7.2999531e-01, - 7.3019499e-01, 7.3039472e-01, 7.3059452e-01, 7.3079431e-01, - 7.3099416e-01, 7.3119402e-01, 7.3139393e-01, 7.3159385e-01, - 7.3179382e-01, 7.3199379e-01, 7.3219377e-01, 7.3239380e-01, - 7.3259389e-01, 7.3279399e-01, 7.3299414e-01, 7.3319429e-01, - 7.3339444e-01, 7.3359466e-01, 7.3379493e-01, 7.3399520e-01, - 7.3419553e-01, 7.3439586e-01, 7.3459619e-01, 7.3479658e-01, - 7.3499703e-01, 7.3519748e-01, 7.3539793e-01, 7.3559844e-01, - 7.3579901e-01, 7.3599958e-01, 7.3620015e-01, 7.3640078e-01, - 7.3660147e-01, 7.3680216e-01, 7.3700285e-01, 7.3720360e-01, - 7.3740441e-01, 7.3760521e-01, 7.3780602e-01, 7.3800689e-01, - 7.3820782e-01, 7.3840874e-01, 7.3860967e-01, 7.3881066e-01, - 7.3901170e-01, 7.3921275e-01, 7.3941380e-01, 7.3961490e-01, - 7.3981607e-01, 7.4001724e-01, 7.4021840e-01, 7.4041963e-01, - 7.4062091e-01, 7.4082220e-01, 7.4102348e-01, 7.4122483e-01, - 7.4142623e-01, 7.4162763e-01, 7.4182904e-01, 7.4203050e-01, - 7.4223202e-01, 7.4243355e-01, 7.4263507e-01, 7.4283665e-01, - 7.4303830e-01, 7.4323994e-01, 7.4344164e-01, 7.4364334e-01, - 7.4384505e-01, 7.4404681e-01, 7.4424863e-01, 7.4445045e-01, - 7.4465233e-01, 7.4485421e-01, 7.4505609e-01, 7.4525809e-01, - 7.4546003e-01, 7.4566203e-01, 7.4586409e-01, 7.4606615e-01, - 7.4626827e-01, 7.4647039e-01, 7.4667257e-01, 7.4687475e-01, - 7.4707699e-01, 7.4727923e-01, 7.4748152e-01, 7.4768382e-01, - 7.4788618e-01, 7.4808854e-01, 7.4829096e-01, 7.4849343e-01, - 7.4869585e-01, 7.4889839e-01, 7.4910092e-01, 7.4930346e-01, - 7.4950606e-01, 7.4970865e-01, 7.4991131e-01, 7.5011402e-01, - 7.5031674e-01, 7.5051945e-01, 7.5072223e-01, 7.5092506e-01, - 7.5112790e-01, 7.5133079e-01, 7.5153369e-01, 7.5173658e-01, - 7.5193954e-01, 7.5214255e-01, 7.5234556e-01, 7.5254864e-01, - 7.5275171e-01, 7.5295484e-01, 7.5315797e-01, 7.5336117e-01, - 7.5356436e-01, 7.5376761e-01, 7.5397086e-01, 7.5417417e-01, - 7.5437754e-01, 7.5458091e-01, 7.5478429e-01, 7.5498772e-01, - 7.5519121e-01, 7.5539470e-01, 7.5559819e-01, 7.5580174e-01, - 7.5600535e-01, 7.5620896e-01, 7.5641263e-01, 7.5661629e-01, - 7.5681996e-01, 7.5702375e-01, 7.5722748e-01, 7.5743133e-01, - 7.5763512e-01, 7.5783902e-01, 7.5804293e-01, 7.5824684e-01, - 7.5845081e-01, 7.5865477e-01, 7.5885880e-01, 7.5906289e-01, - 7.5926697e-01, 7.5947106e-01, 7.5967526e-01, 7.5987941e-01, - 7.6008362e-01, 7.6028788e-01, 7.6049215e-01, 7.6069647e-01, - 7.6090080e-01, 7.6110518e-01, 7.6130962e-01, 7.6151401e-01, - 7.6171851e-01, 7.6192302e-01, 7.6212752e-01, 7.6233208e-01, - 7.6253670e-01, 7.6274133e-01, 7.6294601e-01, 7.6315069e-01, - 7.6335543e-01, 7.6356018e-01, 7.6376498e-01, 7.6396978e-01, - 7.6417464e-01, 7.6437950e-01, 7.6458442e-01, 7.6478940e-01, - 7.6499438e-01, 7.6519936e-01, 7.6540440e-01, 7.6560950e-01, - 7.6581460e-01, 7.6601976e-01, 7.6622492e-01, 7.6643014e-01, - 7.6663536e-01, 7.6684064e-01, 7.6704592e-01, 7.6725125e-01, - 7.6745665e-01, 7.6766205e-01, 7.6786751e-01, 7.6807296e-01, - 7.6827842e-01, 7.6848400e-01, 7.6868951e-01, 7.6889515e-01, - 7.6910079e-01, 7.6930642e-01, 7.6951212e-01, 7.6971781e-01, - 7.6992357e-01, 7.7012938e-01, 7.7033520e-01, 7.7054107e-01, - 7.7074695e-01, 7.7095288e-01, 7.7115881e-01, 7.7136481e-01, - 7.7157086e-01, 7.7177691e-01, 7.7198297e-01, 7.7218908e-01, - 7.7239525e-01, 7.7260143e-01, 7.7280766e-01, 7.7301389e-01, - 7.7322018e-01, 7.7342647e-01, 7.7363282e-01, 7.7383924e-01, - 7.7404565e-01, 7.7425206e-01, 7.7445853e-01, 7.7466506e-01, - 7.7487159e-01, 7.7507818e-01, 7.7528483e-01, 7.7549142e-01, - 7.7569813e-01, 7.7590483e-01, 7.7611160e-01, 7.7631837e-01, - 7.7652514e-01, 7.7673203e-01, 7.7693892e-01, 7.7714580e-01, - 7.7735275e-01, 7.7755970e-01, 7.7776670e-01, 7.7797377e-01, - 7.7818084e-01, 7.7838796e-01, 7.7859509e-01, 7.7880228e-01, - 7.7900952e-01, 7.7921671e-01, 7.7942401e-01, 7.7963132e-01, - 7.7983868e-01, 7.8004605e-01, 7.8025347e-01, 7.8046089e-01, - 7.8066838e-01, 7.8087592e-01, 7.8108346e-01, 7.8129101e-01, - 7.8149861e-01, 7.8170627e-01, 7.8191394e-01, 7.8212166e-01, - 7.8232944e-01, 7.8253722e-01, 7.8274500e-01, 7.8295285e-01, - 7.8316075e-01, 7.8336865e-01, 7.8357661e-01, 7.8378463e-01, - 7.8399265e-01, 7.8420067e-01, 7.8440875e-01, 7.8461689e-01, - 7.8482503e-01, 7.8503323e-01, 7.8524148e-01, 7.8544968e-01, - 7.8565800e-01, 7.8586632e-01, 7.8607470e-01, 7.8628308e-01, - 7.8649151e-01, 7.8669995e-01, 7.8690845e-01, 7.8711700e-01, - 7.8732556e-01, 7.8753418e-01, 7.8774279e-01, 7.8795147e-01, - 7.8816015e-01, 7.8836888e-01, 7.8857768e-01, 7.8878647e-01, - 7.8899533e-01, 7.8920418e-01, 7.8941309e-01, 7.8962201e-01, - 7.8983098e-01, 7.9004002e-01, 7.9024905e-01, 7.9045814e-01, - 7.9066724e-01, 7.9087639e-01, 7.9108560e-01, 7.9129481e-01, - 7.9150409e-01, 7.9171336e-01, 7.9192269e-01, 7.9213202e-01, - 7.9234141e-01, 7.9255086e-01, 7.9276031e-01, 7.9296982e-01, - 7.9317933e-01, 7.9338890e-01, 7.9359853e-01, 7.9380816e-01, - 7.9401779e-01, 7.9422754e-01, 7.9443729e-01, 7.9464704e-01, - 7.9485685e-01, 7.9506671e-01, 7.9527658e-01, 7.9548651e-01, - 7.9569644e-01, 7.9590642e-01, 7.9611647e-01, 7.9632652e-01, - 7.9653656e-01, 7.9674673e-01, 7.9695690e-01, 7.9716706e-01, - 7.9737729e-01, 7.9758757e-01, 7.9779786e-01, 7.9800820e-01, - 7.9821861e-01, 7.9842901e-01, 7.9863942e-01, 7.9884994e-01, - 7.9906040e-01, 7.9927099e-01, 7.9948157e-01, 7.9969221e-01, - 7.9990286e-01, 8.0011356e-01, 8.0032426e-01, 8.0053502e-01, - 8.0074584e-01, 8.0095667e-01, 8.0116755e-01, 8.0137843e-01, - 8.0158937e-01, 8.0180037e-01, 8.0201137e-01, 8.0222243e-01, - 8.0243349e-01, 8.0264461e-01, 8.0285579e-01, 8.0306697e-01, - 8.0327821e-01, 8.0348945e-01, 8.0370075e-01, 8.0391210e-01, - 8.0412346e-01, 8.0433488e-01, 8.0454630e-01, 8.0475777e-01, - 8.0496931e-01, 8.0518085e-01, 8.0539244e-01, 8.0560404e-01, - 8.0581570e-01, 8.0602741e-01, 8.0623913e-01, 8.0645090e-01, - 8.0666268e-01, 8.0687451e-01, 8.0708641e-01, 8.0729830e-01, - 8.0751026e-01, 8.0772227e-01, 8.0793428e-01, 8.0814636e-01, - 8.0835843e-01, 8.0857056e-01, 8.0878270e-01, 8.0899495e-01, - 8.0920714e-01, 8.0941945e-01, 8.0963176e-01, 8.0984408e-01, - 8.1005645e-01, 8.1026888e-01, 8.1048137e-01, 8.1069386e-01, - 8.1090641e-01, 8.1111896e-01, 8.1133157e-01, 8.1154418e-01, - 8.1175685e-01, 8.1196958e-01, 8.1218231e-01, 8.1239510e-01, - 8.1260794e-01, 8.1282079e-01, 8.1303370e-01, 8.1324667e-01, - 8.1345963e-01, 8.1367260e-01, 8.1388569e-01, 8.1409878e-01, - 8.1431186e-01, 8.1452501e-01, 8.1473821e-01, 8.1495148e-01, - 8.1516474e-01, 8.1537801e-01, 8.1559139e-01, 8.1580472e-01, - 8.1601816e-01, 8.1623161e-01, 8.1644511e-01, 8.1665862e-01, - 8.1687218e-01, 8.1708580e-01, 8.1729943e-01, 8.1751311e-01, - 8.1772685e-01, 8.1794059e-01, 8.1815439e-01, 8.1836820e-01, - 8.1858206e-01, 8.1879598e-01, 8.1900990e-01, 8.1922388e-01, - 8.1943792e-01, 8.1965196e-01, 8.1986606e-01, 8.2008016e-01, - 8.2029432e-01, 8.2050854e-01, 8.2072276e-01, 8.2093704e-01, - 8.2115138e-01, 8.2136571e-01, 8.2158011e-01, 8.2179451e-01, - 8.2200897e-01, 8.2222348e-01, 8.2243806e-01, 8.2265264e-01, - 8.2286721e-01, 8.2308191e-01, 8.2329661e-01, 8.2351130e-01, - 8.2372606e-01, 8.2394087e-01, 8.2415575e-01, 8.2437062e-01, - 8.2458556e-01, 8.2480049e-01, 8.2501549e-01, 8.2523054e-01, - 8.2544559e-01, 8.2566071e-01, 8.2587588e-01, 8.2609105e-01, - 8.2630628e-01, 8.2652152e-01, 8.2673687e-01, 8.2695216e-01, - 8.2716757e-01, 8.2738298e-01, 8.2759845e-01, 8.2781392e-01, - 8.2802945e-01, 8.2824504e-01, 8.2846063e-01, 8.2867628e-01, - 8.2889199e-01, 8.2910770e-01, 8.2932347e-01, 8.2953930e-01, - 8.2975513e-01, 8.2997102e-01, 8.3018690e-01, 8.3040285e-01, - 8.3061886e-01, 8.3083493e-01, 8.3105099e-01, 8.3126712e-01, - 8.3148324e-01, 8.3169943e-01, 8.3191568e-01, 8.3213192e-01, - 8.3234823e-01, 8.3256459e-01, 8.3278096e-01, 8.3299738e-01, - 8.3321387e-01, 8.3343035e-01, 8.3364689e-01, 8.3386350e-01, - 8.3408010e-01, 8.3429676e-01, 8.3451349e-01, 8.3473021e-01, - 8.3494699e-01, 8.3516377e-01, 8.3538067e-01, 8.3559757e-01, - 8.3581448e-01, 8.3603144e-01, 8.3624846e-01, 8.3646554e-01, - 8.3668262e-01, 8.3689976e-01, 8.3711690e-01, 8.3733410e-01, - 8.3755136e-01, 8.3776867e-01, 8.3798599e-01, 8.3820337e-01, - 8.3842075e-01, 8.3863819e-01, 8.3885568e-01, 8.3907324e-01, - 8.3929080e-01, 8.3950841e-01, 8.3972603e-01, 8.3994371e-01, - 8.4016144e-01, 8.4037918e-01, 8.4059703e-01, 8.4081483e-01, - 8.4103274e-01, 8.4125066e-01, 8.4146863e-01, 8.4168661e-01, - 8.4190470e-01, 8.4212279e-01, 8.4234089e-01, 8.4255904e-01, - 8.4277725e-01, 8.4299552e-01, 8.4321380e-01, 8.4343213e-01, - 8.4365046e-01, 8.4386891e-01, 8.4408730e-01, 8.4430581e-01, - 8.4452432e-01, 8.4474289e-01, 8.4496152e-01, 8.4518015e-01, - 8.4539884e-01, 8.4561759e-01, 8.4583634e-01, 8.4605515e-01, - 8.4627402e-01, 8.4649289e-01, 8.4671181e-01, 8.4693080e-01, - 8.4714979e-01, 8.4736884e-01, 8.4758794e-01, 8.4780711e-01, - 8.4802628e-01, 8.4824550e-01, 8.4846473e-01, 8.4868401e-01, - 8.4890336e-01, 8.4912276e-01, 8.4934217e-01, 8.4956163e-01, - 8.4978116e-01, 8.5000068e-01, 8.5022026e-01, 8.5043991e-01, - 8.5065955e-01, 8.5087925e-01, 8.5109901e-01, 8.5131878e-01, - 8.5153860e-01, 8.5175848e-01, 8.5197842e-01, 8.5219836e-01, - 8.5241836e-01, 8.5263836e-01, 8.5285848e-01, 8.5307860e-01, - 8.5329872e-01, 8.5351896e-01, 8.5373920e-01, 8.5395950e-01, - 8.5417980e-01, 8.5440016e-01, 8.5462058e-01, 8.5484105e-01, - 8.5506153e-01, 8.5528207e-01, 8.5550261e-01, 8.5572326e-01, - 8.5594392e-01, 8.5616457e-01, 8.5638535e-01, 8.5660613e-01, - 8.5682696e-01, 8.5704780e-01, 8.5726875e-01, 8.5748965e-01, - 8.5771066e-01, 8.5793167e-01, 8.5815281e-01, 8.5837388e-01, - 8.5859507e-01, 8.5881627e-01, 8.5903752e-01, 8.5925877e-01, - 8.5948014e-01, 8.5970151e-01, 8.5992289e-01, 8.6014438e-01, - 8.6036587e-01, 8.6058742e-01, 8.6080897e-01, 8.6103058e-01, - 8.6125225e-01, 8.6147398e-01, 8.6169571e-01, 8.6191750e-01, - 8.6213934e-01, 8.6236125e-01, 8.6258316e-01, 8.6280513e-01, - 8.6302710e-01, 8.6324918e-01, 8.6347127e-01, 8.6369336e-01, - 8.6391556e-01, 8.6413777e-01, 8.6436003e-01, 8.6458236e-01, - 8.6480469e-01, 8.6502707e-01, 8.6524951e-01, 8.6547196e-01, - 8.6569452e-01, 8.6591709e-01, 8.6613965e-01, 8.6636233e-01, - 8.6658502e-01, 8.6680776e-01, 8.6703050e-01, 8.6725330e-01, - 8.6747617e-01, 8.6769909e-01, 8.6792201e-01, 8.6814505e-01, - 8.6836809e-01, 8.6859113e-01, 8.6881423e-01, 8.6903745e-01, - 8.6926061e-01, 8.6948389e-01, 8.6970717e-01, 8.6993051e-01, - 8.7015390e-01, 8.7037730e-01, 8.7060076e-01, 8.7082428e-01, - 8.7104785e-01, 8.7127143e-01, 8.7149507e-01, 8.7171876e-01, - 8.7194252e-01, 8.7216628e-01, 8.7239009e-01, 8.7261397e-01, - 8.7283784e-01, 8.7306178e-01, 8.7328577e-01, 8.7350982e-01, - 8.7373388e-01, 8.7395799e-01, 8.7418216e-01, 8.7440640e-01, - 8.7463063e-01, 8.7485492e-01, 8.7507927e-01, 8.7530369e-01, - 8.7552810e-01, 8.7575257e-01, 8.7597710e-01, 8.7620169e-01, - 8.7642628e-01, 8.7665093e-01, 8.7687564e-01, 8.7710035e-01, - 8.7732512e-01, 8.7754995e-01, 8.7777483e-01, 8.7799978e-01, - 8.7822473e-01, 8.7844974e-01, 8.7867481e-01, 8.7889987e-01, - 8.7912500e-01, 8.7935019e-01, 8.7957543e-01, 8.7980068e-01, - 8.8002604e-01, 8.8025135e-01, 8.8047677e-01, 8.8070226e-01, - 8.8092774e-01, 8.8115329e-01, 8.8137889e-01, 8.8160449e-01, - 8.8183016e-01, 8.8205588e-01, 8.8228166e-01, 8.8250744e-01, - 8.8273335e-01, 8.8295925e-01, 8.8318515e-01, 8.8341117e-01, - 8.8363719e-01, 8.8386327e-01, 8.8408941e-01, 8.8431555e-01, - 8.8454181e-01, 8.8476807e-01, 8.8499439e-01, 8.8522071e-01, - 8.8544714e-01, 8.8567358e-01, 8.8590008e-01, 8.8612658e-01, - 8.8635319e-01, 8.8657981e-01, 8.8680649e-01, 8.8703316e-01, - 8.8725996e-01, 8.8748676e-01, 8.8771361e-01, 8.8794053e-01, - 8.8816744e-01, 8.8839442e-01, 8.8862145e-01, 8.8884854e-01, - 8.8907570e-01, 8.8930285e-01, 8.8953006e-01, 8.8975734e-01, - 8.8998467e-01, 8.9021200e-01, 8.9043945e-01, 8.9066684e-01, - 8.9089435e-01, 8.9112192e-01, 8.9134949e-01, 8.9157712e-01, - 8.9180481e-01, 8.9203256e-01, 8.9226031e-01, 8.9248812e-01, - 8.9271599e-01, 8.9294392e-01, 8.9317185e-01, 8.9339989e-01, - 8.9362794e-01, 8.9385605e-01, 8.9408416e-01, 8.9431238e-01, - 8.9454061e-01, 8.9476889e-01, 8.9499724e-01, 8.9522558e-01, - 8.9545399e-01, 8.9568251e-01, 8.9591098e-01, 8.9613956e-01, - 8.9636821e-01, 8.9659685e-01, 8.9682555e-01, 8.9705431e-01, - 8.9728308e-01, 8.9751196e-01, 8.9774084e-01, 8.9796978e-01, - 8.9819878e-01, 8.9842778e-01, 8.9865690e-01, 8.9888602e-01, - 8.9911520e-01, 8.9934438e-01, 8.9957368e-01, 8.9980298e-01, - 9.0003234e-01, 9.0026176e-01, 9.0049124e-01, 9.0072072e-01, - 9.0095031e-01, 9.0117991e-01, 9.0140957e-01, 9.0163922e-01, - 9.0186900e-01, 9.0209877e-01, 9.0232861e-01, 9.0255851e-01, - 9.0278846e-01, 9.0301841e-01, 9.0324843e-01, 9.0347856e-01, - 9.0370864e-01, 9.0393883e-01, 9.0416908e-01, 9.0439934e-01, - 9.0462965e-01, 9.0486002e-01, 9.0509045e-01, 9.0532088e-01, - 9.0555137e-01, 9.0578198e-01, 9.0601259e-01, 9.0624321e-01, - 9.0647393e-01, 9.0670466e-01, 9.0693545e-01, 9.0716630e-01, - 9.0739721e-01, 9.0762818e-01, 9.0785915e-01, 9.0809017e-01, - 9.0832126e-01, 9.0855241e-01, 9.0878361e-01, 9.0901482e-01, - 9.0924615e-01, 9.0947747e-01, 9.0970886e-01, 9.0994030e-01, - 9.1017175e-01, 9.1040331e-01, 9.1063488e-01, 9.1086650e-01, - 9.1109818e-01, 9.1132987e-01, 9.1156167e-01, 9.1179347e-01, - 9.1202533e-01, 9.1225725e-01, 9.1248924e-01, 9.1272128e-01, - 9.1295332e-01, 9.1318542e-01, 9.1341758e-01, 9.1364980e-01, - 9.1388208e-01, 9.1411442e-01, 9.1434675e-01, 9.1457915e-01, - 9.1481161e-01, 9.1504413e-01, 9.1527671e-01, 9.1550928e-01, - 9.1574198e-01, 9.1597468e-01, 9.1620743e-01, 9.1644025e-01, - 9.1667312e-01, 9.1690600e-01, 9.1713893e-01, 9.1737199e-01, - 9.1760504e-01, 9.1783816e-01, 9.1807127e-01, 9.1830450e-01, - 9.1853774e-01, 9.1877103e-01, 9.1900444e-01, 9.1923779e-01, - 9.1947126e-01, 9.1970479e-01, 9.1993833e-01, 9.2017192e-01, - 9.2040563e-01, 9.2063934e-01, 9.2087305e-01, 9.2110687e-01, - 9.2134070e-01, 9.2157465e-01, 9.2180860e-01, 9.2204261e-01, - 9.2227668e-01, 9.2251080e-01, 9.2274493e-01, 9.2297918e-01, - 9.2321342e-01, 9.2344773e-01, 9.2368209e-01, 9.2391652e-01, - 9.2415094e-01, 9.2438549e-01, 9.2462003e-01, 9.2485470e-01, - 9.2508936e-01, 9.2532408e-01, 9.2555881e-01, 9.2579365e-01, - 9.2602855e-01, 9.2626345e-01, 9.2649841e-01, 9.2673343e-01, - 9.2696851e-01, 9.2720366e-01, 9.2743886e-01, 9.2767406e-01, - 9.2790937e-01, 9.2814469e-01, 9.2838007e-01, 9.2861551e-01, - 9.2885101e-01, 9.2908657e-01, 9.2932212e-01, 9.2955780e-01, - 9.2979348e-01, 9.3002921e-01, 9.3026501e-01, 9.3050086e-01, - 9.3073678e-01, 9.3097270e-01, 9.3120873e-01, 9.3144476e-01, - 9.3168086e-01, 9.3191707e-01, 9.3215328e-01, 9.3238950e-01, - 9.3262583e-01, 9.3286222e-01, 9.3309861e-01, 9.3333513e-01, - 9.3357164e-01, 9.3380821e-01, 9.3404484e-01, 9.3428153e-01, - 9.3451828e-01, 9.3475503e-01, 9.3499190e-01, 9.3522877e-01, - 9.3546569e-01, 9.3570274e-01, 9.3593979e-01, 9.3617690e-01, - 9.3641400e-01, 9.3665123e-01, 9.3688852e-01, 9.3712580e-01, - 9.3736315e-01, 9.3760061e-01, 9.3783808e-01, 9.3807560e-01, - 9.3831319e-01, 9.3855077e-01, 9.3878847e-01, 9.3902624e-01, - 9.3926400e-01, 9.3950182e-01, 9.3973976e-01, 9.3997771e-01, - 9.4021571e-01, 9.4045377e-01, 9.4069183e-01, 9.4093001e-01, - 9.4116825e-01, 9.4140649e-01, 9.4164485e-01, 9.4188321e-01, - 9.4212162e-01, 9.4236010e-01, 9.4259864e-01, 9.4283724e-01, - 9.4307590e-01, 9.4331455e-01, 9.4355333e-01, 9.4379210e-01, - 9.4403100e-01, 9.4426990e-01, 9.4450885e-01, 9.4474787e-01, - 9.4498694e-01, 9.4522607e-01, 9.4546527e-01, 9.4570452e-01, - 9.4594383e-01, 9.4618315e-01, 9.4642258e-01, 9.4666201e-01, - 9.4690150e-01, 9.4714105e-01, 9.4738066e-01, 9.4762039e-01, - 9.4786006e-01, 9.4809985e-01, 9.4833970e-01, 9.4857961e-01, - 9.4881952e-01, 9.4905955e-01, 9.4929957e-01, 9.4953972e-01, - 9.4977987e-01, 9.5002007e-01, 9.5026034e-01, 9.5050067e-01, - 9.5074105e-01, 9.5098150e-01, 9.5122200e-01, 9.5146251e-01, - 9.5170313e-01, 9.5194381e-01, 9.5218450e-01, 9.5242524e-01, - 9.5266610e-01, 9.5290697e-01, 9.5314789e-01, 9.5338887e-01, - 9.5362991e-01, 9.5387101e-01, 9.5411217e-01, 9.5435339e-01, - 9.5459467e-01, 9.5483601e-01, 9.5507735e-01, 9.5531881e-01, - 9.5556027e-01, 9.5580184e-01, 9.5604342e-01, 9.5628506e-01, - 9.5652682e-01, 9.5676857e-01, 9.5701039e-01, 9.5725226e-01, - 9.5749420e-01, 9.5773619e-01, 9.5797825e-01, 9.5822036e-01, - 9.5846248e-01, 9.5870471e-01, 9.5894700e-01, 9.5918930e-01, - 9.5943171e-01, 9.5967412e-01, 9.5991665e-01, 9.6015918e-01, - 9.6040183e-01, 9.6064448e-01, 9.6088719e-01, 9.6112996e-01, - 9.6137279e-01, 9.6161568e-01, 9.6185863e-01, 9.6210164e-01, - 9.6234471e-01, 9.6258783e-01, 9.6283102e-01, 9.6307427e-01, - 9.6331757e-01, 9.6356088e-01, 9.6380430e-01, 9.6404779e-01, - 9.6429127e-01, 9.6453488e-01, 9.6477848e-01, 9.6502221e-01, - 9.6526593e-01, 9.6550977e-01, 9.6575361e-01, 9.6599752e-01, - 9.6624154e-01, 9.6648556e-01, 9.6672964e-01, 9.6697378e-01, - 9.6721798e-01, 9.6746230e-01, 9.6770662e-01, 9.6795100e-01, - 9.6819544e-01, 9.6843994e-01, 9.6868449e-01, 9.6892911e-01, - 9.6917379e-01, 9.6941847e-01, 9.6966326e-01, 9.6990812e-01, - 9.7015303e-01, 9.7039801e-01, 9.7064304e-01, 9.7088808e-01, - 9.7113323e-01, 9.7137845e-01, 9.7162366e-01, 9.7186899e-01, - 9.7211438e-01, 9.7235978e-01, 9.7260529e-01, 9.7285086e-01, - 9.7309643e-01, 9.7334212e-01, 9.7358781e-01, 9.7383362e-01, - 9.7407943e-01, 9.7432536e-01, 9.7457129e-01, 9.7481734e-01, - 9.7506338e-01, 9.7530955e-01, 9.7555572e-01, 9.7580200e-01, - 9.7604829e-01, 9.7629470e-01, 9.7654110e-01, 9.7678757e-01, - 9.7703415e-01, 9.7728074e-01, 9.7752744e-01, 9.7777414e-01, - 9.7802097e-01, 9.7826779e-01, 9.7851467e-01, 9.7876167e-01, - 9.7900867e-01, 9.7925580e-01, 9.7950292e-01, 9.7975016e-01, - 9.7999740e-01, 9.8024470e-01, 9.8049212e-01, 9.8073953e-01, - 9.8098707e-01, 9.8123461e-01, 9.8148227e-01, 9.8172992e-01, - 9.8197770e-01, 9.8222548e-01, 9.8247337e-01, 9.8272127e-01, - 9.8296928e-01, 9.8321730e-01, 9.8346543e-01, 9.8371363e-01, - 9.8396182e-01, 9.8421013e-01, 9.8445845e-01, 9.8470688e-01, - 9.8495537e-01, 9.8520392e-01, 9.8545247e-01, 9.8570114e-01, - 9.8594987e-01, 9.8619866e-01, 9.8644745e-01, 9.8669636e-01, - 9.8694533e-01, 9.8719436e-01, 9.8744345e-01, 9.8769259e-01, - 9.8794180e-01, 9.8819107e-01, 9.8844039e-01, 9.8868978e-01, - 9.8893923e-01, 9.8918873e-01, 9.8943830e-01, 9.8968798e-01, - 9.8993766e-01, 9.9018741e-01, 9.9043721e-01, 9.9068713e-01, - 9.9093705e-01, 9.9118710e-01, 9.9143714e-01, 9.9168730e-01, - 9.9193746e-01, 9.9218774e-01, 9.9243802e-01, 9.9268842e-01, - 9.9293888e-01, 9.9318939e-01, 9.9343991e-01, 9.9369055e-01, - 9.9394125e-01, 9.9419200e-01, 9.9444282e-01, 9.9469370e-01, - 9.9494463e-01, 9.9519563e-01, 9.9544674e-01, 9.9569786e-01, - 9.9594903e-01, 9.9620032e-01, 9.9645162e-01, 9.9670297e-01, - 9.9695444e-01, 9.9720597e-01, 9.9745750e-01, 9.9770916e-01, - 9.9796087e-01, 9.9821264e-01, 9.9846447e-01, 9.9871629e-01, - 9.9896824e-01, 9.9922031e-01, 9.9947238e-01, 9.9972451e-01, - 9.9997669e-01, 1.0002290e+00, 1.0004814e+00, 1.0007337e+00, - 1.0009862e+00, 1.0012387e+00, 1.0014913e+00, 1.0017439e+00, - 1.0019966e+00, 1.0022494e+00, 1.0025022e+00, 1.0027552e+00, - 1.0030081e+00, 1.0032612e+00, 1.0035143e+00, 1.0037675e+00, - 1.0040207e+00, 1.0042740e+00, 1.0045273e+00, 1.0047808e+00, - 1.0050342e+00, 1.0052878e+00, 1.0055413e+00, 1.0057951e+00, - 1.0060488e+00, 1.0063026e+00, 1.0065565e+00, 1.0068104e+00, - 1.0070645e+00, 1.0073185e+00, 1.0075727e+00, 1.0078268e+00, - 1.0080811e+00, 1.0083355e+00, 1.0085899e+00, 1.0088443e+00, - 1.0090988e+00, 1.0093534e+00, 1.0096080e+00, 1.0098628e+00, - 1.0101175e+00, 1.0103724e+00, 1.0106274e+00, 1.0108824e+00, - 1.0111374e+00, 1.0113925e+00, 1.0116477e+00, 1.0119029e+00, - 1.0121583e+00, 1.0124136e+00, 1.0126691e+00, 1.0129246e+00, - 1.0131801e+00, 1.0134358e+00, 1.0136915e+00, 1.0139472e+00, - 1.0142031e+00, 1.0144590e+00, 1.0147150e+00, 1.0149710e+00, - 1.0152272e+00, 1.0154834e+00, 1.0157396e+00, 1.0159959e+00, - 1.0162523e+00, 1.0165087e+00, 1.0167652e+00, 1.0170218e+00, - 1.0172784e+00, 1.0175351e+00, 1.0177919e+00, 1.0180488e+00, - 1.0183057e+00, 1.0185627e+00, 1.0188197e+00, 1.0190768e+00, - 1.0193340e+00, 1.0195912e+00, 1.0198486e+00, 1.0201060e+00, - 1.0203633e+00, 1.0206209e+00, 1.0208784e+00, 1.0211362e+00, - 1.0213939e+00, 1.0216516e+00, 1.0219095e+00, 1.0221674e+00, - 1.0224254e+00, 1.0226835e+00, 1.0229416e+00, 1.0231998e+00, - 1.0234581e+00, 1.0237164e+00, 1.0239748e+00, 1.0242333e+00, - 1.0244918e+00, 1.0247505e+00, 1.0250092e+00, 1.0252678e+00, - 1.0255266e+00, 1.0257856e+00, 1.0260445e+00, 1.0263035e+00, - 1.0265626e+00, 1.0268217e+00, 1.0270810e+00, 1.0273403e+00, - 1.0275997e+00, 1.0278591e+00, 1.0281186e+00, 1.0283781e+00, - 1.0286378e+00, 1.0288975e+00, 1.0291573e+00, 1.0294172e+00, - 1.0296770e+00, 1.0299370e+00, 1.0301971e+00, 1.0304573e+00, - 1.0307175e+00, 1.0309777e+00, 1.0312381e+00, 1.0314984e+00, - 1.0317589e+00, 1.0320195e+00, 1.0322801e+00, 1.0325408e+00, - 1.0328015e+00, 1.0330623e+00, 1.0333233e+00, 1.0335842e+00, - 1.0338453e+00, 1.0341064e+00, 1.0343676e+00, 1.0346289e+00, - 1.0348902e+00, 1.0351515e+00, 1.0354130e+00, 1.0356746e+00, - 1.0359361e+00, 1.0361978e+00, 1.0364596e+00, 1.0367213e+00, - 1.0369833e+00, 1.0372453e+00, 1.0375073e+00, 1.0377693e+00, - 1.0380316e+00, 1.0382938e+00, 1.0385561e+00, 1.0388185e+00, - 1.0390810e+00, 1.0393435e+00, 1.0396061e+00, 1.0398687e+00, - 1.0401314e+00, 1.0403943e+00, 1.0406572e+00, 1.0409201e+00, - 1.0411832e+00, 1.0414463e+00, 1.0417095e+00, 1.0419728e+00, - 1.0422361e+00, 1.0424994e+00, 1.0427629e+00, 1.0430264e+00, - 1.0432900e+00, 1.0435537e+00, 1.0438175e+00, 1.0440813e+00, - 1.0443453e+00, 1.0446092e+00, 1.0448732e+00, 1.0451374e+00, - 1.0454016e+00, 1.0456659e+00, 1.0459301e+00, 1.0461946e+00, - 1.0464591e+00, 1.0467236e+00, 1.0469882e+00, 1.0472530e+00, - 1.0475178e+00, 1.0477827e+00, 1.0480475e+00, 1.0483125e+00, - 1.0485777e+00, 1.0488428e+00, 1.0491080e+00, 1.0493733e+00, - 1.0496386e+00, 1.0499041e+00, 1.0501696e+00, 1.0504352e+00, - 1.0507009e+00, 1.0509666e+00, 1.0512325e+00, 1.0514983e+00, - 1.0517642e+00, 1.0520303e+00, 1.0522964e+00, 1.0525626e+00, - 1.0528289e+00, 1.0530952e+00, 1.0533617e+00, 1.0536281e+00, - 1.0538946e+00, 1.0541613e+00, 1.0544280e+00, 1.0546948e+00, - 1.0549617e+00, 1.0552286e+00, 1.0554956e+00, 1.0557626e+00, - 1.0560298e+00, 1.0562971e+00, 1.0565643e+00, 1.0568317e+00, - 1.0570992e+00, 1.0573667e+00, 1.0576344e+00, 1.0579021e+00, - 1.0581698e+00, 1.0584377e+00, 1.0587056e+00, 1.0589736e+00, - 1.0592417e+00, 1.0595098e+00, 1.0597780e+00, 1.0600463e+00, - 1.0603147e+00, 1.0605831e+00, 1.0608517e+00, 1.0611203e+00, - 1.0613890e+00, 1.0616577e+00, 1.0619265e+00, 1.0621954e+00, - 1.0624644e+00, 1.0627335e+00, 1.0630026e+00, 1.0632719e+00, - 1.0635412e+00, 1.0638105e+00, 1.0640800e+00, 1.0643495e+00, - 1.0646191e+00, 1.0648887e+00, 1.0651585e+00, 1.0654284e+00, - 1.0656983e+00, 1.0659683e+00, 1.0662383e+00, 1.0665085e+00, - 1.0667787e+00, 1.0670490e+00, 1.0673194e+00, 1.0675899e+00, - 1.0678604e+00, 1.0681310e+00, 1.0684017e+00, 1.0686724e+00, - 1.0689433e+00, 1.0692142e+00, 1.0694852e+00, 1.0697563e+00, - 1.0700275e+00, 1.0702987e+00, 1.0705701e+00, 1.0708414e+00, - 1.0711130e+00, 1.0713844e+00, 1.0716561e+00, 1.0719278e+00, - 1.0721996e+00, 1.0724715e+00, 1.0727434e+00, 1.0730155e+00, - 1.0732876e+00, 1.0735598e+00, 1.0738320e+00, 1.0741044e+00, - 1.0743768e+00, 1.0746493e+00, 1.0749220e+00, 1.0751946e+00, - 1.0754673e+00, 1.0757402e+00, 1.0760131e+00, 1.0762861e+00, - 1.0765592e+00, 1.0768323e+00, 1.0771055e+00, 1.0773789e+00, - 1.0776522e+00, 1.0779257e+00, 1.0781993e+00, 1.0784730e+00, - 1.0787467e+00, 1.0790205e+00, 1.0792943e+00, 1.0795683e+00, - 1.0798423e+00, 1.0801164e+00, 1.0803907e+00, 1.0806649e+00, - 1.0809393e+00, 1.0812137e+00, 1.0814883e+00, 1.0817629e+00, - 1.0820376e+00, 1.0823123e+00, 1.0825871e+00, 1.0828621e+00, - 1.0831372e+00, 1.0834122e+00, 1.0836874e+00, 1.0839627e+00, - 1.0842381e+00, 1.0845134e+00, 1.0847889e+00, 1.0850645e+00, - 1.0853403e+00, 1.0856160e+00, 1.0858918e+00, 1.0861677e+00, - 1.0864438e+00, 1.0867199e+00, 1.0869960e+00, 1.0872723e+00, - 1.0875486e+00, 1.0878251e+00, 1.0881015e+00, 1.0883781e+00, - 1.0886548e+00, 1.0889316e+00, 1.0892084e+00, 1.0894853e+00, - 1.0897623e+00, 1.0900394e+00, 1.0903165e+00, 1.0905938e+00, - 1.0908711e+00, 1.0911485e+00, 1.0914260e+00, 1.0917037e+00, - 1.0919813e+00, 1.0922590e+00, 1.0925369e+00, 1.0928148e+00, - 1.0930929e+00, 1.0933709e+00, 1.0936491e+00, 1.0939274e+00, - 1.0942057e+00, 1.0944842e+00, 1.0947627e+00, 1.0950413e+00, - 1.0953200e+00, 1.0955988e+00, 1.0958776e+00, 1.0961566e+00, - 1.0964357e+00, 1.0967147e+00, 1.0969939e+00, 1.0972732e+00, - 1.0975525e+00, 1.0978321e+00, 1.0981116e+00, 1.0983912e+00, - 1.0986710e+00, 1.0989507e+00, 1.0992306e+00, 1.0995106e+00, - 1.0997907e+00, 1.1000708e+00, 1.1003511e+00, 1.1006314e+00, - 1.1009117e+00, 1.1011922e+00, 1.1014729e+00, 1.1017535e+00, - 1.1020342e+00, 1.1023151e+00, 1.1025960e+00, 1.1028770e+00, - 1.1031581e+00, 1.1034393e+00, 1.1037205e+00, 1.1040020e+00, - 1.1042835e+00, 1.1045649e+00, 1.1048466e+00, 1.1051283e+00, - 1.1054101e+00, 1.1056920e+00, 1.1059740e+00, 1.1062560e+00, - 1.1065382e+00, 1.1068205e+00, 1.1071028e+00, 1.1073852e+00, - 1.1076677e+00, 1.1079502e+00, 1.1082330e+00, 1.1085157e+00, - 1.1087985e+00, 1.1090815e+00, 1.1093645e+00, 1.1096476e+00, - 1.1099309e+00, 1.1102142e+00, 1.1104976e+00, 1.1107811e+00, - 1.1110647e+00, 1.1113483e+00, 1.1116320e+00, 1.1119158e+00, - 1.1121998e+00, 1.1124839e+00, 1.1127679e+00, 1.1130521e+00, - 1.1133364e+00, 1.1136208e+00, 1.1139053e+00, 1.1141899e+00, - 1.1144745e+00, 1.1147592e+00, 1.1150440e+00, 1.1153290e+00, - 1.1156139e+00, 1.1158991e+00, 1.1161842e+00, 1.1164695e+00, - 1.1167549e+00, 1.1170404e+00, 1.1173259e+00, 1.1176116e+00, - 1.1178974e+00, 1.1181831e+00, 1.1184691e+00, 1.1187551e+00, - 1.1190412e+00, 1.1193274e+00, 1.1196136e+00, 1.1199001e+00, - 1.1201866e+00, 1.1204731e+00, 1.1207597e+00, 1.1210465e+00, - 1.1213334e+00, 1.1216203e+00, 1.1219074e+00, 1.1221944e+00, - 1.1224816e+00, 1.1227689e+00, 1.1230563e+00, 1.1233438e+00, - 1.1236314e+00, 1.1239190e+00, 1.1242068e+00, 1.1244947e+00, - 1.1247827e+00, 1.1250707e+00, 1.1253588e+00, 1.1256471e+00, - 1.1259354e+00, 1.1262238e+00, 1.1265123e+00, 1.1268009e+00, - 1.1270896e+00, 1.1273785e+00, 1.1276673e+00, 1.1279563e+00, - 1.1282454e+00, 1.1285346e+00, 1.1288238e+00, 1.1291132e+00, - 1.1294026e+00, 1.1296922e+00, 1.1299818e+00, 1.1302716e+00, - 1.1305614e+00, 1.1308513e+00, 1.1311413e+00, 1.1314315e+00, - 1.1317216e+00, 1.1320120e+00, 1.1323024e+00, 1.1325929e+00, - 1.1328834e+00, 1.1331742e+00, 1.1334649e+00, 1.1337558e+00, - 1.1340468e+00, 1.1343379e+00, 1.1346291e+00, 1.1349204e+00, - 1.1352117e+00, 1.1355032e+00, 1.1357948e+00, 1.1360863e+00, - 1.1363782e+00, 1.1366700e+00, 1.1369619e+00, 1.1372540e+00, - 1.1375461e+00, 1.1378384e+00, 1.1381307e+00, 1.1384231e+00, - 1.1387156e+00, 1.1390083e+00, 1.1393009e+00, 1.1395938e+00, - 1.1398867e+00, 1.1401798e+00, 1.1404729e+00, 1.1407660e+00, - 1.1410594e+00, 1.1413528e+00, 1.1416463e+00, 1.1419399e+00, - 1.1422336e+00, 1.1425273e+00, 1.1428213e+00, 1.1431153e+00, - 1.1434094e+00, 1.1437036e+00, 1.1439979e+00, 1.1442922e+00, - 1.1445868e+00, 1.1448814e+00, 1.1451761e+00, 1.1454709e+00, - 1.1457658e+00, 1.1460607e+00, 1.1463559e+00, 1.1466510e+00, - 1.1469463e+00, 1.1472417e+00, 1.1475372e+00, 1.1478328e+00, - 1.1481285e+00, 1.1484243e+00, 1.1487201e+00, 1.1490161e+00, - 1.1493123e+00, 1.1496085e+00, 1.1499047e+00, 1.1502011e+00, - 1.1504977e+00, 1.1507943e+00, 1.1510910e+00, 1.1513877e+00, - 1.1516846e+00, 1.1519816e+00, 1.1522788e+00, 1.1525760e+00, - 1.1528733e+00, 1.1531707e+00, 1.1534683e+00, 1.1537658e+00, - 1.1540636e+00, 1.1543614e+00, 1.1546593e+00, 1.1549573e+00, - 1.1552554e+00, 1.1555537e+00, 1.1558520e+00, 1.1561505e+00, - 1.1564490e+00, 1.1567476e+00, 1.1570463e+00, 1.1573452e+00, - 1.1576442e+00, 1.1579432e+00, 1.1582423e+00, 1.1585417e+00, - 1.1588410e+00, 1.1591405e+00, 1.1594400e+00, 1.1597397e+00, - 1.1600395e+00, 1.1603394e+00, 1.1606394e+00, 1.1609395e+00, - 1.1612397e+00, 1.1615400e+00, 1.1618404e+00, 1.1621410e+00, - 1.1624415e+00, 1.1627423e+00, 1.1630431e+00, 1.1633440e+00, - 1.1636450e+00, 1.1639463e+00, 1.1642475e+00, 1.1645489e+00, - 1.1648504e+00, 1.1651518e+00, 1.1654536e+00, 1.1657554e+00, - 1.1660572e+00, 1.1663592e+00, 1.1666613e+00, 1.1669636e+00, - 1.1672659e+00, 1.1675682e+00, 1.1678708e+00, 1.1681734e+00, - 1.1684762e+00, 1.1687790e+00, 1.1690819e+00, 1.1693851e+00, - 1.1696882e+00, 1.1699915e+00, 1.1702949e+00, 1.1705984e+00, - 1.1709020e+00, 1.1712056e+00, 1.1715095e+00, 1.1718134e+00, - 1.1721175e+00, 1.1724216e+00, 1.1727258e+00, 1.1730303e+00, - 1.1733347e+00, 1.1736393e+00, 1.1739439e+00, 1.1742487e+00, - 1.1745536e+00, 1.1748587e+00, 1.1751637e+00, 1.1754690e+00, - 1.1757743e+00, 1.1760798e+00, 1.1763854e+00, 1.1766911e+00, - 1.1769968e+00, 1.1773027e+00, 1.1776087e+00, 1.1779149e+00, - 1.1782210e+00, 1.1785274e+00, 1.1788338e+00, 1.1791403e+00, - 1.1794471e+00, 1.1797538e+00, 1.1800607e+00, 1.1803677e+00, - 1.1806748e+00, 1.1809820e+00, 1.1812893e+00, 1.1815968e+00, - 1.1819043e+00, 1.1822120e+00, 1.1825198e+00, 1.1828277e+00, - 1.1831357e+00, 1.1834438e+00, 1.1837521e+00, 1.1840603e+00, - 1.1843688e+00, 1.1846774e+00, 1.1849861e+00, 1.1852949e+00, - 1.1856037e+00, 1.1859128e+00, 1.1862220e+00, 1.1865312e+00, - 1.1868405e+00, 1.1871500e+00, 1.1874596e+00, 1.1877693e+00, - 1.1880791e+00, 1.1883891e+00, 1.1886991e+00, 1.1890092e+00, - 1.1893195e+00, 1.1896299e+00, 1.1899403e+00, 1.1902510e+00, - 1.1905618e+00, 1.1908726e+00, 1.1911836e+00, 1.1914946e+00, - 1.1918058e+00, 1.1921171e+00, 1.1924285e+00, 1.1927401e+00, - 1.1930517e+00, 1.1933634e+00, 1.1936754e+00, 1.1939874e+00, - 1.1942995e+00, 1.1946117e+00, 1.1949241e+00, 1.1952366e+00, - 1.1955491e+00, 1.1958618e+00, 1.1961746e+00, 1.1964875e+00, - 1.1968006e+00, 1.1971138e+00, 1.1974270e+00, 1.1977404e+00, - 1.1980540e+00, 1.1983676e+00, 1.1986814e+00, 1.1989952e+00, - 1.1993092e+00, 1.1996233e+00, 1.1999376e+00, 1.2002519e+00, - 1.2005664e+00, 1.2008810e+00, 1.2011957e+00, 1.2015105e+00, - 1.2018255e+00, 1.2021406e+00, 1.2024558e+00, 1.2027711e+00, - 1.2030865e+00, 1.2034019e+00, 1.2037176e+00, 1.2040334e+00, - 1.2043493e+00, 1.2046653e+00, 1.2049814e+00, 1.2052977e+00, - 1.2056141e+00, 1.2059306e+00, 1.2062472e+00, 1.2065639e+00, - 1.2068808e+00, 1.2071979e+00, 1.2075150e+00, 1.2078322e+00, - 1.2081496e+00, 1.2084670e+00, 1.2087846e+00, 1.2091023e+00, - 1.2094202e+00, 1.2097381e+00, 1.2100562e+00, 1.2103744e+00, - 1.2106928e+00, 1.2110112e+00, 1.2113298e+00, 1.2116485e+00, - 1.2119672e+00, 1.2122862e+00, 1.2126052e+00, 1.2129245e+00, - 1.2132438e+00, 1.2135632e+00, 1.2138828e+00, 1.2142025e+00, - 1.2145222e+00, 1.2148422e+00, 1.2151623e+00, 1.2154825e+00, - 1.2158028e+00, 1.2161232e+00, 1.2164438e+00, 1.2167645e+00, - 1.2170852e+00, 1.2174062e+00, 1.2177273e+00, 1.2180485e+00, - 1.2183697e+00, 1.2186912e+00, 1.2190127e+00, 1.2193345e+00, - 1.2196562e+00, 1.2199782e+00, 1.2203002e+00, 1.2206224e+00, - 1.2209448e+00, 1.2212672e+00, 1.2215898e+00, 1.2219125e+00, - 1.2222353e+00, 1.2225583e+00, 1.2228813e+00, 1.2232046e+00, - 1.2235279e+00, 1.2238513e+00, 1.2241750e+00, 1.2244986e+00, - 1.2248225e+00, 1.2251465e+00, 1.2254707e+00, 1.2257949e+00, - 1.2261193e+00, 1.2264438e+00, 1.2267684e+00, 1.2270931e+00, - 1.2274179e+00, 1.2277430e+00, 1.2280681e+00, 1.2283934e+00, - 1.2287189e+00, 1.2290443e+00, 1.2293700e+00, 1.2296958e+00, - 1.2300217e+00, 1.2303478e+00, 1.2306740e+00, 1.2310003e+00, - 1.2313267e+00, 1.2316533e+00, 1.2319801e+00, 1.2323068e+00, - 1.2326338e+00, 1.2329609e+00, 1.2332882e+00, 1.2336155e+00, - 1.2339431e+00, 1.2342707e+00, 1.2345985e+00, 1.2349263e+00, - 1.2352544e+00, 1.2355826e+00, 1.2359109e+00, 1.2362393e+00, - 1.2365679e+00, 1.2368965e+00, 1.2372254e+00, 1.2375543e+00, - 1.2378834e+00, 1.2382127e+00, 1.2385421e+00, 1.2388716e+00, - 1.2392012e+00, 1.2395309e+00, 1.2398609e+00, 1.2401909e+00, - 1.2405211e+00, 1.2408514e+00, 1.2411819e+00, 1.2415124e+00, - 1.2418431e+00, 1.2421740e+00, 1.2425050e+00, 1.2428361e+00, - 1.2431674e+00, 1.2434988e+00, 1.2438303e+00, 1.2441620e+00, - 1.2444938e+00, 1.2448257e+00, 1.2451578e+00, 1.2454901e+00, - 1.2458224e+00, 1.2461549e+00, 1.2464876e+00, 1.2468203e+00, - 1.2471533e+00, 1.2474864e+00, 1.2478195e+00, 1.2481529e+00, - 1.2484863e+00, 1.2488198e+00, 1.2491536e+00, 1.2494875e+00, - 1.2498215e+00, 1.2501557e+00, 1.2504900e+00, 1.2508245e+00, - 1.2511591e+00, 1.2514937e+00, 1.2518286e+00, 1.2521636e+00, - 1.2524987e+00, 1.2528341e+00, 1.2531694e+00, 1.2535050e+00, - 1.2538407e+00, 1.2541766e+00, 1.2545125e+00, 1.2548487e+00, - 1.2551850e+00, 1.2555214e+00, 1.2558579e+00, 1.2561946e+00, - 1.2565315e+00, 1.2568685e+00, 1.2572056e+00, 1.2575428e+00, - 1.2578802e+00, 1.2582178e+00, 1.2585555e+00, 1.2588934e+00, - 1.2592313e+00, 1.2595695e+00, 1.2599077e+00, 1.2602462e+00, - 1.2605847e+00, 1.2609235e+00, 1.2612623e+00, 1.2616013e+00, - 1.2619405e+00, 1.2622797e+00, 1.2626191e+00, 1.2629588e+00, - 1.2632985e+00, 1.2636384e+00, 1.2639784e+00, 1.2643185e+00, - 1.2646588e+00, 1.2649993e+00, 1.2653399e+00, 1.2656807e+00, - 1.2660215e+00, 1.2663625e+00, 1.2667037e+00, 1.2670451e+00, - 1.2673866e+00, 1.2677282e+00, 1.2680700e+00, 1.2684120e+00, - 1.2687540e+00, 1.2690963e+00, 1.2694386e+00, 1.2697811e+00, - 1.2701238e+00, 1.2704667e+00, 1.2708097e+00, 1.2711527e+00, - 1.2714961e+00, 1.2718394e+00, 1.2721829e+00, 1.2725267e+00, - 1.2728705e+00, 1.2732146e+00, 1.2735587e+00, 1.2739031e+00, - 1.2742475e+00, 1.2745922e+00, 1.2749370e+00, 1.2752819e+00, - 1.2756270e+00, 1.2759722e+00, 1.2763176e+00, 1.2766632e+00, - 1.2770089e+00, 1.2773547e+00, 1.2777007e+00, 1.2780468e+00, - 1.2783931e+00, 1.2787396e+00, 1.2790862e+00, 1.2794330e+00, - 1.2797799e+00, 1.2801269e+00, 1.2804742e+00, 1.2808216e+00, - 1.2811691e+00, 1.2815168e+00, 1.2818646e+00, 1.2822126e+00, - 1.2825608e+00, 1.2829090e+00, 1.2832576e+00, 1.2836062e+00, - 1.2839550e+00, 1.2843039e+00, 1.2846529e+00, 1.2850022e+00, - 1.2853516e+00, 1.2857012e+00, 1.2860509e+00, 1.2864008e+00, - 1.2867508e+00, 1.2871010e+00, 1.2874514e+00, 1.2878019e+00, - 1.2881526e+00, 1.2885034e+00, 1.2888544e+00, 1.2892054e+00, - 1.2895567e+00, 1.2899083e+00, 1.2902598e+00, 1.2906116e+00, - 1.2909635e+00, 1.2913157e+00, 1.2916679e+00, 1.2920203e+00, - 1.2923729e+00, 1.2927257e+00, 1.2930785e+00, 1.2934316e+00, - 1.2937849e+00, 1.2941382e+00, 1.2944918e+00, 1.2948455e+00, - 1.2951994e+00, 1.2955534e+00, 1.2959076e+00, 1.2962619e+00, - 1.2966164e+00, 1.2969712e+00, 1.2973260e+00, 1.2976810e+00, - 1.2980362e+00, 1.2983915e+00, 1.2987471e+00, 1.2991027e+00, - 1.2994585e+00, 1.2998145e+00, 1.3001707e+00, 1.3005270e+00, - 1.3008835e+00, 1.3012401e+00, 1.3015970e+00, 1.3019539e+00, - 1.3023111e+00, 1.3026685e+00, 1.3030258e+00, 1.3033836e+00, - 1.3037413e+00, 1.3040993e+00, 1.3044575e+00, 1.3048158e+00, - 1.3051744e+00, 1.3055329e+00, 1.3058918e+00, 1.3062508e+00, - 1.3066100e+00, 1.3069693e+00, 1.3073288e+00, 1.3076885e+00, - 1.3080482e+00, 1.3084083e+00, 1.3087685e+00, 1.3091288e+00, - 1.3094894e+00, 1.3098500e+00, 1.3102108e+00, 1.3105719e+00, - 1.3109331e+00, 1.3112944e+00, 1.3116560e+00, 1.3120177e+00, - 1.3123796e+00, 1.3127416e+00, 1.3131039e+00, 1.3134663e+00, - 1.3138288e+00, 1.3141916e+00, 1.3145545e+00, 1.3149176e+00, - 1.3152809e+00, 1.3156443e+00, 1.3160079e+00, 1.3163717e+00, - 1.3167356e+00, 1.3170998e+00, 1.3174641e+00, 1.3178285e+00, - 1.3181932e+00, 1.3185581e+00, 1.3189231e+00, 1.3192883e+00, - 1.3196536e+00, 1.3200191e+00, 1.3203849e+00, 1.3207508e+00, - 1.3211168e+00, 1.3214831e+00, 1.3218495e+00, 1.3222162e+00, - 1.3225830e+00, 1.3229499e+00, 1.3233171e+00, 1.3236843e+00, - 1.3240519e+00, 1.3244195e+00, 1.3247874e+00, 1.3251554e+00, - 1.3255236e+00, 1.3258920e+00, 1.3262606e+00, 1.3266293e+00, - 1.3269982e+00, 1.3273673e+00, 1.3277366e+00, 1.3281060e+00, - 1.3284757e+00, 1.3288456e+00, 1.3292155e+00, 1.3295858e+00, - 1.3299562e+00, 1.3303267e+00, 1.3306974e+00, 1.3310684e+00, - 1.3314395e+00, 1.3318108e+00, 1.3321823e+00, 1.3325540e+00, - 1.3329258e+00, 1.3332978e+00, 1.3336700e+00, 1.3340424e+00, - 1.3344151e+00, 1.3347878e+00, 1.3351607e+00, 1.3355340e+00, - 1.3359072e+00, 1.3362808e+00, 1.3366544e+00, 1.3370284e+00, - 1.3374025e+00, 1.3377767e+00, 1.3381511e+00, 1.3385258e+00, - 1.3389006e+00, 1.3392756e+00, 1.3396509e+00, 1.3400263e+00, - 1.3404018e+00, 1.3407776e+00, 1.3411535e+00, 1.3415297e+00, - 1.3419061e+00, 1.3422825e+00, 1.3426592e+00, 1.3430362e+00, - 1.3434132e+00, 1.3437905e+00, 1.3441681e+00, 1.3445457e+00, - 1.3449236e+00, 1.3453016e+00, 1.3456799e+00, 1.3460584e+00, - 1.3464370e+00, 1.3468158e+00, 1.3471949e+00, 1.3475741e+00, - 1.3479534e+00, 1.3483331e+00, 1.3487129e+00, 1.3490928e+00, - 1.3494731e+00, 1.3498535e+00, 1.3502340e+00, 1.3506148e+00, - 1.3509958e+00, 1.3513770e+00, 1.3517584e+00, 1.3521399e+00, - 1.3525217e+00, 1.3529036e+00, 1.3532858e+00, 1.3536681e+00, - 1.3540506e+00, 1.3544334e+00, 1.3548163e+00, 1.3551995e+00, - 1.3555828e+00, 1.3559663e+00, 1.3563502e+00, 1.3567340e+00, - 1.3571182e+00, 1.3575026e+00, 1.3578871e+00, 1.3582718e+00, - 1.3586568e+00, 1.3590419e+00, 1.3594273e+00, 1.3598129e+00, - 1.3601986e+00, 1.3605845e+00, 1.3609707e+00, 1.3613571e+00, - 1.3617436e+00, 1.3621304e+00, 1.3625174e+00, 1.3629045e+00, - 1.3632919e+00, 1.3636795e+00, 1.3640673e+00, 1.3644553e+00, - 1.3648435e+00, 1.3652319e+00, 1.3656205e+00, 1.3660094e+00, - 1.3663983e+00, 1.3667876e+00, 1.3671770e+00, 1.3675667e+00, - 1.3679565e+00, 1.3683466e+00, 1.3687369e+00, 1.3691274e+00, - 1.3695180e+00, 1.3699089e+00, 1.3703001e+00, 1.3706913e+00, - 1.3710829e+00, 1.3714746e+00, 1.3718666e+00, 1.3722587e+00, - 1.3726511e+00, 1.3730437e+00, 1.3734365e+00, 1.3738295e+00, - 1.3742226e+00, 1.3746161e+00, 1.3750098e+00, 1.3754036e+00, - 1.3757976e+00, 1.3761920e+00, 1.3765864e+00, 1.3769811e+00, - 1.3773761e+00, 1.3777713e+00, 1.3781666e+00, 1.3785622e+00, - 1.3789580e+00, 1.3793540e+00, 1.3797501e+00, 1.3801466e+00, - 1.3805432e+00, 1.3809402e+00, 1.3813373e+00, 1.3817345e+00, - 1.3821321e+00, 1.3825299e+00, 1.3829278e+00, 1.3833259e+00, - 1.3837243e+00, 1.3841230e+00, 1.3845218e+00, 1.3849208e+00, - 1.3853202e+00, 1.3857197e+00, 1.3861194e+00, 1.3865193e+00, - 1.3869195e+00, 1.3873199e+00, 1.3877205e+00, 1.3881214e+00, - 1.3885224e+00, 1.3889236e+00, 1.3893251e+00, 1.3897269e+00, - 1.3901289e+00, 1.3905311e+00, 1.3909335e+00, 1.3913361e+00, - 1.3917389e+00, 1.3921421e+00, 1.3925453e+00, 1.3929489e+00, - 1.3933526e+00, 1.3937566e+00, 1.3941609e+00, 1.3945652e+00, - 1.3949699e+00, 1.3953749e+00, 1.3957800e+00, 1.3961853e+00, - 1.3965909e+00, 1.3969967e+00, 1.3974028e+00, 1.3978090e+00, - 1.3982155e+00, 1.3986223e+00, 1.3990293e+00, 1.3994365e+00, - 1.3998439e+00, 1.4002516e+00, 1.4006594e+00, 1.4010676e+00, - 1.4014760e+00, 1.4018846e+00, 1.4022934e+00, 1.4027026e+00, - 1.4031118e+00, 1.4035214e+00, 1.4039311e+00, 1.4043411e+00, - 1.4047514e+00, 1.4051619e+00, 1.4055727e+00, 1.4059836e+00, - 1.4063947e+00, 1.4068062e+00, 1.4072179e+00, 1.4076297e+00, - 1.4080420e+00, 1.4084543e+00, 1.4088670e+00, 1.4092798e+00, - 1.4096929e+00, 1.4101063e+00, 1.4105198e+00, 1.4109337e+00, - 1.4113477e+00, 1.4117621e+00, 1.4121766e+00, 1.4125915e+00, - 1.4130065e+00, 1.4134218e+00, 1.4138373e+00, 1.4142531e+00, - 1.4146692e+00, 1.4150854e+00, 1.4155020e+00, 1.4159187e+00, - 1.4163357e+00, 1.4167529e+00, 1.4171704e+00, 1.4175881e+00, - 1.4180062e+00, 1.4184244e+00, 1.4188429e+00, 1.4192616e+00, - 1.4196806e+00, 1.4200999e+00, 1.4205194e+00, 1.4209391e+00, - 1.4213591e+00, 1.4217793e+00, 1.4221997e+00, 1.4226205e+00, - 1.4230415e+00, 1.4234627e+00, 1.4238843e+00, 1.4243060e+00, - 1.4247280e+00, 1.4251503e+00, 1.4255728e+00, 1.4259956e+00, - 1.4264185e+00, 1.4268419e+00, 1.4272654e+00, 1.4276892e+00, - 1.4281132e+00, 1.4285375e+00, 1.4289621e+00, 1.4293869e+00, - 1.4298120e+00, 1.4302373e+00, 1.4306629e+00, 1.4310887e+00, - 1.4315149e+00, 1.4319413e+00, 1.4323678e+00, 1.4327947e+00, - 1.4332219e+00, 1.4336493e+00, 1.4340770e+00, 1.4345050e+00, - 1.4349332e+00, 1.4353616e+00, 1.4357903e+00, 1.4362193e+00, - 1.4366486e+00, 1.4370781e+00, 1.4375079e+00, 1.4379380e+00, - 1.4383683e+00, 1.4387989e+00, 1.4392297e+00, 1.4396608e+00, - 1.4400922e+00, 1.4405239e+00, 1.4409558e+00, 1.4413880e+00, - 1.4418205e+00, 1.4422532e+00, 1.4426862e+00, 1.4431195e+00, - 1.4435530e+00, 1.4439869e+00, 1.4444209e+00, 1.4448553e+00, - 1.4452900e+00, 1.4457248e+00, 1.4461601e+00, 1.4465954e+00, - 1.4470313e+00, 1.4474672e+00, 1.4479035e+00, 1.4483401e+00, - 1.4487768e+00, 1.4492140e+00, 1.4496514e+00, 1.4500890e+00, - 1.4505270e+00, 1.4509652e+00, 1.4514037e+00, 1.4518424e+00, - 1.4522815e+00, 1.4527209e+00, 1.4531605e+00, 1.4536004e+00, - 1.4540405e+00, 1.4544810e+00, 1.4549217e+00, 1.4553628e+00, - 1.4558041e+00, 1.4562457e+00, 1.4566876e+00, 1.4571297e+00, - 1.4575722e+00, 1.4580150e+00, 1.4584579e+00, 1.4589013e+00, - 1.4593449e+00, 1.4597887e+00, 1.4602329e+00, 1.4606774e+00, - 1.4611222e+00, 1.4615672e+00, 1.4620124e+00, 1.4624581e+00, - 1.4629040e+00, 1.4633502e+00, 1.4637966e+00, 1.4642434e+00, - 1.4646906e+00, 1.4651378e+00, 1.4655856e+00, 1.4660335e+00, - 1.4664818e+00, 1.4669303e+00, 1.4673791e+00, 1.4678283e+00, - 1.4682777e+00, 1.4687275e+00, 1.4691775e+00, 1.4696277e+00, - 1.4700783e+00, 1.4705293e+00, 1.4709805e+00, 1.4714320e+00, - 1.4718839e+00, 1.4723359e+00, 1.4727883e+00, 1.4732411e+00, - 1.4736941e+00, 1.4741474e+00, 1.4746010e+00, 1.4750550e+00, - 1.4755093e+00, 1.4759638e+00, 1.4764186e+00, 1.4768738e+00, - 1.4773293e+00, 1.4777850e+00, 1.4782411e+00, 1.4786974e+00, - 1.4791541e+00, 1.4796112e+00, 1.4800684e+00, 1.4805261e+00, - 1.4809840e+00, 1.4814422e+00, 1.4819008e+00, 1.4823596e+00, - 1.4828188e+00, 1.4832783e+00, 1.4837381e+00, 1.4841982e+00, - 1.4846586e+00, 1.4851193e+00, 1.4855804e+00, 1.4860418e+00, - 1.4865035e+00, 1.4869655e+00, 1.4874278e+00, 1.4878905e+00, - 1.4883534e+00, 1.4888167e+00, 1.4892803e+00, 1.4897442e+00, - 1.4902085e+00, 1.4906731e+00, 1.4911379e+00, 1.4916031e+00, - 1.4920686e+00, 1.4925345e+00, 1.4930006e+00, 1.4934672e+00, - 1.4939340e+00, 1.4944011e+00, 1.4948686e+00, 1.4953364e+00, - 1.4958045e+00, 1.4962730e+00, 1.4967418e+00, 1.4972110e+00, - 1.4976804e+00, 1.4981502e+00, 1.4986203e+00, 1.4990907e+00, - 1.4995615e+00, 1.5000327e+00, 1.5005040e+00, 1.5009758e+00, - 1.5014479e+00, 1.5019203e+00, 1.5023931e+00, 1.5028663e+00, - 1.5033398e+00, 1.5038135e+00, 1.5042876e+00, 1.5047621e+00, - 1.5052369e+00, 1.5057120e+00, 1.5061876e+00, 1.5066633e+00, - 1.5071396e+00, 1.5076160e+00, 1.5080929e+00, 1.5085701e+00, - 1.5090476e+00, 1.5095254e+00, 1.5100037e+00, 1.5104823e+00, - 1.5109612e+00, 1.5114404e+00, 1.5119201e+00, 1.5124000e+00, - 1.5128803e+00, 1.5133610e+00, 1.5138420e+00, 1.5143234e+00, - 1.5148051e+00, 1.5152872e+00, 1.5157695e+00, 1.5162523e+00, - 1.5167354e+00, 1.5172189e+00, 1.5177027e+00, 1.5181869e+00, - 1.5186715e+00, 1.5191563e+00, 1.5196416e+00, 1.5201272e+00, - 1.5206132e+00, 1.5210996e+00, 1.5215862e+00, 1.5220733e+00, - 1.5225607e+00, 1.5230485e+00, 1.5235366e+00, 1.5240251e+00, - 1.5245140e+00, 1.5250032e+00, 1.5254928e+00, 1.5259827e+00, - 1.5264730e+00, 1.5269638e+00, 1.5274549e+00, 1.5279462e+00, - 1.5284381e+00, 1.5289302e+00, 1.5294228e+00, 1.5299157e+00, - 1.5304090e+00, 1.5309026e+00, 1.5313966e+00, 1.5318911e+00, - 1.5323858e+00, 1.5328810e+00, 1.5333766e+00, 1.5338725e+00, - 1.5343688e+00, 1.5348654e+00, 1.5353625e+00, 1.5358598e+00, - 1.5363576e+00, 1.5368558e+00, 1.5373545e+00, 1.5378534e+00, - 1.5383527e+00, 1.5388525e+00, 1.5393525e+00, 1.5398530e+00, - 1.5403539e+00, 1.5408552e+00, 1.5413568e+00, 1.5418588e+00, - 1.5423613e+00, 1.5428641e+00, 1.5433673e+00, 1.5438708e+00, - 1.5443748e+00, 1.5448792e+00, 1.5453839e+00, 1.5458891e+00, - 1.5463947e+00, 1.5469006e+00, 1.5474070e+00, 1.5479138e+00, - 1.5484209e+00, 1.5489284e+00, 1.5494363e+00, 1.5499448e+00, - 1.5504534e+00, 1.5509626e+00, 1.5514722e+00, 1.5519822e+00, - 1.5524925e+00, 1.5530032e+00, 1.5535144e+00, 1.5540260e+00, - 1.5545379e+00, 1.5550504e+00, 1.5555631e+00, 1.5560763e+00, - 1.5565900e+00, 1.5571040e+00, 1.5576184e+00, 1.5581332e+00, - 1.5586486e+00, 1.5591642e+00, 1.5596803e+00, 1.5601968e+00, - 1.5607138e+00, 1.5612311e+00, 1.5617489e+00, 1.5622671e+00, - 1.5627856e+00, 1.5633047e+00, 1.5638241e+00, 1.5643439e+00, - 1.5648643e+00, 1.5653850e+00, 1.5659060e+00, 1.5664277e+00, - 1.5669496e+00, 1.5674721e+00, 1.5679950e+00, 1.5685182e+00, - 1.5690418e+00, 1.5695660e+00, 1.5700905e+00, 1.5706155e+00, - 1.5711410e+00, 1.5716668e+00, 1.5721931e+00, 1.5727199e+00, - 1.5732471e+00, 1.5737747e+00, 1.5743027e+00, 1.5748312e+00, - 1.5753602e+00, 1.5758895e+00, 1.5764194e+00, 1.5769496e+00, - 1.5774803e+00, 1.5780114e+00, 1.5785429e+00, 1.5790750e+00, - 1.5796075e+00, 1.5801405e+00, 1.5806738e+00, 1.5812076e+00, - 1.5817419e+00, 1.5822767e+00, 1.5828118e+00, 1.5833474e+00, - 1.5838836e+00, 1.5844201e+00, 1.5849571e+00, 1.5854946e+00, - 1.5860325e+00, 1.5865709e+00, 1.5871097e+00, 1.5876490e+00, - 1.5881888e+00, 1.5887290e+00, 1.5892698e+00, 1.5898108e+00, - 1.5903525e+00, 1.5908946e+00, 1.5914371e+00, 1.5919802e+00, - 1.5925237e+00, 1.5930676e+00, 1.5936121e+00, 1.5941570e+00, - 1.5947024e+00, 1.5952482e+00, 1.5957946e+00, 1.5963414e+00, - 1.5968887e+00, 1.5974364e+00, 1.5979847e+00, 1.5985334e+00, - 1.5990826e+00, 1.5996323e+00, 1.6001825e+00, 1.6007332e+00, - 1.6012843e+00, 1.6018360e+00, 1.6023880e+00, 1.6029407e+00, - 1.6034938e+00, 1.6040474e+00, 1.6046015e+00, 1.6051561e+00, - 1.6057111e+00, 1.6062666e+00, 1.6068227e+00, 1.6073793e+00, - 1.6079364e+00, 1.6084939e+00, 1.6090519e+00, 1.6096106e+00, - 1.6101696e+00, 1.6107291e+00, 1.6112893e+00, 1.6118498e+00, - 1.6124109e+00, 1.6129725e+00, 1.6135346e+00, 1.6140972e+00, - 1.6146603e+00, 1.6152240e+00, 1.6157881e+00, 1.6163528e+00, - 1.6169180e+00, 1.6174836e+00, 1.6180499e+00, 1.6186166e+00, - 1.6191839e+00, 1.6197516e+00, 1.6203200e+00, 1.6208887e+00, - 1.6214581e+00, 1.6220280e+00, 1.6225984e+00, 1.6231693e+00, - 1.6237408e+00, 1.6243128e+00, 1.6248852e+00, 1.6254584e+00, - 1.6260319e+00, 1.6266060e+00, 1.6271807e+00, 1.6277559e+00, - 1.6283317e+00, 1.6289079e+00, 1.6294848e+00, 1.6300621e+00, - 1.6306400e+00, 1.6312184e+00, 1.6317974e+00, 1.6323770e+00, - 1.6329571e+00, 1.6335378e+00, 1.6341189e+00, 1.6347007e+00, - 1.6352830e+00, 1.6358658e+00, 1.6364492e+00, 1.6370332e+00, - 1.6376177e+00, 1.6382028e+00, 1.6387885e+00, 1.6393747e+00, - 1.6399615e+00, 1.6405488e+00, 1.6411368e+00, 1.6417252e+00, - 1.6423142e+00, 1.6429038e+00, 1.6434940e+00, 1.6440848e+00, - 1.6446761e+00, 1.6452681e+00, 1.6458606e+00, 1.6464536e+00, - 1.6470473e+00, 1.6476414e+00, 1.6482363e+00, 1.6488316e+00, - 1.6494277e+00, 1.6500242e+00, 1.6506214e+00, 1.6512191e+00, - 1.6518174e+00, 1.6524163e+00, 1.6530159e+00, 1.6536160e+00, - 1.6542166e+00, 1.6548179e+00, 1.6554199e+00, 1.6560224e+00, - 1.6566255e+00, 1.6572292e+00, 1.6578336e+00, 1.6584384e+00, - 1.6590440e+00, 1.6596501e+00, 1.6602569e+00, 1.6608642e+00, - 1.6614722e+00, 1.6620808e+00, 1.6626899e+00, 1.6632998e+00, - 1.6639103e+00, 1.6645213e+00, 1.6651330e+00, 1.6657453e+00, - 1.6663582e+00, 1.6669718e+00, 1.6675860e+00, 1.6682007e+00, - 1.6688162e+00, 1.6694323e+00, 1.6700491e+00, 1.6706663e+00, - 1.6712843e+00, 1.6719030e+00, 1.6725223e+00, 1.6731422e+00, - 1.6737627e+00, 1.6743839e+00, 1.6750058e+00, 1.6756283e+00, - 1.6762514e+00, 1.6768752e+00, 1.6774997e+00, 1.6781248e+00, - 1.6787505e+00, 1.6793770e+00, 1.6800040e+00, 1.6806318e+00, - 1.6812601e+00, 1.6818892e+00, 1.6825190e+00, 1.6831493e+00, - 1.6837804e+00, 1.6844121e+00, 1.6850445e+00, 1.6856776e+00, - 1.6863114e+00, 1.6869458e+00, 1.6875809e+00, 1.6882168e+00, - 1.6888533e+00, 1.6894904e+00, 1.6901283e+00, 1.6907668e+00, - 1.6914060e+00, 1.6920460e+00, 1.6926867e+00, 1.6933279e+00, - 1.6939700e+00, 1.6946126e+00, 1.6952561e+00, 1.6959002e+00, - 1.6965450e+00, 1.6971905e+00, 1.6978368e+00, 1.6984837e+00, - 1.6991314e+00, 1.6997797e+00, 1.7004288e+00, 1.7010787e+00, - 1.7017292e+00, 1.7023804e+00, 1.7030324e+00, 1.7036850e+00, - 1.7043386e+00, 1.7049927e+00, 1.7056475e+00, 1.7063031e+00, - 1.7069595e+00, 1.7076166e+00, 1.7082744e+00, 1.7089329e+00, - 1.7095922e+00, 1.7102523e+00, 1.7109131e+00, 1.7115746e+00, - 1.7122369e+00, 1.7128999e+00, 1.7135637e+00, 1.7142283e+00, - 1.7148936e+00, 1.7155596e+00, 1.7162265e+00, 1.7168940e+00, - 1.7175624e+00, 1.7182316e+00, 1.7189014e+00, 1.7195721e+00, - 1.7202436e+00, 1.7209158e+00, 1.7215887e+00, 1.7222625e+00, - 1.7229371e+00, 1.7236124e+00, 1.7242886e+00, 1.7249656e+00, - 1.7256433e+00, 1.7263217e+00, 1.7270011e+00, 1.7276812e+00, - 1.7283621e+00, 1.7290437e+00, 1.7297263e+00, 1.7304096e+00, - 1.7310936e+00, 1.7317786e+00, 1.7324644e+00, 1.7331510e+00, - 1.7338383e+00, 1.7345265e+00, 1.7352155e+00, 1.7359054e+00, - 1.7365961e+00, 1.7372876e+00, 1.7379799e+00, 1.7386731e+00, - 1.7393671e+00, 1.7400620e+00, 1.7407576e+00, 1.7414541e+00, - 1.7421515e+00, 1.7428498e+00, 1.7435489e+00, 1.7442487e+00, - 1.7449496e+00, 1.7456512e+00, 1.7463537e+00, 1.7470571e+00, - 1.7477614e+00, 1.7484664e+00, 1.7491723e+00, 1.7498792e+00, - 1.7505870e+00, 1.7512956e+00, 1.7520050e+00, 1.7527153e+00, - 1.7534267e+00, 1.7541387e+00, 1.7548518e+00, 1.7555658e+00, - 1.7562805e+00, 1.7569963e+00, 1.7577128e+00, 1.7584304e+00, - 1.7591488e+00, 1.7598681e+00, 1.7605884e+00, 1.7613095e+00, - 1.7620316e+00, 1.7627546e+00, 1.7634785e+00, 1.7642033e+00, - 1.7649292e+00, 1.7656559e+00, 1.7663834e+00, 1.7671120e+00, - 1.7678416e+00, 1.7685720e+00, 1.7693034e+00, 1.7700357e+00, - 1.7707690e+00, 1.7715033e+00, 1.7722385e+00, 1.7729746e+00, - 1.7737118e+00, 1.7744499e+00, 1.7751889e+00, 1.7759290e+00, - 1.7766700e+00, 1.7774119e+00, 1.7781550e+00, 1.7788988e+00, - 1.7796438e+00, 1.7803898e+00, 1.7811366e+00, 1.7818846e+00, - 1.7826334e+00, 1.7833834e+00, 1.7841343e+00, 1.7848862e+00, - 1.7856392e+00, 1.7863930e+00, 1.7871480e+00, 1.7879040e+00, - 1.7886610e+00, 1.7894191e+00, 1.7901781e+00, 1.7909381e+00, - 1.7916993e+00, 1.7924615e+00, 1.7932247e+00, 1.7939889e+00, - 1.7947543e+00, 1.7955205e+00, 1.7962880e+00, 1.7970564e+00, - 1.7978261e+00, 1.7985966e+00, 1.7993683e+00, 1.8001410e+00, - 1.8009149e+00, 1.8016897e+00, 1.8024657e+00, 1.8032428e+00, - 1.8040210e+00, 1.8048003e+00, 1.8055806e+00, 1.8063620e+00, - 1.8071445e+00, 1.8079282e+00, 1.8087131e+00, 1.8094989e+00, - 1.8102859e+00, 1.8110740e+00, 1.8118633e+00, 1.8126537e+00, - 1.8134452e+00, 1.8142380e+00, 1.8150318e+00, 1.8158267e+00, - 1.8166227e+00, 1.8174200e+00, 1.8182185e+00, 1.8190180e+00, - 1.8198187e+00, 1.8206207e+00, 1.8214238e+00, 1.8222280e+00, - 1.8230335e+00, 1.8238400e+00, 1.8246478e+00, 1.8254569e+00, - 1.8262670e+00, 1.8270785e+00, 1.8278910e+00, 1.8287048e+00, - 1.8295199e+00, 1.8303361e+00, 1.8311535e+00, 1.8319722e+00, - 1.8327922e+00, 1.8336133e+00, 1.8344357e+00, 1.8352593e+00, - 1.8360841e+00, 1.8369104e+00, 1.8377377e+00, 1.8385663e+00, - 1.8393962e+00, 1.8402274e+00, 1.8410599e+00, 1.8418936e+00, - 1.8427286e+00, 1.8435649e+00, 1.8444026e+00, 1.8452414e+00, - 1.8460816e+00, 1.8469231e+00, 1.8477658e+00, 1.8486099e+00, - 1.8494554e+00, 1.8503022e+00, 1.8511503e+00, 1.8519996e+00, - 1.8528504e+00, 1.8537025e+00, 1.8545560e+00, 1.8554108e+00, - 1.8562670e+00, 1.8571244e+00, 1.8579834e+00, 1.8588436e+00, - 1.8597052e+00, 1.8605683e+00, 1.8614327e+00, 1.8622985e+00, - 1.8631657e+00, 1.8640343e+00, 1.8649043e+00, 1.8657757e+00, - 1.8666486e+00, 1.8675228e+00, 1.8683985e+00, 1.8692757e+00, - 1.8701543e+00, 1.8710344e+00, 1.8719158e+00, 1.8727987e+00, - 1.8736831e+00, 1.8745691e+00, 1.8754563e+00, 1.8763452e+00, - 1.8772354e+00, 1.8781272e+00, 1.8790206e+00, 1.8799154e+00, - 1.8808116e+00, 1.8817095e+00, 1.8826088e+00, 1.8835096e+00, - 1.8844121e+00, 1.8853159e+00, 1.8862214e+00, 1.8871284e+00, - 1.8880370e+00, 1.8889471e+00, 1.8898588e+00, 1.8907721e+00, - 1.8916869e+00, 1.8926034e+00, 1.8935214e+00, 1.8944410e+00, - 1.8953623e+00, 1.8962852e+00, 1.8972095e+00, 1.8981357e+00, - 1.8990633e+00, 1.8999927e+00, 1.9009237e+00, 1.9018564e+00, - 1.9027907e+00, 1.9037267e+00, 1.9046643e+00, 1.9056036e+00, - 1.9065447e+00, 1.9074874e+00, 1.9084318e+00, 1.9093778e+00, - 1.9103256e+00, 1.9112751e+00, 1.9122264e+00, 1.9131794e+00, - 1.9141341e+00, 1.9150907e+00, 1.9160489e+00, 1.9170089e+00, - 1.9179707e+00, 1.9189342e+00, 1.9198995e+00, 1.9208666e+00, - 1.9218355e+00, 1.9228063e+00, 1.9237788e+00, 1.9247532e+00, - 1.9257294e+00, 1.9267074e+00, 1.9276873e+00, 1.9286691e+00, - 1.9296527e+00, 1.9306381e+00, 1.9316255e+00, 1.9326147e+00, - 1.9336058e+00, 1.9345989e+00, 1.9355938e+00, 1.9365907e+00, - 1.9375895e+00, 1.9385902e+00, 1.9395928e+00, 1.9405975e+00, - 1.9416041e+00, 1.9426126e+00, 1.9436232e+00, 1.9446357e+00, - 1.9456502e+00, 1.9466668e+00, 1.9476854e+00, 1.9487059e+00, - 1.9497285e+00, 1.9507532e+00, 1.9517798e+00, 1.9528086e+00, - 1.9538395e+00, 1.9548724e+00, 1.9559075e+00, 1.9569446e+00, - 1.9579837e+00, 1.9590250e+00, 1.9600686e+00, 1.9611142e+00, - 1.9621619e+00, 1.9632118e+00, 1.9642639e+00, 1.9653181e+00, - 1.9663746e+00, 1.9674332e+00, 1.9684941e+00, 1.9695572e+00, - 1.9706224e+00, 1.9716901e+00, 1.9727598e+00, 1.9738319e+00, - 1.9749062e+00, 1.9759828e+00, 1.9770617e+00, 1.9781430e+00, - 1.9792265e+00, 1.9803123e+00, 1.9814006e+00, 1.9824911e+00, - 1.9835840e+00, 1.9846793e+00, 1.9857770e+00, 1.9868771e+00, - 1.9879795e+00, 1.9890845e+00, 1.9901918e+00, 1.9913017e+00, - 1.9924139e+00, 1.9935286e+00, 1.9946458e+00, 1.9957654e+00, - 1.9968877e+00, 1.9980124e+00, 1.9991397e+00, 2.0002694e+00, - 2.0014019e+00, 2.0025368e+00, 2.0036743e+00, 2.0048144e+00, - 2.0059571e+00, 2.0071025e+00, 2.0082505e+00, 2.0094011e+00, - 2.0105543e+00, 2.0117104e+00, 2.0128691e+00, 2.0140305e+00, - 2.0151947e+00, 2.0163615e+00, 2.0175312e+00, 2.0187035e+00, - 2.0198786e+00, 2.0210567e+00, 2.0222373e+00, 2.0234210e+00, - 2.0246074e+00, 2.0257967e+00, 2.0269887e+00, 2.0281839e+00, - 2.0293818e+00, 2.0305827e+00, 2.0317864e+00, 2.0329933e+00, - 2.0342031e+00, 2.0354156e+00, 2.0366313e+00, 2.0378501e+00, - 2.0390718e+00, 2.0402968e+00, 2.0415246e+00, 2.0427556e+00, - 2.0439897e+00, 2.0452268e+00, 2.0464671e+00, 2.0477107e+00, - 2.0489573e+00, 2.0502071e+00, 2.0514603e+00, 2.0527165e+00, - 2.0539761e+00, 2.0552390e+00, 2.0565050e+00, 2.0577743e+00, - 2.0590472e+00, 2.0603232e+00, 2.0616026e+00, 2.0628855e+00, - 2.0641716e+00, 2.0654614e+00, 2.0667543e+00, 2.0680509e+00, - 2.0693510e+00, 2.0706546e+00, 2.0719616e+00, 2.0732722e+00, - 2.0745864e+00, 2.0759041e+00, 2.0772257e+00, 2.0785506e+00, - 2.0798793e+00, 2.0812118e+00, 2.0825479e+00, 2.0838876e+00, - 2.0852313e+00, 2.0865786e+00, 2.0879297e+00, 2.0892847e+00, - 2.0906434e+00, 2.0920062e+00, 2.0933728e+00, 2.0947433e+00, - 2.0961177e+00, 2.0974960e+00, 2.0988786e+00, 2.1002650e+00, - 2.1016555e+00, 2.1030500e+00, 2.1044486e+00, 2.1058514e+00, - 2.1072583e+00, 2.1086695e+00, 2.1100848e+00, 2.1115043e+00, - 2.1129284e+00, 2.1143565e+00, 2.1157889e+00, 2.1172256e+00, - 2.1186669e+00, 2.1201127e+00, 2.1215627e+00, 2.1230171e+00, - 2.1244762e+00, 2.1259398e+00, 2.1274080e+00, 2.1288807e+00, - 2.1303580e+00, 2.1318402e+00, 2.1333268e+00, 2.1348183e+00, - 2.1363146e+00, 2.1378157e+00, 2.1393216e+00, 2.1408322e+00, - 2.1423478e+00, 2.1438684e+00, 2.1453941e+00, 2.1469245e+00, - 2.1484601e+00, 2.1500008e+00, 2.1515467e+00, 2.1530976e+00, - 2.1546538e+00, 2.1562152e+00, 2.1577818e+00, 2.1593540e+00, - 2.1609311e+00, 2.1625140e+00, 2.1641021e+00, 2.1656959e+00, - 2.1672950e+00, 2.1688998e+00, 2.1705101e+00, 2.1721261e+00, - 2.1737478e+00, 2.1753752e+00, 2.1770084e+00, 2.1786473e+00, - 2.1802921e+00, 2.1819429e+00, 2.1835999e+00, 2.1852627e+00, - 2.1869316e+00, 2.1886065e+00, 2.1902876e+00, 2.1919749e+00, - 2.1936686e+00, 2.1953685e+00, 2.1970749e+00, 2.1987877e+00, - 2.2005067e+00, 2.2022326e+00, 2.2039647e+00, 2.2057037e+00, - 2.2074494e+00, 2.2092018e+00, 2.2109611e+00, 2.2127271e+00, - 2.2145002e+00, 2.2162802e+00, 2.2180672e+00, 2.2198613e+00, - 2.2216625e+00, 2.2234712e+00, 2.2252872e+00, 2.2271104e+00, - 2.2289410e+00, 2.2307792e+00, 2.2326250e+00, 2.2344782e+00, - 2.2363393e+00, 2.2382083e+00, 2.2400849e+00, 2.2419696e+00, - 2.2438622e+00, 2.2457631e+00, 2.2476718e+00, 2.2495890e+00, - 2.2515142e+00, 2.2534480e+00, 2.2553902e+00, 2.2573411e+00, - 2.2593005e+00, 2.2612686e+00, 2.2632456e+00, 2.2652314e+00, - 2.2672260e+00, 2.2692299e+00, 2.2712429e+00, 2.2732651e+00, - 2.2752967e+00, 2.2773378e+00, 2.2793882e+00, 2.2814484e+00, - 2.2835183e+00, 2.2855980e+00, 2.2876878e+00, 2.2897875e+00, - 2.2918973e+00, 2.2940173e+00, 2.2961478e+00, 2.2982888e+00, - 2.3004403e+00, 2.3026025e+00, 2.3047755e+00, 2.3069596e+00, - 2.3091545e+00, 2.3113608e+00, 2.3135784e+00, 2.3158073e+00, - 2.3180478e+00, 2.3203001e+00, 2.3225641e+00, 2.3248401e+00, - 2.3271282e+00, 2.3294287e+00, 2.3317413e+00, 2.3340669e+00, - 2.3364048e+00, 2.3387556e+00, 2.3411195e+00, 2.3434966e+00, - 2.3458867e+00, 2.3482907e+00, 2.3507080e+00, 2.3531394e+00, - 2.3555846e+00, 2.3580439e+00, 2.3605177e+00, 2.3630061e+00, - 2.3655090e+00, 2.3680270e+00, 2.3705599e+00, 2.3731084e+00, - 2.3756721e+00, 2.3782516e+00, 2.3808472e+00, 2.3834586e+00, - 2.3860867e+00, 2.3887312e+00, 2.3913925e+00, 2.3940709e+00, - 2.3967667e+00, 2.3994799e+00, 2.4022110e+00, 2.4049599e+00, - 2.4077272e+00, 2.4105132e+00, 2.4133179e+00, 2.4161417e+00, - 2.4189849e+00, 2.4218478e+00, 2.4247308e+00, 2.4276340e+00, - 2.4305577e+00, 2.4335027e+00, 2.4364686e+00, 2.4394562e+00, - 2.4424658e+00, 2.4454975e+00, 2.4485519e+00, 2.4516294e+00, - 2.4547303e+00, 2.4578550e+00, 2.4610038e+00, 2.4641774e+00, - 2.4673758e+00, 2.4705997e+00, 2.4738493e+00, 2.4771256e+00, - 2.4804285e+00, 2.4837587e+00, 2.4871166e+00, 2.4905028e+00, - 2.4939179e+00, 2.4973624e+00, 2.5008366e+00, 2.5043414e+00, - 2.5078771e+00, 2.5114446e+00, 2.5150442e+00, 2.5186768e+00, - 2.5223429e+00, 2.5260432e+00, 2.5297785e+00, 2.5335493e+00, - 2.5373566e+00, 2.5412009e+00, 2.5450833e+00, 2.5490043e+00, - 2.5529649e+00, 2.5569661e+00, 2.5610085e+00, 2.5650933e+00, - 2.5692213e+00, 2.5733936e+00, 2.5776110e+00, 2.5818748e+00, - 2.5861864e+00, 2.5905464e+00, 2.5949562e+00, 2.5994170e+00, - 2.6039300e+00, 2.6084969e+00, 2.6131189e+00, 2.6177971e+00, - 2.6225336e+00, 2.6273296e+00, 2.6321869e+00, 2.6371069e+00, - 2.6420918e+00, 2.6471431e+00, 2.6522629e+00, 2.6574533e+00, - 2.6627162e+00, 2.6680539e+00, 2.6734686e+00, 2.6789629e+00, - 2.6845396e+00, 2.6902006e+00, 2.6959493e+00, 2.7017887e+00, - 2.7077217e+00, 2.7137513e+00, 2.7198815e+00, 2.7261155e+00, - 2.7324574e+00, 2.7389109e+00, 2.7454808e+00, 2.7521713e+00, - 2.7589874e+00, 2.7659342e+00, 2.7730169e+00, 2.7802417e+00, - 2.7876146e+00, 2.7951422e+00, 2.8028316e+00, 2.8106904e+00, - 2.8187268e+00, 2.8269496e+00, 2.8353682e+00, 2.8439925e+00, - 2.8528337e+00, 2.8619039e+00, 2.8712158e+00, 2.8807836e+00, - 2.8906226e+00, 2.9007499e+00, 2.9111838e+00, 2.9219446e+00, - 2.9330549e+00, 2.9445398e+00, 2.9564269e+00, 2.9687471e+00, - 2.9815352e+00, 2.9948308e+00, 3.0086782e+00, 3.0231280e+00, - 3.0382385e+00, 3.0540769e+00, 3.0707211e+00, 3.0882633e+00, - 3.1068115e+00, 3.1264958e+00, 3.1474738e+00, 3.1699378e+00, - 3.1941290e+00, 3.2203522e+00, 3.2490034e+00, 3.2806098e+00, - 3.3158946e+00, 3.3558927e+00, 3.4021609e+00, 3.4572146e+00, - 3.5255561e+00, 3.6167130e+00, 3.7595601e+00, 4.0255485e+00 +static const real + gaussian_table[16384] = { + -4.0255485e+00, -3.7595601e+00, -3.6167130e+00, -3.5255561e+00, + -3.4572146e+00, -3.4021609e+00, -3.3558927e+00, -3.3158946e+00, + -3.2806098e+00, -3.2490034e+00, -3.2203522e+00, -3.1941290e+00, + -3.1699378e+00, -3.1474738e+00, -3.1264958e+00, -3.1068115e+00, + -3.0882633e+00, -3.0707211e+00, -3.0540769e+00, -3.0382385e+00, + -3.0231280e+00, -3.0086782e+00, -2.9948308e+00, -2.9815352e+00, + -2.9687471e+00, -2.9564269e+00, -2.9445398e+00, -2.9330549e+00, + -2.9219446e+00, -2.9111838e+00, -2.9007499e+00, -2.8906226e+00, + -2.8807836e+00, -2.8712158e+00, -2.8619039e+00, -2.8528337e+00, + -2.8439925e+00, -2.8353682e+00, -2.8269496e+00, -2.8187268e+00, + -2.8106904e+00, -2.8028316e+00, -2.7951422e+00, -2.7876146e+00, + -2.7802417e+00, -2.7730169e+00, -2.7659342e+00, -2.7589874e+00, + -2.7521713e+00, -2.7454808e+00, -2.7389109e+00, -2.7324574e+00, + -2.7261155e+00, -2.7198815e+00, -2.7137513e+00, -2.7077217e+00, + -2.7017887e+00, -2.6959493e+00, -2.6902006e+00, -2.6845396e+00, + -2.6789629e+00, -2.6734686e+00, -2.6680539e+00, -2.6627162e+00, + -2.6574533e+00, -2.6522629e+00, -2.6471431e+00, -2.6420918e+00, + -2.6371069e+00, -2.6321869e+00, -2.6273296e+00, -2.6225336e+00, + -2.6177971e+00, -2.6131189e+00, -2.6084969e+00, -2.6039300e+00, + -2.5994170e+00, -2.5949562e+00, -2.5905464e+00, -2.5861864e+00, + -2.5818748e+00, -2.5776110e+00, -2.5733936e+00, -2.5692213e+00, + -2.5650933e+00, -2.5610085e+00, -2.5569661e+00, -2.5529649e+00, + -2.5490043e+00, -2.5450833e+00, -2.5412009e+00, -2.5373566e+00, + -2.5335493e+00, -2.5297785e+00, -2.5260432e+00, -2.5223429e+00, + -2.5186768e+00, -2.5150442e+00, -2.5114446e+00, -2.5078771e+00, + -2.5043414e+00, -2.5008366e+00, -2.4973624e+00, -2.4939179e+00, + -2.4905028e+00, -2.4871166e+00, -2.4837587e+00, -2.4804285e+00, + -2.4771256e+00, -2.4738493e+00, -2.4705997e+00, -2.4673758e+00, + -2.4641774e+00, -2.4610038e+00, -2.4578550e+00, -2.4547303e+00, + -2.4516294e+00, -2.4485519e+00, -2.4454975e+00, -2.4424658e+00, + -2.4394562e+00, -2.4364686e+00, -2.4335027e+00, -2.4305577e+00, + -2.4276340e+00, -2.4247308e+00, -2.4218478e+00, -2.4189849e+00, + -2.4161417e+00, -2.4133179e+00, -2.4105132e+00, -2.4077272e+00, + -2.4049599e+00, -2.4022110e+00, -2.3994799e+00, -2.3967667e+00, + -2.3940709e+00, -2.3913925e+00, -2.3887312e+00, -2.3860867e+00, + -2.3834586e+00, -2.3808472e+00, -2.3782516e+00, -2.3756721e+00, + -2.3731084e+00, -2.3705599e+00, -2.3680270e+00, -2.3655090e+00, + -2.3630061e+00, -2.3605177e+00, -2.3580439e+00, -2.3555846e+00, + -2.3531394e+00, -2.3507080e+00, -2.3482907e+00, -2.3458867e+00, + -2.3434966e+00, -2.3411195e+00, -2.3387556e+00, -2.3364048e+00, + -2.3340669e+00, -2.3317413e+00, -2.3294287e+00, -2.3271282e+00, + -2.3248401e+00, -2.3225641e+00, -2.3203001e+00, -2.3180478e+00, + -2.3158073e+00, -2.3135784e+00, -2.3113608e+00, -2.3091545e+00, + -2.3069596e+00, -2.3047755e+00, -2.3026025e+00, -2.3004403e+00, + -2.2982888e+00, -2.2961478e+00, -2.2940173e+00, -2.2918973e+00, + -2.2897875e+00, -2.2876878e+00, -2.2855980e+00, -2.2835183e+00, + -2.2814484e+00, -2.2793882e+00, -2.2773378e+00, -2.2752967e+00, + -2.2732651e+00, -2.2712429e+00, -2.2692299e+00, -2.2672260e+00, + -2.2652314e+00, -2.2632456e+00, -2.2612686e+00, -2.2593005e+00, + -2.2573411e+00, -2.2553902e+00, -2.2534480e+00, -2.2515142e+00, + -2.2495890e+00, -2.2476718e+00, -2.2457631e+00, -2.2438622e+00, + -2.2419696e+00, -2.2400849e+00, -2.2382083e+00, -2.2363393e+00, + -2.2344782e+00, -2.2326250e+00, -2.2307792e+00, -2.2289410e+00, + -2.2271104e+00, -2.2252872e+00, -2.2234712e+00, -2.2216625e+00, + -2.2198613e+00, -2.2180672e+00, -2.2162802e+00, -2.2145002e+00, + -2.2127271e+00, -2.2109611e+00, -2.2092018e+00, -2.2074494e+00, + -2.2057037e+00, -2.2039647e+00, -2.2022326e+00, -2.2005067e+00, + -2.1987877e+00, -2.1970749e+00, -2.1953685e+00, -2.1936686e+00, + -2.1919749e+00, -2.1902876e+00, -2.1886065e+00, -2.1869316e+00, + -2.1852627e+00, -2.1835999e+00, -2.1819429e+00, -2.1802921e+00, + -2.1786473e+00, -2.1770084e+00, -2.1753752e+00, -2.1737478e+00, + -2.1721261e+00, -2.1705101e+00, -2.1688998e+00, -2.1672950e+00, + -2.1656959e+00, -2.1641021e+00, -2.1625140e+00, -2.1609311e+00, + -2.1593540e+00, -2.1577818e+00, -2.1562152e+00, -2.1546538e+00, + -2.1530976e+00, -2.1515467e+00, -2.1500008e+00, -2.1484601e+00, + -2.1469245e+00, -2.1453941e+00, -2.1438684e+00, -2.1423478e+00, + -2.1408322e+00, -2.1393216e+00, -2.1378157e+00, -2.1363146e+00, + -2.1348183e+00, -2.1333268e+00, -2.1318402e+00, -2.1303580e+00, + -2.1288807e+00, -2.1274080e+00, -2.1259398e+00, -2.1244762e+00, + -2.1230171e+00, -2.1215627e+00, -2.1201127e+00, -2.1186669e+00, + -2.1172256e+00, -2.1157889e+00, -2.1143565e+00, -2.1129284e+00, + -2.1115043e+00, -2.1100848e+00, -2.1086695e+00, -2.1072583e+00, + -2.1058514e+00, -2.1044486e+00, -2.1030500e+00, -2.1016555e+00, + -2.1002650e+00, -2.0988786e+00, -2.0974960e+00, -2.0961177e+00, + -2.0947433e+00, -2.0933728e+00, -2.0920062e+00, -2.0906434e+00, + -2.0892847e+00, -2.0879297e+00, -2.0865786e+00, -2.0852313e+00, + -2.0838876e+00, -2.0825479e+00, -2.0812118e+00, -2.0798793e+00, + -2.0785506e+00, -2.0772257e+00, -2.0759041e+00, -2.0745864e+00, + -2.0732722e+00, -2.0719616e+00, -2.0706546e+00, -2.0693510e+00, + -2.0680509e+00, -2.0667543e+00, -2.0654614e+00, -2.0641716e+00, + -2.0628855e+00, -2.0616026e+00, -2.0603232e+00, -2.0590472e+00, + -2.0577743e+00, -2.0565050e+00, -2.0552390e+00, -2.0539761e+00, + -2.0527165e+00, -2.0514603e+00, -2.0502071e+00, -2.0489573e+00, + -2.0477107e+00, -2.0464671e+00, -2.0452268e+00, -2.0439897e+00, + -2.0427556e+00, -2.0415246e+00, -2.0402968e+00, -2.0390718e+00, + -2.0378501e+00, -2.0366313e+00, -2.0354156e+00, -2.0342031e+00, + -2.0329933e+00, -2.0317864e+00, -2.0305827e+00, -2.0293818e+00, + -2.0281839e+00, -2.0269887e+00, -2.0257967e+00, -2.0246074e+00, + -2.0234210e+00, -2.0222373e+00, -2.0210567e+00, -2.0198786e+00, + -2.0187035e+00, -2.0175312e+00, -2.0163615e+00, -2.0151947e+00, + -2.0140305e+00, -2.0128691e+00, -2.0117104e+00, -2.0105543e+00, + -2.0094011e+00, -2.0082505e+00, -2.0071025e+00, -2.0059571e+00, + -2.0048144e+00, -2.0036743e+00, -2.0025368e+00, -2.0014019e+00, + -2.0002694e+00, -1.9991397e+00, -1.9980124e+00, -1.9968877e+00, + -1.9957654e+00, -1.9946458e+00, -1.9935286e+00, -1.9924139e+00, + -1.9913017e+00, -1.9901918e+00, -1.9890845e+00, -1.9879795e+00, + -1.9868771e+00, -1.9857770e+00, -1.9846793e+00, -1.9835840e+00, + -1.9824911e+00, -1.9814006e+00, -1.9803123e+00, -1.9792265e+00, + -1.9781430e+00, -1.9770617e+00, -1.9759828e+00, -1.9749062e+00, + -1.9738319e+00, -1.9727598e+00, -1.9716901e+00, -1.9706224e+00, + -1.9695572e+00, -1.9684941e+00, -1.9674332e+00, -1.9663746e+00, + -1.9653181e+00, -1.9642639e+00, -1.9632118e+00, -1.9621619e+00, + -1.9611142e+00, -1.9600686e+00, -1.9590250e+00, -1.9579837e+00, + -1.9569446e+00, -1.9559075e+00, -1.9548724e+00, -1.9538395e+00, + -1.9528086e+00, -1.9517798e+00, -1.9507532e+00, -1.9497285e+00, + -1.9487059e+00, -1.9476854e+00, -1.9466668e+00, -1.9456502e+00, + -1.9446357e+00, -1.9436232e+00, -1.9426126e+00, -1.9416041e+00, + -1.9405975e+00, -1.9395928e+00, -1.9385902e+00, -1.9375895e+00, + -1.9365907e+00, -1.9355938e+00, -1.9345989e+00, -1.9336058e+00, + -1.9326147e+00, -1.9316255e+00, -1.9306381e+00, -1.9296527e+00, + -1.9286691e+00, -1.9276873e+00, -1.9267074e+00, -1.9257294e+00, + -1.9247532e+00, -1.9237788e+00, -1.9228063e+00, -1.9218355e+00, + -1.9208666e+00, -1.9198995e+00, -1.9189342e+00, -1.9179707e+00, + -1.9170089e+00, -1.9160489e+00, -1.9150907e+00, -1.9141341e+00, + -1.9131794e+00, -1.9122264e+00, -1.9112751e+00, -1.9103256e+00, + -1.9093778e+00, -1.9084318e+00, -1.9074874e+00, -1.9065447e+00, + -1.9056036e+00, -1.9046643e+00, -1.9037267e+00, -1.9027907e+00, + -1.9018564e+00, -1.9009237e+00, -1.8999927e+00, -1.8990633e+00, + -1.8981357e+00, -1.8972095e+00, -1.8962852e+00, -1.8953623e+00, + -1.8944410e+00, -1.8935214e+00, -1.8926034e+00, -1.8916869e+00, + -1.8907721e+00, -1.8898588e+00, -1.8889471e+00, -1.8880370e+00, + -1.8871284e+00, -1.8862214e+00, -1.8853159e+00, -1.8844121e+00, + -1.8835096e+00, -1.8826088e+00, -1.8817095e+00, -1.8808116e+00, + -1.8799154e+00, -1.8790206e+00, -1.8781272e+00, -1.8772354e+00, + -1.8763452e+00, -1.8754563e+00, -1.8745691e+00, -1.8736831e+00, + -1.8727987e+00, -1.8719158e+00, -1.8710344e+00, -1.8701543e+00, + -1.8692757e+00, -1.8683985e+00, -1.8675228e+00, -1.8666486e+00, + -1.8657757e+00, -1.8649043e+00, -1.8640343e+00, -1.8631657e+00, + -1.8622985e+00, -1.8614327e+00, -1.8605683e+00, -1.8597052e+00, + -1.8588436e+00, -1.8579834e+00, -1.8571244e+00, -1.8562670e+00, + -1.8554108e+00, -1.8545560e+00, -1.8537025e+00, -1.8528504e+00, + -1.8519996e+00, -1.8511503e+00, -1.8503022e+00, -1.8494554e+00, + -1.8486099e+00, -1.8477658e+00, -1.8469231e+00, -1.8460816e+00, + -1.8452414e+00, -1.8444026e+00, -1.8435649e+00, -1.8427286e+00, + -1.8418936e+00, -1.8410599e+00, -1.8402274e+00, -1.8393962e+00, + -1.8385663e+00, -1.8377377e+00, -1.8369104e+00, -1.8360841e+00, + -1.8352593e+00, -1.8344357e+00, -1.8336133e+00, -1.8327922e+00, + -1.8319722e+00, -1.8311535e+00, -1.8303361e+00, -1.8295199e+00, + -1.8287048e+00, -1.8278910e+00, -1.8270785e+00, -1.8262670e+00, + -1.8254569e+00, -1.8246478e+00, -1.8238400e+00, -1.8230335e+00, + -1.8222280e+00, -1.8214238e+00, -1.8206207e+00, -1.8198187e+00, + -1.8190180e+00, -1.8182185e+00, -1.8174200e+00, -1.8166227e+00, + -1.8158267e+00, -1.8150318e+00, -1.8142380e+00, -1.8134452e+00, + -1.8126537e+00, -1.8118633e+00, -1.8110740e+00, -1.8102859e+00, + -1.8094989e+00, -1.8087131e+00, -1.8079282e+00, -1.8071445e+00, + -1.8063620e+00, -1.8055806e+00, -1.8048003e+00, -1.8040210e+00, + -1.8032428e+00, -1.8024657e+00, -1.8016897e+00, -1.8009149e+00, + -1.8001410e+00, -1.7993683e+00, -1.7985966e+00, -1.7978261e+00, + -1.7970564e+00, -1.7962880e+00, -1.7955205e+00, -1.7947543e+00, + -1.7939889e+00, -1.7932247e+00, -1.7924615e+00, -1.7916993e+00, + -1.7909381e+00, -1.7901781e+00, -1.7894191e+00, -1.7886610e+00, + -1.7879040e+00, -1.7871480e+00, -1.7863930e+00, -1.7856392e+00, + -1.7848862e+00, -1.7841343e+00, -1.7833834e+00, -1.7826334e+00, + -1.7818846e+00, -1.7811366e+00, -1.7803898e+00, -1.7796438e+00, + -1.7788988e+00, -1.7781550e+00, -1.7774119e+00, -1.7766700e+00, + -1.7759290e+00, -1.7751889e+00, -1.7744499e+00, -1.7737118e+00, + -1.7729746e+00, -1.7722385e+00, -1.7715033e+00, -1.7707690e+00, + -1.7700357e+00, -1.7693034e+00, -1.7685720e+00, -1.7678416e+00, + -1.7671120e+00, -1.7663834e+00, -1.7656559e+00, -1.7649292e+00, + -1.7642033e+00, -1.7634785e+00, -1.7627546e+00, -1.7620316e+00, + -1.7613095e+00, -1.7605884e+00, -1.7598681e+00, -1.7591488e+00, + -1.7584304e+00, -1.7577128e+00, -1.7569963e+00, -1.7562805e+00, + -1.7555658e+00, -1.7548518e+00, -1.7541387e+00, -1.7534267e+00, + -1.7527153e+00, -1.7520050e+00, -1.7512956e+00, -1.7505870e+00, + -1.7498792e+00, -1.7491723e+00, -1.7484664e+00, -1.7477614e+00, + -1.7470571e+00, -1.7463537e+00, -1.7456512e+00, -1.7449496e+00, + -1.7442487e+00, -1.7435489e+00, -1.7428498e+00, -1.7421515e+00, + -1.7414541e+00, -1.7407576e+00, -1.7400620e+00, -1.7393671e+00, + -1.7386731e+00, -1.7379799e+00, -1.7372876e+00, -1.7365961e+00, + -1.7359054e+00, -1.7352155e+00, -1.7345265e+00, -1.7338383e+00, + -1.7331510e+00, -1.7324644e+00, -1.7317786e+00, -1.7310936e+00, + -1.7304096e+00, -1.7297263e+00, -1.7290437e+00, -1.7283621e+00, + -1.7276812e+00, -1.7270011e+00, -1.7263217e+00, -1.7256433e+00, + -1.7249656e+00, -1.7242886e+00, -1.7236124e+00, -1.7229371e+00, + -1.7222625e+00, -1.7215887e+00, -1.7209158e+00, -1.7202436e+00, + -1.7195721e+00, -1.7189014e+00, -1.7182316e+00, -1.7175624e+00, + -1.7168940e+00, -1.7162265e+00, -1.7155596e+00, -1.7148936e+00, + -1.7142283e+00, -1.7135637e+00, -1.7128999e+00, -1.7122369e+00, + -1.7115746e+00, -1.7109131e+00, -1.7102523e+00, -1.7095922e+00, + -1.7089329e+00, -1.7082744e+00, -1.7076166e+00, -1.7069595e+00, + -1.7063031e+00, -1.7056475e+00, -1.7049927e+00, -1.7043386e+00, + -1.7036850e+00, -1.7030324e+00, -1.7023804e+00, -1.7017292e+00, + -1.7010787e+00, -1.7004288e+00, -1.6997797e+00, -1.6991314e+00, + -1.6984837e+00, -1.6978368e+00, -1.6971905e+00, -1.6965450e+00, + -1.6959002e+00, -1.6952561e+00, -1.6946126e+00, -1.6939700e+00, + -1.6933279e+00, -1.6926867e+00, -1.6920460e+00, -1.6914060e+00, + -1.6907668e+00, -1.6901283e+00, -1.6894904e+00, -1.6888533e+00, + -1.6882168e+00, -1.6875809e+00, -1.6869458e+00, -1.6863114e+00, + -1.6856776e+00, -1.6850445e+00, -1.6844121e+00, -1.6837804e+00, + -1.6831493e+00, -1.6825190e+00, -1.6818892e+00, -1.6812601e+00, + -1.6806318e+00, -1.6800040e+00, -1.6793770e+00, -1.6787505e+00, + -1.6781248e+00, -1.6774997e+00, -1.6768752e+00, -1.6762514e+00, + -1.6756283e+00, -1.6750058e+00, -1.6743839e+00, -1.6737627e+00, + -1.6731422e+00, -1.6725223e+00, -1.6719030e+00, -1.6712843e+00, + -1.6706663e+00, -1.6700491e+00, -1.6694323e+00, -1.6688162e+00, + -1.6682007e+00, -1.6675860e+00, -1.6669718e+00, -1.6663582e+00, + -1.6657453e+00, -1.6651330e+00, -1.6645213e+00, -1.6639103e+00, + -1.6632998e+00, -1.6626899e+00, -1.6620808e+00, -1.6614722e+00, + -1.6608642e+00, -1.6602569e+00, -1.6596501e+00, -1.6590440e+00, + -1.6584384e+00, -1.6578336e+00, -1.6572292e+00, -1.6566255e+00, + -1.6560224e+00, -1.6554199e+00, -1.6548179e+00, -1.6542166e+00, + -1.6536160e+00, -1.6530159e+00, -1.6524163e+00, -1.6518174e+00, + -1.6512191e+00, -1.6506214e+00, -1.6500242e+00, -1.6494277e+00, + -1.6488316e+00, -1.6482363e+00, -1.6476414e+00, -1.6470473e+00, + -1.6464536e+00, -1.6458606e+00, -1.6452681e+00, -1.6446761e+00, + -1.6440848e+00, -1.6434940e+00, -1.6429038e+00, -1.6423142e+00, + -1.6417252e+00, -1.6411368e+00, -1.6405488e+00, -1.6399615e+00, + -1.6393747e+00, -1.6387885e+00, -1.6382028e+00, -1.6376177e+00, + -1.6370332e+00, -1.6364492e+00, -1.6358658e+00, -1.6352830e+00, + -1.6347007e+00, -1.6341189e+00, -1.6335378e+00, -1.6329571e+00, + -1.6323770e+00, -1.6317974e+00, -1.6312184e+00, -1.6306400e+00, + -1.6300621e+00, -1.6294848e+00, -1.6289079e+00, -1.6283317e+00, + -1.6277559e+00, -1.6271807e+00, -1.6266060e+00, -1.6260319e+00, + -1.6254584e+00, -1.6248852e+00, -1.6243128e+00, -1.6237408e+00, + -1.6231693e+00, -1.6225984e+00, -1.6220280e+00, -1.6214581e+00, + -1.6208887e+00, -1.6203200e+00, -1.6197516e+00, -1.6191839e+00, + -1.6186166e+00, -1.6180499e+00, -1.6174836e+00, -1.6169180e+00, + -1.6163528e+00, -1.6157881e+00, -1.6152240e+00, -1.6146603e+00, + -1.6140972e+00, -1.6135346e+00, -1.6129725e+00, -1.6124109e+00, + -1.6118498e+00, -1.6112893e+00, -1.6107291e+00, -1.6101696e+00, + -1.6096106e+00, -1.6090519e+00, -1.6084939e+00, -1.6079364e+00, + -1.6073793e+00, -1.6068227e+00, -1.6062666e+00, -1.6057111e+00, + -1.6051561e+00, -1.6046015e+00, -1.6040474e+00, -1.6034938e+00, + -1.6029407e+00, -1.6023880e+00, -1.6018360e+00, -1.6012843e+00, + -1.6007332e+00, -1.6001825e+00, -1.5996323e+00, -1.5990826e+00, + -1.5985334e+00, -1.5979847e+00, -1.5974364e+00, -1.5968887e+00, + -1.5963414e+00, -1.5957946e+00, -1.5952482e+00, -1.5947024e+00, + -1.5941570e+00, -1.5936121e+00, -1.5930676e+00, -1.5925237e+00, + -1.5919802e+00, -1.5914371e+00, -1.5908946e+00, -1.5903525e+00, + -1.5898108e+00, -1.5892698e+00, -1.5887290e+00, -1.5881888e+00, + -1.5876490e+00, -1.5871097e+00, -1.5865709e+00, -1.5860325e+00, + -1.5854946e+00, -1.5849571e+00, -1.5844201e+00, -1.5838836e+00, + -1.5833474e+00, -1.5828118e+00, -1.5822767e+00, -1.5817419e+00, + -1.5812076e+00, -1.5806738e+00, -1.5801405e+00, -1.5796075e+00, + -1.5790750e+00, -1.5785429e+00, -1.5780114e+00, -1.5774803e+00, + -1.5769496e+00, -1.5764194e+00, -1.5758895e+00, -1.5753602e+00, + -1.5748312e+00, -1.5743027e+00, -1.5737747e+00, -1.5732471e+00, + -1.5727199e+00, -1.5721931e+00, -1.5716668e+00, -1.5711410e+00, + -1.5706155e+00, -1.5700905e+00, -1.5695660e+00, -1.5690418e+00, + -1.5685182e+00, -1.5679950e+00, -1.5674721e+00, -1.5669496e+00, + -1.5664277e+00, -1.5659060e+00, -1.5653850e+00, -1.5648643e+00, + -1.5643439e+00, -1.5638241e+00, -1.5633047e+00, -1.5627856e+00, + -1.5622671e+00, -1.5617489e+00, -1.5612311e+00, -1.5607138e+00, + -1.5601968e+00, -1.5596803e+00, -1.5591642e+00, -1.5586486e+00, + -1.5581332e+00, -1.5576184e+00, -1.5571040e+00, -1.5565900e+00, + -1.5560763e+00, -1.5555631e+00, -1.5550504e+00, -1.5545379e+00, + -1.5540260e+00, -1.5535144e+00, -1.5530032e+00, -1.5524925e+00, + -1.5519822e+00, -1.5514722e+00, -1.5509626e+00, -1.5504534e+00, + -1.5499448e+00, -1.5494363e+00, -1.5489284e+00, -1.5484209e+00, + -1.5479138e+00, -1.5474070e+00, -1.5469006e+00, -1.5463947e+00, + -1.5458891e+00, -1.5453839e+00, -1.5448792e+00, -1.5443748e+00, + -1.5438708e+00, -1.5433673e+00, -1.5428641e+00, -1.5423613e+00, + -1.5418588e+00, -1.5413568e+00, -1.5408552e+00, -1.5403539e+00, + -1.5398530e+00, -1.5393525e+00, -1.5388525e+00, -1.5383527e+00, + -1.5378534e+00, -1.5373545e+00, -1.5368558e+00, -1.5363576e+00, + -1.5358598e+00, -1.5353625e+00, -1.5348654e+00, -1.5343688e+00, + -1.5338725e+00, -1.5333766e+00, -1.5328810e+00, -1.5323858e+00, + -1.5318911e+00, -1.5313966e+00, -1.5309026e+00, -1.5304090e+00, + -1.5299157e+00, -1.5294228e+00, -1.5289302e+00, -1.5284381e+00, + -1.5279462e+00, -1.5274549e+00, -1.5269638e+00, -1.5264730e+00, + -1.5259827e+00, -1.5254928e+00, -1.5250032e+00, -1.5245140e+00, + -1.5240251e+00, -1.5235366e+00, -1.5230485e+00, -1.5225607e+00, + -1.5220733e+00, -1.5215862e+00, -1.5210996e+00, -1.5206132e+00, + -1.5201272e+00, -1.5196416e+00, -1.5191563e+00, -1.5186715e+00, + -1.5181869e+00, -1.5177027e+00, -1.5172189e+00, -1.5167354e+00, + -1.5162523e+00, -1.5157695e+00, -1.5152872e+00, -1.5148051e+00, + -1.5143234e+00, -1.5138420e+00, -1.5133610e+00, -1.5128803e+00, + -1.5124000e+00, -1.5119201e+00, -1.5114404e+00, -1.5109612e+00, + -1.5104823e+00, -1.5100037e+00, -1.5095254e+00, -1.5090476e+00, + -1.5085701e+00, -1.5080929e+00, -1.5076160e+00, -1.5071396e+00, + -1.5066633e+00, -1.5061876e+00, -1.5057120e+00, -1.5052369e+00, + -1.5047621e+00, -1.5042876e+00, -1.5038135e+00, -1.5033398e+00, + -1.5028663e+00, -1.5023931e+00, -1.5019203e+00, -1.5014479e+00, + -1.5009758e+00, -1.5005040e+00, -1.5000327e+00, -1.4995615e+00, + -1.4990907e+00, -1.4986203e+00, -1.4981502e+00, -1.4976804e+00, + -1.4972110e+00, -1.4967418e+00, -1.4962730e+00, -1.4958045e+00, + -1.4953364e+00, -1.4948686e+00, -1.4944011e+00, -1.4939340e+00, + -1.4934672e+00, -1.4930006e+00, -1.4925345e+00, -1.4920686e+00, + -1.4916031e+00, -1.4911379e+00, -1.4906731e+00, -1.4902085e+00, + -1.4897442e+00, -1.4892803e+00, -1.4888167e+00, -1.4883534e+00, + -1.4878905e+00, -1.4874278e+00, -1.4869655e+00, -1.4865035e+00, + -1.4860418e+00, -1.4855804e+00, -1.4851193e+00, -1.4846586e+00, + -1.4841982e+00, -1.4837381e+00, -1.4832783e+00, -1.4828188e+00, + -1.4823596e+00, -1.4819008e+00, -1.4814422e+00, -1.4809840e+00, + -1.4805261e+00, -1.4800684e+00, -1.4796112e+00, -1.4791541e+00, + -1.4786974e+00, -1.4782411e+00, -1.4777850e+00, -1.4773293e+00, + -1.4768738e+00, -1.4764186e+00, -1.4759638e+00, -1.4755093e+00, + -1.4750550e+00, -1.4746010e+00, -1.4741474e+00, -1.4736941e+00, + -1.4732411e+00, -1.4727883e+00, -1.4723359e+00, -1.4718839e+00, + -1.4714320e+00, -1.4709805e+00, -1.4705293e+00, -1.4700783e+00, + -1.4696277e+00, -1.4691775e+00, -1.4687275e+00, -1.4682777e+00, + -1.4678283e+00, -1.4673791e+00, -1.4669303e+00, -1.4664818e+00, + -1.4660335e+00, -1.4655856e+00, -1.4651378e+00, -1.4646906e+00, + -1.4642434e+00, -1.4637966e+00, -1.4633502e+00, -1.4629040e+00, + -1.4624581e+00, -1.4620124e+00, -1.4615672e+00, -1.4611222e+00, + -1.4606774e+00, -1.4602329e+00, -1.4597887e+00, -1.4593449e+00, + -1.4589013e+00, -1.4584579e+00, -1.4580150e+00, -1.4575722e+00, + -1.4571297e+00, -1.4566876e+00, -1.4562457e+00, -1.4558041e+00, + -1.4553628e+00, -1.4549217e+00, -1.4544810e+00, -1.4540405e+00, + -1.4536004e+00, -1.4531605e+00, -1.4527209e+00, -1.4522815e+00, + -1.4518424e+00, -1.4514037e+00, -1.4509652e+00, -1.4505270e+00, + -1.4500890e+00, -1.4496514e+00, -1.4492140e+00, -1.4487768e+00, + -1.4483401e+00, -1.4479035e+00, -1.4474672e+00, -1.4470313e+00, + -1.4465954e+00, -1.4461601e+00, -1.4457248e+00, -1.4452900e+00, + -1.4448553e+00, -1.4444209e+00, -1.4439869e+00, -1.4435530e+00, + -1.4431195e+00, -1.4426862e+00, -1.4422532e+00, -1.4418205e+00, + -1.4413880e+00, -1.4409558e+00, -1.4405239e+00, -1.4400922e+00, + -1.4396608e+00, -1.4392297e+00, -1.4387989e+00, -1.4383683e+00, + -1.4379380e+00, -1.4375079e+00, -1.4370781e+00, -1.4366486e+00, + -1.4362193e+00, -1.4357903e+00, -1.4353616e+00, -1.4349332e+00, + -1.4345050e+00, -1.4340770e+00, -1.4336493e+00, -1.4332219e+00, + -1.4327947e+00, -1.4323678e+00, -1.4319413e+00, -1.4315149e+00, + -1.4310887e+00, -1.4306629e+00, -1.4302373e+00, -1.4298120e+00, + -1.4293869e+00, -1.4289621e+00, -1.4285375e+00, -1.4281132e+00, + -1.4276892e+00, -1.4272654e+00, -1.4268419e+00, -1.4264185e+00, + -1.4259956e+00, -1.4255728e+00, -1.4251503e+00, -1.4247280e+00, + -1.4243060e+00, -1.4238843e+00, -1.4234627e+00, -1.4230415e+00, + -1.4226205e+00, -1.4221997e+00, -1.4217793e+00, -1.4213591e+00, + -1.4209391e+00, -1.4205194e+00, -1.4200999e+00, -1.4196806e+00, + -1.4192616e+00, -1.4188429e+00, -1.4184244e+00, -1.4180062e+00, + -1.4175881e+00, -1.4171704e+00, -1.4167529e+00, -1.4163357e+00, + -1.4159187e+00, -1.4155020e+00, -1.4150854e+00, -1.4146692e+00, + -1.4142531e+00, -1.4138373e+00, -1.4134218e+00, -1.4130065e+00, + -1.4125915e+00, -1.4121766e+00, -1.4117621e+00, -1.4113477e+00, + -1.4109337e+00, -1.4105198e+00, -1.4101063e+00, -1.4096929e+00, + -1.4092798e+00, -1.4088670e+00, -1.4084543e+00, -1.4080420e+00, + -1.4076297e+00, -1.4072179e+00, -1.4068062e+00, -1.4063947e+00, + -1.4059836e+00, -1.4055727e+00, -1.4051619e+00, -1.4047514e+00, + -1.4043411e+00, -1.4039311e+00, -1.4035214e+00, -1.4031118e+00, + -1.4027026e+00, -1.4022934e+00, -1.4018846e+00, -1.4014760e+00, + -1.4010676e+00, -1.4006594e+00, -1.4002516e+00, -1.3998439e+00, + -1.3994365e+00, -1.3990293e+00, -1.3986223e+00, -1.3982155e+00, + -1.3978090e+00, -1.3974028e+00, -1.3969967e+00, -1.3965909e+00, + -1.3961853e+00, -1.3957800e+00, -1.3953749e+00, -1.3949699e+00, + -1.3945652e+00, -1.3941609e+00, -1.3937566e+00, -1.3933526e+00, + -1.3929489e+00, -1.3925453e+00, -1.3921421e+00, -1.3917389e+00, + -1.3913361e+00, -1.3909335e+00, -1.3905311e+00, -1.3901289e+00, + -1.3897269e+00, -1.3893251e+00, -1.3889236e+00, -1.3885224e+00, + -1.3881214e+00, -1.3877205e+00, -1.3873199e+00, -1.3869195e+00, + -1.3865193e+00, -1.3861194e+00, -1.3857197e+00, -1.3853202e+00, + -1.3849208e+00, -1.3845218e+00, -1.3841230e+00, -1.3837243e+00, + -1.3833259e+00, -1.3829278e+00, -1.3825299e+00, -1.3821321e+00, + -1.3817345e+00, -1.3813373e+00, -1.3809402e+00, -1.3805432e+00, + -1.3801466e+00, -1.3797501e+00, -1.3793540e+00, -1.3789580e+00, + -1.3785622e+00, -1.3781666e+00, -1.3777713e+00, -1.3773761e+00, + -1.3769811e+00, -1.3765864e+00, -1.3761920e+00, -1.3757976e+00, + -1.3754036e+00, -1.3750098e+00, -1.3746161e+00, -1.3742226e+00, + -1.3738295e+00, -1.3734365e+00, -1.3730437e+00, -1.3726511e+00, + -1.3722587e+00, -1.3718666e+00, -1.3714746e+00, -1.3710829e+00, + -1.3706913e+00, -1.3703001e+00, -1.3699089e+00, -1.3695180e+00, + -1.3691274e+00, -1.3687369e+00, -1.3683466e+00, -1.3679565e+00, + -1.3675667e+00, -1.3671770e+00, -1.3667876e+00, -1.3663983e+00, + -1.3660094e+00, -1.3656205e+00, -1.3652319e+00, -1.3648435e+00, + -1.3644553e+00, -1.3640673e+00, -1.3636795e+00, -1.3632919e+00, + -1.3629045e+00, -1.3625174e+00, -1.3621304e+00, -1.3617436e+00, + -1.3613571e+00, -1.3609707e+00, -1.3605845e+00, -1.3601986e+00, + -1.3598129e+00, -1.3594273e+00, -1.3590419e+00, -1.3586568e+00, + -1.3582718e+00, -1.3578871e+00, -1.3575026e+00, -1.3571182e+00, + -1.3567340e+00, -1.3563502e+00, -1.3559663e+00, -1.3555828e+00, + -1.3551995e+00, -1.3548163e+00, -1.3544334e+00, -1.3540506e+00, + -1.3536681e+00, -1.3532858e+00, -1.3529036e+00, -1.3525217e+00, + -1.3521399e+00, -1.3517584e+00, -1.3513770e+00, -1.3509958e+00, + -1.3506148e+00, -1.3502340e+00, -1.3498535e+00, -1.3494731e+00, + -1.3490928e+00, -1.3487129e+00, -1.3483331e+00, -1.3479534e+00, + -1.3475741e+00, -1.3471949e+00, -1.3468158e+00, -1.3464370e+00, + -1.3460584e+00, -1.3456799e+00, -1.3453016e+00, -1.3449236e+00, + -1.3445457e+00, -1.3441681e+00, -1.3437905e+00, -1.3434132e+00, + -1.3430362e+00, -1.3426592e+00, -1.3422825e+00, -1.3419061e+00, + -1.3415297e+00, -1.3411535e+00, -1.3407776e+00, -1.3404018e+00, + -1.3400263e+00, -1.3396509e+00, -1.3392756e+00, -1.3389006e+00, + -1.3385258e+00, -1.3381511e+00, -1.3377767e+00, -1.3374025e+00, + -1.3370284e+00, -1.3366544e+00, -1.3362808e+00, -1.3359072e+00, + -1.3355340e+00, -1.3351607e+00, -1.3347878e+00, -1.3344151e+00, + -1.3340424e+00, -1.3336700e+00, -1.3332978e+00, -1.3329258e+00, + -1.3325540e+00, -1.3321823e+00, -1.3318108e+00, -1.3314395e+00, + -1.3310684e+00, -1.3306974e+00, -1.3303267e+00, -1.3299562e+00, + -1.3295858e+00, -1.3292155e+00, -1.3288456e+00, -1.3284757e+00, + -1.3281060e+00, -1.3277366e+00, -1.3273673e+00, -1.3269982e+00, + -1.3266293e+00, -1.3262606e+00, -1.3258920e+00, -1.3255236e+00, + -1.3251554e+00, -1.3247874e+00, -1.3244195e+00, -1.3240519e+00, + -1.3236843e+00, -1.3233171e+00, -1.3229499e+00, -1.3225830e+00, + -1.3222162e+00, -1.3218495e+00, -1.3214831e+00, -1.3211168e+00, + -1.3207508e+00, -1.3203849e+00, -1.3200191e+00, -1.3196536e+00, + -1.3192883e+00, -1.3189231e+00, -1.3185581e+00, -1.3181932e+00, + -1.3178285e+00, -1.3174641e+00, -1.3170998e+00, -1.3167356e+00, + -1.3163717e+00, -1.3160079e+00, -1.3156443e+00, -1.3152809e+00, + -1.3149176e+00, -1.3145545e+00, -1.3141916e+00, -1.3138288e+00, + -1.3134663e+00, -1.3131039e+00, -1.3127416e+00, -1.3123796e+00, + -1.3120177e+00, -1.3116560e+00, -1.3112944e+00, -1.3109331e+00, + -1.3105719e+00, -1.3102108e+00, -1.3098500e+00, -1.3094894e+00, + -1.3091288e+00, -1.3087685e+00, -1.3084083e+00, -1.3080482e+00, + -1.3076885e+00, -1.3073288e+00, -1.3069693e+00, -1.3066100e+00, + -1.3062508e+00, -1.3058918e+00, -1.3055329e+00, -1.3051744e+00, + -1.3048158e+00, -1.3044575e+00, -1.3040993e+00, -1.3037413e+00, + -1.3033836e+00, -1.3030258e+00, -1.3026685e+00, -1.3023111e+00, + -1.3019539e+00, -1.3015970e+00, -1.3012401e+00, -1.3008835e+00, + -1.3005270e+00, -1.3001707e+00, -1.2998145e+00, -1.2994585e+00, + -1.2991027e+00, -1.2987471e+00, -1.2983915e+00, -1.2980362e+00, + -1.2976810e+00, -1.2973260e+00, -1.2969712e+00, -1.2966164e+00, + -1.2962619e+00, -1.2959076e+00, -1.2955534e+00, -1.2951994e+00, + -1.2948455e+00, -1.2944918e+00, -1.2941382e+00, -1.2937849e+00, + -1.2934316e+00, -1.2930785e+00, -1.2927257e+00, -1.2923729e+00, + -1.2920203e+00, -1.2916679e+00, -1.2913157e+00, -1.2909635e+00, + -1.2906116e+00, -1.2902598e+00, -1.2899083e+00, -1.2895567e+00, + -1.2892054e+00, -1.2888544e+00, -1.2885034e+00, -1.2881526e+00, + -1.2878019e+00, -1.2874514e+00, -1.2871010e+00, -1.2867508e+00, + -1.2864008e+00, -1.2860509e+00, -1.2857012e+00, -1.2853516e+00, + -1.2850022e+00, -1.2846529e+00, -1.2843039e+00, -1.2839550e+00, + -1.2836062e+00, -1.2832576e+00, -1.2829090e+00, -1.2825608e+00, + -1.2822126e+00, -1.2818646e+00, -1.2815168e+00, -1.2811691e+00, + -1.2808216e+00, -1.2804742e+00, -1.2801269e+00, -1.2797799e+00, + -1.2794330e+00, -1.2790862e+00, -1.2787396e+00, -1.2783931e+00, + -1.2780468e+00, -1.2777007e+00, -1.2773547e+00, -1.2770089e+00, + -1.2766632e+00, -1.2763176e+00, -1.2759722e+00, -1.2756270e+00, + -1.2752819e+00, -1.2749370e+00, -1.2745922e+00, -1.2742475e+00, + -1.2739031e+00, -1.2735587e+00, -1.2732146e+00, -1.2728705e+00, + -1.2725267e+00, -1.2721829e+00, -1.2718394e+00, -1.2714961e+00, + -1.2711527e+00, -1.2708097e+00, -1.2704667e+00, -1.2701238e+00, + -1.2697811e+00, -1.2694386e+00, -1.2690963e+00, -1.2687540e+00, + -1.2684120e+00, -1.2680700e+00, -1.2677282e+00, -1.2673866e+00, + -1.2670451e+00, -1.2667037e+00, -1.2663625e+00, -1.2660215e+00, + -1.2656807e+00, -1.2653399e+00, -1.2649993e+00, -1.2646588e+00, + -1.2643185e+00, -1.2639784e+00, -1.2636384e+00, -1.2632985e+00, + -1.2629588e+00, -1.2626191e+00, -1.2622797e+00, -1.2619405e+00, + -1.2616013e+00, -1.2612623e+00, -1.2609235e+00, -1.2605847e+00, + -1.2602462e+00, -1.2599077e+00, -1.2595695e+00, -1.2592313e+00, + -1.2588934e+00, -1.2585555e+00, -1.2582178e+00, -1.2578802e+00, + -1.2575428e+00, -1.2572056e+00, -1.2568685e+00, -1.2565315e+00, + -1.2561946e+00, -1.2558579e+00, -1.2555214e+00, -1.2551850e+00, + -1.2548487e+00, -1.2545125e+00, -1.2541766e+00, -1.2538407e+00, + -1.2535050e+00, -1.2531694e+00, -1.2528341e+00, -1.2524987e+00, + -1.2521636e+00, -1.2518286e+00, -1.2514937e+00, -1.2511591e+00, + -1.2508245e+00, -1.2504900e+00, -1.2501557e+00, -1.2498215e+00, + -1.2494875e+00, -1.2491536e+00, -1.2488198e+00, -1.2484863e+00, + -1.2481529e+00, -1.2478195e+00, -1.2474864e+00, -1.2471533e+00, + -1.2468203e+00, -1.2464876e+00, -1.2461549e+00, -1.2458224e+00, + -1.2454901e+00, -1.2451578e+00, -1.2448257e+00, -1.2444938e+00, + -1.2441620e+00, -1.2438303e+00, -1.2434988e+00, -1.2431674e+00, + -1.2428361e+00, -1.2425050e+00, -1.2421740e+00, -1.2418431e+00, + -1.2415124e+00, -1.2411819e+00, -1.2408514e+00, -1.2405211e+00, + -1.2401909e+00, -1.2398609e+00, -1.2395309e+00, -1.2392012e+00, + -1.2388716e+00, -1.2385421e+00, -1.2382127e+00, -1.2378834e+00, + -1.2375543e+00, -1.2372254e+00, -1.2368965e+00, -1.2365679e+00, + -1.2362393e+00, -1.2359109e+00, -1.2355826e+00, -1.2352544e+00, + -1.2349263e+00, -1.2345985e+00, -1.2342707e+00, -1.2339431e+00, + -1.2336155e+00, -1.2332882e+00, -1.2329609e+00, -1.2326338e+00, + -1.2323068e+00, -1.2319801e+00, -1.2316533e+00, -1.2313267e+00, + -1.2310003e+00, -1.2306740e+00, -1.2303478e+00, -1.2300217e+00, + -1.2296958e+00, -1.2293700e+00, -1.2290443e+00, -1.2287189e+00, + -1.2283934e+00, -1.2280681e+00, -1.2277430e+00, -1.2274179e+00, + -1.2270931e+00, -1.2267684e+00, -1.2264438e+00, -1.2261193e+00, + -1.2257949e+00, -1.2254707e+00, -1.2251465e+00, -1.2248225e+00, + -1.2244986e+00, -1.2241750e+00, -1.2238513e+00, -1.2235279e+00, + -1.2232046e+00, -1.2228813e+00, -1.2225583e+00, -1.2222353e+00, + -1.2219125e+00, -1.2215898e+00, -1.2212672e+00, -1.2209448e+00, + -1.2206224e+00, -1.2203002e+00, -1.2199782e+00, -1.2196562e+00, + -1.2193345e+00, -1.2190127e+00, -1.2186912e+00, -1.2183697e+00, + -1.2180485e+00, -1.2177273e+00, -1.2174062e+00, -1.2170852e+00, + -1.2167645e+00, -1.2164438e+00, -1.2161232e+00, -1.2158028e+00, + -1.2154825e+00, -1.2151623e+00, -1.2148422e+00, -1.2145222e+00, + -1.2142025e+00, -1.2138828e+00, -1.2135632e+00, -1.2132438e+00, + -1.2129245e+00, -1.2126052e+00, -1.2122862e+00, -1.2119672e+00, + -1.2116485e+00, -1.2113298e+00, -1.2110112e+00, -1.2106928e+00, + -1.2103744e+00, -1.2100562e+00, -1.2097381e+00, -1.2094202e+00, + -1.2091023e+00, -1.2087846e+00, -1.2084670e+00, -1.2081496e+00, + -1.2078322e+00, -1.2075150e+00, -1.2071979e+00, -1.2068808e+00, + -1.2065639e+00, -1.2062472e+00, -1.2059306e+00, -1.2056141e+00, + -1.2052977e+00, -1.2049814e+00, -1.2046653e+00, -1.2043493e+00, + -1.2040334e+00, -1.2037176e+00, -1.2034019e+00, -1.2030865e+00, + -1.2027711e+00, -1.2024558e+00, -1.2021406e+00, -1.2018255e+00, + -1.2015105e+00, -1.2011957e+00, -1.2008810e+00, -1.2005664e+00, + -1.2002519e+00, -1.1999376e+00, -1.1996233e+00, -1.1993092e+00, + -1.1989952e+00, -1.1986814e+00, -1.1983676e+00, -1.1980540e+00, + -1.1977404e+00, -1.1974270e+00, -1.1971138e+00, -1.1968006e+00, + -1.1964875e+00, -1.1961746e+00, -1.1958618e+00, -1.1955491e+00, + -1.1952366e+00, -1.1949241e+00, -1.1946117e+00, -1.1942995e+00, + -1.1939874e+00, -1.1936754e+00, -1.1933634e+00, -1.1930517e+00, + -1.1927401e+00, -1.1924285e+00, -1.1921171e+00, -1.1918058e+00, + -1.1914946e+00, -1.1911836e+00, -1.1908726e+00, -1.1905618e+00, + -1.1902510e+00, -1.1899403e+00, -1.1896299e+00, -1.1893195e+00, + -1.1890092e+00, -1.1886991e+00, -1.1883891e+00, -1.1880791e+00, + -1.1877693e+00, -1.1874596e+00, -1.1871500e+00, -1.1868405e+00, + -1.1865312e+00, -1.1862220e+00, -1.1859128e+00, -1.1856037e+00, + -1.1852949e+00, -1.1849861e+00, -1.1846774e+00, -1.1843688e+00, + -1.1840603e+00, -1.1837521e+00, -1.1834438e+00, -1.1831357e+00, + -1.1828277e+00, -1.1825198e+00, -1.1822120e+00, -1.1819043e+00, + -1.1815968e+00, -1.1812893e+00, -1.1809820e+00, -1.1806748e+00, + -1.1803677e+00, -1.1800607e+00, -1.1797538e+00, -1.1794471e+00, + -1.1791403e+00, -1.1788338e+00, -1.1785274e+00, -1.1782210e+00, + -1.1779149e+00, -1.1776087e+00, -1.1773027e+00, -1.1769968e+00, + -1.1766911e+00, -1.1763854e+00, -1.1760798e+00, -1.1757743e+00, + -1.1754690e+00, -1.1751637e+00, -1.1748587e+00, -1.1745536e+00, + -1.1742487e+00, -1.1739439e+00, -1.1736393e+00, -1.1733347e+00, + -1.1730303e+00, -1.1727258e+00, -1.1724216e+00, -1.1721175e+00, + -1.1718134e+00, -1.1715095e+00, -1.1712056e+00, -1.1709020e+00, + -1.1705984e+00, -1.1702949e+00, -1.1699915e+00, -1.1696882e+00, + -1.1693851e+00, -1.1690819e+00, -1.1687790e+00, -1.1684762e+00, + -1.1681734e+00, -1.1678708e+00, -1.1675682e+00, -1.1672659e+00, + -1.1669636e+00, -1.1666613e+00, -1.1663592e+00, -1.1660572e+00, + -1.1657554e+00, -1.1654536e+00, -1.1651518e+00, -1.1648504e+00, + -1.1645489e+00, -1.1642475e+00, -1.1639463e+00, -1.1636450e+00, + -1.1633440e+00, -1.1630431e+00, -1.1627423e+00, -1.1624415e+00, + -1.1621410e+00, -1.1618404e+00, -1.1615400e+00, -1.1612397e+00, + -1.1609395e+00, -1.1606394e+00, -1.1603394e+00, -1.1600395e+00, + -1.1597397e+00, -1.1594400e+00, -1.1591405e+00, -1.1588410e+00, + -1.1585417e+00, -1.1582423e+00, -1.1579432e+00, -1.1576442e+00, + -1.1573452e+00, -1.1570463e+00, -1.1567476e+00, -1.1564490e+00, + -1.1561505e+00, -1.1558520e+00, -1.1555537e+00, -1.1552554e+00, + -1.1549573e+00, -1.1546593e+00, -1.1543614e+00, -1.1540636e+00, + -1.1537658e+00, -1.1534683e+00, -1.1531707e+00, -1.1528733e+00, + -1.1525760e+00, -1.1522788e+00, -1.1519816e+00, -1.1516846e+00, + -1.1513877e+00, -1.1510910e+00, -1.1507943e+00, -1.1504977e+00, + -1.1502011e+00, -1.1499047e+00, -1.1496085e+00, -1.1493123e+00, + -1.1490161e+00, -1.1487201e+00, -1.1484243e+00, -1.1481285e+00, + -1.1478328e+00, -1.1475372e+00, -1.1472417e+00, -1.1469463e+00, + -1.1466510e+00, -1.1463559e+00, -1.1460607e+00, -1.1457658e+00, + -1.1454709e+00, -1.1451761e+00, -1.1448814e+00, -1.1445868e+00, + -1.1442922e+00, -1.1439979e+00, -1.1437036e+00, -1.1434094e+00, + -1.1431153e+00, -1.1428213e+00, -1.1425273e+00, -1.1422336e+00, + -1.1419399e+00, -1.1416463e+00, -1.1413528e+00, -1.1410594e+00, + -1.1407660e+00, -1.1404729e+00, -1.1401798e+00, -1.1398867e+00, + -1.1395938e+00, -1.1393009e+00, -1.1390083e+00, -1.1387156e+00, + -1.1384231e+00, -1.1381307e+00, -1.1378384e+00, -1.1375461e+00, + -1.1372540e+00, -1.1369619e+00, -1.1366700e+00, -1.1363782e+00, + -1.1360863e+00, -1.1357948e+00, -1.1355032e+00, -1.1352117e+00, + -1.1349204e+00, -1.1346291e+00, -1.1343379e+00, -1.1340468e+00, + -1.1337558e+00, -1.1334649e+00, -1.1331742e+00, -1.1328834e+00, + -1.1325929e+00, -1.1323024e+00, -1.1320120e+00, -1.1317216e+00, + -1.1314315e+00, -1.1311413e+00, -1.1308513e+00, -1.1305614e+00, + -1.1302716e+00, -1.1299818e+00, -1.1296922e+00, -1.1294026e+00, + -1.1291132e+00, -1.1288238e+00, -1.1285346e+00, -1.1282454e+00, + -1.1279563e+00, -1.1276673e+00, -1.1273785e+00, -1.1270896e+00, + -1.1268009e+00, -1.1265123e+00, -1.1262238e+00, -1.1259354e+00, + -1.1256471e+00, -1.1253588e+00, -1.1250707e+00, -1.1247827e+00, + -1.1244947e+00, -1.1242068e+00, -1.1239190e+00, -1.1236314e+00, + -1.1233438e+00, -1.1230563e+00, -1.1227689e+00, -1.1224816e+00, + -1.1221944e+00, -1.1219074e+00, -1.1216203e+00, -1.1213334e+00, + -1.1210465e+00, -1.1207597e+00, -1.1204731e+00, -1.1201866e+00, + -1.1199001e+00, -1.1196136e+00, -1.1193274e+00, -1.1190412e+00, + -1.1187551e+00, -1.1184691e+00, -1.1181831e+00, -1.1178974e+00, + -1.1176116e+00, -1.1173259e+00, -1.1170404e+00, -1.1167549e+00, + -1.1164695e+00, -1.1161842e+00, -1.1158991e+00, -1.1156139e+00, + -1.1153290e+00, -1.1150440e+00, -1.1147592e+00, -1.1144745e+00, + -1.1141899e+00, -1.1139053e+00, -1.1136208e+00, -1.1133364e+00, + -1.1130521e+00, -1.1127679e+00, -1.1124839e+00, -1.1121998e+00, + -1.1119158e+00, -1.1116320e+00, -1.1113483e+00, -1.1110647e+00, + -1.1107811e+00, -1.1104976e+00, -1.1102142e+00, -1.1099309e+00, + -1.1096476e+00, -1.1093645e+00, -1.1090815e+00, -1.1087985e+00, + -1.1085157e+00, -1.1082330e+00, -1.1079502e+00, -1.1076677e+00, + -1.1073852e+00, -1.1071028e+00, -1.1068205e+00, -1.1065382e+00, + -1.1062560e+00, -1.1059740e+00, -1.1056920e+00, -1.1054101e+00, + -1.1051283e+00, -1.1048466e+00, -1.1045649e+00, -1.1042835e+00, + -1.1040020e+00, -1.1037205e+00, -1.1034393e+00, -1.1031581e+00, + -1.1028770e+00, -1.1025960e+00, -1.1023151e+00, -1.1020342e+00, + -1.1017535e+00, -1.1014729e+00, -1.1011922e+00, -1.1009117e+00, + -1.1006314e+00, -1.1003511e+00, -1.1000708e+00, -1.0997907e+00, + -1.0995106e+00, -1.0992306e+00, -1.0989507e+00, -1.0986710e+00, + -1.0983912e+00, -1.0981116e+00, -1.0978321e+00, -1.0975525e+00, + -1.0972732e+00, -1.0969939e+00, -1.0967147e+00, -1.0964357e+00, + -1.0961566e+00, -1.0958776e+00, -1.0955988e+00, -1.0953200e+00, + -1.0950413e+00, -1.0947627e+00, -1.0944842e+00, -1.0942057e+00, + -1.0939274e+00, -1.0936491e+00, -1.0933709e+00, -1.0930929e+00, + -1.0928148e+00, -1.0925369e+00, -1.0922590e+00, -1.0919813e+00, + -1.0917037e+00, -1.0914260e+00, -1.0911485e+00, -1.0908711e+00, + -1.0905938e+00, -1.0903165e+00, -1.0900394e+00, -1.0897623e+00, + -1.0894853e+00, -1.0892084e+00, -1.0889316e+00, -1.0886548e+00, + -1.0883781e+00, -1.0881015e+00, -1.0878251e+00, -1.0875486e+00, + -1.0872723e+00, -1.0869960e+00, -1.0867199e+00, -1.0864438e+00, + -1.0861677e+00, -1.0858918e+00, -1.0856160e+00, -1.0853403e+00, + -1.0850645e+00, -1.0847889e+00, -1.0845134e+00, -1.0842381e+00, + -1.0839627e+00, -1.0836874e+00, -1.0834122e+00, -1.0831372e+00, + -1.0828621e+00, -1.0825871e+00, -1.0823123e+00, -1.0820376e+00, + -1.0817629e+00, -1.0814883e+00, -1.0812137e+00, -1.0809393e+00, + -1.0806649e+00, -1.0803907e+00, -1.0801164e+00, -1.0798423e+00, + -1.0795683e+00, -1.0792943e+00, -1.0790205e+00, -1.0787467e+00, + -1.0784730e+00, -1.0781993e+00, -1.0779257e+00, -1.0776522e+00, + -1.0773789e+00, -1.0771055e+00, -1.0768323e+00, -1.0765592e+00, + -1.0762861e+00, -1.0760131e+00, -1.0757402e+00, -1.0754673e+00, + -1.0751946e+00, -1.0749220e+00, -1.0746493e+00, -1.0743768e+00, + -1.0741044e+00, -1.0738320e+00, -1.0735598e+00, -1.0732876e+00, + -1.0730155e+00, -1.0727434e+00, -1.0724715e+00, -1.0721996e+00, + -1.0719278e+00, -1.0716561e+00, -1.0713844e+00, -1.0711130e+00, + -1.0708414e+00, -1.0705701e+00, -1.0702987e+00, -1.0700275e+00, + -1.0697563e+00, -1.0694852e+00, -1.0692142e+00, -1.0689433e+00, + -1.0686724e+00, -1.0684017e+00, -1.0681310e+00, -1.0678604e+00, + -1.0675899e+00, -1.0673194e+00, -1.0670490e+00, -1.0667787e+00, + -1.0665085e+00, -1.0662383e+00, -1.0659683e+00, -1.0656983e+00, + -1.0654284e+00, -1.0651585e+00, -1.0648887e+00, -1.0646191e+00, + -1.0643495e+00, -1.0640800e+00, -1.0638105e+00, -1.0635412e+00, + -1.0632719e+00, -1.0630026e+00, -1.0627335e+00, -1.0624644e+00, + -1.0621954e+00, -1.0619265e+00, -1.0616577e+00, -1.0613890e+00, + -1.0611203e+00, -1.0608517e+00, -1.0605831e+00, -1.0603147e+00, + -1.0600463e+00, -1.0597780e+00, -1.0595098e+00, -1.0592417e+00, + -1.0589736e+00, -1.0587056e+00, -1.0584377e+00, -1.0581698e+00, + -1.0579021e+00, -1.0576344e+00, -1.0573667e+00, -1.0570992e+00, + -1.0568317e+00, -1.0565643e+00, -1.0562971e+00, -1.0560298e+00, + -1.0557626e+00, -1.0554956e+00, -1.0552286e+00, -1.0549617e+00, + -1.0546948e+00, -1.0544280e+00, -1.0541613e+00, -1.0538946e+00, + -1.0536281e+00, -1.0533617e+00, -1.0530952e+00, -1.0528289e+00, + -1.0525626e+00, -1.0522964e+00, -1.0520303e+00, -1.0517642e+00, + -1.0514983e+00, -1.0512325e+00, -1.0509666e+00, -1.0507009e+00, + -1.0504352e+00, -1.0501696e+00, -1.0499041e+00, -1.0496386e+00, + -1.0493733e+00, -1.0491080e+00, -1.0488428e+00, -1.0485777e+00, + -1.0483125e+00, -1.0480475e+00, -1.0477827e+00, -1.0475178e+00, + -1.0472530e+00, -1.0469882e+00, -1.0467236e+00, -1.0464591e+00, + -1.0461946e+00, -1.0459301e+00, -1.0456659e+00, -1.0454016e+00, + -1.0451374e+00, -1.0448732e+00, -1.0446092e+00, -1.0443453e+00, + -1.0440813e+00, -1.0438175e+00, -1.0435537e+00, -1.0432900e+00, + -1.0430264e+00, -1.0427629e+00, -1.0424994e+00, -1.0422361e+00, + -1.0419728e+00, -1.0417095e+00, -1.0414463e+00, -1.0411832e+00, + -1.0409201e+00, -1.0406572e+00, -1.0403943e+00, -1.0401314e+00, + -1.0398687e+00, -1.0396061e+00, -1.0393435e+00, -1.0390810e+00, + -1.0388185e+00, -1.0385561e+00, -1.0382938e+00, -1.0380316e+00, + -1.0377693e+00, -1.0375073e+00, -1.0372453e+00, -1.0369833e+00, + -1.0367213e+00, -1.0364596e+00, -1.0361978e+00, -1.0359361e+00, + -1.0356746e+00, -1.0354130e+00, -1.0351515e+00, -1.0348902e+00, + -1.0346289e+00, -1.0343676e+00, -1.0341064e+00, -1.0338453e+00, + -1.0335842e+00, -1.0333233e+00, -1.0330623e+00, -1.0328015e+00, + -1.0325408e+00, -1.0322801e+00, -1.0320195e+00, -1.0317589e+00, + -1.0314984e+00, -1.0312381e+00, -1.0309777e+00, -1.0307175e+00, + -1.0304573e+00, -1.0301971e+00, -1.0299370e+00, -1.0296770e+00, + -1.0294172e+00, -1.0291573e+00, -1.0288975e+00, -1.0286378e+00, + -1.0283781e+00, -1.0281186e+00, -1.0278591e+00, -1.0275997e+00, + -1.0273403e+00, -1.0270810e+00, -1.0268217e+00, -1.0265626e+00, + -1.0263035e+00, -1.0260445e+00, -1.0257856e+00, -1.0255266e+00, + -1.0252678e+00, -1.0250092e+00, -1.0247505e+00, -1.0244918e+00, + -1.0242333e+00, -1.0239748e+00, -1.0237164e+00, -1.0234581e+00, + -1.0231998e+00, -1.0229416e+00, -1.0226835e+00, -1.0224254e+00, + -1.0221674e+00, -1.0219095e+00, -1.0216516e+00, -1.0213939e+00, + -1.0211362e+00, -1.0208784e+00, -1.0206209e+00, -1.0203633e+00, + -1.0201060e+00, -1.0198486e+00, -1.0195912e+00, -1.0193340e+00, + -1.0190768e+00, -1.0188197e+00, -1.0185627e+00, -1.0183057e+00, + -1.0180488e+00, -1.0177919e+00, -1.0175351e+00, -1.0172784e+00, + -1.0170218e+00, -1.0167652e+00, -1.0165087e+00, -1.0162523e+00, + -1.0159959e+00, -1.0157396e+00, -1.0154834e+00, -1.0152272e+00, + -1.0149710e+00, -1.0147150e+00, -1.0144590e+00, -1.0142031e+00, + -1.0139472e+00, -1.0136915e+00, -1.0134358e+00, -1.0131801e+00, + -1.0129246e+00, -1.0126691e+00, -1.0124136e+00, -1.0121583e+00, + -1.0119029e+00, -1.0116477e+00, -1.0113925e+00, -1.0111374e+00, + -1.0108824e+00, -1.0106274e+00, -1.0103724e+00, -1.0101175e+00, + -1.0098628e+00, -1.0096080e+00, -1.0093534e+00, -1.0090988e+00, + -1.0088443e+00, -1.0085899e+00, -1.0083355e+00, -1.0080811e+00, + -1.0078268e+00, -1.0075727e+00, -1.0073185e+00, -1.0070645e+00, + -1.0068104e+00, -1.0065565e+00, -1.0063026e+00, -1.0060488e+00, + -1.0057951e+00, -1.0055413e+00, -1.0052878e+00, -1.0050342e+00, + -1.0047808e+00, -1.0045273e+00, -1.0042740e+00, -1.0040207e+00, + -1.0037675e+00, -1.0035143e+00, -1.0032612e+00, -1.0030081e+00, + -1.0027552e+00, -1.0025022e+00, -1.0022494e+00, -1.0019966e+00, + -1.0017439e+00, -1.0014913e+00, -1.0012387e+00, -1.0009862e+00, + -1.0007337e+00, -1.0004814e+00, -1.0002290e+00, -9.9997669e-01, + -9.9972451e-01, -9.9947238e-01, -9.9922031e-01, -9.9896824e-01, + -9.9871629e-01, -9.9846447e-01, -9.9821264e-01, -9.9796087e-01, + -9.9770916e-01, -9.9745750e-01, -9.9720597e-01, -9.9695444e-01, + -9.9670297e-01, -9.9645162e-01, -9.9620032e-01, -9.9594903e-01, + -9.9569786e-01, -9.9544674e-01, -9.9519563e-01, -9.9494463e-01, + -9.9469370e-01, -9.9444282e-01, -9.9419200e-01, -9.9394125e-01, + -9.9369055e-01, -9.9343991e-01, -9.9318939e-01, -9.9293888e-01, + -9.9268842e-01, -9.9243802e-01, -9.9218774e-01, -9.9193746e-01, + -9.9168730e-01, -9.9143714e-01, -9.9118710e-01, -9.9093705e-01, + -9.9068713e-01, -9.9043721e-01, -9.9018741e-01, -9.8993766e-01, + -9.8968798e-01, -9.8943830e-01, -9.8918873e-01, -9.8893923e-01, + -9.8868978e-01, -9.8844039e-01, -9.8819107e-01, -9.8794180e-01, + -9.8769259e-01, -9.8744345e-01, -9.8719436e-01, -9.8694533e-01, + -9.8669636e-01, -9.8644745e-01, -9.8619866e-01, -9.8594987e-01, + -9.8570114e-01, -9.8545247e-01, -9.8520392e-01, -9.8495537e-01, + -9.8470688e-01, -9.8445845e-01, -9.8421013e-01, -9.8396182e-01, + -9.8371363e-01, -9.8346543e-01, -9.8321730e-01, -9.8296928e-01, + -9.8272127e-01, -9.8247337e-01, -9.8222548e-01, -9.8197770e-01, + -9.8172992e-01, -9.8148227e-01, -9.8123461e-01, -9.8098707e-01, + -9.8073953e-01, -9.8049212e-01, -9.8024470e-01, -9.7999740e-01, + -9.7975016e-01, -9.7950292e-01, -9.7925580e-01, -9.7900867e-01, + -9.7876167e-01, -9.7851467e-01, -9.7826779e-01, -9.7802097e-01, + -9.7777414e-01, -9.7752744e-01, -9.7728074e-01, -9.7703415e-01, + -9.7678757e-01, -9.7654110e-01, -9.7629470e-01, -9.7604829e-01, + -9.7580200e-01, -9.7555572e-01, -9.7530955e-01, -9.7506338e-01, + -9.7481734e-01, -9.7457129e-01, -9.7432536e-01, -9.7407943e-01, + -9.7383362e-01, -9.7358781e-01, -9.7334212e-01, -9.7309643e-01, + -9.7285086e-01, -9.7260529e-01, -9.7235978e-01, -9.7211438e-01, + -9.7186899e-01, -9.7162366e-01, -9.7137845e-01, -9.7113323e-01, + -9.7088808e-01, -9.7064304e-01, -9.7039801e-01, -9.7015303e-01, + -9.6990812e-01, -9.6966326e-01, -9.6941847e-01, -9.6917379e-01, + -9.6892911e-01, -9.6868449e-01, -9.6843994e-01, -9.6819544e-01, + -9.6795100e-01, -9.6770662e-01, -9.6746230e-01, -9.6721798e-01, + -9.6697378e-01, -9.6672964e-01, -9.6648556e-01, -9.6624154e-01, + -9.6599752e-01, -9.6575361e-01, -9.6550977e-01, -9.6526593e-01, + -9.6502221e-01, -9.6477848e-01, -9.6453488e-01, -9.6429127e-01, + -9.6404779e-01, -9.6380430e-01, -9.6356088e-01, -9.6331757e-01, + -9.6307427e-01, -9.6283102e-01, -9.6258783e-01, -9.6234471e-01, + -9.6210164e-01, -9.6185863e-01, -9.6161568e-01, -9.6137279e-01, + -9.6112996e-01, -9.6088719e-01, -9.6064448e-01, -9.6040183e-01, + -9.6015918e-01, -9.5991665e-01, -9.5967412e-01, -9.5943171e-01, + -9.5918930e-01, -9.5894700e-01, -9.5870471e-01, -9.5846248e-01, + -9.5822036e-01, -9.5797825e-01, -9.5773619e-01, -9.5749420e-01, + -9.5725226e-01, -9.5701039e-01, -9.5676857e-01, -9.5652682e-01, + -9.5628506e-01, -9.5604342e-01, -9.5580184e-01, -9.5556027e-01, + -9.5531881e-01, -9.5507735e-01, -9.5483601e-01, -9.5459467e-01, + -9.5435339e-01, -9.5411217e-01, -9.5387101e-01, -9.5362991e-01, + -9.5338887e-01, -9.5314789e-01, -9.5290697e-01, -9.5266610e-01, + -9.5242524e-01, -9.5218450e-01, -9.5194381e-01, -9.5170313e-01, + -9.5146251e-01, -9.5122200e-01, -9.5098150e-01, -9.5074105e-01, + -9.5050067e-01, -9.5026034e-01, -9.5002007e-01, -9.4977987e-01, + -9.4953972e-01, -9.4929957e-01, -9.4905955e-01, -9.4881952e-01, + -9.4857961e-01, -9.4833970e-01, -9.4809985e-01, -9.4786006e-01, + -9.4762039e-01, -9.4738066e-01, -9.4714105e-01, -9.4690150e-01, + -9.4666201e-01, -9.4642258e-01, -9.4618315e-01, -9.4594383e-01, + -9.4570452e-01, -9.4546527e-01, -9.4522607e-01, -9.4498694e-01, + -9.4474787e-01, -9.4450885e-01, -9.4426990e-01, -9.4403100e-01, + -9.4379210e-01, -9.4355333e-01, -9.4331455e-01, -9.4307590e-01, + -9.4283724e-01, -9.4259864e-01, -9.4236010e-01, -9.4212162e-01, + -9.4188321e-01, -9.4164485e-01, -9.4140649e-01, -9.4116825e-01, + -9.4093001e-01, -9.4069183e-01, -9.4045377e-01, -9.4021571e-01, + -9.3997771e-01, -9.3973976e-01, -9.3950182e-01, -9.3926400e-01, + -9.3902624e-01, -9.3878847e-01, -9.3855077e-01, -9.3831319e-01, + -9.3807560e-01, -9.3783808e-01, -9.3760061e-01, -9.3736315e-01, + -9.3712580e-01, -9.3688852e-01, -9.3665123e-01, -9.3641400e-01, + -9.3617690e-01, -9.3593979e-01, -9.3570274e-01, -9.3546569e-01, + -9.3522877e-01, -9.3499190e-01, -9.3475503e-01, -9.3451828e-01, + -9.3428153e-01, -9.3404484e-01, -9.3380821e-01, -9.3357164e-01, + -9.3333513e-01, -9.3309861e-01, -9.3286222e-01, -9.3262583e-01, + -9.3238950e-01, -9.3215328e-01, -9.3191707e-01, -9.3168086e-01, + -9.3144476e-01, -9.3120873e-01, -9.3097270e-01, -9.3073678e-01, + -9.3050086e-01, -9.3026501e-01, -9.3002921e-01, -9.2979348e-01, + -9.2955780e-01, -9.2932212e-01, -9.2908657e-01, -9.2885101e-01, + -9.2861551e-01, -9.2838007e-01, -9.2814469e-01, -9.2790937e-01, + -9.2767406e-01, -9.2743886e-01, -9.2720366e-01, -9.2696851e-01, + -9.2673343e-01, -9.2649841e-01, -9.2626345e-01, -9.2602855e-01, + -9.2579365e-01, -9.2555881e-01, -9.2532408e-01, -9.2508936e-01, + -9.2485470e-01, -9.2462003e-01, -9.2438549e-01, -9.2415094e-01, + -9.2391652e-01, -9.2368209e-01, -9.2344773e-01, -9.2321342e-01, + -9.2297918e-01, -9.2274493e-01, -9.2251080e-01, -9.2227668e-01, + -9.2204261e-01, -9.2180860e-01, -9.2157465e-01, -9.2134070e-01, + -9.2110687e-01, -9.2087305e-01, -9.2063934e-01, -9.2040563e-01, + -9.2017192e-01, -9.1993833e-01, -9.1970479e-01, -9.1947126e-01, + -9.1923779e-01, -9.1900444e-01, -9.1877103e-01, -9.1853774e-01, + -9.1830450e-01, -9.1807127e-01, -9.1783816e-01, -9.1760504e-01, + -9.1737199e-01, -9.1713893e-01, -9.1690600e-01, -9.1667312e-01, + -9.1644025e-01, -9.1620743e-01, -9.1597468e-01, -9.1574198e-01, + -9.1550928e-01, -9.1527671e-01, -9.1504413e-01, -9.1481161e-01, + -9.1457915e-01, -9.1434675e-01, -9.1411442e-01, -9.1388208e-01, + -9.1364980e-01, -9.1341758e-01, -9.1318542e-01, -9.1295332e-01, + -9.1272128e-01, -9.1248924e-01, -9.1225725e-01, -9.1202533e-01, + -9.1179347e-01, -9.1156167e-01, -9.1132987e-01, -9.1109818e-01, + -9.1086650e-01, -9.1063488e-01, -9.1040331e-01, -9.1017175e-01, + -9.0994030e-01, -9.0970886e-01, -9.0947747e-01, -9.0924615e-01, + -9.0901482e-01, -9.0878361e-01, -9.0855241e-01, -9.0832126e-01, + -9.0809017e-01, -9.0785915e-01, -9.0762818e-01, -9.0739721e-01, + -9.0716630e-01, -9.0693545e-01, -9.0670466e-01, -9.0647393e-01, + -9.0624321e-01, -9.0601259e-01, -9.0578198e-01, -9.0555137e-01, + -9.0532088e-01, -9.0509045e-01, -9.0486002e-01, -9.0462965e-01, + -9.0439934e-01, -9.0416908e-01, -9.0393883e-01, -9.0370864e-01, + -9.0347856e-01, -9.0324843e-01, -9.0301841e-01, -9.0278846e-01, + -9.0255851e-01, -9.0232861e-01, -9.0209877e-01, -9.0186900e-01, + -9.0163922e-01, -9.0140957e-01, -9.0117991e-01, -9.0095031e-01, + -9.0072072e-01, -9.0049124e-01, -9.0026176e-01, -9.0003234e-01, + -8.9980298e-01, -8.9957368e-01, -8.9934438e-01, -8.9911520e-01, + -8.9888602e-01, -8.9865690e-01, -8.9842778e-01, -8.9819878e-01, + -8.9796978e-01, -8.9774084e-01, -8.9751196e-01, -8.9728308e-01, + -8.9705431e-01, -8.9682555e-01, -8.9659685e-01, -8.9636821e-01, + -8.9613956e-01, -8.9591098e-01, -8.9568251e-01, -8.9545399e-01, + -8.9522558e-01, -8.9499724e-01, -8.9476889e-01, -8.9454061e-01, + -8.9431238e-01, -8.9408416e-01, -8.9385605e-01, -8.9362794e-01, + -8.9339989e-01, -8.9317185e-01, -8.9294392e-01, -8.9271599e-01, + -8.9248812e-01, -8.9226031e-01, -8.9203256e-01, -8.9180481e-01, + -8.9157712e-01, -8.9134949e-01, -8.9112192e-01, -8.9089435e-01, + -8.9066684e-01, -8.9043945e-01, -8.9021200e-01, -8.8998467e-01, + -8.8975734e-01, -8.8953006e-01, -8.8930285e-01, -8.8907570e-01, + -8.8884854e-01, -8.8862145e-01, -8.8839442e-01, -8.8816744e-01, + -8.8794053e-01, -8.8771361e-01, -8.8748676e-01, -8.8725996e-01, + -8.8703316e-01, -8.8680649e-01, -8.8657981e-01, -8.8635319e-01, + -8.8612658e-01, -8.8590008e-01, -8.8567358e-01, -8.8544714e-01, + -8.8522071e-01, -8.8499439e-01, -8.8476807e-01, -8.8454181e-01, + -8.8431555e-01, -8.8408941e-01, -8.8386327e-01, -8.8363719e-01, + -8.8341117e-01, -8.8318515e-01, -8.8295925e-01, -8.8273335e-01, + -8.8250744e-01, -8.8228166e-01, -8.8205588e-01, -8.8183016e-01, + -8.8160449e-01, -8.8137889e-01, -8.8115329e-01, -8.8092774e-01, + -8.8070226e-01, -8.8047677e-01, -8.8025135e-01, -8.8002604e-01, + -8.7980068e-01, -8.7957543e-01, -8.7935019e-01, -8.7912500e-01, + -8.7889987e-01, -8.7867481e-01, -8.7844974e-01, -8.7822473e-01, + -8.7799978e-01, -8.7777483e-01, -8.7754995e-01, -8.7732512e-01, + -8.7710035e-01, -8.7687564e-01, -8.7665093e-01, -8.7642628e-01, + -8.7620169e-01, -8.7597710e-01, -8.7575257e-01, -8.7552810e-01, + -8.7530369e-01, -8.7507927e-01, -8.7485492e-01, -8.7463063e-01, + -8.7440640e-01, -8.7418216e-01, -8.7395799e-01, -8.7373388e-01, + -8.7350982e-01, -8.7328577e-01, -8.7306178e-01, -8.7283784e-01, + -8.7261397e-01, -8.7239009e-01, -8.7216628e-01, -8.7194252e-01, + -8.7171876e-01, -8.7149507e-01, -8.7127143e-01, -8.7104785e-01, + -8.7082428e-01, -8.7060076e-01, -8.7037730e-01, -8.7015390e-01, + -8.6993051e-01, -8.6970717e-01, -8.6948389e-01, -8.6926061e-01, + -8.6903745e-01, -8.6881423e-01, -8.6859113e-01, -8.6836809e-01, + -8.6814505e-01, -8.6792201e-01, -8.6769909e-01, -8.6747617e-01, + -8.6725330e-01, -8.6703050e-01, -8.6680776e-01, -8.6658502e-01, + -8.6636233e-01, -8.6613965e-01, -8.6591709e-01, -8.6569452e-01, + -8.6547196e-01, -8.6524951e-01, -8.6502707e-01, -8.6480469e-01, + -8.6458236e-01, -8.6436003e-01, -8.6413777e-01, -8.6391556e-01, + -8.6369336e-01, -8.6347127e-01, -8.6324918e-01, -8.6302710e-01, + -8.6280513e-01, -8.6258316e-01, -8.6236125e-01, -8.6213934e-01, + -8.6191750e-01, -8.6169571e-01, -8.6147398e-01, -8.6125225e-01, + -8.6103058e-01, -8.6080897e-01, -8.6058742e-01, -8.6036587e-01, + -8.6014438e-01, -8.5992289e-01, -8.5970151e-01, -8.5948014e-01, + -8.5925877e-01, -8.5903752e-01, -8.5881627e-01, -8.5859507e-01, + -8.5837388e-01, -8.5815281e-01, -8.5793167e-01, -8.5771066e-01, + -8.5748965e-01, -8.5726875e-01, -8.5704780e-01, -8.5682696e-01, + -8.5660613e-01, -8.5638535e-01, -8.5616457e-01, -8.5594392e-01, + -8.5572326e-01, -8.5550261e-01, -8.5528207e-01, -8.5506153e-01, + -8.5484105e-01, -8.5462058e-01, -8.5440016e-01, -8.5417980e-01, + -8.5395950e-01, -8.5373920e-01, -8.5351896e-01, -8.5329872e-01, + -8.5307860e-01, -8.5285848e-01, -8.5263836e-01, -8.5241836e-01, + -8.5219836e-01, -8.5197842e-01, -8.5175848e-01, -8.5153860e-01, + -8.5131878e-01, -8.5109901e-01, -8.5087925e-01, -8.5065955e-01, + -8.5043991e-01, -8.5022026e-01, -8.5000068e-01, -8.4978116e-01, + -8.4956163e-01, -8.4934217e-01, -8.4912276e-01, -8.4890336e-01, + -8.4868401e-01, -8.4846473e-01, -8.4824550e-01, -8.4802628e-01, + -8.4780711e-01, -8.4758794e-01, -8.4736884e-01, -8.4714979e-01, + -8.4693080e-01, -8.4671181e-01, -8.4649289e-01, -8.4627402e-01, + -8.4605515e-01, -8.4583634e-01, -8.4561759e-01, -8.4539884e-01, + -8.4518015e-01, -8.4496152e-01, -8.4474289e-01, -8.4452432e-01, + -8.4430581e-01, -8.4408730e-01, -8.4386891e-01, -8.4365046e-01, + -8.4343213e-01, -8.4321380e-01, -8.4299552e-01, -8.4277725e-01, + -8.4255904e-01, -8.4234089e-01, -8.4212279e-01, -8.4190470e-01, + -8.4168661e-01, -8.4146863e-01, -8.4125066e-01, -8.4103274e-01, + -8.4081483e-01, -8.4059703e-01, -8.4037918e-01, -8.4016144e-01, + -8.3994371e-01, -8.3972603e-01, -8.3950841e-01, -8.3929080e-01, + -8.3907324e-01, -8.3885568e-01, -8.3863819e-01, -8.3842075e-01, + -8.3820337e-01, -8.3798599e-01, -8.3776867e-01, -8.3755136e-01, + -8.3733410e-01, -8.3711690e-01, -8.3689976e-01, -8.3668262e-01, + -8.3646554e-01, -8.3624846e-01, -8.3603144e-01, -8.3581448e-01, + -8.3559757e-01, -8.3538067e-01, -8.3516377e-01, -8.3494699e-01, + -8.3473021e-01, -8.3451349e-01, -8.3429676e-01, -8.3408010e-01, + -8.3386350e-01, -8.3364689e-01, -8.3343035e-01, -8.3321387e-01, + -8.3299738e-01, -8.3278096e-01, -8.3256459e-01, -8.3234823e-01, + -8.3213192e-01, -8.3191568e-01, -8.3169943e-01, -8.3148324e-01, + -8.3126712e-01, -8.3105099e-01, -8.3083493e-01, -8.3061886e-01, + -8.3040285e-01, -8.3018690e-01, -8.2997102e-01, -8.2975513e-01, + -8.2953930e-01, -8.2932347e-01, -8.2910770e-01, -8.2889199e-01, + -8.2867628e-01, -8.2846063e-01, -8.2824504e-01, -8.2802945e-01, + -8.2781392e-01, -8.2759845e-01, -8.2738298e-01, -8.2716757e-01, + -8.2695216e-01, -8.2673687e-01, -8.2652152e-01, -8.2630628e-01, + -8.2609105e-01, -8.2587588e-01, -8.2566071e-01, -8.2544559e-01, + -8.2523054e-01, -8.2501549e-01, -8.2480049e-01, -8.2458556e-01, + -8.2437062e-01, -8.2415575e-01, -8.2394087e-01, -8.2372606e-01, + -8.2351130e-01, -8.2329661e-01, -8.2308191e-01, -8.2286721e-01, + -8.2265264e-01, -8.2243806e-01, -8.2222348e-01, -8.2200897e-01, + -8.2179451e-01, -8.2158011e-01, -8.2136571e-01, -8.2115138e-01, + -8.2093704e-01, -8.2072276e-01, -8.2050854e-01, -8.2029432e-01, + -8.2008016e-01, -8.1986606e-01, -8.1965196e-01, -8.1943792e-01, + -8.1922388e-01, -8.1900990e-01, -8.1879598e-01, -8.1858206e-01, + -8.1836820e-01, -8.1815439e-01, -8.1794059e-01, -8.1772685e-01, + -8.1751311e-01, -8.1729943e-01, -8.1708580e-01, -8.1687218e-01, + -8.1665862e-01, -8.1644511e-01, -8.1623161e-01, -8.1601816e-01, + -8.1580472e-01, -8.1559139e-01, -8.1537801e-01, -8.1516474e-01, + -8.1495148e-01, -8.1473821e-01, -8.1452501e-01, -8.1431186e-01, + -8.1409878e-01, -8.1388569e-01, -8.1367260e-01, -8.1345963e-01, + -8.1324667e-01, -8.1303370e-01, -8.1282079e-01, -8.1260794e-01, + -8.1239510e-01, -8.1218231e-01, -8.1196958e-01, -8.1175685e-01, + -8.1154418e-01, -8.1133157e-01, -8.1111896e-01, -8.1090641e-01, + -8.1069386e-01, -8.1048137e-01, -8.1026888e-01, -8.1005645e-01, + -8.0984408e-01, -8.0963176e-01, -8.0941945e-01, -8.0920714e-01, + -8.0899495e-01, -8.0878270e-01, -8.0857056e-01, -8.0835843e-01, + -8.0814636e-01, -8.0793428e-01, -8.0772227e-01, -8.0751026e-01, + -8.0729830e-01, -8.0708641e-01, -8.0687451e-01, -8.0666268e-01, + -8.0645090e-01, -8.0623913e-01, -8.0602741e-01, -8.0581570e-01, + -8.0560404e-01, -8.0539244e-01, -8.0518085e-01, -8.0496931e-01, + -8.0475777e-01, -8.0454630e-01, -8.0433488e-01, -8.0412346e-01, + -8.0391210e-01, -8.0370075e-01, -8.0348945e-01, -8.0327821e-01, + -8.0306697e-01, -8.0285579e-01, -8.0264461e-01, -8.0243349e-01, + -8.0222243e-01, -8.0201137e-01, -8.0180037e-01, -8.0158937e-01, + -8.0137843e-01, -8.0116755e-01, -8.0095667e-01, -8.0074584e-01, + -8.0053502e-01, -8.0032426e-01, -8.0011356e-01, -7.9990286e-01, + -7.9969221e-01, -7.9948157e-01, -7.9927099e-01, -7.9906040e-01, + -7.9884994e-01, -7.9863942e-01, -7.9842901e-01, -7.9821861e-01, + -7.9800820e-01, -7.9779786e-01, -7.9758757e-01, -7.9737729e-01, + -7.9716706e-01, -7.9695690e-01, -7.9674673e-01, -7.9653656e-01, + -7.9632652e-01, -7.9611647e-01, -7.9590642e-01, -7.9569644e-01, + -7.9548651e-01, -7.9527658e-01, -7.9506671e-01, -7.9485685e-01, + -7.9464704e-01, -7.9443729e-01, -7.9422754e-01, -7.9401779e-01, + -7.9380816e-01, -7.9359853e-01, -7.9338890e-01, -7.9317933e-01, + -7.9296982e-01, -7.9276031e-01, -7.9255086e-01, -7.9234141e-01, + -7.9213202e-01, -7.9192269e-01, -7.9171336e-01, -7.9150409e-01, + -7.9129481e-01, -7.9108560e-01, -7.9087639e-01, -7.9066724e-01, + -7.9045814e-01, -7.9024905e-01, -7.9004002e-01, -7.8983098e-01, + -7.8962201e-01, -7.8941309e-01, -7.8920418e-01, -7.8899533e-01, + -7.8878647e-01, -7.8857768e-01, -7.8836888e-01, -7.8816015e-01, + -7.8795147e-01, -7.8774279e-01, -7.8753418e-01, -7.8732556e-01, + -7.8711700e-01, -7.8690845e-01, -7.8669995e-01, -7.8649151e-01, + -7.8628308e-01, -7.8607470e-01, -7.8586632e-01, -7.8565800e-01, + -7.8544968e-01, -7.8524148e-01, -7.8503323e-01, -7.8482503e-01, + -7.8461689e-01, -7.8440875e-01, -7.8420067e-01, -7.8399265e-01, + -7.8378463e-01, -7.8357661e-01, -7.8336865e-01, -7.8316075e-01, + -7.8295285e-01, -7.8274500e-01, -7.8253722e-01, -7.8232944e-01, + -7.8212166e-01, -7.8191394e-01, -7.8170627e-01, -7.8149861e-01, + -7.8129101e-01, -7.8108346e-01, -7.8087592e-01, -7.8066838e-01, + -7.8046089e-01, -7.8025347e-01, -7.8004605e-01, -7.7983868e-01, + -7.7963132e-01, -7.7942401e-01, -7.7921671e-01, -7.7900952e-01, + -7.7880228e-01, -7.7859509e-01, -7.7838796e-01, -7.7818084e-01, + -7.7797377e-01, -7.7776670e-01, -7.7755970e-01, -7.7735275e-01, + -7.7714580e-01, -7.7693892e-01, -7.7673203e-01, -7.7652514e-01, + -7.7631837e-01, -7.7611160e-01, -7.7590483e-01, -7.7569813e-01, + -7.7549142e-01, -7.7528483e-01, -7.7507818e-01, -7.7487159e-01, + -7.7466506e-01, -7.7445853e-01, -7.7425206e-01, -7.7404565e-01, + -7.7383924e-01, -7.7363282e-01, -7.7342647e-01, -7.7322018e-01, + -7.7301389e-01, -7.7280766e-01, -7.7260143e-01, -7.7239525e-01, + -7.7218908e-01, -7.7198297e-01, -7.7177691e-01, -7.7157086e-01, + -7.7136481e-01, -7.7115881e-01, -7.7095288e-01, -7.7074695e-01, + -7.7054107e-01, -7.7033520e-01, -7.7012938e-01, -7.6992357e-01, + -7.6971781e-01, -7.6951212e-01, -7.6930642e-01, -7.6910079e-01, + -7.6889515e-01, -7.6868951e-01, -7.6848400e-01, -7.6827842e-01, + -7.6807296e-01, -7.6786751e-01, -7.6766205e-01, -7.6745665e-01, + -7.6725125e-01, -7.6704592e-01, -7.6684064e-01, -7.6663536e-01, + -7.6643014e-01, -7.6622492e-01, -7.6601976e-01, -7.6581460e-01, + -7.6560950e-01, -7.6540440e-01, -7.6519936e-01, -7.6499438e-01, + -7.6478940e-01, -7.6458442e-01, -7.6437950e-01, -7.6417464e-01, + -7.6396978e-01, -7.6376498e-01, -7.6356018e-01, -7.6335543e-01, + -7.6315069e-01, -7.6294601e-01, -7.6274133e-01, -7.6253670e-01, + -7.6233208e-01, -7.6212752e-01, -7.6192302e-01, -7.6171851e-01, + -7.6151401e-01, -7.6130962e-01, -7.6110518e-01, -7.6090080e-01, + -7.6069647e-01, -7.6049215e-01, -7.6028788e-01, -7.6008362e-01, + -7.5987941e-01, -7.5967526e-01, -7.5947106e-01, -7.5926697e-01, + -7.5906289e-01, -7.5885880e-01, -7.5865477e-01, -7.5845081e-01, + -7.5824684e-01, -7.5804293e-01, -7.5783902e-01, -7.5763512e-01, + -7.5743133e-01, -7.5722748e-01, -7.5702375e-01, -7.5681996e-01, + -7.5661629e-01, -7.5641263e-01, -7.5620896e-01, -7.5600535e-01, + -7.5580174e-01, -7.5559819e-01, -7.5539470e-01, -7.5519121e-01, + -7.5498772e-01, -7.5478429e-01, -7.5458091e-01, -7.5437754e-01, + -7.5417417e-01, -7.5397086e-01, -7.5376761e-01, -7.5356436e-01, + -7.5336117e-01, -7.5315797e-01, -7.5295484e-01, -7.5275171e-01, + -7.5254864e-01, -7.5234556e-01, -7.5214255e-01, -7.5193954e-01, + -7.5173658e-01, -7.5153369e-01, -7.5133079e-01, -7.5112790e-01, + -7.5092506e-01, -7.5072223e-01, -7.5051945e-01, -7.5031674e-01, + -7.5011402e-01, -7.4991131e-01, -7.4970865e-01, -7.4950606e-01, + -7.4930346e-01, -7.4910092e-01, -7.4889839e-01, -7.4869585e-01, + -7.4849343e-01, -7.4829096e-01, -7.4808854e-01, -7.4788618e-01, + -7.4768382e-01, -7.4748152e-01, -7.4727923e-01, -7.4707699e-01, + -7.4687475e-01, -7.4667257e-01, -7.4647039e-01, -7.4626827e-01, + -7.4606615e-01, -7.4586409e-01, -7.4566203e-01, -7.4546003e-01, + -7.4525809e-01, -7.4505609e-01, -7.4485421e-01, -7.4465233e-01, + -7.4445045e-01, -7.4424863e-01, -7.4404681e-01, -7.4384505e-01, + -7.4364334e-01, -7.4344164e-01, -7.4323994e-01, -7.4303830e-01, + -7.4283665e-01, -7.4263507e-01, -7.4243355e-01, -7.4223202e-01, + -7.4203050e-01, -7.4182904e-01, -7.4162763e-01, -7.4142623e-01, + -7.4122483e-01, -7.4102348e-01, -7.4082220e-01, -7.4062091e-01, + -7.4041963e-01, -7.4021840e-01, -7.4001724e-01, -7.3981607e-01, + -7.3961490e-01, -7.3941380e-01, -7.3921275e-01, -7.3901170e-01, + -7.3881066e-01, -7.3860967e-01, -7.3840874e-01, -7.3820782e-01, + -7.3800689e-01, -7.3780602e-01, -7.3760521e-01, -7.3740441e-01, + -7.3720360e-01, -7.3700285e-01, -7.3680216e-01, -7.3660147e-01, + -7.3640078e-01, -7.3620015e-01, -7.3599958e-01, -7.3579901e-01, + -7.3559844e-01, -7.3539793e-01, -7.3519748e-01, -7.3499703e-01, + -7.3479658e-01, -7.3459619e-01, -7.3439586e-01, -7.3419553e-01, + -7.3399520e-01, -7.3379493e-01, -7.3359466e-01, -7.3339444e-01, + -7.3319429e-01, -7.3299414e-01, -7.3279399e-01, -7.3259389e-01, + -7.3239380e-01, -7.3219377e-01, -7.3199379e-01, -7.3179382e-01, + -7.3159385e-01, -7.3139393e-01, -7.3119402e-01, -7.3099416e-01, + -7.3079431e-01, -7.3059452e-01, -7.3039472e-01, -7.3019499e-01, + -7.2999531e-01, -7.2979558e-01, -7.2959596e-01, -7.2939628e-01, + -7.2919673e-01, -7.2899711e-01, -7.2879755e-01, -7.2859806e-01, + -7.2839856e-01, -7.2819912e-01, -7.2799969e-01, -7.2780031e-01, + -7.2760093e-01, -7.2740161e-01, -7.2720230e-01, -7.2700298e-01, + -7.2680372e-01, -7.2660452e-01, -7.2640532e-01, -7.2620612e-01, + -7.2600698e-01, -7.2580791e-01, -7.2560883e-01, -7.2540975e-01, + -7.2521073e-01, -7.2501177e-01, -7.2481281e-01, -7.2461385e-01, + -7.2441494e-01, -7.2421604e-01, -7.2401720e-01, -7.2381836e-01, + -7.2361958e-01, -7.2342080e-01, -7.2322208e-01, -7.2302336e-01, + -7.2282469e-01, -7.2262603e-01, -7.2242743e-01, -7.2222883e-01, + -7.2203022e-01, -7.2183174e-01, -7.2163320e-01, -7.2143471e-01, + -7.2123629e-01, -7.2103786e-01, -7.2083944e-01, -7.2064108e-01, + -7.2044271e-01, -7.2024441e-01, -7.2004616e-01, -7.1984792e-01, + -7.1964967e-01, -7.1945149e-01, -7.1925330e-01, -7.1905518e-01, + -7.1885705e-01, -7.1865898e-01, -7.1846092e-01, -7.1826285e-01, + -7.1806484e-01, -7.1786690e-01, -7.1766895e-01, -7.1747106e-01, + -7.1727318e-01, -7.1707529e-01, -7.1687746e-01, -7.1667963e-01, + -7.1648186e-01, -7.1628416e-01, -7.1608639e-01, -7.1588874e-01, + -7.1569109e-01, -7.1549344e-01, -7.1529579e-01, -7.1509826e-01, + -7.1490067e-01, -7.1470314e-01, -7.1450567e-01, -7.1430820e-01, + -7.1411073e-01, -7.1391332e-01, -7.1371597e-01, -7.1351862e-01, + -7.1332127e-01, -7.1312398e-01, -7.1292669e-01, -7.1272945e-01, + -7.1253222e-01, -7.1233505e-01, -7.1213788e-01, -7.1194077e-01, + -7.1174365e-01, -7.1154654e-01, -7.1134949e-01, -7.1115249e-01, + -7.1095550e-01, -7.1075851e-01, -7.1056157e-01, -7.1036464e-01, + -7.1016777e-01, -7.0997089e-01, -7.0977408e-01, -7.0957726e-01, + -7.0938051e-01, -7.0918375e-01, -7.0898706e-01, -7.0879036e-01, + -7.0859367e-01, -7.0839703e-01, -7.0820040e-01, -7.0800382e-01, + -7.0780730e-01, -7.0761073e-01, -7.0741427e-01, -7.0721775e-01, + -7.0702136e-01, -7.0682490e-01, -7.0662850e-01, -7.0643216e-01, + -7.0623583e-01, -7.0603949e-01, -7.0584321e-01, -7.0564693e-01, + -7.0545071e-01, -7.0525450e-01, -7.0505834e-01, -7.0486218e-01, + -7.0466608e-01, -7.0446998e-01, -7.0427394e-01, -7.0407790e-01, + -7.0388186e-01, -7.0368588e-01, -7.0348990e-01, -7.0329398e-01, + -7.0309806e-01, -7.0290220e-01, -7.0270634e-01, -7.0251054e-01, + -7.0231473e-01, -7.0211893e-01, -7.0192319e-01, -7.0172751e-01, + -7.0153183e-01, -7.0133615e-01, -7.0114052e-01, -7.0094490e-01, + -7.0074934e-01, -7.0055377e-01, -7.0035821e-01, -7.0016271e-01, + -6.9996727e-01, -6.9977182e-01, -6.9957638e-01, -6.9938099e-01, + -6.9918561e-01, -6.9899029e-01, -6.9879496e-01, -6.9859970e-01, + -6.9840443e-01, -6.9820917e-01, -6.9801396e-01, -6.9781876e-01, + -6.9762361e-01, -6.9742852e-01, -6.9723338e-01, -6.9703835e-01, + -6.9684327e-01, -6.9664824e-01, -6.9645327e-01, -6.9625831e-01, + -6.9606334e-01, -6.9586843e-01, -6.9567353e-01, -6.9547868e-01, + -6.9528383e-01, -6.9508904e-01, -6.9489425e-01, -6.9469947e-01, + -6.9450474e-01, -6.9431007e-01, -6.9411534e-01, -6.9392073e-01, + -6.9372606e-01, -6.9353145e-01, -6.9333690e-01, -6.9314235e-01, + -6.9294786e-01, -6.9275331e-01, -6.9255888e-01, -6.9236445e-01, + -6.9217002e-01, -6.9197559e-01, -6.9178128e-01, -6.9158691e-01, + -6.9139260e-01, -6.9119835e-01, -6.9100404e-01, -6.9080985e-01, + -6.9061559e-01, -6.9042146e-01, -6.9022727e-01, -6.9003314e-01, + -6.8983907e-01, -6.8964499e-01, -6.8945092e-01, -6.8925691e-01, + -6.8906289e-01, -6.8886894e-01, -6.8867499e-01, -6.8848103e-01, + -6.8828714e-01, -6.8809330e-01, -6.8789941e-01, -6.8770564e-01, + -6.8751180e-01, -6.8731803e-01, -6.8712431e-01, -6.8693060e-01, + -6.8673688e-01, -6.8654323e-01, -6.8634963e-01, -6.8615597e-01, + -6.8596238e-01, -6.8576884e-01, -6.8557531e-01, -6.8538177e-01, + -6.8518829e-01, -6.8499488e-01, -6.8480140e-01, -6.8460798e-01, + -6.8441463e-01, -6.8422127e-01, -6.8402797e-01, -6.8383461e-01, + -6.8364137e-01, -6.8344808e-01, -6.8325490e-01, -6.8306166e-01, + -6.8286848e-01, -6.8267536e-01, -6.8248224e-01, -6.8228912e-01, + -6.8209606e-01, -6.8190300e-01, -6.8170995e-01, -6.8151695e-01, + -6.8132401e-01, -6.8113106e-01, -6.8093812e-01, -6.8074524e-01, + -6.8055236e-01, -6.8035948e-01, -6.8016666e-01, -6.7997390e-01, + -6.7978114e-01, -6.7958838e-01, -6.7939562e-01, -6.7920297e-01, + -6.7901027e-01, -6.7881763e-01, -6.7862499e-01, -6.7843240e-01, + -6.7823982e-01, -6.7804730e-01, -6.7785478e-01, -6.7766231e-01, + -6.7746985e-01, -6.7727739e-01, -6.7708498e-01, -6.7689258e-01, + -6.7670017e-01, -6.7650783e-01, -6.7631555e-01, -6.7612326e-01, + -6.7593098e-01, -6.7573875e-01, -6.7554653e-01, -6.7535430e-01, + -6.7516214e-01, -6.7496997e-01, -6.7477787e-01, -6.7458576e-01, + -6.7439371e-01, -6.7420167e-01, -6.7400968e-01, -6.7381763e-01, + -6.7362571e-01, -6.7343372e-01, -6.7324179e-01, -6.7304993e-01, + -6.7285806e-01, -6.7266619e-01, -6.7247438e-01, -6.7228258e-01, + -6.7209083e-01, -6.7189908e-01, -6.7170733e-01, -6.7151564e-01, + -6.7132396e-01, -6.7113233e-01, -6.7094070e-01, -6.7074913e-01, + -6.7055756e-01, -6.7036599e-01, -6.7017448e-01, -6.6998297e-01, + -6.6979146e-01, -6.6960001e-01, -6.6940862e-01, -6.6921723e-01, + -6.6902584e-01, -6.6883445e-01, -6.6864312e-01, -6.6845185e-01, + -6.6826057e-01, -6.6806930e-01, -6.6787809e-01, -6.6768688e-01, + -6.6749567e-01, -6.6730452e-01, -6.6711336e-01, -6.6692227e-01, + -6.6673118e-01, -6.6654015e-01, -6.6634911e-01, -6.6615808e-01, + -6.6596711e-01, -6.6577613e-01, -6.6558522e-01, -6.6539431e-01, + -6.6520339e-01, -6.6501254e-01, -6.6482168e-01, -6.6463089e-01, + -6.6444010e-01, -6.6424930e-01, -6.6405857e-01, -6.6386783e-01, + -6.6367716e-01, -6.6348648e-01, -6.6329581e-01, -6.6310519e-01, + -6.6291457e-01, -6.6272402e-01, -6.6253346e-01, -6.6234291e-01, + -6.6215241e-01, -6.6196197e-01, -6.6177148e-01, -6.6158104e-01, + -6.6139066e-01, -6.6120028e-01, -6.6100991e-01, -6.6081959e-01, + -6.6062927e-01, -6.6043895e-01, -6.6024870e-01, -6.6005844e-01, + -6.5986824e-01, -6.5967804e-01, -6.5948790e-01, -6.5929776e-01, + -6.5910763e-01, -6.5891755e-01, -6.5872747e-01, -6.5853739e-01, + -6.5834737e-01, -6.5815735e-01, -6.5796739e-01, -6.5777743e-01, + -6.5758753e-01, -6.5739763e-01, -6.5720773e-01, -6.5701783e-01, + -6.5682805e-01, -6.5663821e-01, -6.5644842e-01, -6.5625864e-01, + -6.5606892e-01, -6.5587920e-01, -6.5568948e-01, -6.5549982e-01, + -6.5531015e-01, -6.5512055e-01, -6.5493095e-01, -6.5474141e-01, + -6.5455180e-01, -6.5436232e-01, -6.5417278e-01, -6.5398329e-01, + -6.5379387e-01, -6.5360439e-01, -6.5341502e-01, -6.5322560e-01, + -6.5303624e-01, -6.5284693e-01, -6.5265757e-01, -6.5246826e-01, + -6.5227902e-01, -6.5208977e-01, -6.5190053e-01, -6.5171134e-01, + -6.5152216e-01, -6.5133303e-01, -6.5114385e-01, -6.5095478e-01, + -6.5076566e-01, -6.5057659e-01, -6.5038759e-01, -6.5019858e-01, + -6.5000957e-01, -6.4982063e-01, -6.4963168e-01, -6.4944273e-01, + -6.4925385e-01, -6.4906496e-01, -6.4887613e-01, -6.4868730e-01, + -6.4849848e-01, -6.4830971e-01, -6.4812094e-01, -6.4793217e-01, + -6.4774346e-01, -6.4755476e-01, -6.4736611e-01, -6.4717746e-01, + -6.4698887e-01, -6.4680022e-01, -6.4661169e-01, -6.4642310e-01, + -6.4623457e-01, -6.4604610e-01, -6.4585757e-01, -6.4566916e-01, + -6.4548069e-01, -6.4529228e-01, -6.4510387e-01, -6.4491552e-01, + -6.4472717e-01, -6.4453882e-01, -6.4435053e-01, -6.4416224e-01, + -6.4397401e-01, -6.4378577e-01, -6.4359754e-01, -6.4340937e-01, + -6.4322120e-01, -6.4303309e-01, -6.4284497e-01, -6.4265686e-01, + -6.4246881e-01, -6.4228076e-01, -6.4209270e-01, -6.4190471e-01, + -6.4171672e-01, -6.4152879e-01, -6.4134085e-01, -6.4115292e-01, + -6.4096504e-01, -6.4077717e-01, -6.4058930e-01, -6.4040148e-01, + -6.4021367e-01, -6.4002591e-01, -6.3983816e-01, -6.3965040e-01, + -6.3946271e-01, -6.3927501e-01, -6.3908732e-01, -6.3889968e-01, + -6.3871205e-01, -6.3852447e-01, -6.3833690e-01, -6.3814932e-01, + -6.3796180e-01, -6.3777429e-01, -6.3758683e-01, -6.3739938e-01, + -6.3721192e-01, -6.3702452e-01, -6.3683712e-01, -6.3664973e-01, + -6.3646239e-01, -6.3627505e-01, -6.3608772e-01, -6.3590044e-01, + -6.3571316e-01, -6.3552594e-01, -6.3533872e-01, -6.3515151e-01, + -6.3496435e-01, -6.3477719e-01, -6.3459009e-01, -6.3440299e-01, + -6.3421589e-01, -6.3402879e-01, -6.3384175e-01, -6.3365477e-01, + -6.3346779e-01, -6.3328081e-01, -6.3309383e-01, -6.3290691e-01, + -6.3271999e-01, -6.3253313e-01, -6.3234627e-01, -6.3215941e-01, + -6.3197261e-01, -6.3178581e-01, -6.3159901e-01, -6.3141227e-01, + -6.3122553e-01, -6.3103884e-01, -6.3085216e-01, -6.3066548e-01, + -6.3047886e-01, -6.3029224e-01, -6.3010561e-01, -6.2991905e-01, + -6.2973249e-01, -6.2954593e-01, -6.2935942e-01, -6.2917292e-01, + -6.2898648e-01, -6.2880003e-01, -6.2861359e-01, -6.2842721e-01, + -6.2824082e-01, -6.2805444e-01, -6.2786812e-01, -6.2768179e-01, + -6.2749553e-01, -6.2730926e-01, -6.2712300e-01, -6.2693679e-01, + -6.2675059e-01, -6.2656438e-01, -6.2637824e-01, -6.2619209e-01, + -6.2600595e-01, -6.2581986e-01, -6.2563378e-01, -6.2544775e-01, + -6.2526166e-01, -6.2507570e-01, -6.2488967e-01, -6.2470371e-01, + -6.2451780e-01, -6.2433183e-01, -6.2414593e-01, -6.2396008e-01, + -6.2377423e-01, -6.2358838e-01, -6.2340254e-01, -6.2321675e-01, + -6.2303096e-01, -6.2284523e-01, -6.2265950e-01, -6.2247378e-01, + -6.2228811e-01, -6.2210244e-01, -6.2191677e-01, -6.2173116e-01, + -6.2154555e-01, -6.2136000e-01, -6.2117440e-01, -6.2098891e-01, + -6.2080336e-01, -6.2061787e-01, -6.2043238e-01, -6.2024695e-01, + -6.2006152e-01, -6.1987609e-01, -6.1969072e-01, -6.1950535e-01, + -6.1931998e-01, -6.1913466e-01, -6.1894935e-01, -6.1876410e-01, + -6.1857885e-01, -6.1839360e-01, -6.1820835e-01, -6.1802316e-01, + -6.1783803e-01, -6.1765283e-01, -6.1746770e-01, -6.1728263e-01, + -6.1709750e-01, -6.1691242e-01, -6.1672741e-01, -6.1654234e-01, + -6.1635733e-01, -6.1617237e-01, -6.1598742e-01, -6.1580247e-01, + -6.1561751e-01, -6.1543262e-01, -6.1524773e-01, -6.1506289e-01, + -6.1487806e-01, -6.1469322e-01, -6.1450845e-01, -6.1432368e-01, + -6.1413890e-01, -6.1395419e-01, -6.1376947e-01, -6.1358476e-01, + -6.1340010e-01, -6.1321545e-01, -6.1303085e-01, -6.1284620e-01, + -6.1266160e-01, -6.1247706e-01, -6.1229253e-01, -6.1210799e-01, + -6.1192352e-01, -6.1173898e-01, -6.1155456e-01, -6.1137009e-01, + -6.1118567e-01, -6.1100125e-01, -6.1081690e-01, -6.1063254e-01, + -6.1044818e-01, -6.1026388e-01, -6.1007959e-01, -6.0989529e-01, + -6.0971105e-01, -6.0952681e-01, -6.0934263e-01, -6.0915840e-01, + -6.0897428e-01, -6.0879010e-01, -6.0860598e-01, -6.0842186e-01, + -6.0823774e-01, -6.0805368e-01, -6.0786963e-01, -6.0768563e-01, + -6.0750163e-01, -6.0731763e-01, -6.0713369e-01, -6.0694975e-01, + -6.0676581e-01, -6.0658187e-01, -6.0639799e-01, -6.0621417e-01, + -6.0603029e-01, -6.0584646e-01, -6.0566270e-01, -6.0547888e-01, + -6.0529512e-01, -6.0511142e-01, -6.0492766e-01, -6.0474396e-01, + -6.0456032e-01, -6.0437661e-01, -6.0419297e-01, -6.0400939e-01, + -6.0382581e-01, -6.0364223e-01, -6.0345864e-01, -6.0327512e-01, + -6.0309160e-01, -6.0290807e-01, -6.0272461e-01, -6.0254115e-01, + -6.0235775e-01, -6.0217434e-01, -6.0199094e-01, -6.0180753e-01, + -6.0162419e-01, -6.0144085e-01, -6.0125756e-01, -6.0107428e-01, + -6.0089099e-01, -6.0070771e-01, -6.0052449e-01, -6.0034126e-01, + -6.0015810e-01, -5.9997493e-01, -5.9979177e-01, -5.9960866e-01, + -5.9942549e-01, -5.9924245e-01, -5.9905934e-01, -5.9887630e-01, + -5.9869325e-01, -5.9851027e-01, -5.9832728e-01, -5.9814429e-01, + -5.9796137e-01, -5.9777844e-01, -5.9759551e-01, -5.9741259e-01, + -5.9722972e-01, -5.9704691e-01, -5.9686404e-01, -5.9668124e-01, + -5.9649843e-01, -5.9631568e-01, -5.9613293e-01, -5.9595019e-01, + -5.9576750e-01, -5.9558481e-01, -5.9540212e-01, -5.9521949e-01, + -5.9503686e-01, -5.9485424e-01, -5.9467161e-01, -5.9448904e-01, + -5.9430653e-01, -5.9412396e-01, -5.9394145e-01, -5.9375894e-01, + -5.9357649e-01, -5.9339404e-01, -5.9321159e-01, -5.9302920e-01, + -5.9284681e-01, -5.9266442e-01, -5.9248203e-01, -5.9229970e-01, + -5.9211743e-01, -5.9193510e-01, -5.9175283e-01, -5.9157056e-01, + -5.9138834e-01, -5.9120613e-01, -5.9102392e-01, -5.9084171e-01, + -5.9065956e-01, -5.9047747e-01, -5.9029531e-01, -5.9011322e-01, + -5.8993113e-01, -5.8974910e-01, -5.8956701e-01, -5.8938503e-01, + -5.8920300e-01, -5.8902103e-01, -5.8883905e-01, -5.8865714e-01, + -5.8847517e-01, -5.8829331e-01, -5.8811140e-01, -5.8792955e-01, + -5.8774769e-01, -5.8756584e-01, -5.8738405e-01, -5.8720225e-01, + -5.8702052e-01, -5.8683872e-01, -5.8665699e-01, -5.8647531e-01, + -5.8629364e-01, -5.8611196e-01, -5.8593029e-01, -5.8574867e-01, + -5.8556706e-01, -5.8538544e-01, -5.8520389e-01, -5.8502233e-01, + -5.8484077e-01, -5.8465928e-01, -5.8447778e-01, -5.8429629e-01, + -5.8411479e-01, -5.8393335e-01, -5.8375198e-01, -5.8357054e-01, + -5.8338916e-01, -5.8320779e-01, -5.8302647e-01, -5.8284515e-01, + -5.8266383e-01, -5.8248252e-01, -5.8230126e-01, -5.8212000e-01, + -5.8193880e-01, -5.8175761e-01, -5.8157641e-01, -5.8139521e-01, + -5.8121407e-01, -5.8103293e-01, -5.8085179e-01, -5.8067071e-01, + -5.8048964e-01, -5.8030856e-01, -5.8012754e-01, -5.7994652e-01, + -5.7976550e-01, -5.7958454e-01, -5.7940358e-01, -5.7922262e-01, + -5.7904172e-01, -5.7886082e-01, -5.7867992e-01, -5.7849902e-01, + -5.7831818e-01, -5.7813734e-01, -5.7795656e-01, -5.7777578e-01, + -5.7759500e-01, -5.7741421e-01, -5.7723349e-01, -5.7705277e-01, + -5.7687205e-01, -5.7669139e-01, -5.7651073e-01, -5.7633007e-01, + -5.7614946e-01, -5.7596886e-01, -5.7578826e-01, -5.7560772e-01, + -5.7542717e-01, -5.7524663e-01, -5.7506609e-01, -5.7488561e-01, + -5.7470512e-01, -5.7452470e-01, -5.7434428e-01, -5.7416385e-01, + -5.7398343e-01, -5.7380307e-01, -5.7362270e-01, -5.7344234e-01, + -5.7326204e-01, -5.7308173e-01, -5.7290143e-01, -5.7272118e-01, + -5.7254094e-01, -5.7236069e-01, -5.7218051e-01, -5.7200027e-01, + -5.7182014e-01, -5.7163996e-01, -5.7145983e-01, -5.7127970e-01, + -5.7109958e-01, -5.7091951e-01, -5.7073945e-01, -5.7055938e-01, + -5.7037938e-01, -5.7019937e-01, -5.7001936e-01, -5.6983942e-01, + -5.6965947e-01, -5.6947953e-01, -5.6929958e-01, -5.6911969e-01, + -5.6893981e-01, -5.6875998e-01, -5.6858015e-01, -5.6840032e-01, + -5.6822050e-01, -5.6804073e-01, -5.6786096e-01, -5.6768119e-01, + -5.6750149e-01, -5.6732172e-01, -5.6714207e-01, -5.6696236e-01, + -5.6678271e-01, -5.6660306e-01, -5.6642348e-01, -5.6624383e-01, + -5.6606424e-01, -5.6588471e-01, -5.6570512e-01, -5.6552559e-01, + -5.6534612e-01, -5.6516659e-01, -5.6498712e-01, -5.6480765e-01, + -5.6462824e-01, -5.6444883e-01, -5.6426942e-01, -5.6409001e-01, + -5.6391066e-01, -5.6373131e-01, -5.6355196e-01, -5.6337267e-01, + -5.6319338e-01, -5.6301409e-01, -5.6283480e-01, -5.6265557e-01, + -5.6247634e-01, -5.6229717e-01, -5.6211799e-01, -5.6193882e-01, + -5.6175965e-01, -5.6158054e-01, -5.6140143e-01, -5.6122231e-01, + -5.6104320e-01, -5.6086415e-01, -5.6068510e-01, -5.6050611e-01, + -5.6032711e-01, -5.6014812e-01, -5.5996913e-01, -5.5979019e-01, + -5.5961126e-01, -5.5943233e-01, -5.5925345e-01, -5.5907458e-01, + -5.5889571e-01, -5.5871683e-01, -5.5853802e-01, -5.5835921e-01, + -5.5818039e-01, -5.5800164e-01, -5.5782288e-01, -5.5764413e-01, + -5.5746543e-01, -5.5728674e-01, -5.5710804e-01, -5.5692935e-01, + -5.5675071e-01, -5.5657208e-01, -5.5639350e-01, -5.5621487e-01, + -5.5603629e-01, -5.5585772e-01, -5.5567920e-01, -5.5550069e-01, + -5.5532217e-01, -5.5514365e-01, -5.5496520e-01, -5.5478674e-01, + -5.5460835e-01, -5.5442989e-01, -5.5425149e-01, -5.5407310e-01, + -5.5389476e-01, -5.5371642e-01, -5.5353808e-01, -5.5335975e-01, + -5.5318147e-01, -5.5300319e-01, -5.5282491e-01, -5.5264670e-01, + -5.5246848e-01, -5.5229026e-01, -5.5211204e-01, -5.5193388e-01, + -5.5175573e-01, -5.5157757e-01, -5.5139947e-01, -5.5122137e-01, + -5.5104327e-01, -5.5086523e-01, -5.5068713e-01, -5.5050915e-01, + -5.5033112e-01, -5.5015314e-01, -5.4997516e-01, -5.4979718e-01, + -5.4961920e-01, -5.4944128e-01, -5.4926342e-01, -5.4908550e-01, + -5.4890764e-01, -5.4872978e-01, -5.4855192e-01, -5.4837412e-01, + -5.4819632e-01, -5.4801852e-01, -5.4784071e-01, -5.4766297e-01, + -5.4748523e-01, -5.4730749e-01, -5.4712981e-01, -5.4695213e-01, + -5.4677445e-01, -5.4659683e-01, -5.4641914e-01, -5.4624158e-01, + -5.4606396e-01, -5.4588640e-01, -5.4570884e-01, -5.4553127e-01, + -5.4535371e-01, -5.4517621e-01, -5.4499871e-01, -5.4482126e-01, + -5.4464376e-01, -5.4446632e-01, -5.4428893e-01, -5.4411149e-01, + -5.4393411e-01, -5.4375672e-01, -5.4357940e-01, -5.4340202e-01, + -5.4322469e-01, -5.4304737e-01, -5.4287010e-01, -5.4269284e-01, + -5.4251558e-01, -5.4233831e-01, -5.4216111e-01, -5.4198390e-01, + -5.4180670e-01, -5.4162955e-01, -5.4145241e-01, -5.4127526e-01, + -5.4109812e-01, -5.4092103e-01, -5.4074395e-01, -5.4056686e-01, + -5.4038984e-01, -5.4021281e-01, -5.4003578e-01, -5.3985876e-01, + -5.3968179e-01, -5.3950483e-01, -5.3932786e-01, -5.3915095e-01, + -5.3897399e-01, -5.3879714e-01, -5.3862023e-01, -5.3844339e-01, + -5.3826654e-01, -5.3808969e-01, -5.3791285e-01, -5.3773606e-01, + -5.3755927e-01, -5.3738254e-01, -5.3720576e-01, -5.3702903e-01, + -5.3685230e-01, -5.3667563e-01, -5.3649896e-01, -5.3632230e-01, + -5.3614563e-01, -5.3596902e-01, -5.3579235e-01, -5.3561580e-01, + -5.3543919e-01, -5.3526264e-01, -5.3508610e-01, -5.3490955e-01, + -5.3473306e-01, -5.3455651e-01, -5.3438008e-01, -5.3420359e-01, + -5.3402716e-01, -5.3385073e-01, -5.3367430e-01, -5.3349787e-01, + -5.3332150e-01, -5.3314513e-01, -5.3296882e-01, -5.3279245e-01, + -5.3261614e-01, -5.3243983e-01, -5.3226358e-01, -5.3208733e-01, + -5.3191108e-01, -5.3173482e-01, -5.3155863e-01, -5.3138238e-01, + -5.3120625e-01, -5.3103006e-01, -5.3085393e-01, -5.3067780e-01, + -5.3050166e-01, -5.3032553e-01, -5.3014946e-01, -5.2997339e-01, + -5.2979738e-01, -5.2962130e-01, -5.2944529e-01, -5.2926928e-01, + -5.2909333e-01, -5.2891731e-01, -5.2874136e-01, -5.2856547e-01, + -5.2838951e-01, -5.2821362e-01, -5.2803773e-01, -5.2786183e-01, + -5.2768600e-01, -5.2751017e-01, -5.2733433e-01, -5.2715856e-01, + -5.2698272e-01, -5.2680695e-01, -5.2663124e-01, -5.2645546e-01, + -5.2627975e-01, -5.2610403e-01, -5.2592838e-01, -5.2575266e-01, + -5.2557701e-01, -5.2540135e-01, -5.2522576e-01, -5.2505010e-01, + -5.2487451e-01, -5.2469897e-01, -5.2452338e-01, -5.2434784e-01, + -5.2417231e-01, -5.2399683e-01, -5.2382129e-01, -5.2364582e-01, + -5.2347034e-01, -5.2329493e-01, -5.2311945e-01, -5.2294403e-01, + -5.2276868e-01, -5.2259326e-01, -5.2241790e-01, -5.2224255e-01, + -5.2206719e-01, -5.2189189e-01, -5.2171659e-01, -5.2154130e-01, + -5.2136600e-01, -5.2119076e-01, -5.2101552e-01, -5.2084029e-01, + -5.2066511e-01, -5.2048987e-01, -5.2031469e-01, -5.2013958e-01, + -5.1996440e-01, -5.1978928e-01, -5.1961416e-01, -5.1943904e-01, + -5.1926398e-01, -5.1908892e-01, -5.1891387e-01, -5.1873887e-01, + -5.1856381e-01, -5.1838881e-01, -5.1821381e-01, -5.1803887e-01, + -5.1786393e-01, -5.1768899e-01, -5.1751405e-01, -5.1733917e-01, + -5.1716423e-01, -5.1698935e-01, -5.1681453e-01, -5.1663965e-01, + -5.1646483e-01, -5.1629001e-01, -5.1611525e-01, -5.1594043e-01, + -5.1576567e-01, -5.1559097e-01, -5.1541620e-01, -5.1524150e-01, + -5.1506680e-01, -5.1489210e-01, -5.1471746e-01, -5.1454276e-01, + -5.1436812e-01, -5.1419353e-01, -5.1401889e-01, -5.1384431e-01, + -5.1366973e-01, -5.1349521e-01, -5.1332062e-01, -5.1314610e-01, + -5.1297158e-01, -5.1279712e-01, -5.1262259e-01, -5.1244813e-01, + -5.1227367e-01, -5.1209927e-01, -5.1192486e-01, -5.1175046e-01, + -5.1157606e-01, -5.1140165e-01, -5.1122731e-01, -5.1105297e-01, + -5.1087862e-01, -5.1070434e-01, -5.1053005e-01, -5.1035577e-01, + -5.1018149e-01, -5.1000726e-01, -5.0983304e-01, -5.0965881e-01, + -5.0948459e-01, -5.0931042e-01, -5.0913620e-01, -5.0896209e-01, + -5.0878793e-01, -5.0861382e-01, -5.0843972e-01, -5.0826561e-01, + -5.0809151e-01, -5.0791746e-01, -5.0774342e-01, -5.0756937e-01, + -5.0739533e-01, -5.0722134e-01, -5.0704736e-01, -5.0687337e-01, + -5.0669944e-01, -5.0652552e-01, -5.0635159e-01, -5.0617766e-01, + -5.0600374e-01, -5.0582987e-01, -5.0565600e-01, -5.0548220e-01, + -5.0530833e-01, -5.0513452e-01, -5.0496072e-01, -5.0478691e-01, + -5.0461316e-01, -5.0443941e-01, -5.0426567e-01, -5.0409192e-01, + -5.0391823e-01, -5.0374454e-01, -5.0357085e-01, -5.0339717e-01, + -5.0322354e-01, -5.0304991e-01, -5.0287628e-01, -5.0270265e-01, + -5.0252908e-01, -5.0235552e-01, -5.0218195e-01, -5.0200838e-01, + -5.0183487e-01, -5.0166136e-01, -5.0148785e-01, -5.0131434e-01, + -5.0114089e-01, -5.0096744e-01, -5.0079399e-01, -5.0062054e-01, + -5.0044715e-01, -5.0027376e-01, -5.0010037e-01, -4.9992701e-01, + -4.9975368e-01, -4.9958032e-01, -4.9940702e-01, -4.9923372e-01, + -4.9906042e-01, -4.9888715e-01, -4.9871388e-01, -4.9854064e-01, + -4.9836743e-01, -4.9819419e-01, -4.9802101e-01, -4.9784783e-01, + -4.9767464e-01, -4.9750149e-01, -4.9732834e-01, -4.9715522e-01, + -4.9698213e-01, -4.9680904e-01, -4.9663594e-01, -4.9646288e-01, + -4.9628982e-01, -4.9611679e-01, -4.9594378e-01, -4.9577075e-01, + -4.9559778e-01, -4.9542481e-01, -4.9525183e-01, -4.9507889e-01, + -4.9490595e-01, -4.9473304e-01, -4.9456015e-01, -4.9438724e-01, + -4.9421439e-01, -4.9404153e-01, -4.9386868e-01, -4.9369586e-01, + -4.9352303e-01, -4.9335024e-01, -4.9317744e-01, -4.9300468e-01, + -4.9283192e-01, -4.9265918e-01, -4.9248648e-01, -4.9231374e-01, + -4.9214107e-01, -4.9196836e-01, -4.9179572e-01, -4.9162304e-01, + -4.9145043e-01, -4.9127778e-01, -4.9110520e-01, -4.9093258e-01, + -4.9076003e-01, -4.9058744e-01, -4.9041489e-01, -4.9024236e-01, + -4.9006984e-01, -4.8989734e-01, -4.8972484e-01, -4.8955238e-01, + -4.8937991e-01, -4.8920748e-01, -4.8903504e-01, -4.8886260e-01, + -4.8869020e-01, -4.8851782e-01, -4.8834544e-01, -4.8817310e-01, + -4.8800075e-01, -4.8782840e-01, -4.8765609e-01, -4.8748380e-01, + -4.8731151e-01, -4.8713923e-01, -4.8696697e-01, -4.8679471e-01, + -4.8662248e-01, -4.8645028e-01, -4.8627809e-01, -4.8610589e-01, + -4.8593372e-01, -4.8576155e-01, -4.8558941e-01, -4.8541728e-01, + -4.8524517e-01, -4.8507306e-01, -4.8490098e-01, -4.8472890e-01, + -4.8455685e-01, -4.8438480e-01, -4.8421279e-01, -4.8404077e-01, + -4.8386878e-01, -4.8369679e-01, -4.8352480e-01, -4.8335287e-01, + -4.8318091e-01, -4.8300898e-01, -4.8283708e-01, -4.8266518e-01, + -4.8249328e-01, -4.8232141e-01, -4.8214954e-01, -4.8197770e-01, + -4.8180589e-01, -4.8163408e-01, -4.8146227e-01, -4.8129049e-01, + -4.8111871e-01, -4.8094696e-01, -4.8077521e-01, -4.8060349e-01, + -4.8043177e-01, -4.8026007e-01, -4.8008838e-01, -4.7991669e-01, + -4.7974506e-01, -4.7957340e-01, -4.7940177e-01, -4.7923017e-01, + -4.7905856e-01, -4.7888696e-01, -4.7871539e-01, -4.7854382e-01, + -4.7837228e-01, -4.7820076e-01, -4.7802925e-01, -4.7785774e-01, + -4.7768626e-01, -4.7751477e-01, -4.7734332e-01, -4.7717187e-01, + -4.7700042e-01, -4.7682902e-01, -4.7665760e-01, -4.7648621e-01, + -4.7631484e-01, -4.7614348e-01, -4.7597212e-01, -4.7580078e-01, + -4.7562948e-01, -4.7545815e-01, -4.7528687e-01, -4.7511560e-01, + -4.7494432e-01, -4.7477308e-01, -4.7460184e-01, -4.7443059e-01, + -4.7425941e-01, -4.7408819e-01, -4.7391701e-01, -4.7374585e-01, + -4.7357470e-01, -4.7340354e-01, -4.7323242e-01, -4.7306132e-01, + -4.7289023e-01, -4.7271913e-01, -4.7254807e-01, -4.7237700e-01, + -4.7220597e-01, -4.7203493e-01, -4.7186393e-01, -4.7169292e-01, + -4.7152191e-01, -4.7135094e-01, -4.7117999e-01, -4.7100905e-01, + -4.7083810e-01, -4.7066718e-01, -4.7049630e-01, -4.7032538e-01, + -4.7015452e-01, -4.6998364e-01, -4.6981281e-01, -4.6964195e-01, + -4.6947113e-01, -4.6930033e-01, -4.6912953e-01, -4.6895874e-01, + -4.6878797e-01, -4.6861723e-01, -4.6844649e-01, -4.6827576e-01, + -4.6810505e-01, -4.6793434e-01, -4.6776366e-01, -4.6759298e-01, + -4.6742234e-01, -4.6725169e-01, -4.6708104e-01, -4.6691042e-01, + -4.6673983e-01, -4.6656922e-01, -4.6639866e-01, -4.6622810e-01, + -4.6605754e-01, -4.6588701e-01, -4.6571648e-01, -4.6554595e-01, + -4.6537545e-01, -4.6520498e-01, -4.6503451e-01, -4.6486405e-01, + -4.6469361e-01, -4.6452320e-01, -4.6435279e-01, -4.6418238e-01, + -4.6401197e-01, -4.6384162e-01, -4.6367124e-01, -4.6350089e-01, + -4.6333057e-01, -4.6316025e-01, -4.6298993e-01, -4.6281964e-01, + -4.6264935e-01, -4.6247908e-01, -4.6230882e-01, -4.6213859e-01, + -4.6196836e-01, -4.6179816e-01, -4.6162796e-01, -4.6145776e-01, + -4.6128759e-01, -4.6111742e-01, -4.6094728e-01, -4.6077716e-01, + -4.6060702e-01, -4.6043691e-01, -4.6026683e-01, -4.6009675e-01, + -4.5992669e-01, -4.5975661e-01, -4.5958659e-01, -4.5941657e-01, + -4.5924655e-01, -4.5907655e-01, -4.5890656e-01, -4.5873657e-01, + -4.5856661e-01, -4.5839667e-01, -4.5822674e-01, -4.5805681e-01, + -4.5788690e-01, -4.5771700e-01, -4.5754713e-01, -4.5737725e-01, + -4.5720741e-01, -4.5703757e-01, -4.5686772e-01, -4.5669791e-01, + -4.5652813e-01, -4.5635834e-01, -4.5618856e-01, -4.5601878e-01, + -4.5584905e-01, -4.5567930e-01, -4.5550957e-01, -4.5533988e-01, + -4.5517018e-01, -4.5500049e-01, -4.5483083e-01, -4.5466116e-01, + -4.5449153e-01, -4.5432189e-01, -4.5415226e-01, -4.5398265e-01, + -4.5381308e-01, -4.5364347e-01, -4.5347393e-01, -4.5330435e-01, + -4.5313483e-01, -4.5296529e-01, -4.5279577e-01, -4.5262629e-01, + -4.5245680e-01, -4.5228732e-01, -4.5211786e-01, -4.5194840e-01, + -4.5177898e-01, -4.5160955e-01, -4.5144013e-01, -4.5127073e-01, + -4.5110136e-01, -4.5093197e-01, -4.5076263e-01, -4.5059326e-01, + -4.5042393e-01, -4.5025462e-01, -4.5008531e-01, -4.4991601e-01, + -4.4974673e-01, -4.4957748e-01, -4.4940820e-01, -4.4923896e-01, + -4.4906974e-01, -4.4890052e-01, -4.4873130e-01, -4.4856212e-01, + -4.4839296e-01, -4.4822377e-01, -4.4805464e-01, -4.4788548e-01, + -4.4771636e-01, -4.4754726e-01, -4.4737816e-01, -4.4720906e-01, + -4.4703999e-01, -4.4687092e-01, -4.4670185e-01, -4.4653282e-01, + -4.4636381e-01, -4.4619480e-01, -4.4602579e-01, -4.4585681e-01, + -4.4568783e-01, -4.4551888e-01, -4.4534993e-01, -4.4518098e-01, + -4.4501206e-01, -4.4484314e-01, -4.4467425e-01, -4.4450536e-01, + -4.4433650e-01, -4.4416764e-01, -4.4399878e-01, -4.4382995e-01, + -4.4366112e-01, -4.4349232e-01, -4.4332352e-01, -4.4315475e-01, + -4.4298598e-01, -4.4281721e-01, -4.4264847e-01, -4.4247973e-01, + -4.4231102e-01, -4.4214231e-01, -4.4197360e-01, -4.4180492e-01, + -4.4163626e-01, -4.4146761e-01, -4.4129896e-01, -4.4113031e-01, + -4.4096169e-01, -4.4079310e-01, -4.4062451e-01, -4.4045591e-01, + -4.4028735e-01, -4.4011879e-01, -4.3995023e-01, -4.3978170e-01, + -4.3961319e-01, -4.3944469e-01, -4.3927619e-01, -4.3910772e-01, + -4.3893924e-01, -4.3877077e-01, -4.3860233e-01, -4.3843389e-01, + -4.3826547e-01, -4.3809706e-01, -4.3792868e-01, -4.3776029e-01, + -4.3759191e-01, -4.3742356e-01, -4.3725520e-01, -4.3708688e-01, + -4.3691856e-01, -4.3675026e-01, -4.3658197e-01, -4.3641368e-01, + -4.3624541e-01, -4.3607715e-01, -4.3590888e-01, -4.3574065e-01, + -4.3557245e-01, -4.3540421e-01, -4.3523604e-01, -4.3506783e-01, + -4.3489966e-01, -4.3473151e-01, -4.3456337e-01, -4.3439522e-01, + -4.3422711e-01, -4.3405899e-01, -4.3389088e-01, -4.3372279e-01, + -4.3355474e-01, -4.3338665e-01, -4.3321860e-01, -4.3305057e-01, + -4.3288255e-01, -4.3271452e-01, -4.3254653e-01, -4.3237853e-01, + -4.3221056e-01, -4.3204260e-01, -4.3187466e-01, -4.3170670e-01, + -4.3153879e-01, -4.3137085e-01, -4.3120295e-01, -4.3103507e-01, + -4.3086720e-01, -4.3069932e-01, -4.3053147e-01, -4.3036363e-01, + -4.3019578e-01, -4.3002796e-01, -4.2986017e-01, -4.2969236e-01, + -4.2952460e-01, -4.2935681e-01, -4.2918906e-01, -4.2902130e-01, + -4.2885357e-01, -4.2868584e-01, -4.2851815e-01, -4.2835045e-01, + -4.2818275e-01, -4.2801508e-01, -4.2784742e-01, -4.2767978e-01, + -4.2751214e-01, -4.2734450e-01, -4.2717689e-01, -4.2700928e-01, + -4.2684171e-01, -4.2667413e-01, -4.2650655e-01, -4.2633900e-01, + -4.2617145e-01, -4.2600393e-01, -4.2583641e-01, -4.2566890e-01, + -4.2550141e-01, -4.2533392e-01, -4.2516646e-01, -4.2499900e-01, + -4.2483154e-01, -4.2466411e-01, -4.2449671e-01, -4.2432928e-01, + -4.2416188e-01, -4.2399451e-01, -4.2382711e-01, -4.2365977e-01, + -4.2349240e-01, -4.2332506e-01, -4.2315775e-01, -4.2299041e-01, + -4.2282313e-01, -4.2265582e-01, -4.2248854e-01, -4.2232129e-01, + -4.2215401e-01, -4.2198679e-01, -4.2181954e-01, -4.2165232e-01, + -4.2148513e-01, -4.2131791e-01, -4.2115071e-01, -4.2098355e-01, + -4.2081639e-01, -4.2064923e-01, -4.2048210e-01, -4.2031497e-01, + -4.2014787e-01, -4.1998076e-01, -4.1981366e-01, -4.1964659e-01, + -4.1947952e-01, -4.1931245e-01, -4.1914541e-01, -4.1897836e-01, + -4.1881135e-01, -4.1864434e-01, -4.1847736e-01, -4.1831037e-01, + -4.1814339e-01, -4.1797641e-01, -4.1780946e-01, -4.1764253e-01, + -4.1747561e-01, -4.1730869e-01, -4.1714177e-01, -4.1697487e-01, + -4.1680801e-01, -4.1664115e-01, -4.1647428e-01, -4.1630742e-01, + -4.1614059e-01, -4.1597375e-01, -4.1580695e-01, -4.1564015e-01, + -4.1547337e-01, -4.1530660e-01, -4.1513982e-01, -4.1497305e-01, + -4.1480631e-01, -4.1463959e-01, -4.1447288e-01, -4.1430616e-01, + -4.1413945e-01, -4.1397277e-01, -4.1380611e-01, -4.1363943e-01, + -4.1347280e-01, -4.1330615e-01, -4.1313952e-01, -4.1297290e-01, + -4.1280630e-01, -4.1263971e-01, -4.1247311e-01, -4.1230655e-01, + -4.1213998e-01, -4.1197345e-01, -4.1180691e-01, -4.1164038e-01, + -4.1147387e-01, -4.1130736e-01, -4.1114089e-01, -4.1097438e-01, + -4.1080794e-01, -4.1064146e-01, -4.1047502e-01, -4.1030860e-01, + -4.1014215e-01, -4.0997577e-01, -4.0980935e-01, -4.0964296e-01, + -4.0947658e-01, -4.0931022e-01, -4.0914387e-01, -4.0897754e-01, + -4.0881118e-01, -4.0864488e-01, -4.0847856e-01, -4.0831226e-01, + -4.0814599e-01, -4.0797970e-01, -4.0781343e-01, -4.0764719e-01, + -4.0748096e-01, -4.0731472e-01, -4.0714851e-01, -4.0698227e-01, + -4.0681610e-01, -4.0664992e-01, -4.0648374e-01, -4.0631756e-01, + -4.0615141e-01, -4.0598527e-01, -4.0581915e-01, -4.0565303e-01, + -4.0548691e-01, -4.0532082e-01, -4.0515473e-01, -4.0498868e-01, + -4.0482262e-01, -4.0465656e-01, -4.0449050e-01, -4.0432447e-01, + -4.0415847e-01, -4.0399247e-01, -4.0382648e-01, -4.0366048e-01, + -4.0349451e-01, -4.0332854e-01, -4.0316260e-01, -4.0299666e-01, + -4.0283072e-01, -4.0266481e-01, -4.0249890e-01, -4.0233302e-01, + -4.0216711e-01, -4.0200126e-01, -4.0183538e-01, -4.0166953e-01, + -4.0150368e-01, -4.0133786e-01, -4.0117204e-01, -4.0100625e-01, + -4.0084043e-01, -4.0067467e-01, -4.0050888e-01, -4.0034312e-01, + -4.0017736e-01, -4.0001163e-01, -3.9984590e-01, -3.9968017e-01, + -3.9951447e-01, -3.9934877e-01, -3.9918309e-01, -3.9901742e-01, + -3.9885175e-01, -3.9868611e-01, -3.9852047e-01, -3.9835483e-01, + -3.9818922e-01, -3.9802361e-01, -3.9785799e-01, -3.9769241e-01, + -3.9752683e-01, -3.9736128e-01, -3.9719570e-01, -3.9703017e-01, + -3.9686462e-01, -3.9669910e-01, -3.9653361e-01, -3.9636809e-01, + -3.9620259e-01, -3.9603713e-01, -3.9587167e-01, -3.9570621e-01, + -3.9554074e-01, -3.9537531e-01, -3.9520991e-01, -3.9504448e-01, + -3.9487907e-01, -3.9471370e-01, -3.9454830e-01, -3.9438292e-01, + -3.9421758e-01, -3.9405224e-01, -3.9388689e-01, -3.9372155e-01, + -3.9355624e-01, -3.9339092e-01, -3.9322564e-01, -3.9306036e-01, + -3.9289507e-01, -3.9272982e-01, -3.9256456e-01, -3.9239931e-01, + -3.9223409e-01, -3.9206886e-01, -3.9190367e-01, -3.9173847e-01, + -3.9157328e-01, -3.9140809e-01, -3.9124292e-01, -3.9107779e-01, + -3.9091262e-01, -3.9074749e-01, -3.9058238e-01, -3.9041725e-01, + -3.9025214e-01, -3.9008707e-01, -3.8992199e-01, -3.8975692e-01, + -3.8959184e-01, -3.8942680e-01, -3.8926175e-01, -3.8909674e-01, + -3.8893172e-01, -3.8876671e-01, -3.8860172e-01, -3.8843673e-01, + -3.8827175e-01, -3.8810679e-01, -3.8794184e-01, -3.8777688e-01, + -3.8761196e-01, -3.8744703e-01, -3.8728210e-01, -3.8711721e-01, + -3.8695231e-01, -3.8678744e-01, -3.8662258e-01, -3.8645771e-01, + -3.8629287e-01, -3.8612801e-01, -3.8596320e-01, -3.8579836e-01, + -3.8563356e-01, -3.8546878e-01, -3.8530397e-01, -3.8513920e-01, + -3.8497445e-01, -3.8480970e-01, -3.8464496e-01, -3.8448021e-01, + -3.8431549e-01, -3.8415077e-01, -3.8398609e-01, -3.8382137e-01, + -3.8365671e-01, -3.8349202e-01, -3.8332736e-01, -3.8316271e-01, + -3.8299808e-01, -3.8283345e-01, -3.8266882e-01, -3.8250422e-01, + -3.8233963e-01, -3.8217503e-01, -3.8201046e-01, -3.8184589e-01, + -3.8168132e-01, -3.8151678e-01, -3.8135225e-01, -3.8118771e-01, + -3.8102320e-01, -3.8085869e-01, -3.8069418e-01, -3.8052970e-01, + -3.8036522e-01, -3.8020077e-01, -3.8003632e-01, -3.7987188e-01, + -3.7970743e-01, -3.7954301e-01, -3.7937859e-01, -3.7921420e-01, + -3.7904981e-01, -3.7888542e-01, -3.7872106e-01, -3.7855670e-01, + -3.7839234e-01, -3.7822798e-01, -3.7806365e-01, -3.7789935e-01, + -3.7773502e-01, -3.7757072e-01, -3.7740645e-01, -3.7724215e-01, + -3.7707788e-01, -3.7691364e-01, -3.7674937e-01, -3.7658513e-01, + -3.7642092e-01, -3.7625667e-01, -3.7609249e-01, -3.7592828e-01, + -3.7576410e-01, -3.7559992e-01, -3.7543574e-01, -3.7527159e-01, + -3.7510744e-01, -3.7494329e-01, -3.7477916e-01, -3.7461504e-01, + -3.7445095e-01, -3.7428683e-01, -3.7412277e-01, -3.7395868e-01, + -3.7379462e-01, -3.7363055e-01, -3.7346649e-01, -3.7330246e-01, + -3.7313843e-01, -3.7297443e-01, -3.7281042e-01, -3.7264642e-01, + -3.7248242e-01, -3.7231845e-01, -3.7215447e-01, -3.7199053e-01, + -3.7182659e-01, -3.7166265e-01, -3.7149870e-01, -3.7133479e-01, + -3.7117088e-01, -3.7100700e-01, -3.7084311e-01, -3.7067923e-01, + -3.7051535e-01, -3.7035149e-01, -3.7018764e-01, -3.7002382e-01, + -3.6985999e-01, -3.6969617e-01, -3.6953235e-01, -3.6936855e-01, + -3.6920476e-01, -3.6904100e-01, -3.6887723e-01, -3.6871347e-01, + -3.6854970e-01, -3.6838597e-01, -3.6822224e-01, -3.6805853e-01, + -3.6789483e-01, -3.6773112e-01, -3.6756742e-01, -3.6740375e-01, + -3.6724007e-01, -3.6707643e-01, -3.6691278e-01, -3.6674914e-01, + -3.6658549e-01, -3.6642188e-01, -3.6625826e-01, -3.6609468e-01, + -3.6593106e-01, -3.6576751e-01, -3.6560392e-01, -3.6544037e-01, + -3.6527681e-01, -3.6511326e-01, -3.6494973e-01, -3.6478621e-01, + -3.6462271e-01, -3.6445919e-01, -3.6429569e-01, -3.6413223e-01, + -3.6396876e-01, -3.6380529e-01, -3.6364183e-01, -3.6347839e-01, + -3.6331496e-01, -3.6315152e-01, -3.6298811e-01, -3.6282471e-01, + -3.6266130e-01, -3.6249793e-01, -3.6233455e-01, -3.6217117e-01, + -3.6200783e-01, -3.6184445e-01, -3.6168113e-01, -3.6151779e-01, + -3.6135447e-01, -3.6119115e-01, -3.6102787e-01, -3.6086458e-01, + -3.6070129e-01, -3.6053804e-01, -3.6037478e-01, -3.6021152e-01, + -3.6004826e-01, -3.5988504e-01, -3.5972181e-01, -3.5955861e-01, + -3.5939538e-01, -3.5923222e-01, -3.5906902e-01, -3.5890585e-01, + -3.5874268e-01, -3.5857952e-01, -3.5841638e-01, -3.5825324e-01, + -3.5809010e-01, -3.5792699e-01, -3.5776389e-01, -3.5760078e-01, + -3.5743770e-01, -3.5727462e-01, -3.5711154e-01, -3.5694849e-01, + -3.5678545e-01, -3.5662240e-01, -3.5645935e-01, -3.5629633e-01, + -3.5613331e-01, -3.5597032e-01, -3.5580733e-01, -3.5564435e-01, + -3.5548136e-01, -3.5531840e-01, -3.5515544e-01, -3.5499248e-01, + -3.5482955e-01, -3.5466662e-01, -3.5450372e-01, -3.5434079e-01, + -3.5417789e-01, -3.5401499e-01, -3.5385212e-01, -3.5368925e-01, + -3.5352638e-01, -3.5336354e-01, -3.5320070e-01, -3.5303786e-01, + -3.5287502e-01, -3.5271221e-01, -3.5254940e-01, -3.5238662e-01, + -3.5222381e-01, -3.5206103e-01, -3.5189828e-01, -3.5173550e-01, + -3.5157275e-01, -3.5141003e-01, -3.5124728e-01, -3.5108456e-01, + -3.5092187e-01, -3.5075915e-01, -3.5059646e-01, -3.5043377e-01, + -3.5027111e-01, -3.5010841e-01, -3.4994578e-01, -3.4978312e-01, + -3.4962049e-01, -3.4945786e-01, -3.4929523e-01, -3.4913263e-01, + -3.4897003e-01, -3.4880742e-01, -3.4864485e-01, -3.4848228e-01, + -3.4831971e-01, -3.4815714e-01, -3.4799460e-01, -3.4783205e-01, + -3.4766954e-01, -3.4750700e-01, -3.4734452e-01, -3.4718201e-01, + -3.4701952e-01, -3.4685704e-01, -3.4669456e-01, -3.4653208e-01, + -3.4636962e-01, -3.4620720e-01, -3.4604475e-01, -3.4588233e-01, + -3.4571990e-01, -3.4555748e-01, -3.4539509e-01, -3.4523270e-01, + -3.4507033e-01, -3.4490794e-01, -3.4474558e-01, -3.4458324e-01, + -3.4442088e-01, -3.4425855e-01, -3.4409621e-01, -3.4393391e-01, + -3.4377158e-01, -3.4360930e-01, -3.4344700e-01, -3.4328473e-01, + -3.4312245e-01, -3.4296018e-01, -3.4279794e-01, -3.4263566e-01, + -3.4247345e-01, -3.4231120e-01, -3.4214899e-01, -3.4198678e-01, + -3.4182459e-01, -3.4166238e-01, -3.4150019e-01, -3.4133804e-01, + -3.4117585e-01, -3.4101370e-01, -3.4085155e-01, -3.4068942e-01, + -3.4052730e-01, -3.4036517e-01, -3.4020305e-01, -3.4004095e-01, + -3.3987886e-01, -3.3971679e-01, -3.3955470e-01, -3.3939263e-01, + -3.3923057e-01, -3.3906853e-01, -3.3890650e-01, -3.3874446e-01, + -3.3858243e-01, -3.3842042e-01, -3.3825842e-01, -3.3809641e-01, + -3.3793443e-01, -3.3777246e-01, -3.3761048e-01, -3.3744854e-01, + -3.3728656e-01, -3.3712465e-01, -3.3696270e-01, -3.3680078e-01, + -3.3663887e-01, -3.3647695e-01, -3.3631504e-01, -3.3615315e-01, + -3.3599129e-01, -3.3582941e-01, -3.3566755e-01, -3.3550569e-01, + -3.3534384e-01, -3.3518201e-01, -3.3502018e-01, -3.3485836e-01, + -3.3469656e-01, -3.3453473e-01, -3.3437297e-01, -3.3421117e-01, + -3.3404940e-01, -3.3388764e-01, -3.3372587e-01, -3.3356413e-01, + -3.3340237e-01, -3.3324066e-01, -3.3307892e-01, -3.3291721e-01, + -3.3275551e-01, -3.3259380e-01, -3.3243212e-01, -3.3227044e-01, + -3.3210877e-01, -3.3194712e-01, -3.3178544e-01, -3.3162379e-01, + -3.3146217e-01, -3.3130056e-01, -3.3113891e-01, -3.3097732e-01, + -3.3081570e-01, -3.3065411e-01, -3.3049253e-01, -3.3033097e-01, + -3.3016938e-01, -3.3000782e-01, -3.2984629e-01, -3.2968473e-01, + -3.2952321e-01, -3.2936168e-01, -3.2920018e-01, -3.2903865e-01, + -3.2887715e-01, -3.2871568e-01, -3.2855418e-01, -3.2839271e-01, + -3.2823125e-01, -3.2806981e-01, -3.2790837e-01, -3.2774693e-01, + -3.2758549e-01, -3.2742405e-01, -3.2726264e-01, -3.2710126e-01, + -3.2693985e-01, -3.2677847e-01, -3.2661709e-01, -3.2645571e-01, + -3.2629436e-01, -3.2613301e-01, -3.2597166e-01, -3.2581031e-01, + -3.2564899e-01, -3.2548767e-01, -3.2532635e-01, -3.2516506e-01, + -3.2500377e-01, -3.2484248e-01, -3.2468119e-01, -3.2451993e-01, + -3.2435867e-01, -3.2419741e-01, -3.2403618e-01, -3.2387495e-01, + -3.2371372e-01, -3.2355249e-01, -3.2339129e-01, -3.2323009e-01, + -3.2306889e-01, -3.2290772e-01, -3.2274655e-01, -3.2258537e-01, + -3.2242420e-01, -3.2226306e-01, -3.2210192e-01, -3.2194078e-01, + -3.2177964e-01, -3.2161853e-01, -3.2145742e-01, -3.2129633e-01, + -3.2113522e-01, -3.2097414e-01, -3.2081306e-01, -3.2065201e-01, + -3.2049096e-01, -3.2032990e-01, -3.2016885e-01, -3.2000783e-01, + -3.1984678e-01, -3.1968579e-01, -3.1952477e-01, -3.1936377e-01, + -3.1920278e-01, -3.1904179e-01, -3.1888083e-01, -3.1871983e-01, + -3.1855887e-01, -3.1839794e-01, -3.1823698e-01, -3.1807604e-01, + -3.1791514e-01, -3.1775421e-01, -3.1759331e-01, -3.1743240e-01, + -3.1727150e-01, -3.1711063e-01, -3.1694973e-01, -3.1678888e-01, + -3.1662801e-01, -3.1646717e-01, -3.1630632e-01, -3.1614548e-01, + -3.1598464e-01, -3.1582382e-01, -3.1566301e-01, -3.1550223e-01, + -3.1534141e-01, -3.1518063e-01, -3.1501985e-01, -3.1485909e-01, + -3.1469831e-01, -3.1453755e-01, -3.1437680e-01, -3.1421608e-01, + -3.1405535e-01, -3.1389463e-01, -3.1373391e-01, -3.1357321e-01, + -3.1341252e-01, -3.1325182e-01, -3.1309113e-01, -3.1293046e-01, + -3.1276980e-01, -3.1260914e-01, -3.1244847e-01, -3.1228784e-01, + -3.1212720e-01, -3.1196660e-01, -3.1180596e-01, -3.1164536e-01, + -3.1148475e-01, -3.1132415e-01, -3.1116357e-01, -3.1100300e-01, + -3.1084242e-01, -3.1068188e-01, -3.1052130e-01, -3.1036076e-01, + -3.1020024e-01, -3.1003970e-01, -3.0987918e-01, -3.0971867e-01, + -3.0955815e-01, -3.0939767e-01, -3.0923718e-01, -3.0907670e-01, + -3.0891621e-01, -3.0875576e-01, -3.0859530e-01, -3.0843484e-01, + -3.0827442e-01, -3.0811396e-01, -3.0795354e-01, -3.0779314e-01, + -3.0763271e-01, -3.0747232e-01, -3.0731192e-01, -3.0715156e-01, + -3.0699116e-01, -3.0683079e-01, -3.0667043e-01, -3.0651006e-01, + -3.0634972e-01, -3.0618939e-01, -3.0602905e-01, -3.0586874e-01, + -3.0570841e-01, -3.0554810e-01, -3.0538782e-01, -3.0522752e-01, + -3.0506724e-01, -3.0490696e-01, -3.0474669e-01, -3.0458644e-01, + -3.0442619e-01, -3.0426595e-01, -3.0410570e-01, -3.0394548e-01, + -3.0378526e-01, -3.0362505e-01, -3.0346483e-01, -3.0330464e-01, + -3.0314445e-01, -3.0298427e-01, -3.0282408e-01, -3.0266392e-01, + -3.0250376e-01, -3.0234361e-01, -3.0218348e-01, -3.0202332e-01, + -3.0186319e-01, -3.0170310e-01, -3.0154297e-01, -3.0138287e-01, + -3.0122277e-01, -3.0106267e-01, -3.0090261e-01, -3.0074254e-01, + -3.0058247e-01, -3.0042240e-01, -3.0026236e-01, -3.0010229e-01, + -2.9994226e-01, -2.9978225e-01, -2.9962221e-01, -2.9946220e-01, + -2.9930219e-01, -2.9914221e-01, -2.9898220e-01, -2.9882222e-01, + -2.9866228e-01, -2.9850230e-01, -2.9834235e-01, -2.9818240e-01, + -2.9802245e-01, -2.9786250e-01, -2.9770258e-01, -2.9754266e-01, + -2.9738274e-01, -2.9722282e-01, -2.9706293e-01, -2.9690304e-01, + -2.9674315e-01, -2.9658329e-01, -2.9642344e-01, -2.9626358e-01, + -2.9610372e-01, -2.9594386e-01, -2.9578403e-01, -2.9562420e-01, + -2.9546437e-01, -2.9530457e-01, -2.9514477e-01, -2.9498497e-01, + -2.9482517e-01, -2.9466537e-01, -2.9450560e-01, -2.9434583e-01, + -2.9418609e-01, -2.9402632e-01, -2.9386657e-01, -2.9370683e-01, + -2.9354709e-01, -2.9338738e-01, -2.9322764e-01, -2.9306796e-01, + -2.9290825e-01, -2.9274854e-01, -2.9258886e-01, -2.9242918e-01, + -2.9226950e-01, -2.9210985e-01, -2.9195020e-01, -2.9179054e-01, + -2.9163089e-01, -2.9147127e-01, -2.9131162e-01, -2.9115203e-01, + -2.9099241e-01, -2.9083279e-01, -2.9067320e-01, -2.9051360e-01, + -2.9035401e-01, -2.9019445e-01, -2.9003489e-01, -2.8987533e-01, + -2.8971577e-01, -2.8955624e-01, -2.8939667e-01, -2.8923714e-01, + -2.8907764e-01, -2.8891811e-01, -2.8875861e-01, -2.8859910e-01, + -2.8843960e-01, -2.8828013e-01, -2.8812063e-01, -2.8796116e-01, + -2.8780171e-01, -2.8764224e-01, -2.8748280e-01, -2.8732336e-01, + -2.8716391e-01, -2.8700447e-01, -2.8684506e-01, -2.8668565e-01, + -2.8652623e-01, -2.8636685e-01, -2.8620744e-01, -2.8604805e-01, + -2.8588867e-01, -2.8572932e-01, -2.8556997e-01, -2.8541058e-01, + -2.8525126e-01, -2.8509191e-01, -2.8493258e-01, -2.8477323e-01, + -2.8461394e-01, -2.8445461e-01, -2.8429532e-01, -2.8413600e-01, + -2.8397670e-01, -2.8381744e-01, -2.8365815e-01, -2.8349888e-01, + -2.8333962e-01, -2.8318036e-01, -2.8302112e-01, -2.8286189e-01, + -2.8270265e-01, -2.8254342e-01, -2.8238422e-01, -2.8222498e-01, + -2.8206578e-01, -2.8190657e-01, -2.8174740e-01, -2.8158823e-01, + -2.8142905e-01, -2.8126988e-01, -2.8111070e-01, -2.8095156e-01, + -2.8079242e-01, -2.8063327e-01, -2.8047413e-01, -2.8031501e-01, + -2.8015590e-01, -2.7999678e-01, -2.7983767e-01, -2.7967858e-01, + -2.7951947e-01, -2.7936038e-01, -2.7920133e-01, -2.7904224e-01, + -2.7888319e-01, -2.7872413e-01, -2.7856508e-01, -2.7840602e-01, + -2.7824700e-01, -2.7808797e-01, -2.7792895e-01, -2.7776995e-01, + -2.7761093e-01, -2.7745193e-01, -2.7729294e-01, -2.7713397e-01, + -2.7697498e-01, -2.7681601e-01, -2.7665704e-01, -2.7649808e-01, + -2.7633914e-01, -2.7618021e-01, -2.7602127e-01, -2.7586234e-01, + -2.7570340e-01, -2.7554449e-01, -2.7538559e-01, -2.7522668e-01, + -2.7506778e-01, -2.7490890e-01, -2.7475002e-01, -2.7459115e-01, + -2.7443227e-01, -2.7427343e-01, -2.7411455e-01, -2.7395570e-01, + -2.7379689e-01, -2.7363804e-01, -2.7347922e-01, -2.7332041e-01, + -2.7316159e-01, -2.7300277e-01, -2.7284399e-01, -2.7268520e-01, + -2.7252641e-01, -2.7236763e-01, -2.7220887e-01, -2.7205011e-01, + -2.7189136e-01, -2.7173260e-01, -2.7157384e-01, -2.7141511e-01, + -2.7125639e-01, -2.7109766e-01, -2.7093893e-01, -2.7078024e-01, + -2.7062154e-01, -2.7046284e-01, -2.7030414e-01, -2.7014548e-01, + -2.6998681e-01, -2.6982814e-01, -2.6966947e-01, -2.6951081e-01, + -2.6935217e-01, -2.6919353e-01, -2.6903489e-01, -2.6887625e-01, + -2.6871765e-01, -2.6855904e-01, -2.6840043e-01, -2.6824182e-01, + -2.6808321e-01, -2.6792464e-01, -2.6776606e-01, -2.6760748e-01, + -2.6744893e-01, -2.6729035e-01, -2.6713181e-01, -2.6697326e-01, + -2.6681474e-01, -2.6665619e-01, -2.6649767e-01, -2.6633915e-01, + -2.6618063e-01, -2.6602212e-01, -2.6586363e-01, -2.6570514e-01, + -2.6554665e-01, -2.6538816e-01, -2.6522970e-01, -2.6507124e-01, + -2.6491278e-01, -2.6475433e-01, -2.6459587e-01, -2.6443744e-01, + -2.6427901e-01, -2.6412058e-01, -2.6396215e-01, -2.6380375e-01, + -2.6364532e-01, -2.6348692e-01, -2.6332855e-01, -2.6317015e-01, + -2.6301178e-01, -2.6285341e-01, -2.6269504e-01, -2.6253667e-01, + -2.6237831e-01, -2.6221997e-01, -2.6206163e-01, -2.6190329e-01, + -2.6174498e-01, -2.6158664e-01, -2.6142833e-01, -2.6127002e-01, + -2.6111174e-01, -2.6095343e-01, -2.6079515e-01, -2.6063687e-01, + -2.6047859e-01, -2.6032031e-01, -2.6016206e-01, -2.6000381e-01, + -2.5984555e-01, -2.5968730e-01, -2.5952908e-01, -2.5937083e-01, + -2.5921261e-01, -2.5905439e-01, -2.5889620e-01, -2.5873798e-01, + -2.5857979e-01, -2.5842160e-01, -2.5826341e-01, -2.5810525e-01, + -2.5794709e-01, -2.5778890e-01, -2.5763074e-01, -2.5747260e-01, + -2.5731444e-01, -2.5715631e-01, -2.5699818e-01, -2.5684005e-01, + -2.5668195e-01, -2.5652382e-01, -2.5636572e-01, -2.5620762e-01, + -2.5604951e-01, -2.5589144e-01, -2.5573334e-01, -2.5557527e-01, + -2.5541720e-01, -2.5525916e-01, -2.5510108e-01, -2.5494304e-01, + -2.5478500e-01, -2.5462696e-01, -2.5446895e-01, -2.5431091e-01, + -2.5415289e-01, -2.5399488e-01, -2.5383687e-01, -2.5367889e-01, + -2.5352088e-01, -2.5336289e-01, -2.5320491e-01, -2.5304696e-01, + -2.5288898e-01, -2.5273103e-01, -2.5257307e-01, -2.5241512e-01, + -2.5225717e-01, -2.5209925e-01, -2.5194132e-01, -2.5178340e-01, + -2.5162548e-01, -2.5146756e-01, -2.5130966e-01, -2.5115177e-01, + -2.5099388e-01, -2.5083598e-01, -2.5067809e-01, -2.5052023e-01, + -2.5036237e-01, -2.5020450e-01, -2.5004664e-01, -2.4988881e-01, + -2.4973096e-01, -2.4957313e-01, -2.4941529e-01, -2.4925748e-01, + -2.4909966e-01, -2.4894185e-01, -2.4878405e-01, -2.4862625e-01, + -2.4846846e-01, -2.4831067e-01, -2.4815290e-01, -2.4799512e-01, + -2.4783735e-01, -2.4767959e-01, -2.4752183e-01, -2.4736409e-01, + -2.4720635e-01, -2.4704860e-01, -2.4689087e-01, -2.4673316e-01, + -2.4657543e-01, -2.4641773e-01, -2.4626002e-01, -2.4610232e-01, + -2.4594462e-01, -2.4578694e-01, -2.4562925e-01, -2.4547158e-01, + -2.4531391e-01, -2.4515624e-01, -2.4499859e-01, -2.4484095e-01, + -2.4468330e-01, -2.4452566e-01, -2.4436803e-01, -2.4421041e-01, + -2.4405278e-01, -2.4389517e-01, -2.4373756e-01, -2.4357995e-01, + -2.4342236e-01, -2.4326476e-01, -2.4310718e-01, -2.4294960e-01, + -2.4279204e-01, -2.4263448e-01, -2.4247691e-01, -2.4231936e-01, + -2.4216181e-01, -2.4200428e-01, -2.4184673e-01, -2.4168921e-01, + -2.4153168e-01, -2.4137416e-01, -2.4121664e-01, -2.4105914e-01, + -2.4090165e-01, -2.4074414e-01, -2.4058667e-01, -2.4042918e-01, + -2.4027170e-01, -2.4011423e-01, -2.3995677e-01, -2.3979931e-01, + -2.3964186e-01, -2.3948441e-01, -2.3932697e-01, -2.3916954e-01, + -2.3901211e-01, -2.3885469e-01, -2.3869728e-01, -2.3853986e-01, + -2.3838246e-01, -2.3822506e-01, -2.3806766e-01, -2.3791027e-01, + -2.3775290e-01, -2.3759551e-01, -2.3743816e-01, -2.3728079e-01, + -2.3712343e-01, -2.3696607e-01, -2.3680873e-01, -2.3665139e-01, + -2.3649406e-01, -2.3633672e-01, -2.3617941e-01, -2.3602208e-01, + -2.3586477e-01, -2.3570748e-01, -2.3555018e-01, -2.3539288e-01, + -2.3523560e-01, -2.3507832e-01, -2.3492104e-01, -2.3476377e-01, + -2.3460650e-01, -2.3444925e-01, -2.3429200e-01, -2.3413475e-01, + -2.3397751e-01, -2.3382027e-01, -2.3366304e-01, -2.3350582e-01, + -2.3334859e-01, -2.3319139e-01, -2.3303418e-01, -2.3287699e-01, + -2.3271978e-01, -2.3256260e-01, -2.3240541e-01, -2.3224823e-01, + -2.3209107e-01, -2.3193389e-01, -2.3177674e-01, -2.3161958e-01, + -2.3146243e-01, -2.3130529e-01, -2.3114815e-01, -2.3099102e-01, + -2.3083389e-01, -2.3067677e-01, -2.3051965e-01, -2.3036255e-01, + -2.3020545e-01, -2.3004834e-01, -2.2989126e-01, -2.2973417e-01, + -2.2957709e-01, -2.2942002e-01, -2.2926295e-01, -2.2910587e-01, + -2.2894882e-01, -2.2879177e-01, -2.2863473e-01, -2.2847769e-01, + -2.2832064e-01, -2.2816361e-01, -2.2800660e-01, -2.2784957e-01, + -2.2769256e-01, -2.2753556e-01, -2.2737855e-01, -2.2722156e-01, + -2.2706456e-01, -2.2690758e-01, -2.2675060e-01, -2.2659363e-01, + -2.2643666e-01, -2.2627969e-01, -2.2612274e-01, -2.2596578e-01, + -2.2580884e-01, -2.2565190e-01, -2.2549497e-01, -2.2533804e-01, + -2.2518112e-01, -2.2502419e-01, -2.2486728e-01, -2.2471038e-01, + -2.2455348e-01, -2.2439659e-01, -2.2423969e-01, -2.2408280e-01, + -2.2392592e-01, -2.2376905e-01, -2.2361219e-01, -2.2345532e-01, + -2.2329846e-01, -2.2314161e-01, -2.2298476e-01, -2.2282793e-01, + -2.2267109e-01, -2.2251426e-01, -2.2235744e-01, -2.2220062e-01, + -2.2204380e-01, -2.2188699e-01, -2.2173019e-01, -2.2157340e-01, + -2.2141661e-01, -2.2125982e-01, -2.2110303e-01, -2.2094625e-01, + -2.2078949e-01, -2.2063272e-01, -2.2047597e-01, -2.2031921e-01, + -2.2016247e-01, -2.2000572e-01, -2.1984898e-01, -2.1969225e-01, + -2.1953553e-01, -2.1937880e-01, -2.1922208e-01, -2.1906538e-01, + -2.1890867e-01, -2.1875197e-01, -2.1859528e-01, -2.1843858e-01, + -2.1828191e-01, -2.1812522e-01, -2.1796855e-01, -2.1781188e-01, + -2.1765523e-01, -2.1749857e-01, -2.1734191e-01, -2.1718527e-01, + -2.1702863e-01, -2.1687199e-01, -2.1671537e-01, -2.1655874e-01, + -2.1640211e-01, -2.1624550e-01, -2.1608889e-01, -2.1593229e-01, + -2.1577568e-01, -2.1561910e-01, -2.1546251e-01, -2.1530592e-01, + -2.1514934e-01, -2.1499278e-01, -2.1483621e-01, -2.1467964e-01, + -2.1452309e-01, -2.1436654e-01, -2.1420999e-01, -2.1405345e-01, + -2.1389692e-01, -2.1374039e-01, -2.1358387e-01, -2.1342735e-01, + -2.1327083e-01, -2.1311432e-01, -2.1295781e-01, -2.1280132e-01, + -2.1264483e-01, -2.1248834e-01, -2.1233186e-01, -2.1217538e-01, + -2.1201891e-01, -2.1186243e-01, -2.1170597e-01, -2.1154952e-01, + -2.1139307e-01, -2.1123663e-01, -2.1108018e-01, -2.1092375e-01, + -2.1076731e-01, -2.1061088e-01, -2.1045446e-01, -2.1029805e-01, + -2.1014164e-01, -2.0998523e-01, -2.0982882e-01, -2.0967244e-01, + -2.0951605e-01, -2.0935966e-01, -2.0920329e-01, -2.0904690e-01, + -2.0889054e-01, -2.0873417e-01, -2.0857781e-01, -2.0842145e-01, + -2.0826511e-01, -2.0810877e-01, -2.0795242e-01, -2.0779610e-01, + -2.0763977e-01, -2.0748344e-01, -2.0732713e-01, -2.0717081e-01, + -2.0701450e-01, -2.0685819e-01, -2.0670189e-01, -2.0654561e-01, + -2.0638931e-01, -2.0623302e-01, -2.0607676e-01, -2.0592047e-01, + -2.0576420e-01, -2.0560795e-01, -2.0545170e-01, -2.0529544e-01, + -2.0513919e-01, -2.0498295e-01, -2.0482671e-01, -2.0467047e-01, + -2.0451425e-01, -2.0435803e-01, -2.0420180e-01, -2.0404559e-01, + -2.0388938e-01, -2.0373318e-01, -2.0357698e-01, -2.0342079e-01, + -2.0326459e-01, -2.0310842e-01, -2.0295224e-01, -2.0279607e-01, + -2.0263989e-01, -2.0248373e-01, -2.0232758e-01, -2.0217142e-01, + -2.0201527e-01, -2.0185913e-01, -2.0170298e-01, -2.0154685e-01, + -2.0139073e-01, -2.0123459e-01, -2.0107847e-01, -2.0092237e-01, + -2.0076625e-01, -2.0061015e-01, -2.0045406e-01, -2.0029795e-01, + -2.0014186e-01, -1.9998579e-01, -1.9982970e-01, -1.9967362e-01, + -1.9951756e-01, -1.9936149e-01, -1.9920543e-01, -1.9904937e-01, + -1.9889332e-01, -1.9873728e-01, -1.9858123e-01, -1.9842520e-01, + -1.9826917e-01, -1.9811314e-01, -1.9795711e-01, -1.9780110e-01, + -1.9764508e-01, -1.9748908e-01, -1.9733308e-01, -1.9717708e-01, + -1.9702108e-01, -1.9686510e-01, -1.9670911e-01, -1.9655314e-01, + -1.9639716e-01, -1.9624120e-01, -1.9608523e-01, -1.9592927e-01, + -1.9577332e-01, -1.9561736e-01, -1.9546142e-01, -1.9530548e-01, + -1.9514954e-01, -1.9499362e-01, -1.9483769e-01, -1.9468176e-01, + -1.9452584e-01, -1.9436993e-01, -1.9421403e-01, -1.9405812e-01, + -1.9390222e-01, -1.9374633e-01, -1.9359045e-01, -1.9343455e-01, + -1.9327869e-01, -1.9312280e-01, -1.9296694e-01, -1.9281107e-01, + -1.9265521e-01, -1.9249935e-01, -1.9234350e-01, -1.9218765e-01, + -1.9203182e-01, -1.9187598e-01, -1.9172014e-01, -1.9156432e-01, + -1.9140849e-01, -1.9125268e-01, -1.9109686e-01, -1.9094105e-01, + -1.9078524e-01, -1.9062945e-01, -1.9047365e-01, -1.9031785e-01, + -1.9016208e-01, -1.9000629e-01, -1.8985051e-01, -1.8969475e-01, + -1.8953897e-01, -1.8938321e-01, -1.8922745e-01, -1.8907170e-01, + -1.8891595e-01, -1.8876021e-01, -1.8860446e-01, -1.8844873e-01, + -1.8829300e-01, -1.8813728e-01, -1.8798155e-01, -1.8782583e-01, + -1.8767013e-01, -1.8751441e-01, -1.8735871e-01, -1.8720300e-01, + -1.8704732e-01, -1.8689163e-01, -1.8673594e-01, -1.8658026e-01, + -1.8642458e-01, -1.8626891e-01, -1.8611324e-01, -1.8595758e-01, + -1.8580192e-01, -1.8564627e-01, -1.8549062e-01, -1.8533497e-01, + -1.8517934e-01, -1.8502370e-01, -1.8486807e-01, -1.8471244e-01, + -1.8455681e-01, -1.8440120e-01, -1.8424559e-01, -1.8408997e-01, + -1.8393438e-01, -1.8377876e-01, -1.8362318e-01, -1.8346758e-01, + -1.8331200e-01, -1.8315642e-01, -1.8300083e-01, -1.8284526e-01, + -1.8268970e-01, -1.8253413e-01, -1.8237856e-01, -1.8222301e-01, + -1.8206745e-01, -1.8191192e-01, -1.8175636e-01, -1.8160082e-01, + -1.8144530e-01, -1.8128976e-01, -1.8113424e-01, -1.8097872e-01, + -1.8082321e-01, -1.8066770e-01, -1.8051219e-01, -1.8035668e-01, + -1.8020119e-01, -1.8004569e-01, -1.7989020e-01, -1.7973471e-01, + -1.7957923e-01, -1.7942375e-01, -1.7926829e-01, -1.7911281e-01, + -1.7895734e-01, -1.7880189e-01, -1.7864643e-01, -1.7849098e-01, + -1.7833553e-01, -1.7818010e-01, -1.7802465e-01, -1.7786922e-01, + -1.7771380e-01, -1.7755836e-01, -1.7740294e-01, -1.7724752e-01, + -1.7709212e-01, -1.7693670e-01, -1.7678130e-01, -1.7662591e-01, + -1.7647050e-01, -1.7631511e-01, -1.7615972e-01, -1.7600435e-01, + -1.7584896e-01, -1.7569359e-01, -1.7553823e-01, -1.7538285e-01, + -1.7522749e-01, -1.7507213e-01, -1.7491679e-01, -1.7476144e-01, + -1.7460610e-01, -1.7445076e-01, -1.7429541e-01, -1.7414008e-01, + -1.7398475e-01, -1.7382944e-01, -1.7367411e-01, -1.7351879e-01, + -1.7336349e-01, -1.7320818e-01, -1.7305288e-01, -1.7289758e-01, + -1.7274229e-01, -1.7258699e-01, -1.7243171e-01, -1.7227642e-01, + -1.7212115e-01, -1.7196588e-01, -1.7181061e-01, -1.7165534e-01, + -1.7150009e-01, -1.7134482e-01, -1.7118958e-01, -1.7103432e-01, + -1.7087908e-01, -1.7072384e-01, -1.7056860e-01, -1.7041337e-01, + -1.7025813e-01, -1.7010292e-01, -1.6994770e-01, -1.6979249e-01, + -1.6963726e-01, -1.6948207e-01, -1.6932686e-01, -1.6917166e-01, + -1.6901647e-01, -1.6886127e-01, -1.6870609e-01, -1.6855091e-01, + -1.6839573e-01, -1.6824055e-01, -1.6808538e-01, -1.6793022e-01, + -1.6777505e-01, -1.6761988e-01, -1.6746473e-01, -1.6730958e-01, + -1.6715443e-01, -1.6699930e-01, -1.6684416e-01, -1.6668902e-01, + -1.6653389e-01, -1.6637877e-01, -1.6622365e-01, -1.6606852e-01, + -1.6591340e-01, -1.6575830e-01, -1.6560319e-01, -1.6544808e-01, + -1.6529299e-01, -1.6513789e-01, -1.6498280e-01, -1.6482772e-01, + -1.6467263e-01, -1.6451755e-01, -1.6436248e-01, -1.6420740e-01, + -1.6405234e-01, -1.6389728e-01, -1.6374221e-01, -1.6358717e-01, + -1.6343211e-01, -1.6327706e-01, -1.6312201e-01, -1.6296698e-01, + -1.6281195e-01, -1.6265692e-01, -1.6250189e-01, -1.6234685e-01, + -1.6219184e-01, -1.6203682e-01, -1.6188180e-01, -1.6172680e-01, + -1.6157180e-01, -1.6141680e-01, -1.6126180e-01, -1.6110681e-01, + -1.6095182e-01, -1.6079684e-01, -1.6064185e-01, -1.6048688e-01, + -1.6033190e-01, -1.6017693e-01, -1.6002196e-01, -1.5986700e-01, + -1.5971205e-01, -1.5955709e-01, -1.5940215e-01, -1.5924719e-01, + -1.5909225e-01, -1.5893732e-01, -1.5878238e-01, -1.5862745e-01, + -1.5847252e-01, -1.5831760e-01, -1.5816268e-01, -1.5800776e-01, + -1.5785284e-01, -1.5769795e-01, -1.5754303e-01, -1.5738814e-01, + -1.5723324e-01, -1.5707834e-01, -1.5692346e-01, -1.5676856e-01, + -1.5661368e-01, -1.5645881e-01, -1.5630393e-01, -1.5614906e-01, + -1.5599419e-01, -1.5583932e-01, -1.5568447e-01, -1.5552962e-01, + -1.5537477e-01, -1.5521991e-01, -1.5506507e-01, -1.5491022e-01, + -1.5475538e-01, -1.5460056e-01, -1.5444572e-01, -1.5429090e-01, + -1.5413608e-01, -1.5398125e-01, -1.5382645e-01, -1.5367164e-01, + -1.5351683e-01, -1.5336202e-01, -1.5320723e-01, -1.5305242e-01, + -1.5289763e-01, -1.5274285e-01, -1.5258805e-01, -1.5243328e-01, + -1.5227850e-01, -1.5212372e-01, -1.5196896e-01, -1.5181418e-01, + -1.5165941e-01, -1.5150465e-01, -1.5134990e-01, -1.5119515e-01, + -1.5104041e-01, -1.5088566e-01, -1.5073091e-01, -1.5057617e-01, + -1.5042144e-01, -1.5026671e-01, -1.5011197e-01, -1.4995725e-01, + -1.4980254e-01, -1.4964782e-01, -1.4949310e-01, -1.4933839e-01, + -1.4918369e-01, -1.4902899e-01, -1.4887428e-01, -1.4871959e-01, + -1.4856490e-01, -1.4841022e-01, -1.4825553e-01, -1.4810084e-01, + -1.4794616e-01, -1.4779149e-01, -1.4763682e-01, -1.4748216e-01, + -1.4732748e-01, -1.4717282e-01, -1.4701818e-01, -1.4686352e-01, + -1.4670888e-01, -1.4655423e-01, -1.4639959e-01, -1.4624494e-01, + -1.4609031e-01, -1.4593567e-01, -1.4578104e-01, -1.4562643e-01, + -1.4547180e-01, -1.4531718e-01, -1.4516257e-01, -1.4500795e-01, + -1.4485335e-01, -1.4469874e-01, -1.4454414e-01, -1.4438954e-01, + -1.4423496e-01, -1.4408036e-01, -1.4392577e-01, -1.4377119e-01, + -1.4361662e-01, -1.4346203e-01, -1.4330746e-01, -1.4315289e-01, + -1.4299832e-01, -1.4284377e-01, -1.4268920e-01, -1.4253464e-01, + -1.4238009e-01, -1.4222555e-01, -1.4207099e-01, -1.4191645e-01, + -1.4176191e-01, -1.4160737e-01, -1.4145285e-01, -1.4129832e-01, + -1.4114380e-01, -1.4098927e-01, -1.4083475e-01, -1.4068024e-01, + -1.4052573e-01, -1.4037122e-01, -1.4021671e-01, -1.4006221e-01, + -1.3990770e-01, -1.3975321e-01, -1.3959873e-01, -1.3944423e-01, + -1.3928975e-01, -1.3913527e-01, -1.3898079e-01, -1.3882631e-01, + -1.3867185e-01, -1.3851736e-01, -1.3836290e-01, -1.3820843e-01, + -1.3805398e-01, -1.3789953e-01, -1.3774507e-01, -1.3759063e-01, + -1.3743618e-01, -1.3728173e-01, -1.3712730e-01, -1.3697286e-01, + -1.3681842e-01, -1.3666400e-01, -1.3650957e-01, -1.3635515e-01, + -1.3620073e-01, -1.3604632e-01, -1.3589190e-01, -1.3573749e-01, + -1.3558309e-01, -1.3542868e-01, -1.3527428e-01, -1.3511989e-01, + -1.3496549e-01, -1.3481110e-01, -1.3465671e-01, -1.3450232e-01, + -1.3434795e-01, -1.3419357e-01, -1.3403919e-01, -1.3388482e-01, + -1.3373046e-01, -1.3357610e-01, -1.3342173e-01, -1.3326737e-01, + -1.3311301e-01, -1.3295867e-01, -1.3280430e-01, -1.3264996e-01, + -1.3249563e-01, -1.3234128e-01, -1.3218695e-01, -1.3203262e-01, + -1.3187829e-01, -1.3172396e-01, -1.3156962e-01, -1.3141531e-01, + -1.3126099e-01, -1.3110667e-01, -1.3095237e-01, -1.3079806e-01, + -1.3064376e-01, -1.3048945e-01, -1.3033515e-01, -1.3018085e-01, + -1.3002656e-01, -1.2987228e-01, -1.2971799e-01, -1.2956370e-01, + -1.2940942e-01, -1.2925515e-01, -1.2910087e-01, -1.2894660e-01, + -1.2879233e-01, -1.2863807e-01, -1.2848380e-01, -1.2832955e-01, + -1.2817529e-01, -1.2802103e-01, -1.2786679e-01, -1.2771255e-01, + -1.2755829e-01, -1.2740405e-01, -1.2724982e-01, -1.2709558e-01, + -1.2694135e-01, -1.2678713e-01, -1.2663290e-01, -1.2647867e-01, + -1.2632446e-01, -1.2617023e-01, -1.2601602e-01, -1.2586181e-01, + -1.2570761e-01, -1.2555340e-01, -1.2539920e-01, -1.2524500e-01, + -1.2509081e-01, -1.2493662e-01, -1.2478243e-01, -1.2462824e-01, + -1.2447406e-01, -1.2431987e-01, -1.2416570e-01, -1.2401152e-01, + -1.2385735e-01, -1.2370318e-01, -1.2354901e-01, -1.2339485e-01, + -1.2324069e-01, -1.2308653e-01, -1.2293238e-01, -1.2277823e-01, + -1.2262408e-01, -1.2246993e-01, -1.2231579e-01, -1.2216165e-01, + -1.2200751e-01, -1.2185338e-01, -1.2169925e-01, -1.2154512e-01, + -1.2139100e-01, -1.2123688e-01, -1.2108275e-01, -1.2092864e-01, + -1.2077452e-01, -1.2062041e-01, -1.2046631e-01, -1.2031220e-01, + -1.2015810e-01, -1.2000400e-01, -1.1984990e-01, -1.1969581e-01, + -1.1954172e-01, -1.1938763e-01, -1.1923354e-01, -1.1907946e-01, + -1.1892538e-01, -1.1877131e-01, -1.1861723e-01, -1.1846316e-01, + -1.1830909e-01, -1.1815502e-01, -1.1800096e-01, -1.1784691e-01, + -1.1769284e-01, -1.1753879e-01, -1.1738474e-01, -1.1723069e-01, + -1.1707664e-01, -1.1692260e-01, -1.1676856e-01, -1.1661452e-01, + -1.1646049e-01, -1.1630645e-01, -1.1615243e-01, -1.1599840e-01, + -1.1584438e-01, -1.1569036e-01, -1.1553634e-01, -1.1538232e-01, + -1.1522831e-01, -1.1507430e-01, -1.1492029e-01, -1.1476628e-01, + -1.1461229e-01, -1.1445829e-01, -1.1430429e-01, -1.1415029e-01, + -1.1399630e-01, -1.1384232e-01, -1.1368833e-01, -1.1353435e-01, + -1.1338037e-01, -1.1322639e-01, -1.1307242e-01, -1.1291844e-01, + -1.1276447e-01, -1.1261050e-01, -1.1245654e-01, -1.1230258e-01, + -1.1214862e-01, -1.1199466e-01, -1.1184071e-01, -1.1168676e-01, + -1.1153281e-01, -1.1137886e-01, -1.1122492e-01, -1.1107098e-01, + -1.1091705e-01, -1.1076311e-01, -1.1060917e-01, -1.1045524e-01, + -1.1030132e-01, -1.1014739e-01, -1.0999347e-01, -1.0983955e-01, + -1.0968564e-01, -1.0953172e-01, -1.0937781e-01, -1.0922390e-01, + -1.0907000e-01, -1.0891609e-01, -1.0876219e-01, -1.0860829e-01, + -1.0845440e-01, -1.0830050e-01, -1.0814661e-01, -1.0799272e-01, + -1.0783884e-01, -1.0768496e-01, -1.0753107e-01, -1.0737719e-01, + -1.0722332e-01, -1.0706945e-01, -1.0691557e-01, -1.0676171e-01, + -1.0660784e-01, -1.0645398e-01, -1.0630012e-01, -1.0614626e-01, + -1.0599241e-01, -1.0583855e-01, -1.0568470e-01, -1.0553085e-01, + -1.0537700e-01, -1.0522316e-01, -1.0506932e-01, -1.0491548e-01, + -1.0476165e-01, -1.0460781e-01, -1.0445399e-01, -1.0430016e-01, + -1.0414633e-01, -1.0399251e-01, -1.0383869e-01, -1.0368487e-01, + -1.0353106e-01, -1.0337724e-01, -1.0322343e-01, -1.0306962e-01, + -1.0291582e-01, -1.0276201e-01, -1.0260821e-01, -1.0245441e-01, + -1.0230061e-01, -1.0214682e-01, -1.0199303e-01, -1.0183924e-01, + -1.0168546e-01, -1.0153167e-01, -1.0137789e-01, -1.0122411e-01, + -1.0107033e-01, -1.0091656e-01, -1.0076278e-01, -1.0060901e-01, + -1.0045525e-01, -1.0030148e-01, -1.0014772e-01, -9.9993959e-02, + -9.9840201e-02, -9.9686444e-02, -9.9532694e-02, -9.9378943e-02, + -9.9225193e-02, -9.9071443e-02, -9.8917700e-02, -9.8763958e-02, + -9.8610222e-02, -9.8456487e-02, -9.8302752e-02, -9.8149016e-02, + -9.7995289e-02, -9.7841561e-02, -9.7687833e-02, -9.7534113e-02, + -9.7380392e-02, -9.7226672e-02, -9.7072959e-02, -9.6919239e-02, + -9.6765533e-02, -9.6611820e-02, -9.6458115e-02, -9.6304409e-02, + -9.6150704e-02, -9.5997006e-02, -9.5843308e-02, -9.5689617e-02, + -9.5535919e-02, -9.5382228e-02, -9.5228538e-02, -9.5074855e-02, + -9.4921172e-02, -9.4767489e-02, -9.4613805e-02, -9.4460130e-02, + -9.4306454e-02, -9.4152778e-02, -9.3999110e-02, -9.3845442e-02, + -9.3691774e-02, -9.3538113e-02, -9.3384452e-02, -9.3230791e-02, + -9.3077131e-02, -9.2923477e-02, -9.2769824e-02, -9.2616171e-02, + -9.2462525e-02, -9.2308879e-02, -9.2155233e-02, -9.2001587e-02, + -9.1847949e-02, -9.1694310e-02, -9.1540672e-02, -9.1387041e-02, + -9.1233410e-02, -9.1079779e-02, -9.0926155e-02, -9.0772524e-02, + -9.0618901e-02, -9.0465285e-02, -9.0311661e-02, -9.0158045e-02, + -9.0004437e-02, -8.9850821e-02, -8.9697212e-02, -8.9543603e-02, + -8.9389995e-02, -8.9236394e-02, -8.9082792e-02, -8.8929191e-02, + -8.8775598e-02, -8.8621996e-02, -8.8468403e-02, -8.8314816e-02, + -8.8161223e-02, -8.8007636e-02, -8.7854050e-02, -8.7700471e-02, + -8.7546885e-02, -8.7393306e-02, -8.7239735e-02, -8.7086156e-02, + -8.6932585e-02, -8.6779013e-02, -8.6625449e-02, -8.6471878e-02, + -8.6318314e-02, -8.6164750e-02, -8.6011194e-02, -8.5857637e-02, + -8.5704081e-02, -8.5550524e-02, -8.5396968e-02, -8.5243419e-02, + -8.5089870e-02, -8.4936328e-02, -8.4782779e-02, -8.4629238e-02, + -8.4475696e-02, -8.4322162e-02, -8.4168628e-02, -8.4015094e-02, + -8.3861560e-02, -8.3708026e-02, -8.3554499e-02, -8.3400972e-02, + -8.3247446e-02, -8.3093926e-02, -8.2940407e-02, -8.2786888e-02, + -8.2633369e-02, -8.2479857e-02, -8.2326345e-02, -8.2172833e-02, + -8.2019322e-02, -8.1865817e-02, -8.1712313e-02, -8.1558809e-02, + -8.1405304e-02, -8.1251808e-02, -8.1098311e-02, -8.0944814e-02, + -8.0791324e-02, -8.0637828e-02, -8.0484338e-02, -8.0330849e-02, + -8.0177367e-02, -8.0023885e-02, -7.9870403e-02, -7.9716921e-02, + -7.9563439e-02, -7.9409964e-02, -7.9256490e-02, -7.9103015e-02, + -7.8949548e-02, -7.8796074e-02, -7.8642607e-02, -7.8489147e-02, + -7.8335680e-02, -7.8182220e-02, -7.8028761e-02, -7.7875301e-02, + -7.7721842e-02, -7.7568389e-02, -7.7414937e-02, -7.7261485e-02, + -7.7108040e-02, -7.6954588e-02, -7.6801144e-02, -7.6647706e-02, + -7.6494262e-02, -7.6340824e-02, -7.6187387e-02, -7.6033950e-02, + -7.5880513e-02, -7.5727083e-02, -7.5573653e-02, -7.5420223e-02, + -7.5266793e-02, -7.5113371e-02, -7.4959941e-02, -7.4806519e-02, + -7.4653104e-02, -7.4499682e-02, -7.4346267e-02, -7.4192852e-02, + -7.4039437e-02, -7.3886029e-02, -7.3732615e-02, -7.3579207e-02, + -7.3425800e-02, -7.3272400e-02, -7.3118992e-02, -7.2965592e-02, + -7.2812192e-02, -7.2658800e-02, -7.2505400e-02, -7.2352007e-02, + -7.2198614e-02, -7.2045222e-02, -7.1891837e-02, -7.1738444e-02, + -7.1585059e-02, -7.1431674e-02, -7.1278296e-02, -7.1124911e-02, + -7.0971534e-02, -7.0818156e-02, -7.0664778e-02, -7.0511408e-02, + -7.0358038e-02, -7.0204668e-02, -7.0051298e-02, -6.9897927e-02, + -6.9744565e-02, -6.9591194e-02, -6.9437832e-02, -6.9284476e-02, + -6.9131114e-02, -6.8977758e-02, -6.8824403e-02, -6.8671048e-02, + -6.8517692e-02, -6.8364345e-02, -6.8210997e-02, -6.8057649e-02, + -6.7904301e-02, -6.7750953e-02, -6.7597613e-02, -6.7444272e-02, + -6.7290932e-02, -6.7137592e-02, -6.6984251e-02, -6.6830918e-02, + -6.6677585e-02, -6.6524252e-02, -6.6370919e-02, -6.6217594e-02, + -6.6064268e-02, -6.5910943e-02, -6.5757617e-02, -6.5604292e-02, + -6.5450974e-02, -6.5297648e-02, -6.5144330e-02, -6.4991020e-02, + -6.4837702e-02, -6.4684391e-02, -6.4531073e-02, -6.4377762e-02, + -6.4224459e-02, -6.4071149e-02, -6.3917845e-02, -6.3764535e-02, + -6.3611232e-02, -6.3457936e-02, -6.3304633e-02, -6.3151337e-02, + -6.2998042e-02, -6.2844746e-02, -6.2691450e-02, -6.2538154e-02, + -6.2384866e-02, -6.2231574e-02, -6.2078286e-02, -6.1925001e-02, + -6.1771713e-02, -6.1618429e-02, -6.1465148e-02, -6.1311867e-02, + -6.1158586e-02, -6.1005309e-02, -6.0852032e-02, -6.0698759e-02, + -6.0545482e-02, -6.0392212e-02, -6.0238939e-02, -6.0085669e-02, + -5.9932403e-02, -5.9779137e-02, -5.9625871e-02, -5.9472606e-02, + -5.9319343e-02, -5.9166081e-02, -5.9012823e-02, -5.8859564e-02, + -5.8706306e-02, -5.8553051e-02, -5.8399796e-02, -5.8246545e-02, + -5.8093295e-02, -5.7940044e-02, -5.7786793e-02, -5.7633545e-02, + -5.7480302e-02, -5.7327054e-02, -5.7173811e-02, -5.7020571e-02, + -5.6867331e-02, -5.6714091e-02, -5.6560852e-02, -5.6407616e-02, + -5.6254379e-02, -5.6101147e-02, -5.5947915e-02, -5.5794682e-02, + -5.5641454e-02, -5.5488225e-02, -5.5334996e-02, -5.5181768e-02, + -5.5028547e-02, -5.4875322e-02, -5.4722100e-02, -5.4568879e-02, + -5.4415658e-02, -5.4262441e-02, -5.4109223e-02, -5.3956006e-02, + -5.3802792e-02, -5.3649578e-02, -5.3496365e-02, -5.3343154e-02, + -5.3189944e-02, -5.3036738e-02, -5.2883528e-02, -5.2730326e-02, + -5.2577119e-02, -5.2423917e-02, -5.2270714e-02, -5.2117512e-02, + -5.1964313e-02, -5.1811114e-02, -5.1657919e-02, -5.1504720e-02, + -5.1351525e-02, -5.1198334e-02, -5.1045138e-02, -5.0891947e-02, + -5.0738759e-02, -5.0585568e-02, -5.0432380e-02, -5.0279196e-02, + -5.0126009e-02, -4.9972825e-02, -4.9819645e-02, -4.9666461e-02, + -4.9513280e-02, -4.9360100e-02, -4.9206924e-02, -4.9053743e-02, + -4.8900571e-02, -4.8747394e-02, -4.8594221e-02, -4.8441049e-02, + -4.8287876e-02, -4.8134707e-02, -4.7981538e-02, -4.7828369e-02, + -4.7675204e-02, -4.7522034e-02, -4.7368873e-02, -4.7215708e-02, + -4.7062546e-02, -4.6909384e-02, -4.6756223e-02, -4.6603065e-02, + -4.6449907e-02, -4.6296749e-02, -4.6143591e-02, -4.5990437e-02, + -4.5837283e-02, -4.5684133e-02, -4.5530979e-02, -4.5377828e-02, + -4.5224681e-02, -4.5071531e-02, -4.4918384e-02, -4.4765238e-02, + -4.4612091e-02, -4.4458948e-02, -4.4305805e-02, -4.4152662e-02, + -4.3999523e-02, -4.3846380e-02, -4.3693241e-02, -4.3540105e-02, + -4.3386966e-02, -4.3233830e-02, -4.3080695e-02, -4.2927563e-02, + -4.2774428e-02, -4.2621296e-02, -4.2468168e-02, -4.2315036e-02, + -4.2161908e-02, -4.2008780e-02, -4.1855652e-02, -4.1702528e-02, + -4.1549399e-02, -4.1396279e-02, -4.1243155e-02, -4.1090030e-02, + -4.0936910e-02, -4.0783789e-02, -4.0630672e-02, -4.0477552e-02, + -4.0324435e-02, -4.0171318e-02, -4.0018205e-02, -3.9865088e-02, + -3.9711975e-02, -3.9558861e-02, -3.9405752e-02, -3.9252639e-02, + -3.9099529e-02, -3.8946420e-02, -3.8793314e-02, -3.8640205e-02, + -3.8487099e-02, -3.8333993e-02, -3.8180891e-02, -3.8027786e-02, + -3.7874684e-02, -3.7721582e-02, -3.7568480e-02, -3.7415382e-02, + -3.7262283e-02, -3.7109185e-02, -3.6956087e-02, -3.6802988e-02, + -3.6649894e-02, -3.6496799e-02, -3.6343705e-02, -3.6190614e-02, + -3.6037520e-02, -3.5884429e-02, -3.5731338e-02, -3.5578247e-02, + -3.5425160e-02, -3.5272073e-02, -3.5118986e-02, -3.4965899e-02, + -3.4812812e-02, -3.4659728e-02, -3.4506645e-02, -3.4353562e-02, + -3.4200478e-02, -3.4047395e-02, -3.3894315e-02, -3.3741236e-02, + -3.3588156e-02, -3.3435080e-02, -3.3282001e-02, -3.3128925e-02, + -3.2975849e-02, -3.2822773e-02, -3.2669697e-02, -3.2516625e-02, + -3.2363553e-02, -3.2210480e-02, -3.2057408e-02, -3.1904336e-02, + -3.1751268e-02, -3.1598199e-02, -3.1445131e-02, -3.1292062e-02, + -3.1138994e-02, -3.0985929e-02, -3.0832862e-02, -3.0679798e-02, + -3.0526733e-02, -3.0373670e-02, -3.0220607e-02, -3.0067546e-02, + -2.9914485e-02, -2.9761424e-02, -2.9608363e-02, -2.9455304e-02, + -2.9302247e-02, -2.9149190e-02, -2.8996132e-02, -2.8843075e-02, + -2.8690020e-02, -2.8536964e-02, -2.8383911e-02, -2.8230855e-02, + -2.8077804e-02, -2.7924750e-02, -2.7771698e-02, -2.7618648e-02, + -2.7465597e-02, -2.7312547e-02, -2.7159499e-02, -2.7006449e-02, + -2.6853401e-02, -2.6700355e-02, -2.6547307e-02, -2.6394261e-02, + -2.6241217e-02, -2.6088171e-02, -2.5935126e-02, -2.5782084e-02, + -2.5629040e-02, -2.5475997e-02, -2.5322957e-02, -2.5169915e-02, + -2.5016874e-02, -2.4863834e-02, -2.4710795e-02, -2.4557756e-02, + -2.4404718e-02, -2.4251681e-02, -2.4098642e-02, -2.3945605e-02, + -2.3792570e-02, -2.3639536e-02, -2.3486501e-02, -2.3333466e-02, + -2.3180431e-02, -2.3027398e-02, -2.2874366e-02, -2.2721333e-02, + -2.2568302e-02, -2.2415271e-02, -2.2262240e-02, -2.2109210e-02, + -2.1956179e-02, -2.1803152e-02, -2.1650122e-02, -2.1497095e-02, + -2.1344068e-02, -2.1191040e-02, -2.1038013e-02, -2.0884987e-02, + -2.0731961e-02, -2.0578936e-02, -2.0425912e-02, -2.0272888e-02, + -2.0119864e-02, -1.9966841e-02, -1.9813819e-02, -1.9660797e-02, + -1.9507775e-02, -1.9354753e-02, -1.9201731e-02, -1.9048711e-02, + -1.8895691e-02, -1.8742671e-02, -1.8589653e-02, -1.8436635e-02, + -1.8283617e-02, -1.8130599e-02, -1.7977580e-02, -1.7824564e-02, + -1.7671548e-02, -1.7518532e-02, -1.7365515e-02, -1.7212501e-02, + -1.7059484e-02, -1.6906470e-02, -1.6753457e-02, -1.6600443e-02, + -1.6447430e-02, -1.6294416e-02, -1.6141403e-02, -1.5988393e-02, + -1.5835380e-02, -1.5682369e-02, -1.5529358e-02, -1.5376347e-02, + -1.5223336e-02, -1.5070327e-02, -1.4917317e-02, -1.4764308e-02, + -1.4611298e-02, -1.4458290e-02, -1.4305281e-02, -1.4152274e-02, + -1.3999267e-02, -1.3846259e-02, -1.3693252e-02, -1.3540246e-02, + -1.3387239e-02, -1.3234233e-02, -1.3081227e-02, -1.2928222e-02, + -1.2775217e-02, -1.2622212e-02, -1.2469208e-02, -1.2316204e-02, + -1.2163199e-02, -1.2010196e-02, -1.1857193e-02, -1.1704190e-02, + -1.1551186e-02, -1.1398184e-02, -1.1245182e-02, -1.1092179e-02, + -1.0939178e-02, -1.0786177e-02, -1.0633175e-02, -1.0480175e-02, + -1.0327173e-02, -1.0174173e-02, -1.0021173e-02, -9.8681729e-03, + -9.7151734e-03, -9.5621739e-03, -9.4091743e-03, -9.2561757e-03, + -9.1031762e-03, -8.9501776e-03, -8.7971790e-03, -8.6441813e-03, + -8.4911827e-03, -8.3381850e-03, -8.1851874e-03, -8.0321897e-03, + -7.8791929e-03, -7.7261953e-03, -7.5731985e-03, -7.4202018e-03, + -7.2672050e-03, -7.1142088e-03, -6.9612125e-03, -6.8082167e-03, + -6.6552204e-03, -6.5022251e-03, -6.3492293e-03, -6.1962339e-03, + -6.0432386e-03, -5.8902432e-03, -5.7372483e-03, -5.5842535e-03, + -5.4312586e-03, -5.2782642e-03, -5.1252693e-03, -4.9722749e-03, + -4.8192809e-03, -4.6662865e-03, -4.5132926e-03, -4.3602986e-03, + -4.2073047e-03, -4.0543112e-03, -3.9013172e-03, -3.7483238e-03, + -3.5953303e-03, -3.4423368e-03, -3.2893436e-03, -3.1363503e-03, + -2.9833571e-03, -2.8303640e-03, -2.6773710e-03, -2.5243780e-03, + -2.3713852e-03, -2.2183922e-03, -2.0653994e-03, -1.9124068e-03, + -1.7594141e-03, -1.6064214e-03, -1.4534288e-03, -1.3004362e-03, + -1.1474437e-03, -9.9445111e-04, -8.4145856e-04, -6.8846607e-04, + -5.3547358e-04, -3.8248114e-04, -2.2948868e-04, -7.6496224e-05, + 7.6496224e-05, 2.2948868e-04, 3.8248114e-04, 5.3547358e-04, + 6.8846607e-04, 8.4145856e-04, 9.9445111e-04, 1.1474437e-03, + 1.3004362e-03, 1.4534288e-03, 1.6064214e-03, 1.7594141e-03, + 1.9124068e-03, 2.0653994e-03, 2.2183922e-03, 2.3713852e-03, + 2.5243780e-03, 2.6773710e-03, 2.8303640e-03, 2.9833571e-03, + 3.1363503e-03, 3.2893436e-03, 3.4423368e-03, 3.5953303e-03, + 3.7483238e-03, 3.9013172e-03, 4.0543112e-03, 4.2073047e-03, + 4.3602986e-03, 4.5132926e-03, 4.6662865e-03, 4.8192809e-03, + 4.9722749e-03, 5.1252693e-03, 5.2782642e-03, 5.4312586e-03, + 5.5842535e-03, 5.7372483e-03, 5.8902432e-03, 6.0432386e-03, + 6.1962339e-03, 6.3492293e-03, 6.5022251e-03, 6.6552204e-03, + 6.8082167e-03, 6.9612125e-03, 7.1142088e-03, 7.2672050e-03, + 7.4202018e-03, 7.5731985e-03, 7.7261953e-03, 7.8791929e-03, + 8.0321897e-03, 8.1851874e-03, 8.3381850e-03, 8.4911827e-03, + 8.6441813e-03, 8.7971790e-03, 8.9501776e-03, 9.1031762e-03, + 9.2561757e-03, 9.4091743e-03, 9.5621739e-03, 9.7151734e-03, + 9.8681729e-03, 1.0021173e-02, 1.0174173e-02, 1.0327173e-02, + 1.0480175e-02, 1.0633175e-02, 1.0786177e-02, 1.0939178e-02, + 1.1092179e-02, 1.1245182e-02, 1.1398184e-02, 1.1551186e-02, + 1.1704190e-02, 1.1857193e-02, 1.2010196e-02, 1.2163199e-02, + 1.2316204e-02, 1.2469208e-02, 1.2622212e-02, 1.2775217e-02, + 1.2928222e-02, 1.3081227e-02, 1.3234233e-02, 1.3387239e-02, + 1.3540246e-02, 1.3693252e-02, 1.3846259e-02, 1.3999267e-02, + 1.4152274e-02, 1.4305281e-02, 1.4458290e-02, 1.4611298e-02, + 1.4764308e-02, 1.4917317e-02, 1.5070327e-02, 1.5223336e-02, + 1.5376347e-02, 1.5529358e-02, 1.5682369e-02, 1.5835380e-02, + 1.5988393e-02, 1.6141403e-02, 1.6294416e-02, 1.6447430e-02, + 1.6600443e-02, 1.6753457e-02, 1.6906470e-02, 1.7059484e-02, + 1.7212501e-02, 1.7365515e-02, 1.7518532e-02, 1.7671548e-02, + 1.7824564e-02, 1.7977580e-02, 1.8130599e-02, 1.8283617e-02, + 1.8436635e-02, 1.8589653e-02, 1.8742671e-02, 1.8895691e-02, + 1.9048711e-02, 1.9201731e-02, 1.9354753e-02, 1.9507775e-02, + 1.9660797e-02, 1.9813819e-02, 1.9966841e-02, 2.0119864e-02, + 2.0272888e-02, 2.0425912e-02, 2.0578936e-02, 2.0731961e-02, + 2.0884987e-02, 2.1038013e-02, 2.1191040e-02, 2.1344068e-02, + 2.1497095e-02, 2.1650122e-02, 2.1803152e-02, 2.1956179e-02, + 2.2109210e-02, 2.2262240e-02, 2.2415271e-02, 2.2568302e-02, + 2.2721333e-02, 2.2874366e-02, 2.3027398e-02, 2.3180431e-02, + 2.3333466e-02, 2.3486501e-02, 2.3639536e-02, 2.3792570e-02, + 2.3945605e-02, 2.4098642e-02, 2.4251681e-02, 2.4404718e-02, + 2.4557756e-02, 2.4710795e-02, 2.4863834e-02, 2.5016874e-02, + 2.5169915e-02, 2.5322957e-02, 2.5475997e-02, 2.5629040e-02, + 2.5782084e-02, 2.5935126e-02, 2.6088171e-02, 2.6241217e-02, + 2.6394261e-02, 2.6547307e-02, 2.6700355e-02, 2.6853401e-02, + 2.7006449e-02, 2.7159499e-02, 2.7312547e-02, 2.7465597e-02, + 2.7618648e-02, 2.7771698e-02, 2.7924750e-02, 2.8077804e-02, + 2.8230855e-02, 2.8383911e-02, 2.8536964e-02, 2.8690020e-02, + 2.8843075e-02, 2.8996132e-02, 2.9149190e-02, 2.9302247e-02, + 2.9455304e-02, 2.9608363e-02, 2.9761424e-02, 2.9914485e-02, + 3.0067546e-02, 3.0220607e-02, 3.0373670e-02, 3.0526733e-02, + 3.0679798e-02, 3.0832862e-02, 3.0985929e-02, 3.1138994e-02, + 3.1292062e-02, 3.1445131e-02, 3.1598199e-02, 3.1751268e-02, + 3.1904336e-02, 3.2057408e-02, 3.2210480e-02, 3.2363553e-02, + 3.2516625e-02, 3.2669697e-02, 3.2822773e-02, 3.2975849e-02, + 3.3128925e-02, 3.3282001e-02, 3.3435080e-02, 3.3588156e-02, + 3.3741236e-02, 3.3894315e-02, 3.4047395e-02, 3.4200478e-02, + 3.4353562e-02, 3.4506645e-02, 3.4659728e-02, 3.4812812e-02, + 3.4965899e-02, 3.5118986e-02, 3.5272073e-02, 3.5425160e-02, + 3.5578247e-02, 3.5731338e-02, 3.5884429e-02, 3.6037520e-02, + 3.6190614e-02, 3.6343705e-02, 3.6496799e-02, 3.6649894e-02, + 3.6802988e-02, 3.6956087e-02, 3.7109185e-02, 3.7262283e-02, + 3.7415382e-02, 3.7568480e-02, 3.7721582e-02, 3.7874684e-02, + 3.8027786e-02, 3.8180891e-02, 3.8333993e-02, 3.8487099e-02, + 3.8640205e-02, 3.8793314e-02, 3.8946420e-02, 3.9099529e-02, + 3.9252639e-02, 3.9405752e-02, 3.9558861e-02, 3.9711975e-02, + 3.9865088e-02, 4.0018205e-02, 4.0171318e-02, 4.0324435e-02, + 4.0477552e-02, 4.0630672e-02, 4.0783789e-02, 4.0936910e-02, + 4.1090030e-02, 4.1243155e-02, 4.1396279e-02, 4.1549399e-02, + 4.1702528e-02, 4.1855652e-02, 4.2008780e-02, 4.2161908e-02, + 4.2315036e-02, 4.2468168e-02, 4.2621296e-02, 4.2774428e-02, + 4.2927563e-02, 4.3080695e-02, 4.3233830e-02, 4.3386966e-02, + 4.3540105e-02, 4.3693241e-02, 4.3846380e-02, 4.3999523e-02, + 4.4152662e-02, 4.4305805e-02, 4.4458948e-02, 4.4612091e-02, + 4.4765238e-02, 4.4918384e-02, 4.5071531e-02, 4.5224681e-02, + 4.5377828e-02, 4.5530979e-02, 4.5684133e-02, 4.5837283e-02, + 4.5990437e-02, 4.6143591e-02, 4.6296749e-02, 4.6449907e-02, + 4.6603065e-02, 4.6756223e-02, 4.6909384e-02, 4.7062546e-02, + 4.7215708e-02, 4.7368873e-02, 4.7522034e-02, 4.7675204e-02, + 4.7828369e-02, 4.7981538e-02, 4.8134707e-02, 4.8287876e-02, + 4.8441049e-02, 4.8594221e-02, 4.8747394e-02, 4.8900571e-02, + 4.9053743e-02, 4.9206924e-02, 4.9360100e-02, 4.9513280e-02, + 4.9666461e-02, 4.9819645e-02, 4.9972825e-02, 5.0126009e-02, + 5.0279196e-02, 5.0432380e-02, 5.0585568e-02, 5.0738759e-02, + 5.0891947e-02, 5.1045138e-02, 5.1198334e-02, 5.1351525e-02, + 5.1504720e-02, 5.1657919e-02, 5.1811114e-02, 5.1964313e-02, + 5.2117512e-02, 5.2270714e-02, 5.2423917e-02, 5.2577119e-02, + 5.2730326e-02, 5.2883528e-02, 5.3036738e-02, 5.3189944e-02, + 5.3343154e-02, 5.3496365e-02, 5.3649578e-02, 5.3802792e-02, + 5.3956006e-02, 5.4109223e-02, 5.4262441e-02, 5.4415658e-02, + 5.4568879e-02, 5.4722100e-02, 5.4875322e-02, 5.5028547e-02, + 5.5181768e-02, 5.5334996e-02, 5.5488225e-02, 5.5641454e-02, + 5.5794682e-02, 5.5947915e-02, 5.6101147e-02, 5.6254379e-02, + 5.6407616e-02, 5.6560852e-02, 5.6714091e-02, 5.6867331e-02, + 5.7020571e-02, 5.7173811e-02, 5.7327054e-02, 5.7480302e-02, + 5.7633545e-02, 5.7786793e-02, 5.7940044e-02, 5.8093295e-02, + 5.8246545e-02, 5.8399796e-02, 5.8553051e-02, 5.8706306e-02, + 5.8859564e-02, 5.9012823e-02, 5.9166081e-02, 5.9319343e-02, + 5.9472606e-02, 5.9625871e-02, 5.9779137e-02, 5.9932403e-02, + 6.0085669e-02, 6.0238939e-02, 6.0392212e-02, 6.0545482e-02, + 6.0698759e-02, 6.0852032e-02, 6.1005309e-02, 6.1158586e-02, + 6.1311867e-02, 6.1465148e-02, 6.1618429e-02, 6.1771713e-02, + 6.1925001e-02, 6.2078286e-02, 6.2231574e-02, 6.2384866e-02, + 6.2538154e-02, 6.2691450e-02, 6.2844746e-02, 6.2998042e-02, + 6.3151337e-02, 6.3304633e-02, 6.3457936e-02, 6.3611232e-02, + 6.3764535e-02, 6.3917845e-02, 6.4071149e-02, 6.4224459e-02, + 6.4377762e-02, 6.4531073e-02, 6.4684391e-02, 6.4837702e-02, + 6.4991020e-02, 6.5144330e-02, 6.5297648e-02, 6.5450974e-02, + 6.5604292e-02, 6.5757617e-02, 6.5910943e-02, 6.6064268e-02, + 6.6217594e-02, 6.6370919e-02, 6.6524252e-02, 6.6677585e-02, + 6.6830918e-02, 6.6984251e-02, 6.7137592e-02, 6.7290932e-02, + 6.7444272e-02, 6.7597613e-02, 6.7750953e-02, 6.7904301e-02, + 6.8057649e-02, 6.8210997e-02, 6.8364345e-02, 6.8517692e-02, + 6.8671048e-02, 6.8824403e-02, 6.8977758e-02, 6.9131114e-02, + 6.9284476e-02, 6.9437832e-02, 6.9591194e-02, 6.9744565e-02, + 6.9897927e-02, 7.0051298e-02, 7.0204668e-02, 7.0358038e-02, + 7.0511408e-02, 7.0664778e-02, 7.0818156e-02, 7.0971534e-02, + 7.1124911e-02, 7.1278296e-02, 7.1431674e-02, 7.1585059e-02, + 7.1738444e-02, 7.1891837e-02, 7.2045222e-02, 7.2198614e-02, + 7.2352007e-02, 7.2505400e-02, 7.2658800e-02, 7.2812192e-02, + 7.2965592e-02, 7.3118992e-02, 7.3272400e-02, 7.3425800e-02, + 7.3579207e-02, 7.3732615e-02, 7.3886029e-02, 7.4039437e-02, + 7.4192852e-02, 7.4346267e-02, 7.4499682e-02, 7.4653104e-02, + 7.4806519e-02, 7.4959941e-02, 7.5113371e-02, 7.5266793e-02, + 7.5420223e-02, 7.5573653e-02, 7.5727083e-02, 7.5880513e-02, + 7.6033950e-02, 7.6187387e-02, 7.6340824e-02, 7.6494262e-02, + 7.6647706e-02, 7.6801144e-02, 7.6954588e-02, 7.7108040e-02, + 7.7261485e-02, 7.7414937e-02, 7.7568389e-02, 7.7721842e-02, + 7.7875301e-02, 7.8028761e-02, 7.8182220e-02, 7.8335680e-02, + 7.8489147e-02, 7.8642607e-02, 7.8796074e-02, 7.8949548e-02, + 7.9103015e-02, 7.9256490e-02, 7.9409964e-02, 7.9563439e-02, + 7.9716921e-02, 7.9870403e-02, 8.0023885e-02, 8.0177367e-02, + 8.0330849e-02, 8.0484338e-02, 8.0637828e-02, 8.0791324e-02, + 8.0944814e-02, 8.1098311e-02, 8.1251808e-02, 8.1405304e-02, + 8.1558809e-02, 8.1712313e-02, 8.1865817e-02, 8.2019322e-02, + 8.2172833e-02, 8.2326345e-02, 8.2479857e-02, 8.2633369e-02, + 8.2786888e-02, 8.2940407e-02, 8.3093926e-02, 8.3247446e-02, + 8.3400972e-02, 8.3554499e-02, 8.3708026e-02, 8.3861560e-02, + 8.4015094e-02, 8.4168628e-02, 8.4322162e-02, 8.4475696e-02, + 8.4629238e-02, 8.4782779e-02, 8.4936328e-02, 8.5089870e-02, + 8.5243419e-02, 8.5396968e-02, 8.5550524e-02, 8.5704081e-02, + 8.5857637e-02, 8.6011194e-02, 8.6164750e-02, 8.6318314e-02, + 8.6471878e-02, 8.6625449e-02, 8.6779013e-02, 8.6932585e-02, + 8.7086156e-02, 8.7239735e-02, 8.7393306e-02, 8.7546885e-02, + 8.7700471e-02, 8.7854050e-02, 8.8007636e-02, 8.8161223e-02, + 8.8314816e-02, 8.8468403e-02, 8.8621996e-02, 8.8775598e-02, + 8.8929191e-02, 8.9082792e-02, 8.9236394e-02, 8.9389995e-02, + 8.9543603e-02, 8.9697212e-02, 8.9850821e-02, 9.0004437e-02, + 9.0158045e-02, 9.0311661e-02, 9.0465285e-02, 9.0618901e-02, + 9.0772524e-02, 9.0926155e-02, 9.1079779e-02, 9.1233410e-02, + 9.1387041e-02, 9.1540672e-02, 9.1694310e-02, 9.1847949e-02, + 9.2001587e-02, 9.2155233e-02, 9.2308879e-02, 9.2462525e-02, + 9.2616171e-02, 9.2769824e-02, 9.2923477e-02, 9.3077131e-02, + 9.3230791e-02, 9.3384452e-02, 9.3538113e-02, 9.3691774e-02, + 9.3845442e-02, 9.3999110e-02, 9.4152778e-02, 9.4306454e-02, + 9.4460130e-02, 9.4613805e-02, 9.4767489e-02, 9.4921172e-02, + 9.5074855e-02, 9.5228538e-02, 9.5382228e-02, 9.5535919e-02, + 9.5689617e-02, 9.5843308e-02, 9.5997006e-02, 9.6150704e-02, + 9.6304409e-02, 9.6458115e-02, 9.6611820e-02, 9.6765533e-02, + 9.6919239e-02, 9.7072959e-02, 9.7226672e-02, 9.7380392e-02, + 9.7534113e-02, 9.7687833e-02, 9.7841561e-02, 9.7995289e-02, + 9.8149016e-02, 9.8302752e-02, 9.8456487e-02, 9.8610222e-02, + 9.8763958e-02, 9.8917700e-02, 9.9071443e-02, 9.9225193e-02, + 9.9378943e-02, 9.9532694e-02, 9.9686444e-02, 9.9840201e-02, + 9.9993959e-02, 1.0014772e-01, 1.0030148e-01, 1.0045525e-01, + 1.0060901e-01, 1.0076278e-01, 1.0091656e-01, 1.0107033e-01, + 1.0122411e-01, 1.0137789e-01, 1.0153167e-01, 1.0168546e-01, + 1.0183924e-01, 1.0199303e-01, 1.0214682e-01, 1.0230061e-01, + 1.0245441e-01, 1.0260821e-01, 1.0276201e-01, 1.0291582e-01, + 1.0306962e-01, 1.0322343e-01, 1.0337724e-01, 1.0353106e-01, + 1.0368487e-01, 1.0383869e-01, 1.0399251e-01, 1.0414633e-01, + 1.0430016e-01, 1.0445399e-01, 1.0460781e-01, 1.0476165e-01, + 1.0491548e-01, 1.0506932e-01, 1.0522316e-01, 1.0537700e-01, + 1.0553085e-01, 1.0568470e-01, 1.0583855e-01, 1.0599241e-01, + 1.0614626e-01, 1.0630012e-01, 1.0645398e-01, 1.0660784e-01, + 1.0676171e-01, 1.0691557e-01, 1.0706945e-01, 1.0722332e-01, + 1.0737719e-01, 1.0753107e-01, 1.0768496e-01, 1.0783884e-01, + 1.0799272e-01, 1.0814661e-01, 1.0830050e-01, 1.0845440e-01, + 1.0860829e-01, 1.0876219e-01, 1.0891609e-01, 1.0907000e-01, + 1.0922390e-01, 1.0937781e-01, 1.0953172e-01, 1.0968564e-01, + 1.0983955e-01, 1.0999347e-01, 1.1014739e-01, 1.1030132e-01, + 1.1045524e-01, 1.1060917e-01, 1.1076311e-01, 1.1091705e-01, + 1.1107098e-01, 1.1122492e-01, 1.1137886e-01, 1.1153281e-01, + 1.1168676e-01, 1.1184071e-01, 1.1199466e-01, 1.1214862e-01, + 1.1230258e-01, 1.1245654e-01, 1.1261050e-01, 1.1276447e-01, + 1.1291844e-01, 1.1307242e-01, 1.1322639e-01, 1.1338037e-01, + 1.1353435e-01, 1.1368833e-01, 1.1384232e-01, 1.1399630e-01, + 1.1415029e-01, 1.1430429e-01, 1.1445829e-01, 1.1461229e-01, + 1.1476628e-01, 1.1492029e-01, 1.1507430e-01, 1.1522831e-01, + 1.1538232e-01, 1.1553634e-01, 1.1569036e-01, 1.1584438e-01, + 1.1599840e-01, 1.1615243e-01, 1.1630645e-01, 1.1646049e-01, + 1.1661452e-01, 1.1676856e-01, 1.1692260e-01, 1.1707664e-01, + 1.1723069e-01, 1.1738474e-01, 1.1753879e-01, 1.1769284e-01, + 1.1784691e-01, 1.1800096e-01, 1.1815502e-01, 1.1830909e-01, + 1.1846316e-01, 1.1861723e-01, 1.1877131e-01, 1.1892538e-01, + 1.1907946e-01, 1.1923354e-01, 1.1938763e-01, 1.1954172e-01, + 1.1969581e-01, 1.1984990e-01, 1.2000400e-01, 1.2015810e-01, + 1.2031220e-01, 1.2046631e-01, 1.2062041e-01, 1.2077452e-01, + 1.2092864e-01, 1.2108275e-01, 1.2123688e-01, 1.2139100e-01, + 1.2154512e-01, 1.2169925e-01, 1.2185338e-01, 1.2200751e-01, + 1.2216165e-01, 1.2231579e-01, 1.2246993e-01, 1.2262408e-01, + 1.2277823e-01, 1.2293238e-01, 1.2308653e-01, 1.2324069e-01, + 1.2339485e-01, 1.2354901e-01, 1.2370318e-01, 1.2385735e-01, + 1.2401152e-01, 1.2416570e-01, 1.2431987e-01, 1.2447406e-01, + 1.2462824e-01, 1.2478243e-01, 1.2493662e-01, 1.2509081e-01, + 1.2524500e-01, 1.2539920e-01, 1.2555340e-01, 1.2570761e-01, + 1.2586181e-01, 1.2601602e-01, 1.2617023e-01, 1.2632446e-01, + 1.2647867e-01, 1.2663290e-01, 1.2678713e-01, 1.2694135e-01, + 1.2709558e-01, 1.2724982e-01, 1.2740405e-01, 1.2755829e-01, + 1.2771255e-01, 1.2786679e-01, 1.2802103e-01, 1.2817529e-01, + 1.2832955e-01, 1.2848380e-01, 1.2863807e-01, 1.2879233e-01, + 1.2894660e-01, 1.2910087e-01, 1.2925515e-01, 1.2940942e-01, + 1.2956370e-01, 1.2971799e-01, 1.2987228e-01, 1.3002656e-01, + 1.3018085e-01, 1.3033515e-01, 1.3048945e-01, 1.3064376e-01, + 1.3079806e-01, 1.3095237e-01, 1.3110667e-01, 1.3126099e-01, + 1.3141531e-01, 1.3156962e-01, 1.3172396e-01, 1.3187829e-01, + 1.3203262e-01, 1.3218695e-01, 1.3234128e-01, 1.3249563e-01, + 1.3264996e-01, 1.3280430e-01, 1.3295867e-01, 1.3311301e-01, + 1.3326737e-01, 1.3342173e-01, 1.3357610e-01, 1.3373046e-01, + 1.3388482e-01, 1.3403919e-01, 1.3419357e-01, 1.3434795e-01, + 1.3450232e-01, 1.3465671e-01, 1.3481110e-01, 1.3496549e-01, + 1.3511989e-01, 1.3527428e-01, 1.3542868e-01, 1.3558309e-01, + 1.3573749e-01, 1.3589190e-01, 1.3604632e-01, 1.3620073e-01, + 1.3635515e-01, 1.3650957e-01, 1.3666400e-01, 1.3681842e-01, + 1.3697286e-01, 1.3712730e-01, 1.3728173e-01, 1.3743618e-01, + 1.3759063e-01, 1.3774507e-01, 1.3789953e-01, 1.3805398e-01, + 1.3820843e-01, 1.3836290e-01, 1.3851736e-01, 1.3867185e-01, + 1.3882631e-01, 1.3898079e-01, 1.3913527e-01, 1.3928975e-01, + 1.3944423e-01, 1.3959873e-01, 1.3975321e-01, 1.3990770e-01, + 1.4006221e-01, 1.4021671e-01, 1.4037122e-01, 1.4052573e-01, + 1.4068024e-01, 1.4083475e-01, 1.4098927e-01, 1.4114380e-01, + 1.4129832e-01, 1.4145285e-01, 1.4160737e-01, 1.4176191e-01, + 1.4191645e-01, 1.4207099e-01, 1.4222555e-01, 1.4238009e-01, + 1.4253464e-01, 1.4268920e-01, 1.4284377e-01, 1.4299832e-01, + 1.4315289e-01, 1.4330746e-01, 1.4346203e-01, 1.4361662e-01, + 1.4377119e-01, 1.4392577e-01, 1.4408036e-01, 1.4423496e-01, + 1.4438954e-01, 1.4454414e-01, 1.4469874e-01, 1.4485335e-01, + 1.4500795e-01, 1.4516257e-01, 1.4531718e-01, 1.4547180e-01, + 1.4562643e-01, 1.4578104e-01, 1.4593567e-01, 1.4609031e-01, + 1.4624494e-01, 1.4639959e-01, 1.4655423e-01, 1.4670888e-01, + 1.4686352e-01, 1.4701818e-01, 1.4717282e-01, 1.4732748e-01, + 1.4748216e-01, 1.4763682e-01, 1.4779149e-01, 1.4794616e-01, + 1.4810084e-01, 1.4825553e-01, 1.4841022e-01, 1.4856490e-01, + 1.4871959e-01, 1.4887428e-01, 1.4902899e-01, 1.4918369e-01, + 1.4933839e-01, 1.4949310e-01, 1.4964782e-01, 1.4980254e-01, + 1.4995725e-01, 1.5011197e-01, 1.5026671e-01, 1.5042144e-01, + 1.5057617e-01, 1.5073091e-01, 1.5088566e-01, 1.5104041e-01, + 1.5119515e-01, 1.5134990e-01, 1.5150465e-01, 1.5165941e-01, + 1.5181418e-01, 1.5196896e-01, 1.5212372e-01, 1.5227850e-01, + 1.5243328e-01, 1.5258805e-01, 1.5274285e-01, 1.5289763e-01, + 1.5305242e-01, 1.5320723e-01, 1.5336202e-01, 1.5351683e-01, + 1.5367164e-01, 1.5382645e-01, 1.5398125e-01, 1.5413608e-01, + 1.5429090e-01, 1.5444572e-01, 1.5460056e-01, 1.5475538e-01, + 1.5491022e-01, 1.5506507e-01, 1.5521991e-01, 1.5537477e-01, + 1.5552962e-01, 1.5568447e-01, 1.5583932e-01, 1.5599419e-01, + 1.5614906e-01, 1.5630393e-01, 1.5645881e-01, 1.5661368e-01, + 1.5676856e-01, 1.5692346e-01, 1.5707834e-01, 1.5723324e-01, + 1.5738814e-01, 1.5754303e-01, 1.5769795e-01, 1.5785284e-01, + 1.5800776e-01, 1.5816268e-01, 1.5831760e-01, 1.5847252e-01, + 1.5862745e-01, 1.5878238e-01, 1.5893732e-01, 1.5909225e-01, + 1.5924719e-01, 1.5940215e-01, 1.5955709e-01, 1.5971205e-01, + 1.5986700e-01, 1.6002196e-01, 1.6017693e-01, 1.6033190e-01, + 1.6048688e-01, 1.6064185e-01, 1.6079684e-01, 1.6095182e-01, + 1.6110681e-01, 1.6126180e-01, 1.6141680e-01, 1.6157180e-01, + 1.6172680e-01, 1.6188180e-01, 1.6203682e-01, 1.6219184e-01, + 1.6234685e-01, 1.6250189e-01, 1.6265692e-01, 1.6281195e-01, + 1.6296698e-01, 1.6312201e-01, 1.6327706e-01, 1.6343211e-01, + 1.6358717e-01, 1.6374221e-01, 1.6389728e-01, 1.6405234e-01, + 1.6420740e-01, 1.6436248e-01, 1.6451755e-01, 1.6467263e-01, + 1.6482772e-01, 1.6498280e-01, 1.6513789e-01, 1.6529299e-01, + 1.6544808e-01, 1.6560319e-01, 1.6575830e-01, 1.6591340e-01, + 1.6606852e-01, 1.6622365e-01, 1.6637877e-01, 1.6653389e-01, + 1.6668902e-01, 1.6684416e-01, 1.6699930e-01, 1.6715443e-01, + 1.6730958e-01, 1.6746473e-01, 1.6761988e-01, 1.6777505e-01, + 1.6793022e-01, 1.6808538e-01, 1.6824055e-01, 1.6839573e-01, + 1.6855091e-01, 1.6870609e-01, 1.6886127e-01, 1.6901647e-01, + 1.6917166e-01, 1.6932686e-01, 1.6948207e-01, 1.6963726e-01, + 1.6979249e-01, 1.6994770e-01, 1.7010292e-01, 1.7025813e-01, + 1.7041337e-01, 1.7056860e-01, 1.7072384e-01, 1.7087908e-01, + 1.7103432e-01, 1.7118958e-01, 1.7134482e-01, 1.7150009e-01, + 1.7165534e-01, 1.7181061e-01, 1.7196588e-01, 1.7212115e-01, + 1.7227642e-01, 1.7243171e-01, 1.7258699e-01, 1.7274229e-01, + 1.7289758e-01, 1.7305288e-01, 1.7320818e-01, 1.7336349e-01, + 1.7351879e-01, 1.7367411e-01, 1.7382944e-01, 1.7398475e-01, + 1.7414008e-01, 1.7429541e-01, 1.7445076e-01, 1.7460610e-01, + 1.7476144e-01, 1.7491679e-01, 1.7507213e-01, 1.7522749e-01, + 1.7538285e-01, 1.7553823e-01, 1.7569359e-01, 1.7584896e-01, + 1.7600435e-01, 1.7615972e-01, 1.7631511e-01, 1.7647050e-01, + 1.7662591e-01, 1.7678130e-01, 1.7693670e-01, 1.7709212e-01, + 1.7724752e-01, 1.7740294e-01, 1.7755836e-01, 1.7771380e-01, + 1.7786922e-01, 1.7802465e-01, 1.7818010e-01, 1.7833553e-01, + 1.7849098e-01, 1.7864643e-01, 1.7880189e-01, 1.7895734e-01, + 1.7911281e-01, 1.7926829e-01, 1.7942375e-01, 1.7957923e-01, + 1.7973471e-01, 1.7989020e-01, 1.8004569e-01, 1.8020119e-01, + 1.8035668e-01, 1.8051219e-01, 1.8066770e-01, 1.8082321e-01, + 1.8097872e-01, 1.8113424e-01, 1.8128976e-01, 1.8144530e-01, + 1.8160082e-01, 1.8175636e-01, 1.8191192e-01, 1.8206745e-01, + 1.8222301e-01, 1.8237856e-01, 1.8253413e-01, 1.8268970e-01, + 1.8284526e-01, 1.8300083e-01, 1.8315642e-01, 1.8331200e-01, + 1.8346758e-01, 1.8362318e-01, 1.8377876e-01, 1.8393438e-01, + 1.8408997e-01, 1.8424559e-01, 1.8440120e-01, 1.8455681e-01, + 1.8471244e-01, 1.8486807e-01, 1.8502370e-01, 1.8517934e-01, + 1.8533497e-01, 1.8549062e-01, 1.8564627e-01, 1.8580192e-01, + 1.8595758e-01, 1.8611324e-01, 1.8626891e-01, 1.8642458e-01, + 1.8658026e-01, 1.8673594e-01, 1.8689163e-01, 1.8704732e-01, + 1.8720300e-01, 1.8735871e-01, 1.8751441e-01, 1.8767013e-01, + 1.8782583e-01, 1.8798155e-01, 1.8813728e-01, 1.8829300e-01, + 1.8844873e-01, 1.8860446e-01, 1.8876021e-01, 1.8891595e-01, + 1.8907170e-01, 1.8922745e-01, 1.8938321e-01, 1.8953897e-01, + 1.8969475e-01, 1.8985051e-01, 1.9000629e-01, 1.9016208e-01, + 1.9031785e-01, 1.9047365e-01, 1.9062945e-01, 1.9078524e-01, + 1.9094105e-01, 1.9109686e-01, 1.9125268e-01, 1.9140849e-01, + 1.9156432e-01, 1.9172014e-01, 1.9187598e-01, 1.9203182e-01, + 1.9218765e-01, 1.9234350e-01, 1.9249935e-01, 1.9265521e-01, + 1.9281107e-01, 1.9296694e-01, 1.9312280e-01, 1.9327869e-01, + 1.9343455e-01, 1.9359045e-01, 1.9374633e-01, 1.9390222e-01, + 1.9405812e-01, 1.9421403e-01, 1.9436993e-01, 1.9452584e-01, + 1.9468176e-01, 1.9483769e-01, 1.9499362e-01, 1.9514954e-01, + 1.9530548e-01, 1.9546142e-01, 1.9561736e-01, 1.9577332e-01, + 1.9592927e-01, 1.9608523e-01, 1.9624120e-01, 1.9639716e-01, + 1.9655314e-01, 1.9670911e-01, 1.9686510e-01, 1.9702108e-01, + 1.9717708e-01, 1.9733308e-01, 1.9748908e-01, 1.9764508e-01, + 1.9780110e-01, 1.9795711e-01, 1.9811314e-01, 1.9826917e-01, + 1.9842520e-01, 1.9858123e-01, 1.9873728e-01, 1.9889332e-01, + 1.9904937e-01, 1.9920543e-01, 1.9936149e-01, 1.9951756e-01, + 1.9967362e-01, 1.9982970e-01, 1.9998579e-01, 2.0014186e-01, + 2.0029795e-01, 2.0045406e-01, 2.0061015e-01, 2.0076625e-01, + 2.0092237e-01, 2.0107847e-01, 2.0123459e-01, 2.0139073e-01, + 2.0154685e-01, 2.0170298e-01, 2.0185913e-01, 2.0201527e-01, + 2.0217142e-01, 2.0232758e-01, 2.0248373e-01, 2.0263989e-01, + 2.0279607e-01, 2.0295224e-01, 2.0310842e-01, 2.0326459e-01, + 2.0342079e-01, 2.0357698e-01, 2.0373318e-01, 2.0388938e-01, + 2.0404559e-01, 2.0420180e-01, 2.0435803e-01, 2.0451425e-01, + 2.0467047e-01, 2.0482671e-01, 2.0498295e-01, 2.0513919e-01, + 2.0529544e-01, 2.0545170e-01, 2.0560795e-01, 2.0576420e-01, + 2.0592047e-01, 2.0607676e-01, 2.0623302e-01, 2.0638931e-01, + 2.0654561e-01, 2.0670189e-01, 2.0685819e-01, 2.0701450e-01, + 2.0717081e-01, 2.0732713e-01, 2.0748344e-01, 2.0763977e-01, + 2.0779610e-01, 2.0795242e-01, 2.0810877e-01, 2.0826511e-01, + 2.0842145e-01, 2.0857781e-01, 2.0873417e-01, 2.0889054e-01, + 2.0904690e-01, 2.0920329e-01, 2.0935966e-01, 2.0951605e-01, + 2.0967244e-01, 2.0982882e-01, 2.0998523e-01, 2.1014164e-01, + 2.1029805e-01, 2.1045446e-01, 2.1061088e-01, 2.1076731e-01, + 2.1092375e-01, 2.1108018e-01, 2.1123663e-01, 2.1139307e-01, + 2.1154952e-01, 2.1170597e-01, 2.1186243e-01, 2.1201891e-01, + 2.1217538e-01, 2.1233186e-01, 2.1248834e-01, 2.1264483e-01, + 2.1280132e-01, 2.1295781e-01, 2.1311432e-01, 2.1327083e-01, + 2.1342735e-01, 2.1358387e-01, 2.1374039e-01, 2.1389692e-01, + 2.1405345e-01, 2.1420999e-01, 2.1436654e-01, 2.1452309e-01, + 2.1467964e-01, 2.1483621e-01, 2.1499278e-01, 2.1514934e-01, + 2.1530592e-01, 2.1546251e-01, 2.1561910e-01, 2.1577568e-01, + 2.1593229e-01, 2.1608889e-01, 2.1624550e-01, 2.1640211e-01, + 2.1655874e-01, 2.1671537e-01, 2.1687199e-01, 2.1702863e-01, + 2.1718527e-01, 2.1734191e-01, 2.1749857e-01, 2.1765523e-01, + 2.1781188e-01, 2.1796855e-01, 2.1812522e-01, 2.1828191e-01, + 2.1843858e-01, 2.1859528e-01, 2.1875197e-01, 2.1890867e-01, + 2.1906538e-01, 2.1922208e-01, 2.1937880e-01, 2.1953553e-01, + 2.1969225e-01, 2.1984898e-01, 2.2000572e-01, 2.2016247e-01, + 2.2031921e-01, 2.2047597e-01, 2.2063272e-01, 2.2078949e-01, + 2.2094625e-01, 2.2110303e-01, 2.2125982e-01, 2.2141661e-01, + 2.2157340e-01, 2.2173019e-01, 2.2188699e-01, 2.2204380e-01, + 2.2220062e-01, 2.2235744e-01, 2.2251426e-01, 2.2267109e-01, + 2.2282793e-01, 2.2298476e-01, 2.2314161e-01, 2.2329846e-01, + 2.2345532e-01, 2.2361219e-01, 2.2376905e-01, 2.2392592e-01, + 2.2408280e-01, 2.2423969e-01, 2.2439659e-01, 2.2455348e-01, + 2.2471038e-01, 2.2486728e-01, 2.2502419e-01, 2.2518112e-01, + 2.2533804e-01, 2.2549497e-01, 2.2565190e-01, 2.2580884e-01, + 2.2596578e-01, 2.2612274e-01, 2.2627969e-01, 2.2643666e-01, + 2.2659363e-01, 2.2675060e-01, 2.2690758e-01, 2.2706456e-01, + 2.2722156e-01, 2.2737855e-01, 2.2753556e-01, 2.2769256e-01, + 2.2784957e-01, 2.2800660e-01, 2.2816361e-01, 2.2832064e-01, + 2.2847769e-01, 2.2863473e-01, 2.2879177e-01, 2.2894882e-01, + 2.2910587e-01, 2.2926295e-01, 2.2942002e-01, 2.2957709e-01, + 2.2973417e-01, 2.2989126e-01, 2.3004834e-01, 2.3020545e-01, + 2.3036255e-01, 2.3051965e-01, 2.3067677e-01, 2.3083389e-01, + 2.3099102e-01, 2.3114815e-01, 2.3130529e-01, 2.3146243e-01, + 2.3161958e-01, 2.3177674e-01, 2.3193389e-01, 2.3209107e-01, + 2.3224823e-01, 2.3240541e-01, 2.3256260e-01, 2.3271978e-01, + 2.3287699e-01, 2.3303418e-01, 2.3319139e-01, 2.3334859e-01, + 2.3350582e-01, 2.3366304e-01, 2.3382027e-01, 2.3397751e-01, + 2.3413475e-01, 2.3429200e-01, 2.3444925e-01, 2.3460650e-01, + 2.3476377e-01, 2.3492104e-01, 2.3507832e-01, 2.3523560e-01, + 2.3539288e-01, 2.3555018e-01, 2.3570748e-01, 2.3586477e-01, + 2.3602208e-01, 2.3617941e-01, 2.3633672e-01, 2.3649406e-01, + 2.3665139e-01, 2.3680873e-01, 2.3696607e-01, 2.3712343e-01, + 2.3728079e-01, 2.3743816e-01, 2.3759551e-01, 2.3775290e-01, + 2.3791027e-01, 2.3806766e-01, 2.3822506e-01, 2.3838246e-01, + 2.3853986e-01, 2.3869728e-01, 2.3885469e-01, 2.3901211e-01, + 2.3916954e-01, 2.3932697e-01, 2.3948441e-01, 2.3964186e-01, + 2.3979931e-01, 2.3995677e-01, 2.4011423e-01, 2.4027170e-01, + 2.4042918e-01, 2.4058667e-01, 2.4074414e-01, 2.4090165e-01, + 2.4105914e-01, 2.4121664e-01, 2.4137416e-01, 2.4153168e-01, + 2.4168921e-01, 2.4184673e-01, 2.4200428e-01, 2.4216181e-01, + 2.4231936e-01, 2.4247691e-01, 2.4263448e-01, 2.4279204e-01, + 2.4294960e-01, 2.4310718e-01, 2.4326476e-01, 2.4342236e-01, + 2.4357995e-01, 2.4373756e-01, 2.4389517e-01, 2.4405278e-01, + 2.4421041e-01, 2.4436803e-01, 2.4452566e-01, 2.4468330e-01, + 2.4484095e-01, 2.4499859e-01, 2.4515624e-01, 2.4531391e-01, + 2.4547158e-01, 2.4562925e-01, 2.4578694e-01, 2.4594462e-01, + 2.4610232e-01, 2.4626002e-01, 2.4641773e-01, 2.4657543e-01, + 2.4673316e-01, 2.4689087e-01, 2.4704860e-01, 2.4720635e-01, + 2.4736409e-01, 2.4752183e-01, 2.4767959e-01, 2.4783735e-01, + 2.4799512e-01, 2.4815290e-01, 2.4831067e-01, 2.4846846e-01, + 2.4862625e-01, 2.4878405e-01, 2.4894185e-01, 2.4909966e-01, + 2.4925748e-01, 2.4941529e-01, 2.4957313e-01, 2.4973096e-01, + 2.4988881e-01, 2.5004664e-01, 2.5020450e-01, 2.5036237e-01, + 2.5052023e-01, 2.5067809e-01, 2.5083598e-01, 2.5099388e-01, + 2.5115177e-01, 2.5130966e-01, 2.5146756e-01, 2.5162548e-01, + 2.5178340e-01, 2.5194132e-01, 2.5209925e-01, 2.5225717e-01, + 2.5241512e-01, 2.5257307e-01, 2.5273103e-01, 2.5288898e-01, + 2.5304696e-01, 2.5320491e-01, 2.5336289e-01, 2.5352088e-01, + 2.5367889e-01, 2.5383687e-01, 2.5399488e-01, 2.5415289e-01, + 2.5431091e-01, 2.5446895e-01, 2.5462696e-01, 2.5478500e-01, + 2.5494304e-01, 2.5510108e-01, 2.5525916e-01, 2.5541720e-01, + 2.5557527e-01, 2.5573334e-01, 2.5589144e-01, 2.5604951e-01, + 2.5620762e-01, 2.5636572e-01, 2.5652382e-01, 2.5668195e-01, + 2.5684005e-01, 2.5699818e-01, 2.5715631e-01, 2.5731444e-01, + 2.5747260e-01, 2.5763074e-01, 2.5778890e-01, 2.5794709e-01, + 2.5810525e-01, 2.5826341e-01, 2.5842160e-01, 2.5857979e-01, + 2.5873798e-01, 2.5889620e-01, 2.5905439e-01, 2.5921261e-01, + 2.5937083e-01, 2.5952908e-01, 2.5968730e-01, 2.5984555e-01, + 2.6000381e-01, 2.6016206e-01, 2.6032031e-01, 2.6047859e-01, + 2.6063687e-01, 2.6079515e-01, 2.6095343e-01, 2.6111174e-01, + 2.6127002e-01, 2.6142833e-01, 2.6158664e-01, 2.6174498e-01, + 2.6190329e-01, 2.6206163e-01, 2.6221997e-01, 2.6237831e-01, + 2.6253667e-01, 2.6269504e-01, 2.6285341e-01, 2.6301178e-01, + 2.6317015e-01, 2.6332855e-01, 2.6348692e-01, 2.6364532e-01, + 2.6380375e-01, 2.6396215e-01, 2.6412058e-01, 2.6427901e-01, + 2.6443744e-01, 2.6459587e-01, 2.6475433e-01, 2.6491278e-01, + 2.6507124e-01, 2.6522970e-01, 2.6538816e-01, 2.6554665e-01, + 2.6570514e-01, 2.6586363e-01, 2.6602212e-01, 2.6618063e-01, + 2.6633915e-01, 2.6649767e-01, 2.6665619e-01, 2.6681474e-01, + 2.6697326e-01, 2.6713181e-01, 2.6729035e-01, 2.6744893e-01, + 2.6760748e-01, 2.6776606e-01, 2.6792464e-01, 2.6808321e-01, + 2.6824182e-01, 2.6840043e-01, 2.6855904e-01, 2.6871765e-01, + 2.6887625e-01, 2.6903489e-01, 2.6919353e-01, 2.6935217e-01, + 2.6951081e-01, 2.6966947e-01, 2.6982814e-01, 2.6998681e-01, + 2.7014548e-01, 2.7030414e-01, 2.7046284e-01, 2.7062154e-01, + 2.7078024e-01, 2.7093893e-01, 2.7109766e-01, 2.7125639e-01, + 2.7141511e-01, 2.7157384e-01, 2.7173260e-01, 2.7189136e-01, + 2.7205011e-01, 2.7220887e-01, 2.7236763e-01, 2.7252641e-01, + 2.7268520e-01, 2.7284399e-01, 2.7300277e-01, 2.7316159e-01, + 2.7332041e-01, 2.7347922e-01, 2.7363804e-01, 2.7379689e-01, + 2.7395570e-01, 2.7411455e-01, 2.7427343e-01, 2.7443227e-01, + 2.7459115e-01, 2.7475002e-01, 2.7490890e-01, 2.7506778e-01, + 2.7522668e-01, 2.7538559e-01, 2.7554449e-01, 2.7570340e-01, + 2.7586234e-01, 2.7602127e-01, 2.7618021e-01, 2.7633914e-01, + 2.7649808e-01, 2.7665704e-01, 2.7681601e-01, 2.7697498e-01, + 2.7713397e-01, 2.7729294e-01, 2.7745193e-01, 2.7761093e-01, + 2.7776995e-01, 2.7792895e-01, 2.7808797e-01, 2.7824700e-01, + 2.7840602e-01, 2.7856508e-01, 2.7872413e-01, 2.7888319e-01, + 2.7904224e-01, 2.7920133e-01, 2.7936038e-01, 2.7951947e-01, + 2.7967858e-01, 2.7983767e-01, 2.7999678e-01, 2.8015590e-01, + 2.8031501e-01, 2.8047413e-01, 2.8063327e-01, 2.8079242e-01, + 2.8095156e-01, 2.8111070e-01, 2.8126988e-01, 2.8142905e-01, + 2.8158823e-01, 2.8174740e-01, 2.8190657e-01, 2.8206578e-01, + 2.8222498e-01, 2.8238422e-01, 2.8254342e-01, 2.8270265e-01, + 2.8286189e-01, 2.8302112e-01, 2.8318036e-01, 2.8333962e-01, + 2.8349888e-01, 2.8365815e-01, 2.8381744e-01, 2.8397670e-01, + 2.8413600e-01, 2.8429532e-01, 2.8445461e-01, 2.8461394e-01, + 2.8477323e-01, 2.8493258e-01, 2.8509191e-01, 2.8525126e-01, + 2.8541058e-01, 2.8556997e-01, 2.8572932e-01, 2.8588867e-01, + 2.8604805e-01, 2.8620744e-01, 2.8636685e-01, 2.8652623e-01, + 2.8668565e-01, 2.8684506e-01, 2.8700447e-01, 2.8716391e-01, + 2.8732336e-01, 2.8748280e-01, 2.8764224e-01, 2.8780171e-01, + 2.8796116e-01, 2.8812063e-01, 2.8828013e-01, 2.8843960e-01, + 2.8859910e-01, 2.8875861e-01, 2.8891811e-01, 2.8907764e-01, + 2.8923714e-01, 2.8939667e-01, 2.8955624e-01, 2.8971577e-01, + 2.8987533e-01, 2.9003489e-01, 2.9019445e-01, 2.9035401e-01, + 2.9051360e-01, 2.9067320e-01, 2.9083279e-01, 2.9099241e-01, + 2.9115203e-01, 2.9131162e-01, 2.9147127e-01, 2.9163089e-01, + 2.9179054e-01, 2.9195020e-01, 2.9210985e-01, 2.9226950e-01, + 2.9242918e-01, 2.9258886e-01, 2.9274854e-01, 2.9290825e-01, + 2.9306796e-01, 2.9322764e-01, 2.9338738e-01, 2.9354709e-01, + 2.9370683e-01, 2.9386657e-01, 2.9402632e-01, 2.9418609e-01, + 2.9434583e-01, 2.9450560e-01, 2.9466537e-01, 2.9482517e-01, + 2.9498497e-01, 2.9514477e-01, 2.9530457e-01, 2.9546437e-01, + 2.9562420e-01, 2.9578403e-01, 2.9594386e-01, 2.9610372e-01, + 2.9626358e-01, 2.9642344e-01, 2.9658329e-01, 2.9674315e-01, + 2.9690304e-01, 2.9706293e-01, 2.9722282e-01, 2.9738274e-01, + 2.9754266e-01, 2.9770258e-01, 2.9786250e-01, 2.9802245e-01, + 2.9818240e-01, 2.9834235e-01, 2.9850230e-01, 2.9866228e-01, + 2.9882222e-01, 2.9898220e-01, 2.9914221e-01, 2.9930219e-01, + 2.9946220e-01, 2.9962221e-01, 2.9978225e-01, 2.9994226e-01, + 3.0010229e-01, 3.0026236e-01, 3.0042240e-01, 3.0058247e-01, + 3.0074254e-01, 3.0090261e-01, 3.0106267e-01, 3.0122277e-01, + 3.0138287e-01, 3.0154297e-01, 3.0170310e-01, 3.0186319e-01, + 3.0202332e-01, 3.0218348e-01, 3.0234361e-01, 3.0250376e-01, + 3.0266392e-01, 3.0282408e-01, 3.0298427e-01, 3.0314445e-01, + 3.0330464e-01, 3.0346483e-01, 3.0362505e-01, 3.0378526e-01, + 3.0394548e-01, 3.0410570e-01, 3.0426595e-01, 3.0442619e-01, + 3.0458644e-01, 3.0474669e-01, 3.0490696e-01, 3.0506724e-01, + 3.0522752e-01, 3.0538782e-01, 3.0554810e-01, 3.0570841e-01, + 3.0586874e-01, 3.0602905e-01, 3.0618939e-01, 3.0634972e-01, + 3.0651006e-01, 3.0667043e-01, 3.0683079e-01, 3.0699116e-01, + 3.0715156e-01, 3.0731192e-01, 3.0747232e-01, 3.0763271e-01, + 3.0779314e-01, 3.0795354e-01, 3.0811396e-01, 3.0827442e-01, + 3.0843484e-01, 3.0859530e-01, 3.0875576e-01, 3.0891621e-01, + 3.0907670e-01, 3.0923718e-01, 3.0939767e-01, 3.0955815e-01, + 3.0971867e-01, 3.0987918e-01, 3.1003970e-01, 3.1020024e-01, + 3.1036076e-01, 3.1052130e-01, 3.1068188e-01, 3.1084242e-01, + 3.1100300e-01, 3.1116357e-01, 3.1132415e-01, 3.1148475e-01, + 3.1164536e-01, 3.1180596e-01, 3.1196660e-01, 3.1212720e-01, + 3.1228784e-01, 3.1244847e-01, 3.1260914e-01, 3.1276980e-01, + 3.1293046e-01, 3.1309113e-01, 3.1325182e-01, 3.1341252e-01, + 3.1357321e-01, 3.1373391e-01, 3.1389463e-01, 3.1405535e-01, + 3.1421608e-01, 3.1437680e-01, 3.1453755e-01, 3.1469831e-01, + 3.1485909e-01, 3.1501985e-01, 3.1518063e-01, 3.1534141e-01, + 3.1550223e-01, 3.1566301e-01, 3.1582382e-01, 3.1598464e-01, + 3.1614548e-01, 3.1630632e-01, 3.1646717e-01, 3.1662801e-01, + 3.1678888e-01, 3.1694973e-01, 3.1711063e-01, 3.1727150e-01, + 3.1743240e-01, 3.1759331e-01, 3.1775421e-01, 3.1791514e-01, + 3.1807604e-01, 3.1823698e-01, 3.1839794e-01, 3.1855887e-01, + 3.1871983e-01, 3.1888083e-01, 3.1904179e-01, 3.1920278e-01, + 3.1936377e-01, 3.1952477e-01, 3.1968579e-01, 3.1984678e-01, + 3.2000783e-01, 3.2016885e-01, 3.2032990e-01, 3.2049096e-01, + 3.2065201e-01, 3.2081306e-01, 3.2097414e-01, 3.2113522e-01, + 3.2129633e-01, 3.2145742e-01, 3.2161853e-01, 3.2177964e-01, + 3.2194078e-01, 3.2210192e-01, 3.2226306e-01, 3.2242420e-01, + 3.2258537e-01, 3.2274655e-01, 3.2290772e-01, 3.2306889e-01, + 3.2323009e-01, 3.2339129e-01, 3.2355249e-01, 3.2371372e-01, + 3.2387495e-01, 3.2403618e-01, 3.2419741e-01, 3.2435867e-01, + 3.2451993e-01, 3.2468119e-01, 3.2484248e-01, 3.2500377e-01, + 3.2516506e-01, 3.2532635e-01, 3.2548767e-01, 3.2564899e-01, + 3.2581031e-01, 3.2597166e-01, 3.2613301e-01, 3.2629436e-01, + 3.2645571e-01, 3.2661709e-01, 3.2677847e-01, 3.2693985e-01, + 3.2710126e-01, 3.2726264e-01, 3.2742405e-01, 3.2758549e-01, + 3.2774693e-01, 3.2790837e-01, 3.2806981e-01, 3.2823125e-01, + 3.2839271e-01, 3.2855418e-01, 3.2871568e-01, 3.2887715e-01, + 3.2903865e-01, 3.2920018e-01, 3.2936168e-01, 3.2952321e-01, + 3.2968473e-01, 3.2984629e-01, 3.3000782e-01, 3.3016938e-01, + 3.3033097e-01, 3.3049253e-01, 3.3065411e-01, 3.3081570e-01, + 3.3097732e-01, 3.3113891e-01, 3.3130056e-01, 3.3146217e-01, + 3.3162379e-01, 3.3178544e-01, 3.3194712e-01, 3.3210877e-01, + 3.3227044e-01, 3.3243212e-01, 3.3259380e-01, 3.3275551e-01, + 3.3291721e-01, 3.3307892e-01, 3.3324066e-01, 3.3340237e-01, + 3.3356413e-01, 3.3372587e-01, 3.3388764e-01, 3.3404940e-01, + 3.3421117e-01, 3.3437297e-01, 3.3453473e-01, 3.3469656e-01, + 3.3485836e-01, 3.3502018e-01, 3.3518201e-01, 3.3534384e-01, + 3.3550569e-01, 3.3566755e-01, 3.3582941e-01, 3.3599129e-01, + 3.3615315e-01, 3.3631504e-01, 3.3647695e-01, 3.3663887e-01, + 3.3680078e-01, 3.3696270e-01, 3.3712465e-01, 3.3728656e-01, + 3.3744854e-01, 3.3761048e-01, 3.3777246e-01, 3.3793443e-01, + 3.3809641e-01, 3.3825842e-01, 3.3842042e-01, 3.3858243e-01, + 3.3874446e-01, 3.3890650e-01, 3.3906853e-01, 3.3923057e-01, + 3.3939263e-01, 3.3955470e-01, 3.3971679e-01, 3.3987886e-01, + 3.4004095e-01, 3.4020305e-01, 3.4036517e-01, 3.4052730e-01, + 3.4068942e-01, 3.4085155e-01, 3.4101370e-01, 3.4117585e-01, + 3.4133804e-01, 3.4150019e-01, 3.4166238e-01, 3.4182459e-01, + 3.4198678e-01, 3.4214899e-01, 3.4231120e-01, 3.4247345e-01, + 3.4263566e-01, 3.4279794e-01, 3.4296018e-01, 3.4312245e-01, + 3.4328473e-01, 3.4344700e-01, 3.4360930e-01, 3.4377158e-01, + 3.4393391e-01, 3.4409621e-01, 3.4425855e-01, 3.4442088e-01, + 3.4458324e-01, 3.4474558e-01, 3.4490794e-01, 3.4507033e-01, + 3.4523270e-01, 3.4539509e-01, 3.4555748e-01, 3.4571990e-01, + 3.4588233e-01, 3.4604475e-01, 3.4620720e-01, 3.4636962e-01, + 3.4653208e-01, 3.4669456e-01, 3.4685704e-01, 3.4701952e-01, + 3.4718201e-01, 3.4734452e-01, 3.4750700e-01, 3.4766954e-01, + 3.4783205e-01, 3.4799460e-01, 3.4815714e-01, 3.4831971e-01, + 3.4848228e-01, 3.4864485e-01, 3.4880742e-01, 3.4897003e-01, + 3.4913263e-01, 3.4929523e-01, 3.4945786e-01, 3.4962049e-01, + 3.4978312e-01, 3.4994578e-01, 3.5010841e-01, 3.5027111e-01, + 3.5043377e-01, 3.5059646e-01, 3.5075915e-01, 3.5092187e-01, + 3.5108456e-01, 3.5124728e-01, 3.5141003e-01, 3.5157275e-01, + 3.5173550e-01, 3.5189828e-01, 3.5206103e-01, 3.5222381e-01, + 3.5238662e-01, 3.5254940e-01, 3.5271221e-01, 3.5287502e-01, + 3.5303786e-01, 3.5320070e-01, 3.5336354e-01, 3.5352638e-01, + 3.5368925e-01, 3.5385212e-01, 3.5401499e-01, 3.5417789e-01, + 3.5434079e-01, 3.5450372e-01, 3.5466662e-01, 3.5482955e-01, + 3.5499248e-01, 3.5515544e-01, 3.5531840e-01, 3.5548136e-01, + 3.5564435e-01, 3.5580733e-01, 3.5597032e-01, 3.5613331e-01, + 3.5629633e-01, 3.5645935e-01, 3.5662240e-01, 3.5678545e-01, + 3.5694849e-01, 3.5711154e-01, 3.5727462e-01, 3.5743770e-01, + 3.5760078e-01, 3.5776389e-01, 3.5792699e-01, 3.5809010e-01, + 3.5825324e-01, 3.5841638e-01, 3.5857952e-01, 3.5874268e-01, + 3.5890585e-01, 3.5906902e-01, 3.5923222e-01, 3.5939538e-01, + 3.5955861e-01, 3.5972181e-01, 3.5988504e-01, 3.6004826e-01, + 3.6021152e-01, 3.6037478e-01, 3.6053804e-01, 3.6070129e-01, + 3.6086458e-01, 3.6102787e-01, 3.6119115e-01, 3.6135447e-01, + 3.6151779e-01, 3.6168113e-01, 3.6184445e-01, 3.6200783e-01, + 3.6217117e-01, 3.6233455e-01, 3.6249793e-01, 3.6266130e-01, + 3.6282471e-01, 3.6298811e-01, 3.6315152e-01, 3.6331496e-01, + 3.6347839e-01, 3.6364183e-01, 3.6380529e-01, 3.6396876e-01, + 3.6413223e-01, 3.6429569e-01, 3.6445919e-01, 3.6462271e-01, + 3.6478621e-01, 3.6494973e-01, 3.6511326e-01, 3.6527681e-01, + 3.6544037e-01, 3.6560392e-01, 3.6576751e-01, 3.6593106e-01, + 3.6609468e-01, 3.6625826e-01, 3.6642188e-01, 3.6658549e-01, + 3.6674914e-01, 3.6691278e-01, 3.6707643e-01, 3.6724007e-01, + 3.6740375e-01, 3.6756742e-01, 3.6773112e-01, 3.6789483e-01, + 3.6805853e-01, 3.6822224e-01, 3.6838597e-01, 3.6854970e-01, + 3.6871347e-01, 3.6887723e-01, 3.6904100e-01, 3.6920476e-01, + 3.6936855e-01, 3.6953235e-01, 3.6969617e-01, 3.6985999e-01, + 3.7002382e-01, 3.7018764e-01, 3.7035149e-01, 3.7051535e-01, + 3.7067923e-01, 3.7084311e-01, 3.7100700e-01, 3.7117088e-01, + 3.7133479e-01, 3.7149870e-01, 3.7166265e-01, 3.7182659e-01, + 3.7199053e-01, 3.7215447e-01, 3.7231845e-01, 3.7248242e-01, + 3.7264642e-01, 3.7281042e-01, 3.7297443e-01, 3.7313843e-01, + 3.7330246e-01, 3.7346649e-01, 3.7363055e-01, 3.7379462e-01, + 3.7395868e-01, 3.7412277e-01, 3.7428683e-01, 3.7445095e-01, + 3.7461504e-01, 3.7477916e-01, 3.7494329e-01, 3.7510744e-01, + 3.7527159e-01, 3.7543574e-01, 3.7559992e-01, 3.7576410e-01, + 3.7592828e-01, 3.7609249e-01, 3.7625667e-01, 3.7642092e-01, + 3.7658513e-01, 3.7674937e-01, 3.7691364e-01, 3.7707788e-01, + 3.7724215e-01, 3.7740645e-01, 3.7757072e-01, 3.7773502e-01, + 3.7789935e-01, 3.7806365e-01, 3.7822798e-01, 3.7839234e-01, + 3.7855670e-01, 3.7872106e-01, 3.7888542e-01, 3.7904981e-01, + 3.7921420e-01, 3.7937859e-01, 3.7954301e-01, 3.7970743e-01, + 3.7987188e-01, 3.8003632e-01, 3.8020077e-01, 3.8036522e-01, + 3.8052970e-01, 3.8069418e-01, 3.8085869e-01, 3.8102320e-01, + 3.8118771e-01, 3.8135225e-01, 3.8151678e-01, 3.8168132e-01, + 3.8184589e-01, 3.8201046e-01, 3.8217503e-01, 3.8233963e-01, + 3.8250422e-01, 3.8266882e-01, 3.8283345e-01, 3.8299808e-01, + 3.8316271e-01, 3.8332736e-01, 3.8349202e-01, 3.8365671e-01, + 3.8382137e-01, 3.8398609e-01, 3.8415077e-01, 3.8431549e-01, + 3.8448021e-01, 3.8464496e-01, 3.8480970e-01, 3.8497445e-01, + 3.8513920e-01, 3.8530397e-01, 3.8546878e-01, 3.8563356e-01, + 3.8579836e-01, 3.8596320e-01, 3.8612801e-01, 3.8629287e-01, + 3.8645771e-01, 3.8662258e-01, 3.8678744e-01, 3.8695231e-01, + 3.8711721e-01, 3.8728210e-01, 3.8744703e-01, 3.8761196e-01, + 3.8777688e-01, 3.8794184e-01, 3.8810679e-01, 3.8827175e-01, + 3.8843673e-01, 3.8860172e-01, 3.8876671e-01, 3.8893172e-01, + 3.8909674e-01, 3.8926175e-01, 3.8942680e-01, 3.8959184e-01, + 3.8975692e-01, 3.8992199e-01, 3.9008707e-01, 3.9025214e-01, + 3.9041725e-01, 3.9058238e-01, 3.9074749e-01, 3.9091262e-01, + 3.9107779e-01, 3.9124292e-01, 3.9140809e-01, 3.9157328e-01, + 3.9173847e-01, 3.9190367e-01, 3.9206886e-01, 3.9223409e-01, + 3.9239931e-01, 3.9256456e-01, 3.9272982e-01, 3.9289507e-01, + 3.9306036e-01, 3.9322564e-01, 3.9339092e-01, 3.9355624e-01, + 3.9372155e-01, 3.9388689e-01, 3.9405224e-01, 3.9421758e-01, + 3.9438292e-01, 3.9454830e-01, 3.9471370e-01, 3.9487907e-01, + 3.9504448e-01, 3.9520991e-01, 3.9537531e-01, 3.9554074e-01, + 3.9570621e-01, 3.9587167e-01, 3.9603713e-01, 3.9620259e-01, + 3.9636809e-01, 3.9653361e-01, 3.9669910e-01, 3.9686462e-01, + 3.9703017e-01, 3.9719570e-01, 3.9736128e-01, 3.9752683e-01, + 3.9769241e-01, 3.9785799e-01, 3.9802361e-01, 3.9818922e-01, + 3.9835483e-01, 3.9852047e-01, 3.9868611e-01, 3.9885175e-01, + 3.9901742e-01, 3.9918309e-01, 3.9934877e-01, 3.9951447e-01, + 3.9968017e-01, 3.9984590e-01, 4.0001163e-01, 4.0017736e-01, + 4.0034312e-01, 4.0050888e-01, 4.0067467e-01, 4.0084043e-01, + 4.0100625e-01, 4.0117204e-01, 4.0133786e-01, 4.0150368e-01, + 4.0166953e-01, 4.0183538e-01, 4.0200126e-01, 4.0216711e-01, + 4.0233302e-01, 4.0249890e-01, 4.0266481e-01, 4.0283072e-01, + 4.0299666e-01, 4.0316260e-01, 4.0332854e-01, 4.0349451e-01, + 4.0366048e-01, 4.0382648e-01, 4.0399247e-01, 4.0415847e-01, + 4.0432447e-01, 4.0449050e-01, 4.0465656e-01, 4.0482262e-01, + 4.0498868e-01, 4.0515473e-01, 4.0532082e-01, 4.0548691e-01, + 4.0565303e-01, 4.0581915e-01, 4.0598527e-01, 4.0615141e-01, + 4.0631756e-01, 4.0648374e-01, 4.0664992e-01, 4.0681610e-01, + 4.0698227e-01, 4.0714851e-01, 4.0731472e-01, 4.0748096e-01, + 4.0764719e-01, 4.0781343e-01, 4.0797970e-01, 4.0814599e-01, + 4.0831226e-01, 4.0847856e-01, 4.0864488e-01, 4.0881118e-01, + 4.0897754e-01, 4.0914387e-01, 4.0931022e-01, 4.0947658e-01, + 4.0964296e-01, 4.0980935e-01, 4.0997577e-01, 4.1014215e-01, + 4.1030860e-01, 4.1047502e-01, 4.1064146e-01, 4.1080794e-01, + 4.1097438e-01, 4.1114089e-01, 4.1130736e-01, 4.1147387e-01, + 4.1164038e-01, 4.1180691e-01, 4.1197345e-01, 4.1213998e-01, + 4.1230655e-01, 4.1247311e-01, 4.1263971e-01, 4.1280630e-01, + 4.1297290e-01, 4.1313952e-01, 4.1330615e-01, 4.1347280e-01, + 4.1363943e-01, 4.1380611e-01, 4.1397277e-01, 4.1413945e-01, + 4.1430616e-01, 4.1447288e-01, 4.1463959e-01, 4.1480631e-01, + 4.1497305e-01, 4.1513982e-01, 4.1530660e-01, 4.1547337e-01, + 4.1564015e-01, 4.1580695e-01, 4.1597375e-01, 4.1614059e-01, + 4.1630742e-01, 4.1647428e-01, 4.1664115e-01, 4.1680801e-01, + 4.1697487e-01, 4.1714177e-01, 4.1730869e-01, 4.1747561e-01, + 4.1764253e-01, 4.1780946e-01, 4.1797641e-01, 4.1814339e-01, + 4.1831037e-01, 4.1847736e-01, 4.1864434e-01, 4.1881135e-01, + 4.1897836e-01, 4.1914541e-01, 4.1931245e-01, 4.1947952e-01, + 4.1964659e-01, 4.1981366e-01, 4.1998076e-01, 4.2014787e-01, + 4.2031497e-01, 4.2048210e-01, 4.2064923e-01, 4.2081639e-01, + 4.2098355e-01, 4.2115071e-01, 4.2131791e-01, 4.2148513e-01, + 4.2165232e-01, 4.2181954e-01, 4.2198679e-01, 4.2215401e-01, + 4.2232129e-01, 4.2248854e-01, 4.2265582e-01, 4.2282313e-01, + 4.2299041e-01, 4.2315775e-01, 4.2332506e-01, 4.2349240e-01, + 4.2365977e-01, 4.2382711e-01, 4.2399451e-01, 4.2416188e-01, + 4.2432928e-01, 4.2449671e-01, 4.2466411e-01, 4.2483154e-01, + 4.2499900e-01, 4.2516646e-01, 4.2533392e-01, 4.2550141e-01, + 4.2566890e-01, 4.2583641e-01, 4.2600393e-01, 4.2617145e-01, + 4.2633900e-01, 4.2650655e-01, 4.2667413e-01, 4.2684171e-01, + 4.2700928e-01, 4.2717689e-01, 4.2734450e-01, 4.2751214e-01, + 4.2767978e-01, 4.2784742e-01, 4.2801508e-01, 4.2818275e-01, + 4.2835045e-01, 4.2851815e-01, 4.2868584e-01, 4.2885357e-01, + 4.2902130e-01, 4.2918906e-01, 4.2935681e-01, 4.2952460e-01, + 4.2969236e-01, 4.2986017e-01, 4.3002796e-01, 4.3019578e-01, + 4.3036363e-01, 4.3053147e-01, 4.3069932e-01, 4.3086720e-01, + 4.3103507e-01, 4.3120295e-01, 4.3137085e-01, 4.3153879e-01, + 4.3170670e-01, 4.3187466e-01, 4.3204260e-01, 4.3221056e-01, + 4.3237853e-01, 4.3254653e-01, 4.3271452e-01, 4.3288255e-01, + 4.3305057e-01, 4.3321860e-01, 4.3338665e-01, 4.3355474e-01, + 4.3372279e-01, 4.3389088e-01, 4.3405899e-01, 4.3422711e-01, + 4.3439522e-01, 4.3456337e-01, 4.3473151e-01, 4.3489966e-01, + 4.3506783e-01, 4.3523604e-01, 4.3540421e-01, 4.3557245e-01, + 4.3574065e-01, 4.3590888e-01, 4.3607715e-01, 4.3624541e-01, + 4.3641368e-01, 4.3658197e-01, 4.3675026e-01, 4.3691856e-01, + 4.3708688e-01, 4.3725520e-01, 4.3742356e-01, 4.3759191e-01, + 4.3776029e-01, 4.3792868e-01, 4.3809706e-01, 4.3826547e-01, + 4.3843389e-01, 4.3860233e-01, 4.3877077e-01, 4.3893924e-01, + 4.3910772e-01, 4.3927619e-01, 4.3944469e-01, 4.3961319e-01, + 4.3978170e-01, 4.3995023e-01, 4.4011879e-01, 4.4028735e-01, + 4.4045591e-01, 4.4062451e-01, 4.4079310e-01, 4.4096169e-01, + 4.4113031e-01, 4.4129896e-01, 4.4146761e-01, 4.4163626e-01, + 4.4180492e-01, 4.4197360e-01, 4.4214231e-01, 4.4231102e-01, + 4.4247973e-01, 4.4264847e-01, 4.4281721e-01, 4.4298598e-01, + 4.4315475e-01, 4.4332352e-01, 4.4349232e-01, 4.4366112e-01, + 4.4382995e-01, 4.4399878e-01, 4.4416764e-01, 4.4433650e-01, + 4.4450536e-01, 4.4467425e-01, 4.4484314e-01, 4.4501206e-01, + 4.4518098e-01, 4.4534993e-01, 4.4551888e-01, 4.4568783e-01, + 4.4585681e-01, 4.4602579e-01, 4.4619480e-01, 4.4636381e-01, + 4.4653282e-01, 4.4670185e-01, 4.4687092e-01, 4.4703999e-01, + 4.4720906e-01, 4.4737816e-01, 4.4754726e-01, 4.4771636e-01, + 4.4788548e-01, 4.4805464e-01, 4.4822377e-01, 4.4839296e-01, + 4.4856212e-01, 4.4873130e-01, 4.4890052e-01, 4.4906974e-01, + 4.4923896e-01, 4.4940820e-01, 4.4957748e-01, 4.4974673e-01, + 4.4991601e-01, 4.5008531e-01, 4.5025462e-01, 4.5042393e-01, + 4.5059326e-01, 4.5076263e-01, 4.5093197e-01, 4.5110136e-01, + 4.5127073e-01, 4.5144013e-01, 4.5160955e-01, 4.5177898e-01, + 4.5194840e-01, 4.5211786e-01, 4.5228732e-01, 4.5245680e-01, + 4.5262629e-01, 4.5279577e-01, 4.5296529e-01, 4.5313483e-01, + 4.5330435e-01, 4.5347393e-01, 4.5364347e-01, 4.5381308e-01, + 4.5398265e-01, 4.5415226e-01, 4.5432189e-01, 4.5449153e-01, + 4.5466116e-01, 4.5483083e-01, 4.5500049e-01, 4.5517018e-01, + 4.5533988e-01, 4.5550957e-01, 4.5567930e-01, 4.5584905e-01, + 4.5601878e-01, 4.5618856e-01, 4.5635834e-01, 4.5652813e-01, + 4.5669791e-01, 4.5686772e-01, 4.5703757e-01, 4.5720741e-01, + 4.5737725e-01, 4.5754713e-01, 4.5771700e-01, 4.5788690e-01, + 4.5805681e-01, 4.5822674e-01, 4.5839667e-01, 4.5856661e-01, + 4.5873657e-01, 4.5890656e-01, 4.5907655e-01, 4.5924655e-01, + 4.5941657e-01, 4.5958659e-01, 4.5975661e-01, 4.5992669e-01, + 4.6009675e-01, 4.6026683e-01, 4.6043691e-01, 4.6060702e-01, + 4.6077716e-01, 4.6094728e-01, 4.6111742e-01, 4.6128759e-01, + 4.6145776e-01, 4.6162796e-01, 4.6179816e-01, 4.6196836e-01, + 4.6213859e-01, 4.6230882e-01, 4.6247908e-01, 4.6264935e-01, + 4.6281964e-01, 4.6298993e-01, 4.6316025e-01, 4.6333057e-01, + 4.6350089e-01, 4.6367124e-01, 4.6384162e-01, 4.6401197e-01, + 4.6418238e-01, 4.6435279e-01, 4.6452320e-01, 4.6469361e-01, + 4.6486405e-01, 4.6503451e-01, 4.6520498e-01, 4.6537545e-01, + 4.6554595e-01, 4.6571648e-01, 4.6588701e-01, 4.6605754e-01, + 4.6622810e-01, 4.6639866e-01, 4.6656922e-01, 4.6673983e-01, + 4.6691042e-01, 4.6708104e-01, 4.6725169e-01, 4.6742234e-01, + 4.6759298e-01, 4.6776366e-01, 4.6793434e-01, 4.6810505e-01, + 4.6827576e-01, 4.6844649e-01, 4.6861723e-01, 4.6878797e-01, + 4.6895874e-01, 4.6912953e-01, 4.6930033e-01, 4.6947113e-01, + 4.6964195e-01, 4.6981281e-01, 4.6998364e-01, 4.7015452e-01, + 4.7032538e-01, 4.7049630e-01, 4.7066718e-01, 4.7083810e-01, + 4.7100905e-01, 4.7117999e-01, 4.7135094e-01, 4.7152191e-01, + 4.7169292e-01, 4.7186393e-01, 4.7203493e-01, 4.7220597e-01, + 4.7237700e-01, 4.7254807e-01, 4.7271913e-01, 4.7289023e-01, + 4.7306132e-01, 4.7323242e-01, 4.7340354e-01, 4.7357470e-01, + 4.7374585e-01, 4.7391701e-01, 4.7408819e-01, 4.7425941e-01, + 4.7443059e-01, 4.7460184e-01, 4.7477308e-01, 4.7494432e-01, + 4.7511560e-01, 4.7528687e-01, 4.7545815e-01, 4.7562948e-01, + 4.7580078e-01, 4.7597212e-01, 4.7614348e-01, 4.7631484e-01, + 4.7648621e-01, 4.7665760e-01, 4.7682902e-01, 4.7700042e-01, + 4.7717187e-01, 4.7734332e-01, 4.7751477e-01, 4.7768626e-01, + 4.7785774e-01, 4.7802925e-01, 4.7820076e-01, 4.7837228e-01, + 4.7854382e-01, 4.7871539e-01, 4.7888696e-01, 4.7905856e-01, + 4.7923017e-01, 4.7940177e-01, 4.7957340e-01, 4.7974506e-01, + 4.7991669e-01, 4.8008838e-01, 4.8026007e-01, 4.8043177e-01, + 4.8060349e-01, 4.8077521e-01, 4.8094696e-01, 4.8111871e-01, + 4.8129049e-01, 4.8146227e-01, 4.8163408e-01, 4.8180589e-01, + 4.8197770e-01, 4.8214954e-01, 4.8232141e-01, 4.8249328e-01, + 4.8266518e-01, 4.8283708e-01, 4.8300898e-01, 4.8318091e-01, + 4.8335287e-01, 4.8352480e-01, 4.8369679e-01, 4.8386878e-01, + 4.8404077e-01, 4.8421279e-01, 4.8438480e-01, 4.8455685e-01, + 4.8472890e-01, 4.8490098e-01, 4.8507306e-01, 4.8524517e-01, + 4.8541728e-01, 4.8558941e-01, 4.8576155e-01, 4.8593372e-01, + 4.8610589e-01, 4.8627809e-01, 4.8645028e-01, 4.8662248e-01, + 4.8679471e-01, 4.8696697e-01, 4.8713923e-01, 4.8731151e-01, + 4.8748380e-01, 4.8765609e-01, 4.8782840e-01, 4.8800075e-01, + 4.8817310e-01, 4.8834544e-01, 4.8851782e-01, 4.8869020e-01, + 4.8886260e-01, 4.8903504e-01, 4.8920748e-01, 4.8937991e-01, + 4.8955238e-01, 4.8972484e-01, 4.8989734e-01, 4.9006984e-01, + 4.9024236e-01, 4.9041489e-01, 4.9058744e-01, 4.9076003e-01, + 4.9093258e-01, 4.9110520e-01, 4.9127778e-01, 4.9145043e-01, + 4.9162304e-01, 4.9179572e-01, 4.9196836e-01, 4.9214107e-01, + 4.9231374e-01, 4.9248648e-01, 4.9265918e-01, 4.9283192e-01, + 4.9300468e-01, 4.9317744e-01, 4.9335024e-01, 4.9352303e-01, + 4.9369586e-01, 4.9386868e-01, 4.9404153e-01, 4.9421439e-01, + 4.9438724e-01, 4.9456015e-01, 4.9473304e-01, 4.9490595e-01, + 4.9507889e-01, 4.9525183e-01, 4.9542481e-01, 4.9559778e-01, + 4.9577075e-01, 4.9594378e-01, 4.9611679e-01, 4.9628982e-01, + 4.9646288e-01, 4.9663594e-01, 4.9680904e-01, 4.9698213e-01, + 4.9715522e-01, 4.9732834e-01, 4.9750149e-01, 4.9767464e-01, + 4.9784783e-01, 4.9802101e-01, 4.9819419e-01, 4.9836743e-01, + 4.9854064e-01, 4.9871388e-01, 4.9888715e-01, 4.9906042e-01, + 4.9923372e-01, 4.9940702e-01, 4.9958032e-01, 4.9975368e-01, + 4.9992701e-01, 5.0010037e-01, 5.0027376e-01, 5.0044715e-01, + 5.0062054e-01, 5.0079399e-01, 5.0096744e-01, 5.0114089e-01, + 5.0131434e-01, 5.0148785e-01, 5.0166136e-01, 5.0183487e-01, + 5.0200838e-01, 5.0218195e-01, 5.0235552e-01, 5.0252908e-01, + 5.0270265e-01, 5.0287628e-01, 5.0304991e-01, 5.0322354e-01, + 5.0339717e-01, 5.0357085e-01, 5.0374454e-01, 5.0391823e-01, + 5.0409192e-01, 5.0426567e-01, 5.0443941e-01, 5.0461316e-01, + 5.0478691e-01, 5.0496072e-01, 5.0513452e-01, 5.0530833e-01, + 5.0548220e-01, 5.0565600e-01, 5.0582987e-01, 5.0600374e-01, + 5.0617766e-01, 5.0635159e-01, 5.0652552e-01, 5.0669944e-01, + 5.0687337e-01, 5.0704736e-01, 5.0722134e-01, 5.0739533e-01, + 5.0756937e-01, 5.0774342e-01, 5.0791746e-01, 5.0809151e-01, + 5.0826561e-01, 5.0843972e-01, 5.0861382e-01, 5.0878793e-01, + 5.0896209e-01, 5.0913620e-01, 5.0931042e-01, 5.0948459e-01, + 5.0965881e-01, 5.0983304e-01, 5.1000726e-01, 5.1018149e-01, + 5.1035577e-01, 5.1053005e-01, 5.1070434e-01, 5.1087862e-01, + 5.1105297e-01, 5.1122731e-01, 5.1140165e-01, 5.1157606e-01, + 5.1175046e-01, 5.1192486e-01, 5.1209927e-01, 5.1227367e-01, + 5.1244813e-01, 5.1262259e-01, 5.1279712e-01, 5.1297158e-01, + 5.1314610e-01, 5.1332062e-01, 5.1349521e-01, 5.1366973e-01, + 5.1384431e-01, 5.1401889e-01, 5.1419353e-01, 5.1436812e-01, + 5.1454276e-01, 5.1471746e-01, 5.1489210e-01, 5.1506680e-01, + 5.1524150e-01, 5.1541620e-01, 5.1559097e-01, 5.1576567e-01, + 5.1594043e-01, 5.1611525e-01, 5.1629001e-01, 5.1646483e-01, + 5.1663965e-01, 5.1681453e-01, 5.1698935e-01, 5.1716423e-01, + 5.1733917e-01, 5.1751405e-01, 5.1768899e-01, 5.1786393e-01, + 5.1803887e-01, 5.1821381e-01, 5.1838881e-01, 5.1856381e-01, + 5.1873887e-01, 5.1891387e-01, 5.1908892e-01, 5.1926398e-01, + 5.1943904e-01, 5.1961416e-01, 5.1978928e-01, 5.1996440e-01, + 5.2013958e-01, 5.2031469e-01, 5.2048987e-01, 5.2066511e-01, + 5.2084029e-01, 5.2101552e-01, 5.2119076e-01, 5.2136600e-01, + 5.2154130e-01, 5.2171659e-01, 5.2189189e-01, 5.2206719e-01, + 5.2224255e-01, 5.2241790e-01, 5.2259326e-01, 5.2276868e-01, + 5.2294403e-01, 5.2311945e-01, 5.2329493e-01, 5.2347034e-01, + 5.2364582e-01, 5.2382129e-01, 5.2399683e-01, 5.2417231e-01, + 5.2434784e-01, 5.2452338e-01, 5.2469897e-01, 5.2487451e-01, + 5.2505010e-01, 5.2522576e-01, 5.2540135e-01, 5.2557701e-01, + 5.2575266e-01, 5.2592838e-01, 5.2610403e-01, 5.2627975e-01, + 5.2645546e-01, 5.2663124e-01, 5.2680695e-01, 5.2698272e-01, + 5.2715856e-01, 5.2733433e-01, 5.2751017e-01, 5.2768600e-01, + 5.2786183e-01, 5.2803773e-01, 5.2821362e-01, 5.2838951e-01, + 5.2856547e-01, 5.2874136e-01, 5.2891731e-01, 5.2909333e-01, + 5.2926928e-01, 5.2944529e-01, 5.2962130e-01, 5.2979738e-01, + 5.2997339e-01, 5.3014946e-01, 5.3032553e-01, 5.3050166e-01, + 5.3067780e-01, 5.3085393e-01, 5.3103006e-01, 5.3120625e-01, + 5.3138238e-01, 5.3155863e-01, 5.3173482e-01, 5.3191108e-01, + 5.3208733e-01, 5.3226358e-01, 5.3243983e-01, 5.3261614e-01, + 5.3279245e-01, 5.3296882e-01, 5.3314513e-01, 5.3332150e-01, + 5.3349787e-01, 5.3367430e-01, 5.3385073e-01, 5.3402716e-01, + 5.3420359e-01, 5.3438008e-01, 5.3455651e-01, 5.3473306e-01, + 5.3490955e-01, 5.3508610e-01, 5.3526264e-01, 5.3543919e-01, + 5.3561580e-01, 5.3579235e-01, 5.3596902e-01, 5.3614563e-01, + 5.3632230e-01, 5.3649896e-01, 5.3667563e-01, 5.3685230e-01, + 5.3702903e-01, 5.3720576e-01, 5.3738254e-01, 5.3755927e-01, + 5.3773606e-01, 5.3791285e-01, 5.3808969e-01, 5.3826654e-01, + 5.3844339e-01, 5.3862023e-01, 5.3879714e-01, 5.3897399e-01, + 5.3915095e-01, 5.3932786e-01, 5.3950483e-01, 5.3968179e-01, + 5.3985876e-01, 5.4003578e-01, 5.4021281e-01, 5.4038984e-01, + 5.4056686e-01, 5.4074395e-01, 5.4092103e-01, 5.4109812e-01, + 5.4127526e-01, 5.4145241e-01, 5.4162955e-01, 5.4180670e-01, + 5.4198390e-01, 5.4216111e-01, 5.4233831e-01, 5.4251558e-01, + 5.4269284e-01, 5.4287010e-01, 5.4304737e-01, 5.4322469e-01, + 5.4340202e-01, 5.4357940e-01, 5.4375672e-01, 5.4393411e-01, + 5.4411149e-01, 5.4428893e-01, 5.4446632e-01, 5.4464376e-01, + 5.4482126e-01, 5.4499871e-01, 5.4517621e-01, 5.4535371e-01, + 5.4553127e-01, 5.4570884e-01, 5.4588640e-01, 5.4606396e-01, + 5.4624158e-01, 5.4641914e-01, 5.4659683e-01, 5.4677445e-01, + 5.4695213e-01, 5.4712981e-01, 5.4730749e-01, 5.4748523e-01, + 5.4766297e-01, 5.4784071e-01, 5.4801852e-01, 5.4819632e-01, + 5.4837412e-01, 5.4855192e-01, 5.4872978e-01, 5.4890764e-01, + 5.4908550e-01, 5.4926342e-01, 5.4944128e-01, 5.4961920e-01, + 5.4979718e-01, 5.4997516e-01, 5.5015314e-01, 5.5033112e-01, + 5.5050915e-01, 5.5068713e-01, 5.5086523e-01, 5.5104327e-01, + 5.5122137e-01, 5.5139947e-01, 5.5157757e-01, 5.5175573e-01, + 5.5193388e-01, 5.5211204e-01, 5.5229026e-01, 5.5246848e-01, + 5.5264670e-01, 5.5282491e-01, 5.5300319e-01, 5.5318147e-01, + 5.5335975e-01, 5.5353808e-01, 5.5371642e-01, 5.5389476e-01, + 5.5407310e-01, 5.5425149e-01, 5.5442989e-01, 5.5460835e-01, + 5.5478674e-01, 5.5496520e-01, 5.5514365e-01, 5.5532217e-01, + 5.5550069e-01, 5.5567920e-01, 5.5585772e-01, 5.5603629e-01, + 5.5621487e-01, 5.5639350e-01, 5.5657208e-01, 5.5675071e-01, + 5.5692935e-01, 5.5710804e-01, 5.5728674e-01, 5.5746543e-01, + 5.5764413e-01, 5.5782288e-01, 5.5800164e-01, 5.5818039e-01, + 5.5835921e-01, 5.5853802e-01, 5.5871683e-01, 5.5889571e-01, + 5.5907458e-01, 5.5925345e-01, 5.5943233e-01, 5.5961126e-01, + 5.5979019e-01, 5.5996913e-01, 5.6014812e-01, 5.6032711e-01, + 5.6050611e-01, 5.6068510e-01, 5.6086415e-01, 5.6104320e-01, + 5.6122231e-01, 5.6140143e-01, 5.6158054e-01, 5.6175965e-01, + 5.6193882e-01, 5.6211799e-01, 5.6229717e-01, 5.6247634e-01, + 5.6265557e-01, 5.6283480e-01, 5.6301409e-01, 5.6319338e-01, + 5.6337267e-01, 5.6355196e-01, 5.6373131e-01, 5.6391066e-01, + 5.6409001e-01, 5.6426942e-01, 5.6444883e-01, 5.6462824e-01, + 5.6480765e-01, 5.6498712e-01, 5.6516659e-01, 5.6534612e-01, + 5.6552559e-01, 5.6570512e-01, 5.6588471e-01, 5.6606424e-01, + 5.6624383e-01, 5.6642348e-01, 5.6660306e-01, 5.6678271e-01, + 5.6696236e-01, 5.6714207e-01, 5.6732172e-01, 5.6750149e-01, + 5.6768119e-01, 5.6786096e-01, 5.6804073e-01, 5.6822050e-01, + 5.6840032e-01, 5.6858015e-01, 5.6875998e-01, 5.6893981e-01, + 5.6911969e-01, 5.6929958e-01, 5.6947953e-01, 5.6965947e-01, + 5.6983942e-01, 5.7001936e-01, 5.7019937e-01, 5.7037938e-01, + 5.7055938e-01, 5.7073945e-01, 5.7091951e-01, 5.7109958e-01, + 5.7127970e-01, 5.7145983e-01, 5.7163996e-01, 5.7182014e-01, + 5.7200027e-01, 5.7218051e-01, 5.7236069e-01, 5.7254094e-01, + 5.7272118e-01, 5.7290143e-01, 5.7308173e-01, 5.7326204e-01, + 5.7344234e-01, 5.7362270e-01, 5.7380307e-01, 5.7398343e-01, + 5.7416385e-01, 5.7434428e-01, 5.7452470e-01, 5.7470512e-01, + 5.7488561e-01, 5.7506609e-01, 5.7524663e-01, 5.7542717e-01, + 5.7560772e-01, 5.7578826e-01, 5.7596886e-01, 5.7614946e-01, + 5.7633007e-01, 5.7651073e-01, 5.7669139e-01, 5.7687205e-01, + 5.7705277e-01, 5.7723349e-01, 5.7741421e-01, 5.7759500e-01, + 5.7777578e-01, 5.7795656e-01, 5.7813734e-01, 5.7831818e-01, + 5.7849902e-01, 5.7867992e-01, 5.7886082e-01, 5.7904172e-01, + 5.7922262e-01, 5.7940358e-01, 5.7958454e-01, 5.7976550e-01, + 5.7994652e-01, 5.8012754e-01, 5.8030856e-01, 5.8048964e-01, + 5.8067071e-01, 5.8085179e-01, 5.8103293e-01, 5.8121407e-01, + 5.8139521e-01, 5.8157641e-01, 5.8175761e-01, 5.8193880e-01, + 5.8212000e-01, 5.8230126e-01, 5.8248252e-01, 5.8266383e-01, + 5.8284515e-01, 5.8302647e-01, 5.8320779e-01, 5.8338916e-01, + 5.8357054e-01, 5.8375198e-01, 5.8393335e-01, 5.8411479e-01, + 5.8429629e-01, 5.8447778e-01, 5.8465928e-01, 5.8484077e-01, + 5.8502233e-01, 5.8520389e-01, 5.8538544e-01, 5.8556706e-01, + 5.8574867e-01, 5.8593029e-01, 5.8611196e-01, 5.8629364e-01, + 5.8647531e-01, 5.8665699e-01, 5.8683872e-01, 5.8702052e-01, + 5.8720225e-01, 5.8738405e-01, 5.8756584e-01, 5.8774769e-01, + 5.8792955e-01, 5.8811140e-01, 5.8829331e-01, 5.8847517e-01, + 5.8865714e-01, 5.8883905e-01, 5.8902103e-01, 5.8920300e-01, + 5.8938503e-01, 5.8956701e-01, 5.8974910e-01, 5.8993113e-01, + 5.9011322e-01, 5.9029531e-01, 5.9047747e-01, 5.9065956e-01, + 5.9084171e-01, 5.9102392e-01, 5.9120613e-01, 5.9138834e-01, + 5.9157056e-01, 5.9175283e-01, 5.9193510e-01, 5.9211743e-01, + 5.9229970e-01, 5.9248203e-01, 5.9266442e-01, 5.9284681e-01, + 5.9302920e-01, 5.9321159e-01, 5.9339404e-01, 5.9357649e-01, + 5.9375894e-01, 5.9394145e-01, 5.9412396e-01, 5.9430653e-01, + 5.9448904e-01, 5.9467161e-01, 5.9485424e-01, 5.9503686e-01, + 5.9521949e-01, 5.9540212e-01, 5.9558481e-01, 5.9576750e-01, + 5.9595019e-01, 5.9613293e-01, 5.9631568e-01, 5.9649843e-01, + 5.9668124e-01, 5.9686404e-01, 5.9704691e-01, 5.9722972e-01, + 5.9741259e-01, 5.9759551e-01, 5.9777844e-01, 5.9796137e-01, + 5.9814429e-01, 5.9832728e-01, 5.9851027e-01, 5.9869325e-01, + 5.9887630e-01, 5.9905934e-01, 5.9924245e-01, 5.9942549e-01, + 5.9960866e-01, 5.9979177e-01, 5.9997493e-01, 6.0015810e-01, + 6.0034126e-01, 6.0052449e-01, 6.0070771e-01, 6.0089099e-01, + 6.0107428e-01, 6.0125756e-01, 6.0144085e-01, 6.0162419e-01, + 6.0180753e-01, 6.0199094e-01, 6.0217434e-01, 6.0235775e-01, + 6.0254115e-01, 6.0272461e-01, 6.0290807e-01, 6.0309160e-01, + 6.0327512e-01, 6.0345864e-01, 6.0364223e-01, 6.0382581e-01, + 6.0400939e-01, 6.0419297e-01, 6.0437661e-01, 6.0456032e-01, + 6.0474396e-01, 6.0492766e-01, 6.0511142e-01, 6.0529512e-01, + 6.0547888e-01, 6.0566270e-01, 6.0584646e-01, 6.0603029e-01, + 6.0621417e-01, 6.0639799e-01, 6.0658187e-01, 6.0676581e-01, + 6.0694975e-01, 6.0713369e-01, 6.0731763e-01, 6.0750163e-01, + 6.0768563e-01, 6.0786963e-01, 6.0805368e-01, 6.0823774e-01, + 6.0842186e-01, 6.0860598e-01, 6.0879010e-01, 6.0897428e-01, + 6.0915840e-01, 6.0934263e-01, 6.0952681e-01, 6.0971105e-01, + 6.0989529e-01, 6.1007959e-01, 6.1026388e-01, 6.1044818e-01, + 6.1063254e-01, 6.1081690e-01, 6.1100125e-01, 6.1118567e-01, + 6.1137009e-01, 6.1155456e-01, 6.1173898e-01, 6.1192352e-01, + 6.1210799e-01, 6.1229253e-01, 6.1247706e-01, 6.1266160e-01, + 6.1284620e-01, 6.1303085e-01, 6.1321545e-01, 6.1340010e-01, + 6.1358476e-01, 6.1376947e-01, 6.1395419e-01, 6.1413890e-01, + 6.1432368e-01, 6.1450845e-01, 6.1469322e-01, 6.1487806e-01, + 6.1506289e-01, 6.1524773e-01, 6.1543262e-01, 6.1561751e-01, + 6.1580247e-01, 6.1598742e-01, 6.1617237e-01, 6.1635733e-01, + 6.1654234e-01, 6.1672741e-01, 6.1691242e-01, 6.1709750e-01, + 6.1728263e-01, 6.1746770e-01, 6.1765283e-01, 6.1783803e-01, + 6.1802316e-01, 6.1820835e-01, 6.1839360e-01, 6.1857885e-01, + 6.1876410e-01, 6.1894935e-01, 6.1913466e-01, 6.1931998e-01, + 6.1950535e-01, 6.1969072e-01, 6.1987609e-01, 6.2006152e-01, + 6.2024695e-01, 6.2043238e-01, 6.2061787e-01, 6.2080336e-01, + 6.2098891e-01, 6.2117440e-01, 6.2136000e-01, 6.2154555e-01, + 6.2173116e-01, 6.2191677e-01, 6.2210244e-01, 6.2228811e-01, + 6.2247378e-01, 6.2265950e-01, 6.2284523e-01, 6.2303096e-01, + 6.2321675e-01, 6.2340254e-01, 6.2358838e-01, 6.2377423e-01, + 6.2396008e-01, 6.2414593e-01, 6.2433183e-01, 6.2451780e-01, + 6.2470371e-01, 6.2488967e-01, 6.2507570e-01, 6.2526166e-01, + 6.2544775e-01, 6.2563378e-01, 6.2581986e-01, 6.2600595e-01, + 6.2619209e-01, 6.2637824e-01, 6.2656438e-01, 6.2675059e-01, + 6.2693679e-01, 6.2712300e-01, 6.2730926e-01, 6.2749553e-01, + 6.2768179e-01, 6.2786812e-01, 6.2805444e-01, 6.2824082e-01, + 6.2842721e-01, 6.2861359e-01, 6.2880003e-01, 6.2898648e-01, + 6.2917292e-01, 6.2935942e-01, 6.2954593e-01, 6.2973249e-01, + 6.2991905e-01, 6.3010561e-01, 6.3029224e-01, 6.3047886e-01, + 6.3066548e-01, 6.3085216e-01, 6.3103884e-01, 6.3122553e-01, + 6.3141227e-01, 6.3159901e-01, 6.3178581e-01, 6.3197261e-01, + 6.3215941e-01, 6.3234627e-01, 6.3253313e-01, 6.3271999e-01, + 6.3290691e-01, 6.3309383e-01, 6.3328081e-01, 6.3346779e-01, + 6.3365477e-01, 6.3384175e-01, 6.3402879e-01, 6.3421589e-01, + 6.3440299e-01, 6.3459009e-01, 6.3477719e-01, 6.3496435e-01, + 6.3515151e-01, 6.3533872e-01, 6.3552594e-01, 6.3571316e-01, + 6.3590044e-01, 6.3608772e-01, 6.3627505e-01, 6.3646239e-01, + 6.3664973e-01, 6.3683712e-01, 6.3702452e-01, 6.3721192e-01, + 6.3739938e-01, 6.3758683e-01, 6.3777429e-01, 6.3796180e-01, + 6.3814932e-01, 6.3833690e-01, 6.3852447e-01, 6.3871205e-01, + 6.3889968e-01, 6.3908732e-01, 6.3927501e-01, 6.3946271e-01, + 6.3965040e-01, 6.3983816e-01, 6.4002591e-01, 6.4021367e-01, + 6.4040148e-01, 6.4058930e-01, 6.4077717e-01, 6.4096504e-01, + 6.4115292e-01, 6.4134085e-01, 6.4152879e-01, 6.4171672e-01, + 6.4190471e-01, 6.4209270e-01, 6.4228076e-01, 6.4246881e-01, + 6.4265686e-01, 6.4284497e-01, 6.4303309e-01, 6.4322120e-01, + 6.4340937e-01, 6.4359754e-01, 6.4378577e-01, 6.4397401e-01, + 6.4416224e-01, 6.4435053e-01, 6.4453882e-01, 6.4472717e-01, + 6.4491552e-01, 6.4510387e-01, 6.4529228e-01, 6.4548069e-01, + 6.4566916e-01, 6.4585757e-01, 6.4604610e-01, 6.4623457e-01, + 6.4642310e-01, 6.4661169e-01, 6.4680022e-01, 6.4698887e-01, + 6.4717746e-01, 6.4736611e-01, 6.4755476e-01, 6.4774346e-01, + 6.4793217e-01, 6.4812094e-01, 6.4830971e-01, 6.4849848e-01, + 6.4868730e-01, 6.4887613e-01, 6.4906496e-01, 6.4925385e-01, + 6.4944273e-01, 6.4963168e-01, 6.4982063e-01, 6.5000957e-01, + 6.5019858e-01, 6.5038759e-01, 6.5057659e-01, 6.5076566e-01, + 6.5095478e-01, 6.5114385e-01, 6.5133303e-01, 6.5152216e-01, + 6.5171134e-01, 6.5190053e-01, 6.5208977e-01, 6.5227902e-01, + 6.5246826e-01, 6.5265757e-01, 6.5284693e-01, 6.5303624e-01, + 6.5322560e-01, 6.5341502e-01, 6.5360439e-01, 6.5379387e-01, + 6.5398329e-01, 6.5417278e-01, 6.5436232e-01, 6.5455180e-01, + 6.5474141e-01, 6.5493095e-01, 6.5512055e-01, 6.5531015e-01, + 6.5549982e-01, 6.5568948e-01, 6.5587920e-01, 6.5606892e-01, + 6.5625864e-01, 6.5644842e-01, 6.5663821e-01, 6.5682805e-01, + 6.5701783e-01, 6.5720773e-01, 6.5739763e-01, 6.5758753e-01, + 6.5777743e-01, 6.5796739e-01, 6.5815735e-01, 6.5834737e-01, + 6.5853739e-01, 6.5872747e-01, 6.5891755e-01, 6.5910763e-01, + 6.5929776e-01, 6.5948790e-01, 6.5967804e-01, 6.5986824e-01, + 6.6005844e-01, 6.6024870e-01, 6.6043895e-01, 6.6062927e-01, + 6.6081959e-01, 6.6100991e-01, 6.6120028e-01, 6.6139066e-01, + 6.6158104e-01, 6.6177148e-01, 6.6196197e-01, 6.6215241e-01, + 6.6234291e-01, 6.6253346e-01, 6.6272402e-01, 6.6291457e-01, + 6.6310519e-01, 6.6329581e-01, 6.6348648e-01, 6.6367716e-01, + 6.6386783e-01, 6.6405857e-01, 6.6424930e-01, 6.6444010e-01, + 6.6463089e-01, 6.6482168e-01, 6.6501254e-01, 6.6520339e-01, + 6.6539431e-01, 6.6558522e-01, 6.6577613e-01, 6.6596711e-01, + 6.6615808e-01, 6.6634911e-01, 6.6654015e-01, 6.6673118e-01, + 6.6692227e-01, 6.6711336e-01, 6.6730452e-01, 6.6749567e-01, + 6.6768688e-01, 6.6787809e-01, 6.6806930e-01, 6.6826057e-01, + 6.6845185e-01, 6.6864312e-01, 6.6883445e-01, 6.6902584e-01, + 6.6921723e-01, 6.6940862e-01, 6.6960001e-01, 6.6979146e-01, + 6.6998297e-01, 6.7017448e-01, 6.7036599e-01, 6.7055756e-01, + 6.7074913e-01, 6.7094070e-01, 6.7113233e-01, 6.7132396e-01, + 6.7151564e-01, 6.7170733e-01, 6.7189908e-01, 6.7209083e-01, + 6.7228258e-01, 6.7247438e-01, 6.7266619e-01, 6.7285806e-01, + 6.7304993e-01, 6.7324179e-01, 6.7343372e-01, 6.7362571e-01, + 6.7381763e-01, 6.7400968e-01, 6.7420167e-01, 6.7439371e-01, + 6.7458576e-01, 6.7477787e-01, 6.7496997e-01, 6.7516214e-01, + 6.7535430e-01, 6.7554653e-01, 6.7573875e-01, 6.7593098e-01, + 6.7612326e-01, 6.7631555e-01, 6.7650783e-01, 6.7670017e-01, + 6.7689258e-01, 6.7708498e-01, 6.7727739e-01, 6.7746985e-01, + 6.7766231e-01, 6.7785478e-01, 6.7804730e-01, 6.7823982e-01, + 6.7843240e-01, 6.7862499e-01, 6.7881763e-01, 6.7901027e-01, + 6.7920297e-01, 6.7939562e-01, 6.7958838e-01, 6.7978114e-01, + 6.7997390e-01, 6.8016666e-01, 6.8035948e-01, 6.8055236e-01, + 6.8074524e-01, 6.8093812e-01, 6.8113106e-01, 6.8132401e-01, + 6.8151695e-01, 6.8170995e-01, 6.8190300e-01, 6.8209606e-01, + 6.8228912e-01, 6.8248224e-01, 6.8267536e-01, 6.8286848e-01, + 6.8306166e-01, 6.8325490e-01, 6.8344808e-01, 6.8364137e-01, + 6.8383461e-01, 6.8402797e-01, 6.8422127e-01, 6.8441463e-01, + 6.8460798e-01, 6.8480140e-01, 6.8499488e-01, 6.8518829e-01, + 6.8538177e-01, 6.8557531e-01, 6.8576884e-01, 6.8596238e-01, + 6.8615597e-01, 6.8634963e-01, 6.8654323e-01, 6.8673688e-01, + 6.8693060e-01, 6.8712431e-01, 6.8731803e-01, 6.8751180e-01, + 6.8770564e-01, 6.8789941e-01, 6.8809330e-01, 6.8828714e-01, + 6.8848103e-01, 6.8867499e-01, 6.8886894e-01, 6.8906289e-01, + 6.8925691e-01, 6.8945092e-01, 6.8964499e-01, 6.8983907e-01, + 6.9003314e-01, 6.9022727e-01, 6.9042146e-01, 6.9061559e-01, + 6.9080985e-01, 6.9100404e-01, 6.9119835e-01, 6.9139260e-01, + 6.9158691e-01, 6.9178128e-01, 6.9197559e-01, 6.9217002e-01, + 6.9236445e-01, 6.9255888e-01, 6.9275331e-01, 6.9294786e-01, + 6.9314235e-01, 6.9333690e-01, 6.9353145e-01, 6.9372606e-01, + 6.9392073e-01, 6.9411534e-01, 6.9431007e-01, 6.9450474e-01, + 6.9469947e-01, 6.9489425e-01, 6.9508904e-01, 6.9528383e-01, + 6.9547868e-01, 6.9567353e-01, 6.9586843e-01, 6.9606334e-01, + 6.9625831e-01, 6.9645327e-01, 6.9664824e-01, 6.9684327e-01, + 6.9703835e-01, 6.9723338e-01, 6.9742852e-01, 6.9762361e-01, + 6.9781876e-01, 6.9801396e-01, 6.9820917e-01, 6.9840443e-01, + 6.9859970e-01, 6.9879496e-01, 6.9899029e-01, 6.9918561e-01, + 6.9938099e-01, 6.9957638e-01, 6.9977182e-01, 6.9996727e-01, + 7.0016271e-01, 7.0035821e-01, 7.0055377e-01, 7.0074934e-01, + 7.0094490e-01, 7.0114052e-01, 7.0133615e-01, 7.0153183e-01, + 7.0172751e-01, 7.0192319e-01, 7.0211893e-01, 7.0231473e-01, + 7.0251054e-01, 7.0270634e-01, 7.0290220e-01, 7.0309806e-01, + 7.0329398e-01, 7.0348990e-01, 7.0368588e-01, 7.0388186e-01, + 7.0407790e-01, 7.0427394e-01, 7.0446998e-01, 7.0466608e-01, + 7.0486218e-01, 7.0505834e-01, 7.0525450e-01, 7.0545071e-01, + 7.0564693e-01, 7.0584321e-01, 7.0603949e-01, 7.0623583e-01, + 7.0643216e-01, 7.0662850e-01, 7.0682490e-01, 7.0702136e-01, + 7.0721775e-01, 7.0741427e-01, 7.0761073e-01, 7.0780730e-01, + 7.0800382e-01, 7.0820040e-01, 7.0839703e-01, 7.0859367e-01, + 7.0879036e-01, 7.0898706e-01, 7.0918375e-01, 7.0938051e-01, + 7.0957726e-01, 7.0977408e-01, 7.0997089e-01, 7.1016777e-01, + 7.1036464e-01, 7.1056157e-01, 7.1075851e-01, 7.1095550e-01, + 7.1115249e-01, 7.1134949e-01, 7.1154654e-01, 7.1174365e-01, + 7.1194077e-01, 7.1213788e-01, 7.1233505e-01, 7.1253222e-01, + 7.1272945e-01, 7.1292669e-01, 7.1312398e-01, 7.1332127e-01, + 7.1351862e-01, 7.1371597e-01, 7.1391332e-01, 7.1411073e-01, + 7.1430820e-01, 7.1450567e-01, 7.1470314e-01, 7.1490067e-01, + 7.1509826e-01, 7.1529579e-01, 7.1549344e-01, 7.1569109e-01, + 7.1588874e-01, 7.1608639e-01, 7.1628416e-01, 7.1648186e-01, + 7.1667963e-01, 7.1687746e-01, 7.1707529e-01, 7.1727318e-01, + 7.1747106e-01, 7.1766895e-01, 7.1786690e-01, 7.1806484e-01, + 7.1826285e-01, 7.1846092e-01, 7.1865898e-01, 7.1885705e-01, + 7.1905518e-01, 7.1925330e-01, 7.1945149e-01, 7.1964967e-01, + 7.1984792e-01, 7.2004616e-01, 7.2024441e-01, 7.2044271e-01, + 7.2064108e-01, 7.2083944e-01, 7.2103786e-01, 7.2123629e-01, + 7.2143471e-01, 7.2163320e-01, 7.2183174e-01, 7.2203022e-01, + 7.2222883e-01, 7.2242743e-01, 7.2262603e-01, 7.2282469e-01, + 7.2302336e-01, 7.2322208e-01, 7.2342080e-01, 7.2361958e-01, + 7.2381836e-01, 7.2401720e-01, 7.2421604e-01, 7.2441494e-01, + 7.2461385e-01, 7.2481281e-01, 7.2501177e-01, 7.2521073e-01, + 7.2540975e-01, 7.2560883e-01, 7.2580791e-01, 7.2600698e-01, + 7.2620612e-01, 7.2640532e-01, 7.2660452e-01, 7.2680372e-01, + 7.2700298e-01, 7.2720230e-01, 7.2740161e-01, 7.2760093e-01, + 7.2780031e-01, 7.2799969e-01, 7.2819912e-01, 7.2839856e-01, + 7.2859806e-01, 7.2879755e-01, 7.2899711e-01, 7.2919673e-01, + 7.2939628e-01, 7.2959596e-01, 7.2979558e-01, 7.2999531e-01, + 7.3019499e-01, 7.3039472e-01, 7.3059452e-01, 7.3079431e-01, + 7.3099416e-01, 7.3119402e-01, 7.3139393e-01, 7.3159385e-01, + 7.3179382e-01, 7.3199379e-01, 7.3219377e-01, 7.3239380e-01, + 7.3259389e-01, 7.3279399e-01, 7.3299414e-01, 7.3319429e-01, + 7.3339444e-01, 7.3359466e-01, 7.3379493e-01, 7.3399520e-01, + 7.3419553e-01, 7.3439586e-01, 7.3459619e-01, 7.3479658e-01, + 7.3499703e-01, 7.3519748e-01, 7.3539793e-01, 7.3559844e-01, + 7.3579901e-01, 7.3599958e-01, 7.3620015e-01, 7.3640078e-01, + 7.3660147e-01, 7.3680216e-01, 7.3700285e-01, 7.3720360e-01, + 7.3740441e-01, 7.3760521e-01, 7.3780602e-01, 7.3800689e-01, + 7.3820782e-01, 7.3840874e-01, 7.3860967e-01, 7.3881066e-01, + 7.3901170e-01, 7.3921275e-01, 7.3941380e-01, 7.3961490e-01, + 7.3981607e-01, 7.4001724e-01, 7.4021840e-01, 7.4041963e-01, + 7.4062091e-01, 7.4082220e-01, 7.4102348e-01, 7.4122483e-01, + 7.4142623e-01, 7.4162763e-01, 7.4182904e-01, 7.4203050e-01, + 7.4223202e-01, 7.4243355e-01, 7.4263507e-01, 7.4283665e-01, + 7.4303830e-01, 7.4323994e-01, 7.4344164e-01, 7.4364334e-01, + 7.4384505e-01, 7.4404681e-01, 7.4424863e-01, 7.4445045e-01, + 7.4465233e-01, 7.4485421e-01, 7.4505609e-01, 7.4525809e-01, + 7.4546003e-01, 7.4566203e-01, 7.4586409e-01, 7.4606615e-01, + 7.4626827e-01, 7.4647039e-01, 7.4667257e-01, 7.4687475e-01, + 7.4707699e-01, 7.4727923e-01, 7.4748152e-01, 7.4768382e-01, + 7.4788618e-01, 7.4808854e-01, 7.4829096e-01, 7.4849343e-01, + 7.4869585e-01, 7.4889839e-01, 7.4910092e-01, 7.4930346e-01, + 7.4950606e-01, 7.4970865e-01, 7.4991131e-01, 7.5011402e-01, + 7.5031674e-01, 7.5051945e-01, 7.5072223e-01, 7.5092506e-01, + 7.5112790e-01, 7.5133079e-01, 7.5153369e-01, 7.5173658e-01, + 7.5193954e-01, 7.5214255e-01, 7.5234556e-01, 7.5254864e-01, + 7.5275171e-01, 7.5295484e-01, 7.5315797e-01, 7.5336117e-01, + 7.5356436e-01, 7.5376761e-01, 7.5397086e-01, 7.5417417e-01, + 7.5437754e-01, 7.5458091e-01, 7.5478429e-01, 7.5498772e-01, + 7.5519121e-01, 7.5539470e-01, 7.5559819e-01, 7.5580174e-01, + 7.5600535e-01, 7.5620896e-01, 7.5641263e-01, 7.5661629e-01, + 7.5681996e-01, 7.5702375e-01, 7.5722748e-01, 7.5743133e-01, + 7.5763512e-01, 7.5783902e-01, 7.5804293e-01, 7.5824684e-01, + 7.5845081e-01, 7.5865477e-01, 7.5885880e-01, 7.5906289e-01, + 7.5926697e-01, 7.5947106e-01, 7.5967526e-01, 7.5987941e-01, + 7.6008362e-01, 7.6028788e-01, 7.6049215e-01, 7.6069647e-01, + 7.6090080e-01, 7.6110518e-01, 7.6130962e-01, 7.6151401e-01, + 7.6171851e-01, 7.6192302e-01, 7.6212752e-01, 7.6233208e-01, + 7.6253670e-01, 7.6274133e-01, 7.6294601e-01, 7.6315069e-01, + 7.6335543e-01, 7.6356018e-01, 7.6376498e-01, 7.6396978e-01, + 7.6417464e-01, 7.6437950e-01, 7.6458442e-01, 7.6478940e-01, + 7.6499438e-01, 7.6519936e-01, 7.6540440e-01, 7.6560950e-01, + 7.6581460e-01, 7.6601976e-01, 7.6622492e-01, 7.6643014e-01, + 7.6663536e-01, 7.6684064e-01, 7.6704592e-01, 7.6725125e-01, + 7.6745665e-01, 7.6766205e-01, 7.6786751e-01, 7.6807296e-01, + 7.6827842e-01, 7.6848400e-01, 7.6868951e-01, 7.6889515e-01, + 7.6910079e-01, 7.6930642e-01, 7.6951212e-01, 7.6971781e-01, + 7.6992357e-01, 7.7012938e-01, 7.7033520e-01, 7.7054107e-01, + 7.7074695e-01, 7.7095288e-01, 7.7115881e-01, 7.7136481e-01, + 7.7157086e-01, 7.7177691e-01, 7.7198297e-01, 7.7218908e-01, + 7.7239525e-01, 7.7260143e-01, 7.7280766e-01, 7.7301389e-01, + 7.7322018e-01, 7.7342647e-01, 7.7363282e-01, 7.7383924e-01, + 7.7404565e-01, 7.7425206e-01, 7.7445853e-01, 7.7466506e-01, + 7.7487159e-01, 7.7507818e-01, 7.7528483e-01, 7.7549142e-01, + 7.7569813e-01, 7.7590483e-01, 7.7611160e-01, 7.7631837e-01, + 7.7652514e-01, 7.7673203e-01, 7.7693892e-01, 7.7714580e-01, + 7.7735275e-01, 7.7755970e-01, 7.7776670e-01, 7.7797377e-01, + 7.7818084e-01, 7.7838796e-01, 7.7859509e-01, 7.7880228e-01, + 7.7900952e-01, 7.7921671e-01, 7.7942401e-01, 7.7963132e-01, + 7.7983868e-01, 7.8004605e-01, 7.8025347e-01, 7.8046089e-01, + 7.8066838e-01, 7.8087592e-01, 7.8108346e-01, 7.8129101e-01, + 7.8149861e-01, 7.8170627e-01, 7.8191394e-01, 7.8212166e-01, + 7.8232944e-01, 7.8253722e-01, 7.8274500e-01, 7.8295285e-01, + 7.8316075e-01, 7.8336865e-01, 7.8357661e-01, 7.8378463e-01, + 7.8399265e-01, 7.8420067e-01, 7.8440875e-01, 7.8461689e-01, + 7.8482503e-01, 7.8503323e-01, 7.8524148e-01, 7.8544968e-01, + 7.8565800e-01, 7.8586632e-01, 7.8607470e-01, 7.8628308e-01, + 7.8649151e-01, 7.8669995e-01, 7.8690845e-01, 7.8711700e-01, + 7.8732556e-01, 7.8753418e-01, 7.8774279e-01, 7.8795147e-01, + 7.8816015e-01, 7.8836888e-01, 7.8857768e-01, 7.8878647e-01, + 7.8899533e-01, 7.8920418e-01, 7.8941309e-01, 7.8962201e-01, + 7.8983098e-01, 7.9004002e-01, 7.9024905e-01, 7.9045814e-01, + 7.9066724e-01, 7.9087639e-01, 7.9108560e-01, 7.9129481e-01, + 7.9150409e-01, 7.9171336e-01, 7.9192269e-01, 7.9213202e-01, + 7.9234141e-01, 7.9255086e-01, 7.9276031e-01, 7.9296982e-01, + 7.9317933e-01, 7.9338890e-01, 7.9359853e-01, 7.9380816e-01, + 7.9401779e-01, 7.9422754e-01, 7.9443729e-01, 7.9464704e-01, + 7.9485685e-01, 7.9506671e-01, 7.9527658e-01, 7.9548651e-01, + 7.9569644e-01, 7.9590642e-01, 7.9611647e-01, 7.9632652e-01, + 7.9653656e-01, 7.9674673e-01, 7.9695690e-01, 7.9716706e-01, + 7.9737729e-01, 7.9758757e-01, 7.9779786e-01, 7.9800820e-01, + 7.9821861e-01, 7.9842901e-01, 7.9863942e-01, 7.9884994e-01, + 7.9906040e-01, 7.9927099e-01, 7.9948157e-01, 7.9969221e-01, + 7.9990286e-01, 8.0011356e-01, 8.0032426e-01, 8.0053502e-01, + 8.0074584e-01, 8.0095667e-01, 8.0116755e-01, 8.0137843e-01, + 8.0158937e-01, 8.0180037e-01, 8.0201137e-01, 8.0222243e-01, + 8.0243349e-01, 8.0264461e-01, 8.0285579e-01, 8.0306697e-01, + 8.0327821e-01, 8.0348945e-01, 8.0370075e-01, 8.0391210e-01, + 8.0412346e-01, 8.0433488e-01, 8.0454630e-01, 8.0475777e-01, + 8.0496931e-01, 8.0518085e-01, 8.0539244e-01, 8.0560404e-01, + 8.0581570e-01, 8.0602741e-01, 8.0623913e-01, 8.0645090e-01, + 8.0666268e-01, 8.0687451e-01, 8.0708641e-01, 8.0729830e-01, + 8.0751026e-01, 8.0772227e-01, 8.0793428e-01, 8.0814636e-01, + 8.0835843e-01, 8.0857056e-01, 8.0878270e-01, 8.0899495e-01, + 8.0920714e-01, 8.0941945e-01, 8.0963176e-01, 8.0984408e-01, + 8.1005645e-01, 8.1026888e-01, 8.1048137e-01, 8.1069386e-01, + 8.1090641e-01, 8.1111896e-01, 8.1133157e-01, 8.1154418e-01, + 8.1175685e-01, 8.1196958e-01, 8.1218231e-01, 8.1239510e-01, + 8.1260794e-01, 8.1282079e-01, 8.1303370e-01, 8.1324667e-01, + 8.1345963e-01, 8.1367260e-01, 8.1388569e-01, 8.1409878e-01, + 8.1431186e-01, 8.1452501e-01, 8.1473821e-01, 8.1495148e-01, + 8.1516474e-01, 8.1537801e-01, 8.1559139e-01, 8.1580472e-01, + 8.1601816e-01, 8.1623161e-01, 8.1644511e-01, 8.1665862e-01, + 8.1687218e-01, 8.1708580e-01, 8.1729943e-01, 8.1751311e-01, + 8.1772685e-01, 8.1794059e-01, 8.1815439e-01, 8.1836820e-01, + 8.1858206e-01, 8.1879598e-01, 8.1900990e-01, 8.1922388e-01, + 8.1943792e-01, 8.1965196e-01, 8.1986606e-01, 8.2008016e-01, + 8.2029432e-01, 8.2050854e-01, 8.2072276e-01, 8.2093704e-01, + 8.2115138e-01, 8.2136571e-01, 8.2158011e-01, 8.2179451e-01, + 8.2200897e-01, 8.2222348e-01, 8.2243806e-01, 8.2265264e-01, + 8.2286721e-01, 8.2308191e-01, 8.2329661e-01, 8.2351130e-01, + 8.2372606e-01, 8.2394087e-01, 8.2415575e-01, 8.2437062e-01, + 8.2458556e-01, 8.2480049e-01, 8.2501549e-01, 8.2523054e-01, + 8.2544559e-01, 8.2566071e-01, 8.2587588e-01, 8.2609105e-01, + 8.2630628e-01, 8.2652152e-01, 8.2673687e-01, 8.2695216e-01, + 8.2716757e-01, 8.2738298e-01, 8.2759845e-01, 8.2781392e-01, + 8.2802945e-01, 8.2824504e-01, 8.2846063e-01, 8.2867628e-01, + 8.2889199e-01, 8.2910770e-01, 8.2932347e-01, 8.2953930e-01, + 8.2975513e-01, 8.2997102e-01, 8.3018690e-01, 8.3040285e-01, + 8.3061886e-01, 8.3083493e-01, 8.3105099e-01, 8.3126712e-01, + 8.3148324e-01, 8.3169943e-01, 8.3191568e-01, 8.3213192e-01, + 8.3234823e-01, 8.3256459e-01, 8.3278096e-01, 8.3299738e-01, + 8.3321387e-01, 8.3343035e-01, 8.3364689e-01, 8.3386350e-01, + 8.3408010e-01, 8.3429676e-01, 8.3451349e-01, 8.3473021e-01, + 8.3494699e-01, 8.3516377e-01, 8.3538067e-01, 8.3559757e-01, + 8.3581448e-01, 8.3603144e-01, 8.3624846e-01, 8.3646554e-01, + 8.3668262e-01, 8.3689976e-01, 8.3711690e-01, 8.3733410e-01, + 8.3755136e-01, 8.3776867e-01, 8.3798599e-01, 8.3820337e-01, + 8.3842075e-01, 8.3863819e-01, 8.3885568e-01, 8.3907324e-01, + 8.3929080e-01, 8.3950841e-01, 8.3972603e-01, 8.3994371e-01, + 8.4016144e-01, 8.4037918e-01, 8.4059703e-01, 8.4081483e-01, + 8.4103274e-01, 8.4125066e-01, 8.4146863e-01, 8.4168661e-01, + 8.4190470e-01, 8.4212279e-01, 8.4234089e-01, 8.4255904e-01, + 8.4277725e-01, 8.4299552e-01, 8.4321380e-01, 8.4343213e-01, + 8.4365046e-01, 8.4386891e-01, 8.4408730e-01, 8.4430581e-01, + 8.4452432e-01, 8.4474289e-01, 8.4496152e-01, 8.4518015e-01, + 8.4539884e-01, 8.4561759e-01, 8.4583634e-01, 8.4605515e-01, + 8.4627402e-01, 8.4649289e-01, 8.4671181e-01, 8.4693080e-01, + 8.4714979e-01, 8.4736884e-01, 8.4758794e-01, 8.4780711e-01, + 8.4802628e-01, 8.4824550e-01, 8.4846473e-01, 8.4868401e-01, + 8.4890336e-01, 8.4912276e-01, 8.4934217e-01, 8.4956163e-01, + 8.4978116e-01, 8.5000068e-01, 8.5022026e-01, 8.5043991e-01, + 8.5065955e-01, 8.5087925e-01, 8.5109901e-01, 8.5131878e-01, + 8.5153860e-01, 8.5175848e-01, 8.5197842e-01, 8.5219836e-01, + 8.5241836e-01, 8.5263836e-01, 8.5285848e-01, 8.5307860e-01, + 8.5329872e-01, 8.5351896e-01, 8.5373920e-01, 8.5395950e-01, + 8.5417980e-01, 8.5440016e-01, 8.5462058e-01, 8.5484105e-01, + 8.5506153e-01, 8.5528207e-01, 8.5550261e-01, 8.5572326e-01, + 8.5594392e-01, 8.5616457e-01, 8.5638535e-01, 8.5660613e-01, + 8.5682696e-01, 8.5704780e-01, 8.5726875e-01, 8.5748965e-01, + 8.5771066e-01, 8.5793167e-01, 8.5815281e-01, 8.5837388e-01, + 8.5859507e-01, 8.5881627e-01, 8.5903752e-01, 8.5925877e-01, + 8.5948014e-01, 8.5970151e-01, 8.5992289e-01, 8.6014438e-01, + 8.6036587e-01, 8.6058742e-01, 8.6080897e-01, 8.6103058e-01, + 8.6125225e-01, 8.6147398e-01, 8.6169571e-01, 8.6191750e-01, + 8.6213934e-01, 8.6236125e-01, 8.6258316e-01, 8.6280513e-01, + 8.6302710e-01, 8.6324918e-01, 8.6347127e-01, 8.6369336e-01, + 8.6391556e-01, 8.6413777e-01, 8.6436003e-01, 8.6458236e-01, + 8.6480469e-01, 8.6502707e-01, 8.6524951e-01, 8.6547196e-01, + 8.6569452e-01, 8.6591709e-01, 8.6613965e-01, 8.6636233e-01, + 8.6658502e-01, 8.6680776e-01, 8.6703050e-01, 8.6725330e-01, + 8.6747617e-01, 8.6769909e-01, 8.6792201e-01, 8.6814505e-01, + 8.6836809e-01, 8.6859113e-01, 8.6881423e-01, 8.6903745e-01, + 8.6926061e-01, 8.6948389e-01, 8.6970717e-01, 8.6993051e-01, + 8.7015390e-01, 8.7037730e-01, 8.7060076e-01, 8.7082428e-01, + 8.7104785e-01, 8.7127143e-01, 8.7149507e-01, 8.7171876e-01, + 8.7194252e-01, 8.7216628e-01, 8.7239009e-01, 8.7261397e-01, + 8.7283784e-01, 8.7306178e-01, 8.7328577e-01, 8.7350982e-01, + 8.7373388e-01, 8.7395799e-01, 8.7418216e-01, 8.7440640e-01, + 8.7463063e-01, 8.7485492e-01, 8.7507927e-01, 8.7530369e-01, + 8.7552810e-01, 8.7575257e-01, 8.7597710e-01, 8.7620169e-01, + 8.7642628e-01, 8.7665093e-01, 8.7687564e-01, 8.7710035e-01, + 8.7732512e-01, 8.7754995e-01, 8.7777483e-01, 8.7799978e-01, + 8.7822473e-01, 8.7844974e-01, 8.7867481e-01, 8.7889987e-01, + 8.7912500e-01, 8.7935019e-01, 8.7957543e-01, 8.7980068e-01, + 8.8002604e-01, 8.8025135e-01, 8.8047677e-01, 8.8070226e-01, + 8.8092774e-01, 8.8115329e-01, 8.8137889e-01, 8.8160449e-01, + 8.8183016e-01, 8.8205588e-01, 8.8228166e-01, 8.8250744e-01, + 8.8273335e-01, 8.8295925e-01, 8.8318515e-01, 8.8341117e-01, + 8.8363719e-01, 8.8386327e-01, 8.8408941e-01, 8.8431555e-01, + 8.8454181e-01, 8.8476807e-01, 8.8499439e-01, 8.8522071e-01, + 8.8544714e-01, 8.8567358e-01, 8.8590008e-01, 8.8612658e-01, + 8.8635319e-01, 8.8657981e-01, 8.8680649e-01, 8.8703316e-01, + 8.8725996e-01, 8.8748676e-01, 8.8771361e-01, 8.8794053e-01, + 8.8816744e-01, 8.8839442e-01, 8.8862145e-01, 8.8884854e-01, + 8.8907570e-01, 8.8930285e-01, 8.8953006e-01, 8.8975734e-01, + 8.8998467e-01, 8.9021200e-01, 8.9043945e-01, 8.9066684e-01, + 8.9089435e-01, 8.9112192e-01, 8.9134949e-01, 8.9157712e-01, + 8.9180481e-01, 8.9203256e-01, 8.9226031e-01, 8.9248812e-01, + 8.9271599e-01, 8.9294392e-01, 8.9317185e-01, 8.9339989e-01, + 8.9362794e-01, 8.9385605e-01, 8.9408416e-01, 8.9431238e-01, + 8.9454061e-01, 8.9476889e-01, 8.9499724e-01, 8.9522558e-01, + 8.9545399e-01, 8.9568251e-01, 8.9591098e-01, 8.9613956e-01, + 8.9636821e-01, 8.9659685e-01, 8.9682555e-01, 8.9705431e-01, + 8.9728308e-01, 8.9751196e-01, 8.9774084e-01, 8.9796978e-01, + 8.9819878e-01, 8.9842778e-01, 8.9865690e-01, 8.9888602e-01, + 8.9911520e-01, 8.9934438e-01, 8.9957368e-01, 8.9980298e-01, + 9.0003234e-01, 9.0026176e-01, 9.0049124e-01, 9.0072072e-01, + 9.0095031e-01, 9.0117991e-01, 9.0140957e-01, 9.0163922e-01, + 9.0186900e-01, 9.0209877e-01, 9.0232861e-01, 9.0255851e-01, + 9.0278846e-01, 9.0301841e-01, 9.0324843e-01, 9.0347856e-01, + 9.0370864e-01, 9.0393883e-01, 9.0416908e-01, 9.0439934e-01, + 9.0462965e-01, 9.0486002e-01, 9.0509045e-01, 9.0532088e-01, + 9.0555137e-01, 9.0578198e-01, 9.0601259e-01, 9.0624321e-01, + 9.0647393e-01, 9.0670466e-01, 9.0693545e-01, 9.0716630e-01, + 9.0739721e-01, 9.0762818e-01, 9.0785915e-01, 9.0809017e-01, + 9.0832126e-01, 9.0855241e-01, 9.0878361e-01, 9.0901482e-01, + 9.0924615e-01, 9.0947747e-01, 9.0970886e-01, 9.0994030e-01, + 9.1017175e-01, 9.1040331e-01, 9.1063488e-01, 9.1086650e-01, + 9.1109818e-01, 9.1132987e-01, 9.1156167e-01, 9.1179347e-01, + 9.1202533e-01, 9.1225725e-01, 9.1248924e-01, 9.1272128e-01, + 9.1295332e-01, 9.1318542e-01, 9.1341758e-01, 9.1364980e-01, + 9.1388208e-01, 9.1411442e-01, 9.1434675e-01, 9.1457915e-01, + 9.1481161e-01, 9.1504413e-01, 9.1527671e-01, 9.1550928e-01, + 9.1574198e-01, 9.1597468e-01, 9.1620743e-01, 9.1644025e-01, + 9.1667312e-01, 9.1690600e-01, 9.1713893e-01, 9.1737199e-01, + 9.1760504e-01, 9.1783816e-01, 9.1807127e-01, 9.1830450e-01, + 9.1853774e-01, 9.1877103e-01, 9.1900444e-01, 9.1923779e-01, + 9.1947126e-01, 9.1970479e-01, 9.1993833e-01, 9.2017192e-01, + 9.2040563e-01, 9.2063934e-01, 9.2087305e-01, 9.2110687e-01, + 9.2134070e-01, 9.2157465e-01, 9.2180860e-01, 9.2204261e-01, + 9.2227668e-01, 9.2251080e-01, 9.2274493e-01, 9.2297918e-01, + 9.2321342e-01, 9.2344773e-01, 9.2368209e-01, 9.2391652e-01, + 9.2415094e-01, 9.2438549e-01, 9.2462003e-01, 9.2485470e-01, + 9.2508936e-01, 9.2532408e-01, 9.2555881e-01, 9.2579365e-01, + 9.2602855e-01, 9.2626345e-01, 9.2649841e-01, 9.2673343e-01, + 9.2696851e-01, 9.2720366e-01, 9.2743886e-01, 9.2767406e-01, + 9.2790937e-01, 9.2814469e-01, 9.2838007e-01, 9.2861551e-01, + 9.2885101e-01, 9.2908657e-01, 9.2932212e-01, 9.2955780e-01, + 9.2979348e-01, 9.3002921e-01, 9.3026501e-01, 9.3050086e-01, + 9.3073678e-01, 9.3097270e-01, 9.3120873e-01, 9.3144476e-01, + 9.3168086e-01, 9.3191707e-01, 9.3215328e-01, 9.3238950e-01, + 9.3262583e-01, 9.3286222e-01, 9.3309861e-01, 9.3333513e-01, + 9.3357164e-01, 9.3380821e-01, 9.3404484e-01, 9.3428153e-01, + 9.3451828e-01, 9.3475503e-01, 9.3499190e-01, 9.3522877e-01, + 9.3546569e-01, 9.3570274e-01, 9.3593979e-01, 9.3617690e-01, + 9.3641400e-01, 9.3665123e-01, 9.3688852e-01, 9.3712580e-01, + 9.3736315e-01, 9.3760061e-01, 9.3783808e-01, 9.3807560e-01, + 9.3831319e-01, 9.3855077e-01, 9.3878847e-01, 9.3902624e-01, + 9.3926400e-01, 9.3950182e-01, 9.3973976e-01, 9.3997771e-01, + 9.4021571e-01, 9.4045377e-01, 9.4069183e-01, 9.4093001e-01, + 9.4116825e-01, 9.4140649e-01, 9.4164485e-01, 9.4188321e-01, + 9.4212162e-01, 9.4236010e-01, 9.4259864e-01, 9.4283724e-01, + 9.4307590e-01, 9.4331455e-01, 9.4355333e-01, 9.4379210e-01, + 9.4403100e-01, 9.4426990e-01, 9.4450885e-01, 9.4474787e-01, + 9.4498694e-01, 9.4522607e-01, 9.4546527e-01, 9.4570452e-01, + 9.4594383e-01, 9.4618315e-01, 9.4642258e-01, 9.4666201e-01, + 9.4690150e-01, 9.4714105e-01, 9.4738066e-01, 9.4762039e-01, + 9.4786006e-01, 9.4809985e-01, 9.4833970e-01, 9.4857961e-01, + 9.4881952e-01, 9.4905955e-01, 9.4929957e-01, 9.4953972e-01, + 9.4977987e-01, 9.5002007e-01, 9.5026034e-01, 9.5050067e-01, + 9.5074105e-01, 9.5098150e-01, 9.5122200e-01, 9.5146251e-01, + 9.5170313e-01, 9.5194381e-01, 9.5218450e-01, 9.5242524e-01, + 9.5266610e-01, 9.5290697e-01, 9.5314789e-01, 9.5338887e-01, + 9.5362991e-01, 9.5387101e-01, 9.5411217e-01, 9.5435339e-01, + 9.5459467e-01, 9.5483601e-01, 9.5507735e-01, 9.5531881e-01, + 9.5556027e-01, 9.5580184e-01, 9.5604342e-01, 9.5628506e-01, + 9.5652682e-01, 9.5676857e-01, 9.5701039e-01, 9.5725226e-01, + 9.5749420e-01, 9.5773619e-01, 9.5797825e-01, 9.5822036e-01, + 9.5846248e-01, 9.5870471e-01, 9.5894700e-01, 9.5918930e-01, + 9.5943171e-01, 9.5967412e-01, 9.5991665e-01, 9.6015918e-01, + 9.6040183e-01, 9.6064448e-01, 9.6088719e-01, 9.6112996e-01, + 9.6137279e-01, 9.6161568e-01, 9.6185863e-01, 9.6210164e-01, + 9.6234471e-01, 9.6258783e-01, 9.6283102e-01, 9.6307427e-01, + 9.6331757e-01, 9.6356088e-01, 9.6380430e-01, 9.6404779e-01, + 9.6429127e-01, 9.6453488e-01, 9.6477848e-01, 9.6502221e-01, + 9.6526593e-01, 9.6550977e-01, 9.6575361e-01, 9.6599752e-01, + 9.6624154e-01, 9.6648556e-01, 9.6672964e-01, 9.6697378e-01, + 9.6721798e-01, 9.6746230e-01, 9.6770662e-01, 9.6795100e-01, + 9.6819544e-01, 9.6843994e-01, 9.6868449e-01, 9.6892911e-01, + 9.6917379e-01, 9.6941847e-01, 9.6966326e-01, 9.6990812e-01, + 9.7015303e-01, 9.7039801e-01, 9.7064304e-01, 9.7088808e-01, + 9.7113323e-01, 9.7137845e-01, 9.7162366e-01, 9.7186899e-01, + 9.7211438e-01, 9.7235978e-01, 9.7260529e-01, 9.7285086e-01, + 9.7309643e-01, 9.7334212e-01, 9.7358781e-01, 9.7383362e-01, + 9.7407943e-01, 9.7432536e-01, 9.7457129e-01, 9.7481734e-01, + 9.7506338e-01, 9.7530955e-01, 9.7555572e-01, 9.7580200e-01, + 9.7604829e-01, 9.7629470e-01, 9.7654110e-01, 9.7678757e-01, + 9.7703415e-01, 9.7728074e-01, 9.7752744e-01, 9.7777414e-01, + 9.7802097e-01, 9.7826779e-01, 9.7851467e-01, 9.7876167e-01, + 9.7900867e-01, 9.7925580e-01, 9.7950292e-01, 9.7975016e-01, + 9.7999740e-01, 9.8024470e-01, 9.8049212e-01, 9.8073953e-01, + 9.8098707e-01, 9.8123461e-01, 9.8148227e-01, 9.8172992e-01, + 9.8197770e-01, 9.8222548e-01, 9.8247337e-01, 9.8272127e-01, + 9.8296928e-01, 9.8321730e-01, 9.8346543e-01, 9.8371363e-01, + 9.8396182e-01, 9.8421013e-01, 9.8445845e-01, 9.8470688e-01, + 9.8495537e-01, 9.8520392e-01, 9.8545247e-01, 9.8570114e-01, + 9.8594987e-01, 9.8619866e-01, 9.8644745e-01, 9.8669636e-01, + 9.8694533e-01, 9.8719436e-01, 9.8744345e-01, 9.8769259e-01, + 9.8794180e-01, 9.8819107e-01, 9.8844039e-01, 9.8868978e-01, + 9.8893923e-01, 9.8918873e-01, 9.8943830e-01, 9.8968798e-01, + 9.8993766e-01, 9.9018741e-01, 9.9043721e-01, 9.9068713e-01, + 9.9093705e-01, 9.9118710e-01, 9.9143714e-01, 9.9168730e-01, + 9.9193746e-01, 9.9218774e-01, 9.9243802e-01, 9.9268842e-01, + 9.9293888e-01, 9.9318939e-01, 9.9343991e-01, 9.9369055e-01, + 9.9394125e-01, 9.9419200e-01, 9.9444282e-01, 9.9469370e-01, + 9.9494463e-01, 9.9519563e-01, 9.9544674e-01, 9.9569786e-01, + 9.9594903e-01, 9.9620032e-01, 9.9645162e-01, 9.9670297e-01, + 9.9695444e-01, 9.9720597e-01, 9.9745750e-01, 9.9770916e-01, + 9.9796087e-01, 9.9821264e-01, 9.9846447e-01, 9.9871629e-01, + 9.9896824e-01, 9.9922031e-01, 9.9947238e-01, 9.9972451e-01, + 9.9997669e-01, 1.0002290e+00, 1.0004814e+00, 1.0007337e+00, + 1.0009862e+00, 1.0012387e+00, 1.0014913e+00, 1.0017439e+00, + 1.0019966e+00, 1.0022494e+00, 1.0025022e+00, 1.0027552e+00, + 1.0030081e+00, 1.0032612e+00, 1.0035143e+00, 1.0037675e+00, + 1.0040207e+00, 1.0042740e+00, 1.0045273e+00, 1.0047808e+00, + 1.0050342e+00, 1.0052878e+00, 1.0055413e+00, 1.0057951e+00, + 1.0060488e+00, 1.0063026e+00, 1.0065565e+00, 1.0068104e+00, + 1.0070645e+00, 1.0073185e+00, 1.0075727e+00, 1.0078268e+00, + 1.0080811e+00, 1.0083355e+00, 1.0085899e+00, 1.0088443e+00, + 1.0090988e+00, 1.0093534e+00, 1.0096080e+00, 1.0098628e+00, + 1.0101175e+00, 1.0103724e+00, 1.0106274e+00, 1.0108824e+00, + 1.0111374e+00, 1.0113925e+00, 1.0116477e+00, 1.0119029e+00, + 1.0121583e+00, 1.0124136e+00, 1.0126691e+00, 1.0129246e+00, + 1.0131801e+00, 1.0134358e+00, 1.0136915e+00, 1.0139472e+00, + 1.0142031e+00, 1.0144590e+00, 1.0147150e+00, 1.0149710e+00, + 1.0152272e+00, 1.0154834e+00, 1.0157396e+00, 1.0159959e+00, + 1.0162523e+00, 1.0165087e+00, 1.0167652e+00, 1.0170218e+00, + 1.0172784e+00, 1.0175351e+00, 1.0177919e+00, 1.0180488e+00, + 1.0183057e+00, 1.0185627e+00, 1.0188197e+00, 1.0190768e+00, + 1.0193340e+00, 1.0195912e+00, 1.0198486e+00, 1.0201060e+00, + 1.0203633e+00, 1.0206209e+00, 1.0208784e+00, 1.0211362e+00, + 1.0213939e+00, 1.0216516e+00, 1.0219095e+00, 1.0221674e+00, + 1.0224254e+00, 1.0226835e+00, 1.0229416e+00, 1.0231998e+00, + 1.0234581e+00, 1.0237164e+00, 1.0239748e+00, 1.0242333e+00, + 1.0244918e+00, 1.0247505e+00, 1.0250092e+00, 1.0252678e+00, + 1.0255266e+00, 1.0257856e+00, 1.0260445e+00, 1.0263035e+00, + 1.0265626e+00, 1.0268217e+00, 1.0270810e+00, 1.0273403e+00, + 1.0275997e+00, 1.0278591e+00, 1.0281186e+00, 1.0283781e+00, + 1.0286378e+00, 1.0288975e+00, 1.0291573e+00, 1.0294172e+00, + 1.0296770e+00, 1.0299370e+00, 1.0301971e+00, 1.0304573e+00, + 1.0307175e+00, 1.0309777e+00, 1.0312381e+00, 1.0314984e+00, + 1.0317589e+00, 1.0320195e+00, 1.0322801e+00, 1.0325408e+00, + 1.0328015e+00, 1.0330623e+00, 1.0333233e+00, 1.0335842e+00, + 1.0338453e+00, 1.0341064e+00, 1.0343676e+00, 1.0346289e+00, + 1.0348902e+00, 1.0351515e+00, 1.0354130e+00, 1.0356746e+00, + 1.0359361e+00, 1.0361978e+00, 1.0364596e+00, 1.0367213e+00, + 1.0369833e+00, 1.0372453e+00, 1.0375073e+00, 1.0377693e+00, + 1.0380316e+00, 1.0382938e+00, 1.0385561e+00, 1.0388185e+00, + 1.0390810e+00, 1.0393435e+00, 1.0396061e+00, 1.0398687e+00, + 1.0401314e+00, 1.0403943e+00, 1.0406572e+00, 1.0409201e+00, + 1.0411832e+00, 1.0414463e+00, 1.0417095e+00, 1.0419728e+00, + 1.0422361e+00, 1.0424994e+00, 1.0427629e+00, 1.0430264e+00, + 1.0432900e+00, 1.0435537e+00, 1.0438175e+00, 1.0440813e+00, + 1.0443453e+00, 1.0446092e+00, 1.0448732e+00, 1.0451374e+00, + 1.0454016e+00, 1.0456659e+00, 1.0459301e+00, 1.0461946e+00, + 1.0464591e+00, 1.0467236e+00, 1.0469882e+00, 1.0472530e+00, + 1.0475178e+00, 1.0477827e+00, 1.0480475e+00, 1.0483125e+00, + 1.0485777e+00, 1.0488428e+00, 1.0491080e+00, 1.0493733e+00, + 1.0496386e+00, 1.0499041e+00, 1.0501696e+00, 1.0504352e+00, + 1.0507009e+00, 1.0509666e+00, 1.0512325e+00, 1.0514983e+00, + 1.0517642e+00, 1.0520303e+00, 1.0522964e+00, 1.0525626e+00, + 1.0528289e+00, 1.0530952e+00, 1.0533617e+00, 1.0536281e+00, + 1.0538946e+00, 1.0541613e+00, 1.0544280e+00, 1.0546948e+00, + 1.0549617e+00, 1.0552286e+00, 1.0554956e+00, 1.0557626e+00, + 1.0560298e+00, 1.0562971e+00, 1.0565643e+00, 1.0568317e+00, + 1.0570992e+00, 1.0573667e+00, 1.0576344e+00, 1.0579021e+00, + 1.0581698e+00, 1.0584377e+00, 1.0587056e+00, 1.0589736e+00, + 1.0592417e+00, 1.0595098e+00, 1.0597780e+00, 1.0600463e+00, + 1.0603147e+00, 1.0605831e+00, 1.0608517e+00, 1.0611203e+00, + 1.0613890e+00, 1.0616577e+00, 1.0619265e+00, 1.0621954e+00, + 1.0624644e+00, 1.0627335e+00, 1.0630026e+00, 1.0632719e+00, + 1.0635412e+00, 1.0638105e+00, 1.0640800e+00, 1.0643495e+00, + 1.0646191e+00, 1.0648887e+00, 1.0651585e+00, 1.0654284e+00, + 1.0656983e+00, 1.0659683e+00, 1.0662383e+00, 1.0665085e+00, + 1.0667787e+00, 1.0670490e+00, 1.0673194e+00, 1.0675899e+00, + 1.0678604e+00, 1.0681310e+00, 1.0684017e+00, 1.0686724e+00, + 1.0689433e+00, 1.0692142e+00, 1.0694852e+00, 1.0697563e+00, + 1.0700275e+00, 1.0702987e+00, 1.0705701e+00, 1.0708414e+00, + 1.0711130e+00, 1.0713844e+00, 1.0716561e+00, 1.0719278e+00, + 1.0721996e+00, 1.0724715e+00, 1.0727434e+00, 1.0730155e+00, + 1.0732876e+00, 1.0735598e+00, 1.0738320e+00, 1.0741044e+00, + 1.0743768e+00, 1.0746493e+00, 1.0749220e+00, 1.0751946e+00, + 1.0754673e+00, 1.0757402e+00, 1.0760131e+00, 1.0762861e+00, + 1.0765592e+00, 1.0768323e+00, 1.0771055e+00, 1.0773789e+00, + 1.0776522e+00, 1.0779257e+00, 1.0781993e+00, 1.0784730e+00, + 1.0787467e+00, 1.0790205e+00, 1.0792943e+00, 1.0795683e+00, + 1.0798423e+00, 1.0801164e+00, 1.0803907e+00, 1.0806649e+00, + 1.0809393e+00, 1.0812137e+00, 1.0814883e+00, 1.0817629e+00, + 1.0820376e+00, 1.0823123e+00, 1.0825871e+00, 1.0828621e+00, + 1.0831372e+00, 1.0834122e+00, 1.0836874e+00, 1.0839627e+00, + 1.0842381e+00, 1.0845134e+00, 1.0847889e+00, 1.0850645e+00, + 1.0853403e+00, 1.0856160e+00, 1.0858918e+00, 1.0861677e+00, + 1.0864438e+00, 1.0867199e+00, 1.0869960e+00, 1.0872723e+00, + 1.0875486e+00, 1.0878251e+00, 1.0881015e+00, 1.0883781e+00, + 1.0886548e+00, 1.0889316e+00, 1.0892084e+00, 1.0894853e+00, + 1.0897623e+00, 1.0900394e+00, 1.0903165e+00, 1.0905938e+00, + 1.0908711e+00, 1.0911485e+00, 1.0914260e+00, 1.0917037e+00, + 1.0919813e+00, 1.0922590e+00, 1.0925369e+00, 1.0928148e+00, + 1.0930929e+00, 1.0933709e+00, 1.0936491e+00, 1.0939274e+00, + 1.0942057e+00, 1.0944842e+00, 1.0947627e+00, 1.0950413e+00, + 1.0953200e+00, 1.0955988e+00, 1.0958776e+00, 1.0961566e+00, + 1.0964357e+00, 1.0967147e+00, 1.0969939e+00, 1.0972732e+00, + 1.0975525e+00, 1.0978321e+00, 1.0981116e+00, 1.0983912e+00, + 1.0986710e+00, 1.0989507e+00, 1.0992306e+00, 1.0995106e+00, + 1.0997907e+00, 1.1000708e+00, 1.1003511e+00, 1.1006314e+00, + 1.1009117e+00, 1.1011922e+00, 1.1014729e+00, 1.1017535e+00, + 1.1020342e+00, 1.1023151e+00, 1.1025960e+00, 1.1028770e+00, + 1.1031581e+00, 1.1034393e+00, 1.1037205e+00, 1.1040020e+00, + 1.1042835e+00, 1.1045649e+00, 1.1048466e+00, 1.1051283e+00, + 1.1054101e+00, 1.1056920e+00, 1.1059740e+00, 1.1062560e+00, + 1.1065382e+00, 1.1068205e+00, 1.1071028e+00, 1.1073852e+00, + 1.1076677e+00, 1.1079502e+00, 1.1082330e+00, 1.1085157e+00, + 1.1087985e+00, 1.1090815e+00, 1.1093645e+00, 1.1096476e+00, + 1.1099309e+00, 1.1102142e+00, 1.1104976e+00, 1.1107811e+00, + 1.1110647e+00, 1.1113483e+00, 1.1116320e+00, 1.1119158e+00, + 1.1121998e+00, 1.1124839e+00, 1.1127679e+00, 1.1130521e+00, + 1.1133364e+00, 1.1136208e+00, 1.1139053e+00, 1.1141899e+00, + 1.1144745e+00, 1.1147592e+00, 1.1150440e+00, 1.1153290e+00, + 1.1156139e+00, 1.1158991e+00, 1.1161842e+00, 1.1164695e+00, + 1.1167549e+00, 1.1170404e+00, 1.1173259e+00, 1.1176116e+00, + 1.1178974e+00, 1.1181831e+00, 1.1184691e+00, 1.1187551e+00, + 1.1190412e+00, 1.1193274e+00, 1.1196136e+00, 1.1199001e+00, + 1.1201866e+00, 1.1204731e+00, 1.1207597e+00, 1.1210465e+00, + 1.1213334e+00, 1.1216203e+00, 1.1219074e+00, 1.1221944e+00, + 1.1224816e+00, 1.1227689e+00, 1.1230563e+00, 1.1233438e+00, + 1.1236314e+00, 1.1239190e+00, 1.1242068e+00, 1.1244947e+00, + 1.1247827e+00, 1.1250707e+00, 1.1253588e+00, 1.1256471e+00, + 1.1259354e+00, 1.1262238e+00, 1.1265123e+00, 1.1268009e+00, + 1.1270896e+00, 1.1273785e+00, 1.1276673e+00, 1.1279563e+00, + 1.1282454e+00, 1.1285346e+00, 1.1288238e+00, 1.1291132e+00, + 1.1294026e+00, 1.1296922e+00, 1.1299818e+00, 1.1302716e+00, + 1.1305614e+00, 1.1308513e+00, 1.1311413e+00, 1.1314315e+00, + 1.1317216e+00, 1.1320120e+00, 1.1323024e+00, 1.1325929e+00, + 1.1328834e+00, 1.1331742e+00, 1.1334649e+00, 1.1337558e+00, + 1.1340468e+00, 1.1343379e+00, 1.1346291e+00, 1.1349204e+00, + 1.1352117e+00, 1.1355032e+00, 1.1357948e+00, 1.1360863e+00, + 1.1363782e+00, 1.1366700e+00, 1.1369619e+00, 1.1372540e+00, + 1.1375461e+00, 1.1378384e+00, 1.1381307e+00, 1.1384231e+00, + 1.1387156e+00, 1.1390083e+00, 1.1393009e+00, 1.1395938e+00, + 1.1398867e+00, 1.1401798e+00, 1.1404729e+00, 1.1407660e+00, + 1.1410594e+00, 1.1413528e+00, 1.1416463e+00, 1.1419399e+00, + 1.1422336e+00, 1.1425273e+00, 1.1428213e+00, 1.1431153e+00, + 1.1434094e+00, 1.1437036e+00, 1.1439979e+00, 1.1442922e+00, + 1.1445868e+00, 1.1448814e+00, 1.1451761e+00, 1.1454709e+00, + 1.1457658e+00, 1.1460607e+00, 1.1463559e+00, 1.1466510e+00, + 1.1469463e+00, 1.1472417e+00, 1.1475372e+00, 1.1478328e+00, + 1.1481285e+00, 1.1484243e+00, 1.1487201e+00, 1.1490161e+00, + 1.1493123e+00, 1.1496085e+00, 1.1499047e+00, 1.1502011e+00, + 1.1504977e+00, 1.1507943e+00, 1.1510910e+00, 1.1513877e+00, + 1.1516846e+00, 1.1519816e+00, 1.1522788e+00, 1.1525760e+00, + 1.1528733e+00, 1.1531707e+00, 1.1534683e+00, 1.1537658e+00, + 1.1540636e+00, 1.1543614e+00, 1.1546593e+00, 1.1549573e+00, + 1.1552554e+00, 1.1555537e+00, 1.1558520e+00, 1.1561505e+00, + 1.1564490e+00, 1.1567476e+00, 1.1570463e+00, 1.1573452e+00, + 1.1576442e+00, 1.1579432e+00, 1.1582423e+00, 1.1585417e+00, + 1.1588410e+00, 1.1591405e+00, 1.1594400e+00, 1.1597397e+00, + 1.1600395e+00, 1.1603394e+00, 1.1606394e+00, 1.1609395e+00, + 1.1612397e+00, 1.1615400e+00, 1.1618404e+00, 1.1621410e+00, + 1.1624415e+00, 1.1627423e+00, 1.1630431e+00, 1.1633440e+00, + 1.1636450e+00, 1.1639463e+00, 1.1642475e+00, 1.1645489e+00, + 1.1648504e+00, 1.1651518e+00, 1.1654536e+00, 1.1657554e+00, + 1.1660572e+00, 1.1663592e+00, 1.1666613e+00, 1.1669636e+00, + 1.1672659e+00, 1.1675682e+00, 1.1678708e+00, 1.1681734e+00, + 1.1684762e+00, 1.1687790e+00, 1.1690819e+00, 1.1693851e+00, + 1.1696882e+00, 1.1699915e+00, 1.1702949e+00, 1.1705984e+00, + 1.1709020e+00, 1.1712056e+00, 1.1715095e+00, 1.1718134e+00, + 1.1721175e+00, 1.1724216e+00, 1.1727258e+00, 1.1730303e+00, + 1.1733347e+00, 1.1736393e+00, 1.1739439e+00, 1.1742487e+00, + 1.1745536e+00, 1.1748587e+00, 1.1751637e+00, 1.1754690e+00, + 1.1757743e+00, 1.1760798e+00, 1.1763854e+00, 1.1766911e+00, + 1.1769968e+00, 1.1773027e+00, 1.1776087e+00, 1.1779149e+00, + 1.1782210e+00, 1.1785274e+00, 1.1788338e+00, 1.1791403e+00, + 1.1794471e+00, 1.1797538e+00, 1.1800607e+00, 1.1803677e+00, + 1.1806748e+00, 1.1809820e+00, 1.1812893e+00, 1.1815968e+00, + 1.1819043e+00, 1.1822120e+00, 1.1825198e+00, 1.1828277e+00, + 1.1831357e+00, 1.1834438e+00, 1.1837521e+00, 1.1840603e+00, + 1.1843688e+00, 1.1846774e+00, 1.1849861e+00, 1.1852949e+00, + 1.1856037e+00, 1.1859128e+00, 1.1862220e+00, 1.1865312e+00, + 1.1868405e+00, 1.1871500e+00, 1.1874596e+00, 1.1877693e+00, + 1.1880791e+00, 1.1883891e+00, 1.1886991e+00, 1.1890092e+00, + 1.1893195e+00, 1.1896299e+00, 1.1899403e+00, 1.1902510e+00, + 1.1905618e+00, 1.1908726e+00, 1.1911836e+00, 1.1914946e+00, + 1.1918058e+00, 1.1921171e+00, 1.1924285e+00, 1.1927401e+00, + 1.1930517e+00, 1.1933634e+00, 1.1936754e+00, 1.1939874e+00, + 1.1942995e+00, 1.1946117e+00, 1.1949241e+00, 1.1952366e+00, + 1.1955491e+00, 1.1958618e+00, 1.1961746e+00, 1.1964875e+00, + 1.1968006e+00, 1.1971138e+00, 1.1974270e+00, 1.1977404e+00, + 1.1980540e+00, 1.1983676e+00, 1.1986814e+00, 1.1989952e+00, + 1.1993092e+00, 1.1996233e+00, 1.1999376e+00, 1.2002519e+00, + 1.2005664e+00, 1.2008810e+00, 1.2011957e+00, 1.2015105e+00, + 1.2018255e+00, 1.2021406e+00, 1.2024558e+00, 1.2027711e+00, + 1.2030865e+00, 1.2034019e+00, 1.2037176e+00, 1.2040334e+00, + 1.2043493e+00, 1.2046653e+00, 1.2049814e+00, 1.2052977e+00, + 1.2056141e+00, 1.2059306e+00, 1.2062472e+00, 1.2065639e+00, + 1.2068808e+00, 1.2071979e+00, 1.2075150e+00, 1.2078322e+00, + 1.2081496e+00, 1.2084670e+00, 1.2087846e+00, 1.2091023e+00, + 1.2094202e+00, 1.2097381e+00, 1.2100562e+00, 1.2103744e+00, + 1.2106928e+00, 1.2110112e+00, 1.2113298e+00, 1.2116485e+00, + 1.2119672e+00, 1.2122862e+00, 1.2126052e+00, 1.2129245e+00, + 1.2132438e+00, 1.2135632e+00, 1.2138828e+00, 1.2142025e+00, + 1.2145222e+00, 1.2148422e+00, 1.2151623e+00, 1.2154825e+00, + 1.2158028e+00, 1.2161232e+00, 1.2164438e+00, 1.2167645e+00, + 1.2170852e+00, 1.2174062e+00, 1.2177273e+00, 1.2180485e+00, + 1.2183697e+00, 1.2186912e+00, 1.2190127e+00, 1.2193345e+00, + 1.2196562e+00, 1.2199782e+00, 1.2203002e+00, 1.2206224e+00, + 1.2209448e+00, 1.2212672e+00, 1.2215898e+00, 1.2219125e+00, + 1.2222353e+00, 1.2225583e+00, 1.2228813e+00, 1.2232046e+00, + 1.2235279e+00, 1.2238513e+00, 1.2241750e+00, 1.2244986e+00, + 1.2248225e+00, 1.2251465e+00, 1.2254707e+00, 1.2257949e+00, + 1.2261193e+00, 1.2264438e+00, 1.2267684e+00, 1.2270931e+00, + 1.2274179e+00, 1.2277430e+00, 1.2280681e+00, 1.2283934e+00, + 1.2287189e+00, 1.2290443e+00, 1.2293700e+00, 1.2296958e+00, + 1.2300217e+00, 1.2303478e+00, 1.2306740e+00, 1.2310003e+00, + 1.2313267e+00, 1.2316533e+00, 1.2319801e+00, 1.2323068e+00, + 1.2326338e+00, 1.2329609e+00, 1.2332882e+00, 1.2336155e+00, + 1.2339431e+00, 1.2342707e+00, 1.2345985e+00, 1.2349263e+00, + 1.2352544e+00, 1.2355826e+00, 1.2359109e+00, 1.2362393e+00, + 1.2365679e+00, 1.2368965e+00, 1.2372254e+00, 1.2375543e+00, + 1.2378834e+00, 1.2382127e+00, 1.2385421e+00, 1.2388716e+00, + 1.2392012e+00, 1.2395309e+00, 1.2398609e+00, 1.2401909e+00, + 1.2405211e+00, 1.2408514e+00, 1.2411819e+00, 1.2415124e+00, + 1.2418431e+00, 1.2421740e+00, 1.2425050e+00, 1.2428361e+00, + 1.2431674e+00, 1.2434988e+00, 1.2438303e+00, 1.2441620e+00, + 1.2444938e+00, 1.2448257e+00, 1.2451578e+00, 1.2454901e+00, + 1.2458224e+00, 1.2461549e+00, 1.2464876e+00, 1.2468203e+00, + 1.2471533e+00, 1.2474864e+00, 1.2478195e+00, 1.2481529e+00, + 1.2484863e+00, 1.2488198e+00, 1.2491536e+00, 1.2494875e+00, + 1.2498215e+00, 1.2501557e+00, 1.2504900e+00, 1.2508245e+00, + 1.2511591e+00, 1.2514937e+00, 1.2518286e+00, 1.2521636e+00, + 1.2524987e+00, 1.2528341e+00, 1.2531694e+00, 1.2535050e+00, + 1.2538407e+00, 1.2541766e+00, 1.2545125e+00, 1.2548487e+00, + 1.2551850e+00, 1.2555214e+00, 1.2558579e+00, 1.2561946e+00, + 1.2565315e+00, 1.2568685e+00, 1.2572056e+00, 1.2575428e+00, + 1.2578802e+00, 1.2582178e+00, 1.2585555e+00, 1.2588934e+00, + 1.2592313e+00, 1.2595695e+00, 1.2599077e+00, 1.2602462e+00, + 1.2605847e+00, 1.2609235e+00, 1.2612623e+00, 1.2616013e+00, + 1.2619405e+00, 1.2622797e+00, 1.2626191e+00, 1.2629588e+00, + 1.2632985e+00, 1.2636384e+00, 1.2639784e+00, 1.2643185e+00, + 1.2646588e+00, 1.2649993e+00, 1.2653399e+00, 1.2656807e+00, + 1.2660215e+00, 1.2663625e+00, 1.2667037e+00, 1.2670451e+00, + 1.2673866e+00, 1.2677282e+00, 1.2680700e+00, 1.2684120e+00, + 1.2687540e+00, 1.2690963e+00, 1.2694386e+00, 1.2697811e+00, + 1.2701238e+00, 1.2704667e+00, 1.2708097e+00, 1.2711527e+00, + 1.2714961e+00, 1.2718394e+00, 1.2721829e+00, 1.2725267e+00, + 1.2728705e+00, 1.2732146e+00, 1.2735587e+00, 1.2739031e+00, + 1.2742475e+00, 1.2745922e+00, 1.2749370e+00, 1.2752819e+00, + 1.2756270e+00, 1.2759722e+00, 1.2763176e+00, 1.2766632e+00, + 1.2770089e+00, 1.2773547e+00, 1.2777007e+00, 1.2780468e+00, + 1.2783931e+00, 1.2787396e+00, 1.2790862e+00, 1.2794330e+00, + 1.2797799e+00, 1.2801269e+00, 1.2804742e+00, 1.2808216e+00, + 1.2811691e+00, 1.2815168e+00, 1.2818646e+00, 1.2822126e+00, + 1.2825608e+00, 1.2829090e+00, 1.2832576e+00, 1.2836062e+00, + 1.2839550e+00, 1.2843039e+00, 1.2846529e+00, 1.2850022e+00, + 1.2853516e+00, 1.2857012e+00, 1.2860509e+00, 1.2864008e+00, + 1.2867508e+00, 1.2871010e+00, 1.2874514e+00, 1.2878019e+00, + 1.2881526e+00, 1.2885034e+00, 1.2888544e+00, 1.2892054e+00, + 1.2895567e+00, 1.2899083e+00, 1.2902598e+00, 1.2906116e+00, + 1.2909635e+00, 1.2913157e+00, 1.2916679e+00, 1.2920203e+00, + 1.2923729e+00, 1.2927257e+00, 1.2930785e+00, 1.2934316e+00, + 1.2937849e+00, 1.2941382e+00, 1.2944918e+00, 1.2948455e+00, + 1.2951994e+00, 1.2955534e+00, 1.2959076e+00, 1.2962619e+00, + 1.2966164e+00, 1.2969712e+00, 1.2973260e+00, 1.2976810e+00, + 1.2980362e+00, 1.2983915e+00, 1.2987471e+00, 1.2991027e+00, + 1.2994585e+00, 1.2998145e+00, 1.3001707e+00, 1.3005270e+00, + 1.3008835e+00, 1.3012401e+00, 1.3015970e+00, 1.3019539e+00, + 1.3023111e+00, 1.3026685e+00, 1.3030258e+00, 1.3033836e+00, + 1.3037413e+00, 1.3040993e+00, 1.3044575e+00, 1.3048158e+00, + 1.3051744e+00, 1.3055329e+00, 1.3058918e+00, 1.3062508e+00, + 1.3066100e+00, 1.3069693e+00, 1.3073288e+00, 1.3076885e+00, + 1.3080482e+00, 1.3084083e+00, 1.3087685e+00, 1.3091288e+00, + 1.3094894e+00, 1.3098500e+00, 1.3102108e+00, 1.3105719e+00, + 1.3109331e+00, 1.3112944e+00, 1.3116560e+00, 1.3120177e+00, + 1.3123796e+00, 1.3127416e+00, 1.3131039e+00, 1.3134663e+00, + 1.3138288e+00, 1.3141916e+00, 1.3145545e+00, 1.3149176e+00, + 1.3152809e+00, 1.3156443e+00, 1.3160079e+00, 1.3163717e+00, + 1.3167356e+00, 1.3170998e+00, 1.3174641e+00, 1.3178285e+00, + 1.3181932e+00, 1.3185581e+00, 1.3189231e+00, 1.3192883e+00, + 1.3196536e+00, 1.3200191e+00, 1.3203849e+00, 1.3207508e+00, + 1.3211168e+00, 1.3214831e+00, 1.3218495e+00, 1.3222162e+00, + 1.3225830e+00, 1.3229499e+00, 1.3233171e+00, 1.3236843e+00, + 1.3240519e+00, 1.3244195e+00, 1.3247874e+00, 1.3251554e+00, + 1.3255236e+00, 1.3258920e+00, 1.3262606e+00, 1.3266293e+00, + 1.3269982e+00, 1.3273673e+00, 1.3277366e+00, 1.3281060e+00, + 1.3284757e+00, 1.3288456e+00, 1.3292155e+00, 1.3295858e+00, + 1.3299562e+00, 1.3303267e+00, 1.3306974e+00, 1.3310684e+00, + 1.3314395e+00, 1.3318108e+00, 1.3321823e+00, 1.3325540e+00, + 1.3329258e+00, 1.3332978e+00, 1.3336700e+00, 1.3340424e+00, + 1.3344151e+00, 1.3347878e+00, 1.3351607e+00, 1.3355340e+00, + 1.3359072e+00, 1.3362808e+00, 1.3366544e+00, 1.3370284e+00, + 1.3374025e+00, 1.3377767e+00, 1.3381511e+00, 1.3385258e+00, + 1.3389006e+00, 1.3392756e+00, 1.3396509e+00, 1.3400263e+00, + 1.3404018e+00, 1.3407776e+00, 1.3411535e+00, 1.3415297e+00, + 1.3419061e+00, 1.3422825e+00, 1.3426592e+00, 1.3430362e+00, + 1.3434132e+00, 1.3437905e+00, 1.3441681e+00, 1.3445457e+00, + 1.3449236e+00, 1.3453016e+00, 1.3456799e+00, 1.3460584e+00, + 1.3464370e+00, 1.3468158e+00, 1.3471949e+00, 1.3475741e+00, + 1.3479534e+00, 1.3483331e+00, 1.3487129e+00, 1.3490928e+00, + 1.3494731e+00, 1.3498535e+00, 1.3502340e+00, 1.3506148e+00, + 1.3509958e+00, 1.3513770e+00, 1.3517584e+00, 1.3521399e+00, + 1.3525217e+00, 1.3529036e+00, 1.3532858e+00, 1.3536681e+00, + 1.3540506e+00, 1.3544334e+00, 1.3548163e+00, 1.3551995e+00, + 1.3555828e+00, 1.3559663e+00, 1.3563502e+00, 1.3567340e+00, + 1.3571182e+00, 1.3575026e+00, 1.3578871e+00, 1.3582718e+00, + 1.3586568e+00, 1.3590419e+00, 1.3594273e+00, 1.3598129e+00, + 1.3601986e+00, 1.3605845e+00, 1.3609707e+00, 1.3613571e+00, + 1.3617436e+00, 1.3621304e+00, 1.3625174e+00, 1.3629045e+00, + 1.3632919e+00, 1.3636795e+00, 1.3640673e+00, 1.3644553e+00, + 1.3648435e+00, 1.3652319e+00, 1.3656205e+00, 1.3660094e+00, + 1.3663983e+00, 1.3667876e+00, 1.3671770e+00, 1.3675667e+00, + 1.3679565e+00, 1.3683466e+00, 1.3687369e+00, 1.3691274e+00, + 1.3695180e+00, 1.3699089e+00, 1.3703001e+00, 1.3706913e+00, + 1.3710829e+00, 1.3714746e+00, 1.3718666e+00, 1.3722587e+00, + 1.3726511e+00, 1.3730437e+00, 1.3734365e+00, 1.3738295e+00, + 1.3742226e+00, 1.3746161e+00, 1.3750098e+00, 1.3754036e+00, + 1.3757976e+00, 1.3761920e+00, 1.3765864e+00, 1.3769811e+00, + 1.3773761e+00, 1.3777713e+00, 1.3781666e+00, 1.3785622e+00, + 1.3789580e+00, 1.3793540e+00, 1.3797501e+00, 1.3801466e+00, + 1.3805432e+00, 1.3809402e+00, 1.3813373e+00, 1.3817345e+00, + 1.3821321e+00, 1.3825299e+00, 1.3829278e+00, 1.3833259e+00, + 1.3837243e+00, 1.3841230e+00, 1.3845218e+00, 1.3849208e+00, + 1.3853202e+00, 1.3857197e+00, 1.3861194e+00, 1.3865193e+00, + 1.3869195e+00, 1.3873199e+00, 1.3877205e+00, 1.3881214e+00, + 1.3885224e+00, 1.3889236e+00, 1.3893251e+00, 1.3897269e+00, + 1.3901289e+00, 1.3905311e+00, 1.3909335e+00, 1.3913361e+00, + 1.3917389e+00, 1.3921421e+00, 1.3925453e+00, 1.3929489e+00, + 1.3933526e+00, 1.3937566e+00, 1.3941609e+00, 1.3945652e+00, + 1.3949699e+00, 1.3953749e+00, 1.3957800e+00, 1.3961853e+00, + 1.3965909e+00, 1.3969967e+00, 1.3974028e+00, 1.3978090e+00, + 1.3982155e+00, 1.3986223e+00, 1.3990293e+00, 1.3994365e+00, + 1.3998439e+00, 1.4002516e+00, 1.4006594e+00, 1.4010676e+00, + 1.4014760e+00, 1.4018846e+00, 1.4022934e+00, 1.4027026e+00, + 1.4031118e+00, 1.4035214e+00, 1.4039311e+00, 1.4043411e+00, + 1.4047514e+00, 1.4051619e+00, 1.4055727e+00, 1.4059836e+00, + 1.4063947e+00, 1.4068062e+00, 1.4072179e+00, 1.4076297e+00, + 1.4080420e+00, 1.4084543e+00, 1.4088670e+00, 1.4092798e+00, + 1.4096929e+00, 1.4101063e+00, 1.4105198e+00, 1.4109337e+00, + 1.4113477e+00, 1.4117621e+00, 1.4121766e+00, 1.4125915e+00, + 1.4130065e+00, 1.4134218e+00, 1.4138373e+00, 1.4142531e+00, + 1.4146692e+00, 1.4150854e+00, 1.4155020e+00, 1.4159187e+00, + 1.4163357e+00, 1.4167529e+00, 1.4171704e+00, 1.4175881e+00, + 1.4180062e+00, 1.4184244e+00, 1.4188429e+00, 1.4192616e+00, + 1.4196806e+00, 1.4200999e+00, 1.4205194e+00, 1.4209391e+00, + 1.4213591e+00, 1.4217793e+00, 1.4221997e+00, 1.4226205e+00, + 1.4230415e+00, 1.4234627e+00, 1.4238843e+00, 1.4243060e+00, + 1.4247280e+00, 1.4251503e+00, 1.4255728e+00, 1.4259956e+00, + 1.4264185e+00, 1.4268419e+00, 1.4272654e+00, 1.4276892e+00, + 1.4281132e+00, 1.4285375e+00, 1.4289621e+00, 1.4293869e+00, + 1.4298120e+00, 1.4302373e+00, 1.4306629e+00, 1.4310887e+00, + 1.4315149e+00, 1.4319413e+00, 1.4323678e+00, 1.4327947e+00, + 1.4332219e+00, 1.4336493e+00, 1.4340770e+00, 1.4345050e+00, + 1.4349332e+00, 1.4353616e+00, 1.4357903e+00, 1.4362193e+00, + 1.4366486e+00, 1.4370781e+00, 1.4375079e+00, 1.4379380e+00, + 1.4383683e+00, 1.4387989e+00, 1.4392297e+00, 1.4396608e+00, + 1.4400922e+00, 1.4405239e+00, 1.4409558e+00, 1.4413880e+00, + 1.4418205e+00, 1.4422532e+00, 1.4426862e+00, 1.4431195e+00, + 1.4435530e+00, 1.4439869e+00, 1.4444209e+00, 1.4448553e+00, + 1.4452900e+00, 1.4457248e+00, 1.4461601e+00, 1.4465954e+00, + 1.4470313e+00, 1.4474672e+00, 1.4479035e+00, 1.4483401e+00, + 1.4487768e+00, 1.4492140e+00, 1.4496514e+00, 1.4500890e+00, + 1.4505270e+00, 1.4509652e+00, 1.4514037e+00, 1.4518424e+00, + 1.4522815e+00, 1.4527209e+00, 1.4531605e+00, 1.4536004e+00, + 1.4540405e+00, 1.4544810e+00, 1.4549217e+00, 1.4553628e+00, + 1.4558041e+00, 1.4562457e+00, 1.4566876e+00, 1.4571297e+00, + 1.4575722e+00, 1.4580150e+00, 1.4584579e+00, 1.4589013e+00, + 1.4593449e+00, 1.4597887e+00, 1.4602329e+00, 1.4606774e+00, + 1.4611222e+00, 1.4615672e+00, 1.4620124e+00, 1.4624581e+00, + 1.4629040e+00, 1.4633502e+00, 1.4637966e+00, 1.4642434e+00, + 1.4646906e+00, 1.4651378e+00, 1.4655856e+00, 1.4660335e+00, + 1.4664818e+00, 1.4669303e+00, 1.4673791e+00, 1.4678283e+00, + 1.4682777e+00, 1.4687275e+00, 1.4691775e+00, 1.4696277e+00, + 1.4700783e+00, 1.4705293e+00, 1.4709805e+00, 1.4714320e+00, + 1.4718839e+00, 1.4723359e+00, 1.4727883e+00, 1.4732411e+00, + 1.4736941e+00, 1.4741474e+00, 1.4746010e+00, 1.4750550e+00, + 1.4755093e+00, 1.4759638e+00, 1.4764186e+00, 1.4768738e+00, + 1.4773293e+00, 1.4777850e+00, 1.4782411e+00, 1.4786974e+00, + 1.4791541e+00, 1.4796112e+00, 1.4800684e+00, 1.4805261e+00, + 1.4809840e+00, 1.4814422e+00, 1.4819008e+00, 1.4823596e+00, + 1.4828188e+00, 1.4832783e+00, 1.4837381e+00, 1.4841982e+00, + 1.4846586e+00, 1.4851193e+00, 1.4855804e+00, 1.4860418e+00, + 1.4865035e+00, 1.4869655e+00, 1.4874278e+00, 1.4878905e+00, + 1.4883534e+00, 1.4888167e+00, 1.4892803e+00, 1.4897442e+00, + 1.4902085e+00, 1.4906731e+00, 1.4911379e+00, 1.4916031e+00, + 1.4920686e+00, 1.4925345e+00, 1.4930006e+00, 1.4934672e+00, + 1.4939340e+00, 1.4944011e+00, 1.4948686e+00, 1.4953364e+00, + 1.4958045e+00, 1.4962730e+00, 1.4967418e+00, 1.4972110e+00, + 1.4976804e+00, 1.4981502e+00, 1.4986203e+00, 1.4990907e+00, + 1.4995615e+00, 1.5000327e+00, 1.5005040e+00, 1.5009758e+00, + 1.5014479e+00, 1.5019203e+00, 1.5023931e+00, 1.5028663e+00, + 1.5033398e+00, 1.5038135e+00, 1.5042876e+00, 1.5047621e+00, + 1.5052369e+00, 1.5057120e+00, 1.5061876e+00, 1.5066633e+00, + 1.5071396e+00, 1.5076160e+00, 1.5080929e+00, 1.5085701e+00, + 1.5090476e+00, 1.5095254e+00, 1.5100037e+00, 1.5104823e+00, + 1.5109612e+00, 1.5114404e+00, 1.5119201e+00, 1.5124000e+00, + 1.5128803e+00, 1.5133610e+00, 1.5138420e+00, 1.5143234e+00, + 1.5148051e+00, 1.5152872e+00, 1.5157695e+00, 1.5162523e+00, + 1.5167354e+00, 1.5172189e+00, 1.5177027e+00, 1.5181869e+00, + 1.5186715e+00, 1.5191563e+00, 1.5196416e+00, 1.5201272e+00, + 1.5206132e+00, 1.5210996e+00, 1.5215862e+00, 1.5220733e+00, + 1.5225607e+00, 1.5230485e+00, 1.5235366e+00, 1.5240251e+00, + 1.5245140e+00, 1.5250032e+00, 1.5254928e+00, 1.5259827e+00, + 1.5264730e+00, 1.5269638e+00, 1.5274549e+00, 1.5279462e+00, + 1.5284381e+00, 1.5289302e+00, 1.5294228e+00, 1.5299157e+00, + 1.5304090e+00, 1.5309026e+00, 1.5313966e+00, 1.5318911e+00, + 1.5323858e+00, 1.5328810e+00, 1.5333766e+00, 1.5338725e+00, + 1.5343688e+00, 1.5348654e+00, 1.5353625e+00, 1.5358598e+00, + 1.5363576e+00, 1.5368558e+00, 1.5373545e+00, 1.5378534e+00, + 1.5383527e+00, 1.5388525e+00, 1.5393525e+00, 1.5398530e+00, + 1.5403539e+00, 1.5408552e+00, 1.5413568e+00, 1.5418588e+00, + 1.5423613e+00, 1.5428641e+00, 1.5433673e+00, 1.5438708e+00, + 1.5443748e+00, 1.5448792e+00, 1.5453839e+00, 1.5458891e+00, + 1.5463947e+00, 1.5469006e+00, 1.5474070e+00, 1.5479138e+00, + 1.5484209e+00, 1.5489284e+00, 1.5494363e+00, 1.5499448e+00, + 1.5504534e+00, 1.5509626e+00, 1.5514722e+00, 1.5519822e+00, + 1.5524925e+00, 1.5530032e+00, 1.5535144e+00, 1.5540260e+00, + 1.5545379e+00, 1.5550504e+00, 1.5555631e+00, 1.5560763e+00, + 1.5565900e+00, 1.5571040e+00, 1.5576184e+00, 1.5581332e+00, + 1.5586486e+00, 1.5591642e+00, 1.5596803e+00, 1.5601968e+00, + 1.5607138e+00, 1.5612311e+00, 1.5617489e+00, 1.5622671e+00, + 1.5627856e+00, 1.5633047e+00, 1.5638241e+00, 1.5643439e+00, + 1.5648643e+00, 1.5653850e+00, 1.5659060e+00, 1.5664277e+00, + 1.5669496e+00, 1.5674721e+00, 1.5679950e+00, 1.5685182e+00, + 1.5690418e+00, 1.5695660e+00, 1.5700905e+00, 1.5706155e+00, + 1.5711410e+00, 1.5716668e+00, 1.5721931e+00, 1.5727199e+00, + 1.5732471e+00, 1.5737747e+00, 1.5743027e+00, 1.5748312e+00, + 1.5753602e+00, 1.5758895e+00, 1.5764194e+00, 1.5769496e+00, + 1.5774803e+00, 1.5780114e+00, 1.5785429e+00, 1.5790750e+00, + 1.5796075e+00, 1.5801405e+00, 1.5806738e+00, 1.5812076e+00, + 1.5817419e+00, 1.5822767e+00, 1.5828118e+00, 1.5833474e+00, + 1.5838836e+00, 1.5844201e+00, 1.5849571e+00, 1.5854946e+00, + 1.5860325e+00, 1.5865709e+00, 1.5871097e+00, 1.5876490e+00, + 1.5881888e+00, 1.5887290e+00, 1.5892698e+00, 1.5898108e+00, + 1.5903525e+00, 1.5908946e+00, 1.5914371e+00, 1.5919802e+00, + 1.5925237e+00, 1.5930676e+00, 1.5936121e+00, 1.5941570e+00, + 1.5947024e+00, 1.5952482e+00, 1.5957946e+00, 1.5963414e+00, + 1.5968887e+00, 1.5974364e+00, 1.5979847e+00, 1.5985334e+00, + 1.5990826e+00, 1.5996323e+00, 1.6001825e+00, 1.6007332e+00, + 1.6012843e+00, 1.6018360e+00, 1.6023880e+00, 1.6029407e+00, + 1.6034938e+00, 1.6040474e+00, 1.6046015e+00, 1.6051561e+00, + 1.6057111e+00, 1.6062666e+00, 1.6068227e+00, 1.6073793e+00, + 1.6079364e+00, 1.6084939e+00, 1.6090519e+00, 1.6096106e+00, + 1.6101696e+00, 1.6107291e+00, 1.6112893e+00, 1.6118498e+00, + 1.6124109e+00, 1.6129725e+00, 1.6135346e+00, 1.6140972e+00, + 1.6146603e+00, 1.6152240e+00, 1.6157881e+00, 1.6163528e+00, + 1.6169180e+00, 1.6174836e+00, 1.6180499e+00, 1.6186166e+00, + 1.6191839e+00, 1.6197516e+00, 1.6203200e+00, 1.6208887e+00, + 1.6214581e+00, 1.6220280e+00, 1.6225984e+00, 1.6231693e+00, + 1.6237408e+00, 1.6243128e+00, 1.6248852e+00, 1.6254584e+00, + 1.6260319e+00, 1.6266060e+00, 1.6271807e+00, 1.6277559e+00, + 1.6283317e+00, 1.6289079e+00, 1.6294848e+00, 1.6300621e+00, + 1.6306400e+00, 1.6312184e+00, 1.6317974e+00, 1.6323770e+00, + 1.6329571e+00, 1.6335378e+00, 1.6341189e+00, 1.6347007e+00, + 1.6352830e+00, 1.6358658e+00, 1.6364492e+00, 1.6370332e+00, + 1.6376177e+00, 1.6382028e+00, 1.6387885e+00, 1.6393747e+00, + 1.6399615e+00, 1.6405488e+00, 1.6411368e+00, 1.6417252e+00, + 1.6423142e+00, 1.6429038e+00, 1.6434940e+00, 1.6440848e+00, + 1.6446761e+00, 1.6452681e+00, 1.6458606e+00, 1.6464536e+00, + 1.6470473e+00, 1.6476414e+00, 1.6482363e+00, 1.6488316e+00, + 1.6494277e+00, 1.6500242e+00, 1.6506214e+00, 1.6512191e+00, + 1.6518174e+00, 1.6524163e+00, 1.6530159e+00, 1.6536160e+00, + 1.6542166e+00, 1.6548179e+00, 1.6554199e+00, 1.6560224e+00, + 1.6566255e+00, 1.6572292e+00, 1.6578336e+00, 1.6584384e+00, + 1.6590440e+00, 1.6596501e+00, 1.6602569e+00, 1.6608642e+00, + 1.6614722e+00, 1.6620808e+00, 1.6626899e+00, 1.6632998e+00, + 1.6639103e+00, 1.6645213e+00, 1.6651330e+00, 1.6657453e+00, + 1.6663582e+00, 1.6669718e+00, 1.6675860e+00, 1.6682007e+00, + 1.6688162e+00, 1.6694323e+00, 1.6700491e+00, 1.6706663e+00, + 1.6712843e+00, 1.6719030e+00, 1.6725223e+00, 1.6731422e+00, + 1.6737627e+00, 1.6743839e+00, 1.6750058e+00, 1.6756283e+00, + 1.6762514e+00, 1.6768752e+00, 1.6774997e+00, 1.6781248e+00, + 1.6787505e+00, 1.6793770e+00, 1.6800040e+00, 1.6806318e+00, + 1.6812601e+00, 1.6818892e+00, 1.6825190e+00, 1.6831493e+00, + 1.6837804e+00, 1.6844121e+00, 1.6850445e+00, 1.6856776e+00, + 1.6863114e+00, 1.6869458e+00, 1.6875809e+00, 1.6882168e+00, + 1.6888533e+00, 1.6894904e+00, 1.6901283e+00, 1.6907668e+00, + 1.6914060e+00, 1.6920460e+00, 1.6926867e+00, 1.6933279e+00, + 1.6939700e+00, 1.6946126e+00, 1.6952561e+00, 1.6959002e+00, + 1.6965450e+00, 1.6971905e+00, 1.6978368e+00, 1.6984837e+00, + 1.6991314e+00, 1.6997797e+00, 1.7004288e+00, 1.7010787e+00, + 1.7017292e+00, 1.7023804e+00, 1.7030324e+00, 1.7036850e+00, + 1.7043386e+00, 1.7049927e+00, 1.7056475e+00, 1.7063031e+00, + 1.7069595e+00, 1.7076166e+00, 1.7082744e+00, 1.7089329e+00, + 1.7095922e+00, 1.7102523e+00, 1.7109131e+00, 1.7115746e+00, + 1.7122369e+00, 1.7128999e+00, 1.7135637e+00, 1.7142283e+00, + 1.7148936e+00, 1.7155596e+00, 1.7162265e+00, 1.7168940e+00, + 1.7175624e+00, 1.7182316e+00, 1.7189014e+00, 1.7195721e+00, + 1.7202436e+00, 1.7209158e+00, 1.7215887e+00, 1.7222625e+00, + 1.7229371e+00, 1.7236124e+00, 1.7242886e+00, 1.7249656e+00, + 1.7256433e+00, 1.7263217e+00, 1.7270011e+00, 1.7276812e+00, + 1.7283621e+00, 1.7290437e+00, 1.7297263e+00, 1.7304096e+00, + 1.7310936e+00, 1.7317786e+00, 1.7324644e+00, 1.7331510e+00, + 1.7338383e+00, 1.7345265e+00, 1.7352155e+00, 1.7359054e+00, + 1.7365961e+00, 1.7372876e+00, 1.7379799e+00, 1.7386731e+00, + 1.7393671e+00, 1.7400620e+00, 1.7407576e+00, 1.7414541e+00, + 1.7421515e+00, 1.7428498e+00, 1.7435489e+00, 1.7442487e+00, + 1.7449496e+00, 1.7456512e+00, 1.7463537e+00, 1.7470571e+00, + 1.7477614e+00, 1.7484664e+00, 1.7491723e+00, 1.7498792e+00, + 1.7505870e+00, 1.7512956e+00, 1.7520050e+00, 1.7527153e+00, + 1.7534267e+00, 1.7541387e+00, 1.7548518e+00, 1.7555658e+00, + 1.7562805e+00, 1.7569963e+00, 1.7577128e+00, 1.7584304e+00, + 1.7591488e+00, 1.7598681e+00, 1.7605884e+00, 1.7613095e+00, + 1.7620316e+00, 1.7627546e+00, 1.7634785e+00, 1.7642033e+00, + 1.7649292e+00, 1.7656559e+00, 1.7663834e+00, 1.7671120e+00, + 1.7678416e+00, 1.7685720e+00, 1.7693034e+00, 1.7700357e+00, + 1.7707690e+00, 1.7715033e+00, 1.7722385e+00, 1.7729746e+00, + 1.7737118e+00, 1.7744499e+00, 1.7751889e+00, 1.7759290e+00, + 1.7766700e+00, 1.7774119e+00, 1.7781550e+00, 1.7788988e+00, + 1.7796438e+00, 1.7803898e+00, 1.7811366e+00, 1.7818846e+00, + 1.7826334e+00, 1.7833834e+00, 1.7841343e+00, 1.7848862e+00, + 1.7856392e+00, 1.7863930e+00, 1.7871480e+00, 1.7879040e+00, + 1.7886610e+00, 1.7894191e+00, 1.7901781e+00, 1.7909381e+00, + 1.7916993e+00, 1.7924615e+00, 1.7932247e+00, 1.7939889e+00, + 1.7947543e+00, 1.7955205e+00, 1.7962880e+00, 1.7970564e+00, + 1.7978261e+00, 1.7985966e+00, 1.7993683e+00, 1.8001410e+00, + 1.8009149e+00, 1.8016897e+00, 1.8024657e+00, 1.8032428e+00, + 1.8040210e+00, 1.8048003e+00, 1.8055806e+00, 1.8063620e+00, + 1.8071445e+00, 1.8079282e+00, 1.8087131e+00, 1.8094989e+00, + 1.8102859e+00, 1.8110740e+00, 1.8118633e+00, 1.8126537e+00, + 1.8134452e+00, 1.8142380e+00, 1.8150318e+00, 1.8158267e+00, + 1.8166227e+00, 1.8174200e+00, 1.8182185e+00, 1.8190180e+00, + 1.8198187e+00, 1.8206207e+00, 1.8214238e+00, 1.8222280e+00, + 1.8230335e+00, 1.8238400e+00, 1.8246478e+00, 1.8254569e+00, + 1.8262670e+00, 1.8270785e+00, 1.8278910e+00, 1.8287048e+00, + 1.8295199e+00, 1.8303361e+00, 1.8311535e+00, 1.8319722e+00, + 1.8327922e+00, 1.8336133e+00, 1.8344357e+00, 1.8352593e+00, + 1.8360841e+00, 1.8369104e+00, 1.8377377e+00, 1.8385663e+00, + 1.8393962e+00, 1.8402274e+00, 1.8410599e+00, 1.8418936e+00, + 1.8427286e+00, 1.8435649e+00, 1.8444026e+00, 1.8452414e+00, + 1.8460816e+00, 1.8469231e+00, 1.8477658e+00, 1.8486099e+00, + 1.8494554e+00, 1.8503022e+00, 1.8511503e+00, 1.8519996e+00, + 1.8528504e+00, 1.8537025e+00, 1.8545560e+00, 1.8554108e+00, + 1.8562670e+00, 1.8571244e+00, 1.8579834e+00, 1.8588436e+00, + 1.8597052e+00, 1.8605683e+00, 1.8614327e+00, 1.8622985e+00, + 1.8631657e+00, 1.8640343e+00, 1.8649043e+00, 1.8657757e+00, + 1.8666486e+00, 1.8675228e+00, 1.8683985e+00, 1.8692757e+00, + 1.8701543e+00, 1.8710344e+00, 1.8719158e+00, 1.8727987e+00, + 1.8736831e+00, 1.8745691e+00, 1.8754563e+00, 1.8763452e+00, + 1.8772354e+00, 1.8781272e+00, 1.8790206e+00, 1.8799154e+00, + 1.8808116e+00, 1.8817095e+00, 1.8826088e+00, 1.8835096e+00, + 1.8844121e+00, 1.8853159e+00, 1.8862214e+00, 1.8871284e+00, + 1.8880370e+00, 1.8889471e+00, 1.8898588e+00, 1.8907721e+00, + 1.8916869e+00, 1.8926034e+00, 1.8935214e+00, 1.8944410e+00, + 1.8953623e+00, 1.8962852e+00, 1.8972095e+00, 1.8981357e+00, + 1.8990633e+00, 1.8999927e+00, 1.9009237e+00, 1.9018564e+00, + 1.9027907e+00, 1.9037267e+00, 1.9046643e+00, 1.9056036e+00, + 1.9065447e+00, 1.9074874e+00, 1.9084318e+00, 1.9093778e+00, + 1.9103256e+00, 1.9112751e+00, 1.9122264e+00, 1.9131794e+00, + 1.9141341e+00, 1.9150907e+00, 1.9160489e+00, 1.9170089e+00, + 1.9179707e+00, 1.9189342e+00, 1.9198995e+00, 1.9208666e+00, + 1.9218355e+00, 1.9228063e+00, 1.9237788e+00, 1.9247532e+00, + 1.9257294e+00, 1.9267074e+00, 1.9276873e+00, 1.9286691e+00, + 1.9296527e+00, 1.9306381e+00, 1.9316255e+00, 1.9326147e+00, + 1.9336058e+00, 1.9345989e+00, 1.9355938e+00, 1.9365907e+00, + 1.9375895e+00, 1.9385902e+00, 1.9395928e+00, 1.9405975e+00, + 1.9416041e+00, 1.9426126e+00, 1.9436232e+00, 1.9446357e+00, + 1.9456502e+00, 1.9466668e+00, 1.9476854e+00, 1.9487059e+00, + 1.9497285e+00, 1.9507532e+00, 1.9517798e+00, 1.9528086e+00, + 1.9538395e+00, 1.9548724e+00, 1.9559075e+00, 1.9569446e+00, + 1.9579837e+00, 1.9590250e+00, 1.9600686e+00, 1.9611142e+00, + 1.9621619e+00, 1.9632118e+00, 1.9642639e+00, 1.9653181e+00, + 1.9663746e+00, 1.9674332e+00, 1.9684941e+00, 1.9695572e+00, + 1.9706224e+00, 1.9716901e+00, 1.9727598e+00, 1.9738319e+00, + 1.9749062e+00, 1.9759828e+00, 1.9770617e+00, 1.9781430e+00, + 1.9792265e+00, 1.9803123e+00, 1.9814006e+00, 1.9824911e+00, + 1.9835840e+00, 1.9846793e+00, 1.9857770e+00, 1.9868771e+00, + 1.9879795e+00, 1.9890845e+00, 1.9901918e+00, 1.9913017e+00, + 1.9924139e+00, 1.9935286e+00, 1.9946458e+00, 1.9957654e+00, + 1.9968877e+00, 1.9980124e+00, 1.9991397e+00, 2.0002694e+00, + 2.0014019e+00, 2.0025368e+00, 2.0036743e+00, 2.0048144e+00, + 2.0059571e+00, 2.0071025e+00, 2.0082505e+00, 2.0094011e+00, + 2.0105543e+00, 2.0117104e+00, 2.0128691e+00, 2.0140305e+00, + 2.0151947e+00, 2.0163615e+00, 2.0175312e+00, 2.0187035e+00, + 2.0198786e+00, 2.0210567e+00, 2.0222373e+00, 2.0234210e+00, + 2.0246074e+00, 2.0257967e+00, 2.0269887e+00, 2.0281839e+00, + 2.0293818e+00, 2.0305827e+00, 2.0317864e+00, 2.0329933e+00, + 2.0342031e+00, 2.0354156e+00, 2.0366313e+00, 2.0378501e+00, + 2.0390718e+00, 2.0402968e+00, 2.0415246e+00, 2.0427556e+00, + 2.0439897e+00, 2.0452268e+00, 2.0464671e+00, 2.0477107e+00, + 2.0489573e+00, 2.0502071e+00, 2.0514603e+00, 2.0527165e+00, + 2.0539761e+00, 2.0552390e+00, 2.0565050e+00, 2.0577743e+00, + 2.0590472e+00, 2.0603232e+00, 2.0616026e+00, 2.0628855e+00, + 2.0641716e+00, 2.0654614e+00, 2.0667543e+00, 2.0680509e+00, + 2.0693510e+00, 2.0706546e+00, 2.0719616e+00, 2.0732722e+00, + 2.0745864e+00, 2.0759041e+00, 2.0772257e+00, 2.0785506e+00, + 2.0798793e+00, 2.0812118e+00, 2.0825479e+00, 2.0838876e+00, + 2.0852313e+00, 2.0865786e+00, 2.0879297e+00, 2.0892847e+00, + 2.0906434e+00, 2.0920062e+00, 2.0933728e+00, 2.0947433e+00, + 2.0961177e+00, 2.0974960e+00, 2.0988786e+00, 2.1002650e+00, + 2.1016555e+00, 2.1030500e+00, 2.1044486e+00, 2.1058514e+00, + 2.1072583e+00, 2.1086695e+00, 2.1100848e+00, 2.1115043e+00, + 2.1129284e+00, 2.1143565e+00, 2.1157889e+00, 2.1172256e+00, + 2.1186669e+00, 2.1201127e+00, 2.1215627e+00, 2.1230171e+00, + 2.1244762e+00, 2.1259398e+00, 2.1274080e+00, 2.1288807e+00, + 2.1303580e+00, 2.1318402e+00, 2.1333268e+00, 2.1348183e+00, + 2.1363146e+00, 2.1378157e+00, 2.1393216e+00, 2.1408322e+00, + 2.1423478e+00, 2.1438684e+00, 2.1453941e+00, 2.1469245e+00, + 2.1484601e+00, 2.1500008e+00, 2.1515467e+00, 2.1530976e+00, + 2.1546538e+00, 2.1562152e+00, 2.1577818e+00, 2.1593540e+00, + 2.1609311e+00, 2.1625140e+00, 2.1641021e+00, 2.1656959e+00, + 2.1672950e+00, 2.1688998e+00, 2.1705101e+00, 2.1721261e+00, + 2.1737478e+00, 2.1753752e+00, 2.1770084e+00, 2.1786473e+00, + 2.1802921e+00, 2.1819429e+00, 2.1835999e+00, 2.1852627e+00, + 2.1869316e+00, 2.1886065e+00, 2.1902876e+00, 2.1919749e+00, + 2.1936686e+00, 2.1953685e+00, 2.1970749e+00, 2.1987877e+00, + 2.2005067e+00, 2.2022326e+00, 2.2039647e+00, 2.2057037e+00, + 2.2074494e+00, 2.2092018e+00, 2.2109611e+00, 2.2127271e+00, + 2.2145002e+00, 2.2162802e+00, 2.2180672e+00, 2.2198613e+00, + 2.2216625e+00, 2.2234712e+00, 2.2252872e+00, 2.2271104e+00, + 2.2289410e+00, 2.2307792e+00, 2.2326250e+00, 2.2344782e+00, + 2.2363393e+00, 2.2382083e+00, 2.2400849e+00, 2.2419696e+00, + 2.2438622e+00, 2.2457631e+00, 2.2476718e+00, 2.2495890e+00, + 2.2515142e+00, 2.2534480e+00, 2.2553902e+00, 2.2573411e+00, + 2.2593005e+00, 2.2612686e+00, 2.2632456e+00, 2.2652314e+00, + 2.2672260e+00, 2.2692299e+00, 2.2712429e+00, 2.2732651e+00, + 2.2752967e+00, 2.2773378e+00, 2.2793882e+00, 2.2814484e+00, + 2.2835183e+00, 2.2855980e+00, 2.2876878e+00, 2.2897875e+00, + 2.2918973e+00, 2.2940173e+00, 2.2961478e+00, 2.2982888e+00, + 2.3004403e+00, 2.3026025e+00, 2.3047755e+00, 2.3069596e+00, + 2.3091545e+00, 2.3113608e+00, 2.3135784e+00, 2.3158073e+00, + 2.3180478e+00, 2.3203001e+00, 2.3225641e+00, 2.3248401e+00, + 2.3271282e+00, 2.3294287e+00, 2.3317413e+00, 2.3340669e+00, + 2.3364048e+00, 2.3387556e+00, 2.3411195e+00, 2.3434966e+00, + 2.3458867e+00, 2.3482907e+00, 2.3507080e+00, 2.3531394e+00, + 2.3555846e+00, 2.3580439e+00, 2.3605177e+00, 2.3630061e+00, + 2.3655090e+00, 2.3680270e+00, 2.3705599e+00, 2.3731084e+00, + 2.3756721e+00, 2.3782516e+00, 2.3808472e+00, 2.3834586e+00, + 2.3860867e+00, 2.3887312e+00, 2.3913925e+00, 2.3940709e+00, + 2.3967667e+00, 2.3994799e+00, 2.4022110e+00, 2.4049599e+00, + 2.4077272e+00, 2.4105132e+00, 2.4133179e+00, 2.4161417e+00, + 2.4189849e+00, 2.4218478e+00, 2.4247308e+00, 2.4276340e+00, + 2.4305577e+00, 2.4335027e+00, 2.4364686e+00, 2.4394562e+00, + 2.4424658e+00, 2.4454975e+00, 2.4485519e+00, 2.4516294e+00, + 2.4547303e+00, 2.4578550e+00, 2.4610038e+00, 2.4641774e+00, + 2.4673758e+00, 2.4705997e+00, 2.4738493e+00, 2.4771256e+00, + 2.4804285e+00, 2.4837587e+00, 2.4871166e+00, 2.4905028e+00, + 2.4939179e+00, 2.4973624e+00, 2.5008366e+00, 2.5043414e+00, + 2.5078771e+00, 2.5114446e+00, 2.5150442e+00, 2.5186768e+00, + 2.5223429e+00, 2.5260432e+00, 2.5297785e+00, 2.5335493e+00, + 2.5373566e+00, 2.5412009e+00, 2.5450833e+00, 2.5490043e+00, + 2.5529649e+00, 2.5569661e+00, 2.5610085e+00, 2.5650933e+00, + 2.5692213e+00, 2.5733936e+00, 2.5776110e+00, 2.5818748e+00, + 2.5861864e+00, 2.5905464e+00, 2.5949562e+00, 2.5994170e+00, + 2.6039300e+00, 2.6084969e+00, 2.6131189e+00, 2.6177971e+00, + 2.6225336e+00, 2.6273296e+00, 2.6321869e+00, 2.6371069e+00, + 2.6420918e+00, 2.6471431e+00, 2.6522629e+00, 2.6574533e+00, + 2.6627162e+00, 2.6680539e+00, 2.6734686e+00, 2.6789629e+00, + 2.6845396e+00, 2.6902006e+00, 2.6959493e+00, 2.7017887e+00, + 2.7077217e+00, 2.7137513e+00, 2.7198815e+00, 2.7261155e+00, + 2.7324574e+00, 2.7389109e+00, 2.7454808e+00, 2.7521713e+00, + 2.7589874e+00, 2.7659342e+00, 2.7730169e+00, 2.7802417e+00, + 2.7876146e+00, 2.7951422e+00, 2.8028316e+00, 2.8106904e+00, + 2.8187268e+00, 2.8269496e+00, 2.8353682e+00, 2.8439925e+00, + 2.8528337e+00, 2.8619039e+00, 2.8712158e+00, 2.8807836e+00, + 2.8906226e+00, 2.9007499e+00, 2.9111838e+00, 2.9219446e+00, + 2.9330549e+00, 2.9445398e+00, 2.9564269e+00, 2.9687471e+00, + 2.9815352e+00, 2.9948308e+00, 3.0086782e+00, 3.0231280e+00, + 3.0382385e+00, 3.0540769e+00, 3.0707211e+00, 3.0882633e+00, + 3.1068115e+00, 3.1264958e+00, 3.1474738e+00, 3.1699378e+00, + 3.1941290e+00, 3.2203522e+00, 3.2490034e+00, 3.2806098e+00, + 3.3158946e+00, 3.3558927e+00, 3.4021609e+00, 3.4572146e+00, + 3.5255561e+00, 3.6167130e+00, 3.7595601e+00, 4.0255485e+00 }; diff --git a/src/gromacs/gmxlib/gmx_sort.c b/src/gromacs/gmxlib/gmx_sort.c index e0fe87bd1f..51c61026da 100644 --- a/src/gromacs/gmxlib/gmx_sort.c +++ b/src/gromacs/gmxlib/gmx_sort.c @@ -1,6 +1,6 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This file is part of Gromacs Copyright (c) 1991-2010 * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen. * @@ -11,7 +11,7 @@ * * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org - * + * * And Hey: * Gnomes, ROck Monsters And Chili Sauce */ @@ -24,36 +24,36 @@ #include "gmx_sort.h" -static void +static void qsort_swapfunc(void * a, void * b, - size_t n, + size_t n, int swaptype) { - int * ia; - int * ib; - int itmp; - + int * ia; + int * ib; + int itmp; + char * ca; char * cb; - char ctmp; - - if (swaptype <= 1) + char ctmp; + + if (swaptype <= 1) { ia = (int *)a; ib = (int *)b; - for( ; n > 0; ia += 1, ib += 1, n -= sizeof(int)) + for (; n > 0; ia += 1, ib += 1, n -= sizeof(int)) { itmp = *ia; *ia = *ib; *ib = itmp; - } - } - else + } + } + else { ca = (char *)a; cb = (char *)b; - for( ; n > 0; ca += 1, cb += 1, n -= 1) + for (; n > 0; ca += 1, cb += 1, n -= 1) { ctmp = *ca; *ca = *cb; @@ -65,27 +65,39 @@ qsort_swapfunc(void * a, static void * qsort_med3(void * a, - void * b, - void * c, + void * b, + void * c, int (*compar) (const void *a, const void *b)) -{ - if(compar(a,b) < 0) +{ + if (compar(a, b) < 0) { - if(compar(b,c) < 0) + if (compar(b, c) < 0) + { return b; - else if(compar(a,c) < 0) + } + else if (compar(a, c) < 0) + { return c; + } else + { return a; + } } else { - if(compar(b,c) > 0) + if (compar(b, c) > 0) + { return b; - else if(compar(a,c) > 0) + } + else if (compar(a, c) > 0) + { return c; + } else + { return a; + } } } @@ -98,85 +110,85 @@ gmx_qsort(void * base, { #define QSORT_EXCH(a, b, t) (t = a, a = b, b = t) #define QSORT_SWAP(a, b) swaptype != 0 ? qsort_swapfunc(a, b, size, swaptype) : \ - (void)QSORT_EXCH(*(int *)(a), *(int *)(b), t) - - char *pa, *pb, *pc, *pd, *pl, *pm, *pn, *pv, *cbase; - int r, swaptype; - int t, v; + (void)QSORT_EXCH(*(int *)(a), *(int *)(b), t) + + char *pa, *pb, *pc, *pd, *pl, *pm, *pn, *pv, *cbase; + int r, swaptype; + int t, v; size_t s, st; - + cbase = (char *)base; - - swaptype = (size_t)(cbase - (char *)0) % sizeof(int) || size % sizeof(int) ? 2 : size == sizeof(int)? 0 : 1; - + + swaptype = (size_t)(cbase - (char *)0) % sizeof(int) || size % sizeof(int) ? 2 : size == sizeof(int) ? 0 : 1; + if (nmemb < 7) { /* Insertion sort on smallest arrays */ for (pm = cbase + size; pm < cbase + nmemb*size; pm += size) { - for (pl = pm; (pl > cbase) && compar((void *)(pl-size),(void *) pl) > 0; pl -= size) + for (pl = pm; (pl > cbase) && compar((void *)(pl-size), (void *) pl) > 0; pl -= size) { QSORT_SWAP(pl, pl-size); } } return; } - + /* Small arrays, middle element */ - pm = cbase + (nmemb/2)*size; - + pm = cbase + (nmemb/2)*size; + if (nmemb > 7) { pl = cbase; pn = cbase + (nmemb-1)*size; if (nmemb > 40) - { + { /* Big arrays, pseudomedian of 9 */ - s = (nmemb/8)*size; + s = (nmemb/8)*size; pl = (char *)qsort_med3((void *)pl, (void *)((size_t)pl+s), (void *)((size_t)pl+2*s), compar); pm = (char *)qsort_med3((void *)((size_t)pm-s), (void *)pm, (void *)((size_t)pm+s), compar); pn = (char *)qsort_med3((void *)((size_t)pn-2*s), (void *)((size_t)pn-s), (void *)pn, compar); } /* Mid-size, med of 3 */ - pm = (char *)qsort_med3((void *)pl, (void *)pm, (void *)pn, compar); + pm = (char *)qsort_med3((void *)pl, (void *)pm, (void *)pn, compar); } - + /* pv points to partition value */ - if (swaptype != 0) - { + if (swaptype != 0) + { pv = cbase; - QSORT_SWAP(pv, pm); - } - else + QSORT_SWAP(pv, pm); + } + else { - pv = (char*)(void*)&v; - v = *(int *)pm; + pv = (char*)(void*)&v; + v = *(int *)pm; } - + pa = pb = cbase; pc = pd = cbase + (nmemb-1)*size; - - for (;;) + + for (;; ) { - while (pb <= pc && (r = compar((void *)pb,(void *) pv)) <= 0) + while (pb <= pc && (r = compar((void *)pb, (void *) pv)) <= 0) { - if (r == 0) - { - QSORT_SWAP(pa, pb); + if (r == 0) + { + QSORT_SWAP(pa, pb); pa += size; } pb += size; } - while (pc >= pb && (r = compar((void *)pc,(void *) pv)) >= 0) + while (pc >= pb && (r = compar((void *)pc, (void *) pv)) >= 0) { if (r == 0) - { - QSORT_SWAP(pc, pd); - pd -= size; + { + QSORT_SWAP(pc, pd); + pd -= size; } pc -= size; } - if (pb > pc) + if (pb > pc) { break; } @@ -185,46 +197,43 @@ gmx_qsort(void * base, pc -= size; } pn = cbase + nmemb*size; - + s = pa-cbase; st = pb-pa; - if(st0) + + if (s > 0) { qsort_swapfunc(cbase, pb-s, s, swaptype); } - - s = pd-pc; + + s = pd-pc; st = pn-pd-size; - if(st0) + + if (s > 0) { qsort_swapfunc(pb, pn-s, s, swaptype); } - - if ((s = pb-pa) > size) + + if ((s = pb-pa) > size) { gmx_qsort(cbase, s/size, size, compar); } - - if ((s = pd-pc) > size) + + if ((s = pd-pc) > size) { gmx_qsort(pn-s, s/size, size, compar); } - + #undef QSORT_EXCH #undef QSORT_SWAP - + return; } - - - diff --git a/src/gromacs/gmxlib/gmx_system_xdr.c b/src/gromacs/gmxlib/gmx_system_xdr.c index e66a59970c..b9ebaaf4c1 100644 --- a/src/gromacs/gmxlib/gmx_system_xdr.c +++ b/src/gromacs/gmxlib/gmx_system_xdr.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -49,17 +49,17 @@ /* NB - THIS FILE IS ONLY USED ON MICROSOFT WINDOWS, since that * system doesn't provide any standard XDR system libraries. It will * most probably work on other platforms too, but make sure you - * test that the xtc files produced are ok before using it. + * test that the xtc files produced are ok before using it. * - * This header file contains Gromacs versions of the definitions for + * This header file contains Gromacs versions of the definitions for * Sun External Data Representation (XDR) headers and routines. * - * On most UNIX systems this is already present as part of your + * On most UNIX systems this is already present as part of your * system libraries, but since we want to make Gromacs portable to * platforms like Microsoft Windows we have created a private version * of the necessary routines and distribute them with the Gromacs source. - * - * Although the rest of Gromacs is GPL, you can copy and use the XDR + * + * Although the rest of Gromacs is GPL, you can copy and use the XDR * routines in any way you want as long as you obey Sun's license: * * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -88,7 +88,7 @@ * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 - */ + */ @@ -99,39 +99,47 @@ static char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0}; static xdr_uint32_t xdr_swapbytes(xdr_uint32_t x) { - xdr_uint32_t y; - int i; - char *px=(char *)&x; - char *py=(char *)&y; - - for(i=0;i<4;i++) - py[i]=px[3-i]; - - return y; + xdr_uint32_t y; + int i; + char *px = (char *)&x; + char *py = (char *)&y; + + for (i = 0; i < 4; i++) + { + py[i] = px[3-i]; + } + + return y; } static xdr_uint32_t xdr_htonl(xdr_uint32_t x) { - short s=0x0F00; - if( *((char *)&s)==(char)0x0F) { - /* bigendian, do nothing */ - return x; - } else { - /* smallendian,swap bytes */ - return xdr_swapbytes(x); - } + short s = 0x0F00; + if (*((char *)&s) == (char)0x0F) + { + /* bigendian, do nothing */ + return x; + } + else + { + /* smallendian,swap bytes */ + return xdr_swapbytes(x); + } } static xdr_uint32_t xdr_ntohl(xdr_uint32_t x) { - short s=0x0F00; - if( *((char *)&s)==(char)0x0F) { - /* bigendian, do nothing */ - return x; - } else { - /* smallendian, swap bytes */ - return xdr_swapbytes(x); - } + short s = 0x0F00; + if (*((char *)&s) == (char)0x0F) + { + /* bigendian, do nothing */ + return x; + } + else + { + /* smallendian, swap bytes */ + return xdr_swapbytes(x); + } } @@ -142,10 +150,10 @@ static xdr_uint32_t xdr_ntohl(xdr_uint32_t x) void xdr_free (xdrproc_t proc, char *objp) { - XDR x; + XDR x; - x.x_op = XDR_FREE; - (*proc) (&x, objp); + x.x_op = XDR_FREE; + (*proc) ( &x, objp); } /* @@ -154,7 +162,7 @@ xdr_free (xdrproc_t proc, char *objp) bool_t xdr_void (void) { - return TRUE; + return TRUE; } /* @@ -163,25 +171,25 @@ xdr_void (void) bool_t xdr_int (XDR *xdrs, int *ip) { - xdr_int32_t l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (xdr_int32_t) (*ip); - return xdr_putint32 (xdrs, &l); - - case XDR_DECODE: - if (!xdr_getint32 (xdrs, &l)) - { - return FALSE; - } - *ip = (int) l; - - case XDR_FREE: - return TRUE; - } - return FALSE; + xdr_int32_t l; + + switch (xdrs->x_op) + { + case XDR_ENCODE: + l = (xdr_int32_t) (*ip); + return xdr_putint32 (xdrs, &l); + + case XDR_DECODE: + if (!xdr_getint32 (xdrs, &l)) + { + return FALSE; + } + *ip = (int) l; + + case XDR_FREE: + return TRUE; + } + return FALSE; } @@ -191,25 +199,25 @@ xdr_int (XDR *xdrs, int *ip) bool_t xdr_u_int (XDR *xdrs, unsigned int *up) { - xdr_uint32_t l; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - l = (xdr_uint32_t) (*up); - return xdr_putuint32 (xdrs, &l); - - case XDR_DECODE: - if (!xdr_getuint32 (xdrs, &l)) - { - return FALSE; - } - *up = (unsigned int) l; - - case XDR_FREE: - return TRUE; - } - return FALSE; + xdr_uint32_t l; + + switch (xdrs->x_op) + { + case XDR_ENCODE: + l = (xdr_uint32_t) (*up); + return xdr_putuint32 (xdrs, &l); + + case XDR_DECODE: + if (!xdr_getuint32 (xdrs, &l)) + { + return FALSE; + } + *up = (unsigned int) l; + + case XDR_FREE: + return TRUE; + } + return FALSE; } @@ -221,26 +229,26 @@ xdr_u_int (XDR *xdrs, unsigned int *up) bool_t xdr_short (XDR *xdrs, short *sp) { - xdr_int32_t l; + xdr_int32_t l; - switch (xdrs->x_op) + switch (xdrs->x_op) { - case XDR_ENCODE: - l = (xdr_int32_t) *sp; - return xdr_putint32 (xdrs, &l); - - case XDR_DECODE: - if (!xdr_getint32 (xdrs, &l)) - { - return FALSE; - } - *sp = (short) l; - return TRUE; - - case XDR_FREE: - return TRUE; + case XDR_ENCODE: + l = (xdr_int32_t) *sp; + return xdr_putint32 (xdrs, &l); + + case XDR_DECODE: + if (!xdr_getint32 (xdrs, &l)) + { + return FALSE; + } + *sp = (short) l; + return TRUE; + + case XDR_FREE: + return TRUE; } - return FALSE; + return FALSE; } @@ -250,26 +258,26 @@ xdr_short (XDR *xdrs, short *sp) bool_t xdr_u_short (XDR *xdrs, unsigned short *usp) { - xdr_uint32_t l; + xdr_uint32_t l; - switch (xdrs->x_op) + switch (xdrs->x_op) { - case XDR_ENCODE: - l = (xdr_uint32_t) *usp; - return xdr_putuint32 (xdrs, &l); - - case XDR_DECODE: - if (!xdr_getuint32 (xdrs, &l)) - { - return FALSE; - } - *usp = (unsigned short) l; - return TRUE; - - case XDR_FREE: - return TRUE; + case XDR_ENCODE: + l = (xdr_uint32_t) *usp; + return xdr_putuint32 (xdrs, &l); + + case XDR_DECODE: + if (!xdr_getuint32 (xdrs, &l)) + { + return FALSE; + } + *usp = (unsigned short) l; + return TRUE; + + case XDR_FREE: + return TRUE; } - return FALSE; + return FALSE; } @@ -279,15 +287,15 @@ xdr_u_short (XDR *xdrs, unsigned short *usp) bool_t xdr_char (XDR *xdrs, char *cp) { - int i; + int i; - i = (*cp); - if (!xdr_int (xdrs, &i)) + i = (*cp); + if (!xdr_int (xdrs, &i)) { - return FALSE; + return FALSE; } - *cp = i; - return TRUE; + *cp = i; + return TRUE; } /* @@ -296,15 +304,15 @@ xdr_char (XDR *xdrs, char *cp) bool_t xdr_u_char (XDR *xdrs, unsigned char *cp) { - unsigned int u; + unsigned int u; - u = (*cp); - if (!xdr_u_int (xdrs, &u)) + u = (*cp); + if (!xdr_u_int (xdrs, &u)) { - return FALSE; + return FALSE; } - *cp = u; - return TRUE; + *cp = u; + return TRUE; } /* @@ -313,29 +321,29 @@ xdr_u_char (XDR *xdrs, unsigned char *cp) bool_t xdr_bool (XDR *xdrs, int *bp) { -#define XDR_FALSE ((xdr_int32_t) 0) -#define XDR_TRUE ((xdr_int32_t) 1) +#define XDR_FALSE ((xdr_int32_t) 0) +#define XDR_TRUE ((xdr_int32_t) 1) - xdr_int32_t lb; + xdr_int32_t lb; - switch (xdrs->x_op) + switch (xdrs->x_op) { - case XDR_ENCODE: - lb = *bp ? XDR_TRUE : XDR_FALSE; - return xdr_putint32 (xdrs, &lb); - - case XDR_DECODE: - if (!xdr_getint32 (xdrs, &lb)) - { - return FALSE; - } - *bp = (lb == XDR_FALSE) ? FALSE : TRUE; - return TRUE; - - case XDR_FREE: - return TRUE; + case XDR_ENCODE: + lb = *bp ? XDR_TRUE : XDR_FALSE; + return xdr_putint32 (xdrs, &lb); + + case XDR_DECODE: + if (!xdr_getint32 (xdrs, &lb)) + { + return FALSE; + } + *bp = (lb == XDR_FALSE) ? FALSE : TRUE; + return TRUE; + + case XDR_FREE: + return TRUE; } - return FALSE; + return FALSE; #undef XDR_FALSE #undef XDR_TRUE } @@ -350,46 +358,54 @@ xdr_bool (XDR *xdrs, int *bp) bool_t xdr_opaque (XDR *xdrs, char *cp, unsigned int cnt) { - unsigned int rndup; - char crud[BYTES_PER_XDR_UNIT]; + unsigned int rndup; + char crud[BYTES_PER_XDR_UNIT]; - /* - * if no data we are done - */ - if (cnt == 0) - return TRUE; + /* + * if no data we are done + */ + if (cnt == 0) + { + return TRUE; + } - /* - * round byte count to full xdr units - */ - rndup = cnt % BYTES_PER_XDR_UNIT; - if (rndup > 0) - rndup = BYTES_PER_XDR_UNIT - rndup; + /* + * round byte count to full xdr units + */ + rndup = cnt % BYTES_PER_XDR_UNIT; + if (rndup > 0) + { + rndup = BYTES_PER_XDR_UNIT - rndup; + } - switch (xdrs->x_op) + switch (xdrs->x_op) { - case XDR_DECODE: - if (!xdr_getbytes (xdrs, cp, cnt)) - { - return FALSE; - } - if (rndup == 0) - return TRUE; - return xdr_getbytes (xdrs, (char *)crud, rndup); - - case XDR_ENCODE: - if (!xdr_putbytes (xdrs, cp, cnt)) - { - return FALSE; - } - if (rndup == 0) - return TRUE; - return xdr_putbytes (xdrs, xdr_zero, rndup); - - case XDR_FREE: - return TRUE; + case XDR_DECODE: + if (!xdr_getbytes (xdrs, cp, cnt)) + { + return FALSE; + } + if (rndup == 0) + { + return TRUE; + } + return xdr_getbytes (xdrs, (char *)crud, rndup); + + case XDR_ENCODE: + if (!xdr_putbytes (xdrs, cp, cnt)) + { + return FALSE; + } + if (rndup == 0) + { + return TRUE; + } + return xdr_putbytes (xdrs, xdr_zero, rndup); + + case XDR_FREE: + return TRUE; } - return FALSE; + return FALSE; } @@ -403,73 +419,77 @@ xdr_opaque (XDR *xdrs, char *cp, unsigned int cnt) */ bool_t xdr_string (xdrs, cpp, maxsize) - XDR *xdrs; - char **cpp; - unsigned int maxsize; +XDR *xdrs; +char **cpp; +unsigned int maxsize; { - char *sp = *cpp; /* sp is the actual string pointer */ - unsigned int size = 0; - unsigned int nodesize = 0; - - /* - * first deal with the length since xdr strings are counted-strings - */ - switch (xdrs->x_op) + char *sp = *cpp; /* sp is the actual string pointer */ + unsigned int size = 0; + unsigned int nodesize = 0; + + /* + * first deal with the length since xdr strings are counted-strings + */ + switch (xdrs->x_op) { - case XDR_FREE: - if (sp == NULL) - { - return TRUE; /* already free */ - } - /* fall through... */ - case XDR_ENCODE: - if (sp == NULL) - return FALSE; - size = strlen (sp); - break; - case XDR_DECODE: - break; + case XDR_FREE: + if (sp == NULL) + { + return TRUE; /* already free */ + } + /* fall through... */ + case XDR_ENCODE: + if (sp == NULL) + { + return FALSE; + } + size = strlen (sp); + break; + case XDR_DECODE: + break; } - - if (!xdr_u_int (xdrs, &size)) + + if (!xdr_u_int (xdrs, &size)) { - return FALSE; + return FALSE; } - if (size > maxsize) + if (size > maxsize) { - return FALSE; + return FALSE; } - nodesize = size + 1; + nodesize = size + 1; - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) + /* + * now deal with the actual bytes + */ + switch (xdrs->x_op) { - case XDR_DECODE: - if (nodesize == 0) - { - return TRUE; - } - if (sp == NULL) - *cpp = sp = (char *) malloc (nodesize); - if (sp == NULL) - { - (void) fputs ("xdr_string: out of memory\n", stderr); - return FALSE; - } - sp[size] = 0; - /* fall into ... */ - - case XDR_ENCODE: - return xdr_opaque (xdrs, sp, size); - - case XDR_FREE: - free (sp); - *cpp = NULL; - return TRUE; + case XDR_DECODE: + if (nodesize == 0) + { + return TRUE; + } + if (sp == NULL) + { + *cpp = sp = (char *) malloc (nodesize); + } + if (sp == NULL) + { + (void) fputs ("xdr_string: out of memory\n", stderr); + return FALSE; + } + sp[size] = 0; + /* fall into ... */ + + case XDR_ENCODE: + return xdr_opaque (xdrs, sp, size); + + case XDR_FREE: + free (sp); + *cpp = NULL; + return TRUE; } - return FALSE; + return FALSE; } @@ -478,108 +498,118 @@ xdr_string (xdrs, cpp, maxsize) bool_t xdr_float(xdrs, fp) - XDR *xdrs; - float *fp; +XDR *xdrs; +float *fp; { - xdr_int32_t tmp; - - switch (xdrs->x_op) { + xdr_int32_t tmp; + + switch (xdrs->x_op) + { - case XDR_ENCODE: - tmp = *(xdr_int32_t *)fp; - return (xdr_putint32(xdrs, &tmp)); + case XDR_ENCODE: + tmp = *(xdr_int32_t *)fp; + return (xdr_putint32(xdrs, &tmp)); - break; + break; - case XDR_DECODE: - if (xdr_getint32(xdrs, &tmp)) { - *(xdr_int32_t *)fp = tmp; - return (TRUE); - } + case XDR_DECODE: + if (xdr_getint32(xdrs, &tmp)) + { + *(xdr_int32_t *)fp = tmp; + return (TRUE); + } - break; + break; - case XDR_FREE: - return (TRUE); - } - return (FALSE); + case XDR_FREE: + return (TRUE); + } + return (FALSE); } bool_t xdr_double(xdrs, dp) - XDR *xdrs; - double *dp; +XDR *xdrs; +double *dp; { - /* Windows and some other systems dont define double-precision - * word order in the header files, so unfortunately we have - * to calculate it! - * - * For thread safety, we calculate it every time: locking this would - * be more expensive. - */ - /*static int LSW=-1;*/ /* Least significant fp word */ - int LSW=-1; /* Least significant fp word */ - - - int *ip; - xdr_int32_t tmp[2]; - - if(LSW<0) { - double x=0.987654321; /* Just a number */ - - /* Possible representations in IEEE double precision: - * (S=small endian, B=big endian) - * - * Byte order, Word order, Hex - * S S b8 56 0e 3c dd 9a ef 3f - * B S 3c 0e 56 b8 3f ef 9a dd - * S B dd 9a ef 3f b8 56 0e 3c - * B B 3f ef 9a dd 3c 0e 56 b8 - */ - - unsigned char ix = *((char *)&x); - - if(ix==0xdd || ix==0x3f) - LSW=1; /* Big endian word order */ - else if(ix==0xb8 || ix==0x3c) - LSW=0; /* Small endian word order */ - else { /* Catch strange errors */ - printf("Error when detecting floating-point word order.\n" - "Do you have a non-IEEE system?\n" - "If possible, use the XDR libraries provided with your system,\n" - "instead of the Gromacs fallback XDR source.\n"); - exit(0); - } - } - - switch (xdrs->x_op) { - - case XDR_ENCODE: - ip = (int *)dp; - tmp[0] = ip[!LSW]; - tmp[1] = ip[LSW]; - return (xdr_putint32(xdrs, tmp) && - xdr_putint32(xdrs, tmp+1)); - - break; - - case XDR_DECODE: - ip = (int *)dp; - if (xdr_getint32(xdrs, tmp+!LSW) && - xdr_getint32(xdrs, tmp+LSW)) { - ip[0] = tmp[0]; - ip[1] = tmp[1]; - return (TRUE); + /* Windows and some other systems dont define double-precision + * word order in the header files, so unfortunately we have + * to calculate it! + * + * For thread safety, we calculate it every time: locking this would + * be more expensive. + */ + /*static int LSW=-1;*/ /* Least significant fp word */ + int LSW = -1; /* Least significant fp word */ + + + int *ip; + xdr_int32_t tmp[2]; + + if (LSW < 0) + { + double x = 0.987654321; /* Just a number */ + + /* Possible representations in IEEE double precision: + * (S=small endian, B=big endian) + * + * Byte order, Word order, Hex + * S S b8 56 0e 3c dd 9a ef 3f + * B S 3c 0e 56 b8 3f ef 9a dd + * S B dd 9a ef 3f b8 56 0e 3c + * B B 3f ef 9a dd 3c 0e 56 b8 + */ + + unsigned char ix = *((char *)&x); + + if (ix == 0xdd || ix == 0x3f) + { + LSW = 1; /* Big endian word order */ + } + else if (ix == 0xb8 || ix == 0x3c) + { + LSW = 0; /* Small endian word order */ + } + else /* Catch strange errors */ + { + printf("Error when detecting floating-point word order.\n" + "Do you have a non-IEEE system?\n" + "If possible, use the XDR libraries provided with your system,\n" + "instead of the Gromacs fallback XDR source.\n"); + exit(0); + } } - break; - - case XDR_FREE: - return (TRUE); - } - return (FALSE); + switch (xdrs->x_op) + { + + case XDR_ENCODE: + ip = (int *)dp; + tmp[0] = ip[!LSW]; + tmp[1] = ip[LSW]; + return (xdr_putint32(xdrs, tmp) && + xdr_putint32(xdrs, tmp+1)); + + break; + + case XDR_DECODE: + ip = (int *)dp; + if (xdr_getint32(xdrs, tmp+!LSW) && + xdr_getint32(xdrs, tmp+LSW)) + { + ip[0] = tmp[0]; + ip[1] = tmp[1]; + return (TRUE); + } + + break; + + case XDR_FREE: + return (TRUE); + } + return (FALSE); } @@ -597,26 +627,26 @@ xdr_double(xdrs, dp) */ bool_t xdr_vector (xdrs, basep, nelem, elemsize, xdr_elem) - XDR *xdrs; - char *basep; - unsigned int nelem; - unsigned int elemsize; - xdrproc_t xdr_elem; +XDR *xdrs; +char *basep; +unsigned int nelem; +unsigned int elemsize; +xdrproc_t xdr_elem; { -#define LASTUNSIGNED ((unsigned int)0-1) - unsigned int i; - char *elptr; +#define LASTUNSIGNED ((unsigned int)0-1) + unsigned int i; + char *elptr; - elptr = basep; - for (i = 0; i < nelem; i++) + elptr = basep; + for (i = 0; i < nelem; i++) { - if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) - { - return FALSE; - } - elptr += elemsize; + if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) + { + return FALSE; + } + elptr += elemsize; } - return TRUE; + return TRUE; #undef LASTUNSIGNED } @@ -638,16 +668,16 @@ static bool_t xdrstdio_putuint32 (XDR *, xdr_uint32_t *); */ static const struct xdr_ops xdrstdio_ops = { - xdrstdio_getbytes, /* deserialize counted bytes */ - xdrstdio_putbytes, /* serialize counted bytes */ - xdrstdio_getpos, /* get offset in the stream */ - xdrstdio_setpos, /* set offset in the stream */ - xdrstdio_inline, /* prime stream for inline macros */ - xdrstdio_destroy, /* destroy stream */ - xdrstdio_getint32, /* deserialize a int */ - xdrstdio_putint32, /* serialize a int */ - xdrstdio_getuint32, /* deserialize a int */ - xdrstdio_putuint32 /* serialize a int */ + xdrstdio_getbytes, /* deserialize counted bytes */ + xdrstdio_putbytes, /* serialize counted bytes */ + xdrstdio_getpos, /* get offset in the stream */ + xdrstdio_setpos, /* set offset in the stream */ + xdrstdio_inline, /* prime stream for inline macros */ + xdrstdio_destroy, /* destroy stream */ + xdrstdio_getint32, /* deserialize a int */ + xdrstdio_putint32, /* serialize a int */ + xdrstdio_getuint32, /* deserialize a int */ + xdrstdio_putuint32 /* serialize a int */ }; /* @@ -658,13 +688,13 @@ static const struct xdr_ops xdrstdio_ops = void xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op) { - xdrs->x_op = op; - /* We have to add the const since the `struct xdr_ops' in `struct XDR' - is not `const'. */ - xdrs->x_ops = (struct xdr_ops *) &xdrstdio_ops; - xdrs->x_private = (char *) file; - xdrs->x_handy = 0; - xdrs->x_base = 0; + xdrs->x_op = op; + /* We have to add the const since the `struct xdr_ops' in `struct XDR' + is not `const'. */ + xdrs->x_ops = (struct xdr_ops *) &xdrstdio_ops; + xdrs->x_private = (char *) file; + xdrs->x_handy = 0; + xdrs->x_base = 0; } /* @@ -674,101 +704,113 @@ xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op) static void xdrstdio_destroy (XDR *xdrs) { - (void) fflush ((FILE *) xdrs->x_private); - /* xx should we close the file ?? */ + (void) fflush ((FILE *) xdrs->x_private); + /* xx should we close the file ?? */ } static bool_t xdrstdio_getbytes (XDR *xdrs, char *addr, unsigned int len) { - if ((len != 0) && (fread (addr, (int) len, 1, - (FILE *) xdrs->x_private) != 1)) - return FALSE; - return TRUE; + if ((len != 0) && (fread (addr, (int) len, 1, + (FILE *) xdrs->x_private) != 1)) + { + return FALSE; + } + return TRUE; } static bool_t xdrstdio_putbytes (XDR *xdrs, char *addr, unsigned int len) { - if ((len != 0) && (fwrite (addr, (int) len, 1, - (FILE *) xdrs->x_private) != 1)) - return FALSE; - return TRUE; + if ((len != 0) && (fwrite (addr, (int) len, 1, + (FILE *) xdrs->x_private) != 1)) + { + return FALSE; + } + return TRUE; } static unsigned int xdrstdio_getpos (XDR *xdrs) { - return (unsigned int) ftell ((FILE *) xdrs->x_private); + return (unsigned int) ftell ((FILE *) xdrs->x_private); } static bool_t xdrstdio_setpos (XDR *xdrs, unsigned int pos) { - return fseek ((FILE *) xdrs->x_private, (xdr_int32_t) pos, 0) < 0 ? FALSE : TRUE; + return fseek ((FILE *) xdrs->x_private, (xdr_int32_t) pos, 0) < 0 ? FALSE : TRUE; } static xdr_int32_t * xdrstdio_inline (XDR *xdrs, int len) { - /* - * Must do some work to implement this: must insure - * enough data in the underlying stdio buffer, - * that the buffer is aligned so that we can indirect through a - * long *, and stuff this pointer in xdrs->x_buf. Doing - * a fread or fwrite to a scratch buffer would defeat - * most of the gains to be had here and require storage - * management on this buffer, so we don't do this. - */ - return NULL; + /* + * Must do some work to implement this: must insure + * enough data in the underlying stdio buffer, + * that the buffer is aligned so that we can indirect through a + * long *, and stuff this pointer in xdrs->x_buf. Doing + * a fread or fwrite to a scratch buffer would defeat + * most of the gains to be had here and require storage + * management on this buffer, so we don't do this. + */ + return NULL; } static bool_t xdrstdio_getint32 (XDR *xdrs, xdr_int32_t *ip) { - xdr_int32_t mycopy; + xdr_int32_t mycopy; - if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - *ip = xdr_ntohl (mycopy); - return TRUE; + if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) + { + return FALSE; + } + *ip = xdr_ntohl (mycopy); + return TRUE; } static bool_t xdrstdio_putint32 (XDR *xdrs, xdr_int32_t *ip) { - xdr_int32_t mycopy = xdr_htonl (*ip); + xdr_int32_t mycopy = xdr_htonl (*ip); - ip = &mycopy; - if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - return TRUE; + ip = &mycopy; + if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1) + { + return FALSE; + } + return TRUE; } static bool_t xdrstdio_getuint32 (XDR *xdrs, xdr_uint32_t *ip) { - xdr_uint32_t mycopy; - - if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - *ip = xdr_ntohl (mycopy); - return TRUE; + xdr_uint32_t mycopy; + + if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) + { + return FALSE; + } + *ip = xdr_ntohl (mycopy); + return TRUE; } static bool_t xdrstdio_putuint32 (XDR *xdrs, xdr_uint32_t *ip) { - xdr_uint32_t mycopy = xdr_htonl (*ip); - - ip = &mycopy; - if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1) - return FALSE; - return TRUE; + xdr_uint32_t mycopy = xdr_htonl (*ip); + + ip = &mycopy; + if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1) + { + return FALSE; + } + return TRUE; } #else int -gmx_system_xdr_empty; + gmx_system_xdr_empty; #endif /* GMX_SYSTEM_XDR */ diff --git a/src/gromacs/gmxlib/gmx_thread_affinity.c b/src/gromacs/gmxlib/gmx_thread_affinity.c index c67b961a2a..919af6eef8 100644 --- a/src/gromacs/gmxlib/gmx_thread_affinity.c +++ b/src/gromacs/gmxlib/gmx_thread_affinity.c @@ -64,18 +64,18 @@ get_thread_affinity_layout(FILE *fplog, int pin_offset, int * pin_stride, const int **locality_order) { - int nhwthreads,npkg,ncores,nhwthreads_per_core,rc; + int nhwthreads, npkg, ncores, nhwthreads_per_core, rc; const int * pkg_id; const int * core_id; const int * hwthread_id; if (pin_offset < 0) { - gmx_fatal(FARGS,"Negative thread pinning offset requested"); + gmx_fatal(FARGS, "Negative thread pinning offset requested"); } if (*pin_stride < 0) { - gmx_fatal(FARGS,"Negative thread pinning stride requested"); + gmx_fatal(FARGS, "Negative thread pinning stride requested"); } rc = gmx_cpuid_topology(hwinfo->cpuid_info, &nhwthreads, &npkg, &ncores, @@ -130,7 +130,7 @@ get_thread_affinity_layout(FILE *fplog, if (fplog != NULL) { - fprintf(fplog,"Pinning threads with a logical core stride of %d\n", + fprintf(fplog, "Pinning threads with a logical core stride of %d\n", *pin_stride); } } @@ -157,20 +157,20 @@ get_thread_affinity_layout(FILE *fplog, in the case that only some ranks have threads. Thus it is important that GROMACS sets the affinity internally if only PME is using threads. -*/ + */ void -gmx_set_thread_affinity(FILE *fplog, - const t_commrec *cr, - gmx_hw_opt_t *hw_opt, - int nthreads_pme, +gmx_set_thread_affinity(FILE *fplog, + const t_commrec *cr, + gmx_hw_opt_t *hw_opt, + int nthreads_pme, const gmx_hw_info_t *hwinfo, - const t_inputrec *inputrec) + const t_inputrec *inputrec) { - int nth_affinity_set, thread_id_node, thread_id, - nthread_local, nthread_node, nthread_hw_max, nphyscore; - int offset; + int nth_affinity_set, thread_id_node, thread_id, + nthread_local, nthread_node, nthread_hw_max, nphyscore; + int offset; const int *locality_order; - int rc; + int rc; if (hw_opt->thread_affinity == threadaffOFF) { @@ -204,7 +204,7 @@ gmx_set_thread_affinity(FILE *fplog, /* map the current process to cores */ thread_id_node = 0; - nthread_node = nthread_local; + nthread_node = nthread_local; #ifdef GMX_MPI if (PAR(cr) || MULTISIM(cr)) { @@ -213,13 +213,13 @@ gmx_set_thread_affinity(FILE *fplog, */ MPI_Comm comm_intra; - MPI_Comm_split(MPI_COMM_WORLD,gmx_hostname_num(),cr->rank_intranode, + MPI_Comm_split(MPI_COMM_WORLD, gmx_hostname_num(), cr->rank_intranode, &comm_intra); - MPI_Scan(&nthread_local,&thread_id_node,1,MPI_INT,MPI_SUM,comm_intra); + MPI_Scan(&nthread_local, &thread_id_node, 1, MPI_INT, MPI_SUM, comm_intra); /* MPI_Scan is inclusive, but here we need exclusive */ thread_id_node -= nthread_local; /* Get the total number of threads on this physical node */ - MPI_Allreduce(&nthread_local,&nthread_node,1,MPI_INT,MPI_SUM,comm_intra); + MPI_Allreduce(&nthread_local, &nthread_node, 1, MPI_INT, MPI_SUM, comm_intra); MPI_Comm_free(&comm_intra); } #endif @@ -243,7 +243,7 @@ gmx_set_thread_affinity(FILE *fplog, if (hw_opt->core_pinning_offset != 0) { offset = hw_opt->core_pinning_offset; - md_print_info(cr,fplog,"Applying core pinning offset %d\n", offset); + md_print_info(cr, fplog, "Applying core pinning offset %d\n", offset); } rc = get_thread_affinity_layout(fplog, cr, hwinfo, @@ -264,9 +264,9 @@ gmx_set_thread_affinity(FILE *fplog, */ nth_affinity_set = 0; #pragma omp parallel firstprivate(thread_id_node) num_threads(nthread_local) \ - reduction(+:nth_affinity_set) + reduction(+:nth_affinity_set) { - int index,core; + int index, core; gmx_bool setaffinity_ret; thread_id = gmx_omp_get_thread_num(); @@ -313,10 +313,10 @@ gmx_set_thread_affinity(FILE *fplog, #ifdef GMX_MPI #ifdef GMX_THREAD_MPI sprintf(sbuf1, "In thread-MPI thread #%d: ", cr->nodeid); -#else /* GMX_LIB_MPI */ +#else /* GMX_LIB_MPI */ sprintf(sbuf1, "In MPI process #%d: ", cr->nodeid); #endif -#endif /* GMX_MPI */ +#endif /* GMX_MPI */ if (nthread_local > 1) { diff --git a/src/gromacs/gmxlib/gmxcpp.c b/src/gromacs/gmxlib/gmxcpp.c index 84c421e60f..a0253ea74f 100644 --- a/src/gromacs/gmxlib/gmxcpp.c +++ b/src/gromacs/gmxlib/gmxcpp.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon */ @@ -53,393 +53,486 @@ #include "gmxcpp.h" typedef struct { - char *name; - char *def; + char *name; + char *def; } t_define; -static int ndef = 0; -static t_define *defs = NULL; -static int nincl = 0; -static char **incl = 0; +static int ndef = 0; +static t_define *defs = NULL; +static int nincl = 0; +static char **incl = 0; /* enum used for handling ifdefs */ -enum { eifTRUE, eifFALSE, eifIGNORE, eifNR }; +enum { + eifTRUE, eifFALSE, eifIGNORE, eifNR +}; typedef struct gmx_cpp { - FILE *fp; - char *path,*cwd; - char *fn; - int line_len; - char *line; - int line_nr; - int nifdef; - int *ifdefs; - struct gmx_cpp *child,*parent; + FILE *fp; + char *path, *cwd; + char *fn; + int line_len; + char *line; + int line_nr; + int nifdef; + int *ifdefs; + struct gmx_cpp *child, *parent; } gmx_cpp; static gmx_bool is_word_end(char c) { - return !(isalnum(c) || c == '_'); + return !(isalnum(c) || c == '_'); } -static const char *strstrw(const char *buf,const char *word) +static const char *strstrw(const char *buf, const char *word) { - const char *ptr; - - while ((ptr = strstr(buf,word)) != NULL) { - /* Check if we did not find part of a longer word */ - if (ptr && - is_word_end(ptr[strlen(word)]) && - (((ptr > buf) && is_word_end(ptr[-1])) || (ptr == buf))) - return ptr; - - buf = ptr + strlen(word); - } - return NULL; + const char *ptr; + + while ((ptr = strstr(buf, word)) != NULL) + { + /* Check if we did not find part of a longer word */ + if (ptr && + is_word_end(ptr[strlen(word)]) && + (((ptr > buf) && is_word_end(ptr[-1])) || (ptr == buf))) + { + return ptr; + } + + buf = ptr + strlen(word); + } + return NULL; } static gmx_bool find_directive(char *buf, char **name, char **val) { - /* Skip initial whitespace */ - while (isspace(*buf)) ++buf; - /* Check if this is a directive */ - if (*buf != '#') - return FALSE; - /* Skip the hash and any space after it */ - ++buf; - while (isspace(*buf)) ++buf; - /* Set the name pointer and find the next space */ - *name = buf; - while (*buf != 0 && !isspace(*buf)) ++buf; - /* Set the end of the name here, and skip any space */ - if (*buf != 0) - { - *buf = 0; + /* Skip initial whitespace */ + while (isspace(*buf)) + { + ++buf; + } + /* Check if this is a directive */ + if (*buf != '#') + { + return FALSE; + } + /* Skip the hash and any space after it */ ++buf; - while (isspace(*buf)) ++buf; - } - /* Check if anything is remaining */ - *val = (*buf != 0) ? buf : NULL; - return TRUE; + while (isspace(*buf)) + { + ++buf; + } + /* Set the name pointer and find the next space */ + *name = buf; + while (*buf != 0 && !isspace(*buf)) + { + ++buf; + } + /* Set the end of the name here, and skip any space */ + if (*buf != 0) + { + *buf = 0; + ++buf; + while (isspace(*buf)) + { + ++buf; + } + } + /* Check if anything is remaining */ + *val = (*buf != 0) ? buf : NULL; + return TRUE; } static gmx_bool is_ifdeffed_out(gmx_cpp_t handle) { - return ((handle->nifdef > 0) && (handle->ifdefs[handle->nifdef-1] != eifTRUE)); + return ((handle->nifdef > 0) && (handle->ifdefs[handle->nifdef-1] != eifTRUE)); } static void add_include(const char *include) { - int i; - - if (include == NULL) - return; - - for(i=0; (i 0) - defs[i].def = strdup(value); - else - defs[i].def = NULL; + int i; + + for (i = 0; (i < ndef); i++) + { + if (strcmp(defs[i].name, name) == 0) + { + break; + } + } + if (i == ndef) + { + ndef++; + srenew(defs, ndef); + i = ndef - 1; + defs[i].name = strdup(name); + } + else if (defs[i].def) + { + if (debug) + { + fprintf(debug, "Overriding define %s\n", name); + } + sfree(defs[i].def); + } + if (value && strlen(value) > 0) + { + defs[i].def = strdup(value); + } + else + { + defs[i].def = NULL; + } } /* Open the file to be processed. The handle variable holds internal info for the cpp emulator. Return integer status */ -int cpp_open_file(const char *filenm,gmx_cpp_t *handle, char **cppopts) +int cpp_open_file(const char *filenm, gmx_cpp_t *handle, char **cppopts) { - gmx_cpp_t cpp; - char *buf,*pdum; - char *ptr, *ptr2; - int i; - unsigned int i1; - - /* First process options, they might be necessary for opening files - (especially include statements). */ - i = 0; - if (cppopts) { - while(cppopts[i]) { - if (strstr(cppopts[i],"-I") == cppopts[i]) - add_include(cppopts[i]+2); - if (strstr(cppopts[i],"-D") == cppopts[i]) - { - /* If the option contains a =, split it into name and value. */ - ptr = strchr(cppopts[i], '='); - if (ptr) - { - buf = gmx_strndup(cppopts[i] + 2, ptr - cppopts[i] - 2); - add_define(buf, ptr + 1); - sfree(buf); + gmx_cpp_t cpp; + char *buf, *pdum; + char *ptr, *ptr2; + int i; + unsigned int i1; + + /* First process options, they might be necessary for opening files + (especially include statements). */ + i = 0; + if (cppopts) + { + while (cppopts[i]) + { + if (strstr(cppopts[i], "-I") == cppopts[i]) + { + add_include(cppopts[i]+2); + } + if (strstr(cppopts[i], "-D") == cppopts[i]) + { + /* If the option contains a =, split it into name and value. */ + ptr = strchr(cppopts[i], '='); + if (ptr) + { + buf = gmx_strndup(cppopts[i] + 2, ptr - cppopts[i] - 2); + add_define(buf, ptr + 1); + sfree(buf); + } + else + { + add_define(cppopts[i] + 2, NULL); + } + } + i++; } - else + } + if (debug) + { + fprintf(debug, "GMXCPP: added %d command line arguments\n", i); + } + + snew(cpp, 1); + *handle = cpp; + cpp->fn = NULL; + /* Find the file. First check whether it is in the current directory. */ + if (gmx_fexist(filenm)) + { + cpp->fn = strdup(filenm); + } + else + { + /* If not, check all the paths given with -I. */ + for (i = 0; i < nincl; ++i) + { + snew(buf, strlen(incl[i]) + strlen(filenm) + 2); + sprintf(buf, "%s/%s", incl[i], filenm); + if (gmx_fexist(buf)) + { + cpp->fn = buf; + break; + } + sfree(buf); + } + /* If still not found, check the Gromacs library search path. */ + if (!cpp->fn) { - add_define(cppopts[i] + 2, NULL); - } - } - i++; - } - } - if (debug) - fprintf(debug,"GMXCPP: added %d command line arguments\n",i); - - snew(cpp,1); - *handle = cpp; - cpp->fn = NULL; - /* Find the file. First check whether it is in the current directory. */ - if (gmx_fexist(filenm)) - { - cpp->fn = strdup(filenm); - } - else - { - /* If not, check all the paths given with -I. */ - for (i = 0; i < nincl; ++i) - { - snew(buf, strlen(incl[i]) + strlen(filenm) + 2); - sprintf(buf, "%s/%s", incl[i], filenm); - if (gmx_fexist(buf)) - { - cpp->fn = buf; - break; - } - sfree(buf); - } - /* If still not found, check the Gromacs library search path. */ + cpp->fn = low_gmxlibfn(filenm, FALSE, FALSE); + } + } if (!cpp->fn) { - cpp->fn = low_gmxlibfn(filenm, FALSE, FALSE); - } - } - if (!cpp->fn) - { - gmx_fatal(FARGS, "Topology include file \"%s\" not found", filenm); - } - if (NULL != debug) { - fprintf(debug,"GMXCPP: cpp file open %s\n",cpp->fn); - } - /* If the file name has a path component, we need to change to that - * directory. Note that we - just as C - always use UNIX path separators - * internally in include file names. - */ - ptr = strrchr(cpp->fn, '/'); - ptr2 = strrchr(cpp->fn, DIR_SEPARATOR); - - if (ptr == NULL || (ptr2 != NULL && ptr2 > ptr)) - { - ptr = ptr2; - } - if(ptr==NULL) - { - cpp->path = NULL; - cpp->cwd = NULL; - } - else - { - cpp->path = cpp->fn; - *ptr = '\0'; - cpp->fn = strdup(ptr+1); - snew(cpp->cwd,STRLEN); - - gmx_getcwd(cpp->cwd, STRLEN); - if (NULL != debug) { - fprintf(debug,"GMXCPP: cwd %s\n",cpp->cwd); - } - gmx_chdir(cpp->path); - + gmx_fatal(FARGS, "Topology include file \"%s\" not found", filenm); + } if (NULL != debug) - fprintf(debug,"GMXCPP: chdir to %s\n",cpp->path); - } - cpp->line_len= 0; - cpp->line = NULL; - cpp->line_nr = 0; - cpp->nifdef = 0; - cpp->ifdefs = NULL; - cpp->child = NULL; - cpp->parent = NULL; - if (cpp->fp == NULL) { - if (NULL != debug) { - fprintf(debug,"GMXCPP: opening file %s\n",cpp->fn); - } - cpp->fp = fopen(cpp->fn, "r"); - } - if (cpp->fp == NULL) { - switch(errno) { - case EINVAL: - default: - return eCPP_UNKNOWN; - } - } - return eCPP_OK; + { + fprintf(debug, "GMXCPP: cpp file open %s\n", cpp->fn); + } + /* If the file name has a path component, we need to change to that + * directory. Note that we - just as C - always use UNIX path separators + * internally in include file names. + */ + ptr = strrchr(cpp->fn, '/'); + ptr2 = strrchr(cpp->fn, DIR_SEPARATOR); + + if (ptr == NULL || (ptr2 != NULL && ptr2 > ptr)) + { + ptr = ptr2; + } + if (ptr == NULL) + { + cpp->path = NULL; + cpp->cwd = NULL; + } + else + { + cpp->path = cpp->fn; + *ptr = '\0'; + cpp->fn = strdup(ptr+1); + snew(cpp->cwd, STRLEN); + + gmx_getcwd(cpp->cwd, STRLEN); + if (NULL != debug) + { + fprintf(debug, "GMXCPP: cwd %s\n", cpp->cwd); + } + gmx_chdir(cpp->path); + + if (NULL != debug) + { + fprintf(debug, "GMXCPP: chdir to %s\n", cpp->path); + } + } + cpp->line_len = 0; + cpp->line = NULL; + cpp->line_nr = 0; + cpp->nifdef = 0; + cpp->ifdefs = NULL; + cpp->child = NULL; + cpp->parent = NULL; + if (cpp->fp == NULL) + { + if (NULL != debug) + { + fprintf(debug, "GMXCPP: opening file %s\n", cpp->fn); + } + cpp->fp = fopen(cpp->fn, "r"); + } + if (cpp->fp == NULL) + { + switch (errno) + { + case EINVAL: + default: + return eCPP_UNKNOWN; + } + } + return eCPP_OK; } static int process_directive(gmx_cpp_t *handlep, const char *dname, const char *dval) { - gmx_cpp_t handle = (gmx_cpp_t)*handlep; - int i,i0,len,status; - unsigned int i1; - char *inc_fn,*name; - const char *ptr; - int bIfdef,bIfndef; - - /* #ifdef or ifndef statement */ - bIfdef = (strcmp(dname,"ifdef") == 0); - bIfndef = (strcmp(dname,"ifndef") == 0); - if (bIfdef || bIfndef) { - if ((handle->nifdef > 0) && (handle->ifdefs[handle->nifdef-1] != eifTRUE)) { - handle->nifdef++; - srenew(handle->ifdefs,handle->nifdef); - handle->ifdefs[handle->nifdef-1] = eifIGNORE; - } - else { - snew(name,strlen(dval)+1); - sscanf(dval,"%s",name); - for(i=0; (inifdef++; - srenew(handle->ifdefs,handle->nifdef); - if ((bIfdef && (i < ndef)) || (bIfndef && (i == ndef))) - handle->ifdefs[handle->nifdef-1] = eifTRUE; - else - handle->ifdefs[handle->nifdef-1] = eifFALSE; - sfree(name); + gmx_cpp_t handle = (gmx_cpp_t)*handlep; + int i, i0, len, status; + unsigned int i1; + char *inc_fn, *name; + const char *ptr; + int bIfdef, bIfndef; + + /* #ifdef or ifndef statement */ + bIfdef = (strcmp(dname, "ifdef") == 0); + bIfndef = (strcmp(dname, "ifndef") == 0); + if (bIfdef || bIfndef) + { + if ((handle->nifdef > 0) && (handle->ifdefs[handle->nifdef-1] != eifTRUE)) + { + handle->nifdef++; + srenew(handle->ifdefs, handle->nifdef); + handle->ifdefs[handle->nifdef-1] = eifIGNORE; + } + else + { + snew(name, strlen(dval)+1); + sscanf(dval, "%s", name); + for (i = 0; (i < ndef); i++) + { + if (strcmp(defs[i].name, name) == 0) + { + break; + } + } + handle->nifdef++; + srenew(handle->ifdefs, handle->nifdef); + if ((bIfdef && (i < ndef)) || (bIfndef && (i == ndef))) + { + handle->ifdefs[handle->nifdef-1] = eifTRUE; + } + else + { + handle->ifdefs[handle->nifdef-1] = eifFALSE; + } + sfree(name); + } + return eCPP_OK; } - return eCPP_OK; - } - - /* #else statement */ - if (strcmp(dname,"else") == 0) { - if (handle->nifdef <= 0) - return eCPP_SYNTAX; - if (handle->ifdefs[handle->nifdef-1] == eifTRUE) - handle->ifdefs[handle->nifdef-1] = eifFALSE; - else if (handle->ifdefs[handle->nifdef-1] == eifFALSE) - handle->ifdefs[handle->nifdef-1] = eifTRUE; - return eCPP_OK; - } - - /* #endif statement */ - if (strcmp(dname,"endif") == 0) { - if (handle->nifdef <= 0) - return eCPP_SYNTAX; - handle->nifdef--; - return eCPP_OK; - } - /* Check whether we're not ifdeffed out. The order of this statement - is important. It has to come after #ifdef, #else and #endif, but - anything else should be ignored. */ - if (is_ifdeffed_out(handle)) { - return eCPP_OK; - } - - /* Check for include statements */ - if (strcmp(dname,"include") == 0) { - len = -1; - i0 = 0; - for(i1=0; (i1')) { - if (len == -1) { - i0 = i1+1; - len = 0; - } - else - break; - } - else if (len >= 0) - len++; - } - if (len == -1) { - return eCPP_SYNTAX; - } - snew(inc_fn,len+1); - strncpy(inc_fn,dval+i0,len); - inc_fn[len] = '\0'; - - if (debug) - fprintf(debug,"Going to open include file '%s' i0 = %d, strlen = %d\n", - inc_fn,i0,len); - /* Open include file and store it as a child in the handle structure */ - status = cpp_open_file(inc_fn,&(handle->child),NULL); - sfree(inc_fn); - if (status != eCPP_OK) { - handle->child = NULL; - return status; - } - /* Make a linked list of open files and move on to the include file */ - handle->child->parent = handle; - *handlep = handle->child; - handle = *handlep; - return eCPP_OK; - } - - /* #define statement */ - if (strcmp(dname,"define") == 0) { - /* Split it into name and value. */ - ptr = dval; - while ((*ptr != '\0') && !isspace(*ptr)) - ptr++; - name = gmx_strndup(dval, ptr - dval); - - while ((*ptr != '\0') && isspace(*ptr)) - ptr++; - - add_define(name, ptr); - sfree(name); - return eCPP_OK; - } - - /* #undef statement */ - if (strcmp(dname,"undef") == 0) { - snew(name,strlen(dval)+1); - sscanf(dval,"%s",name); - for(i=0; (inifdef <= 0) + { + return eCPP_SYNTAX; + } + if (handle->ifdefs[handle->nifdef-1] == eifTRUE) + { + handle->ifdefs[handle->nifdef-1] = eifFALSE; + } + else if (handle->ifdefs[handle->nifdef-1] == eifFALSE) + { + handle->ifdefs[handle->nifdef-1] = eifTRUE; + } + return eCPP_OK; + } - /* If we haven't matched anything, this is an unknown directive */ - return eCPP_SYNTAX; + /* #endif statement */ + if (strcmp(dname, "endif") == 0) + { + if (handle->nifdef <= 0) + { + return eCPP_SYNTAX; + } + handle->nifdef--; + return eCPP_OK; + } + + /* Check whether we're not ifdeffed out. The order of this statement + is important. It has to come after #ifdef, #else and #endif, but + anything else should be ignored. */ + if (is_ifdeffed_out(handle)) + { + return eCPP_OK; + } + + /* Check for include statements */ + if (strcmp(dname, "include") == 0) + { + len = -1; + i0 = 0; + for (i1 = 0; (i1 < strlen(dval)); i1++) + { + if ((dval[i1] == '"') || (dval[i1] == '<') || (dval[i1] == '>')) + { + if (len == -1) + { + i0 = i1+1; + len = 0; + } + else + { + break; + } + } + else if (len >= 0) + { + len++; + } + } + if (len == -1) + { + return eCPP_SYNTAX; + } + snew(inc_fn, len+1); + strncpy(inc_fn, dval+i0, len); + inc_fn[len] = '\0'; + + if (debug) + { + fprintf(debug, "Going to open include file '%s' i0 = %d, strlen = %d\n", + inc_fn, i0, len); + } + /* Open include file and store it as a child in the handle structure */ + status = cpp_open_file(inc_fn, &(handle->child), NULL); + sfree(inc_fn); + if (status != eCPP_OK) + { + handle->child = NULL; + return status; + } + /* Make a linked list of open files and move on to the include file */ + handle->child->parent = handle; + *handlep = handle->child; + handle = *handlep; + return eCPP_OK; + } + + /* #define statement */ + if (strcmp(dname, "define") == 0) + { + /* Split it into name and value. */ + ptr = dval; + while ((*ptr != '\0') && !isspace(*ptr)) + { + ptr++; + } + name = gmx_strndup(dval, ptr - dval); + + while ((*ptr != '\0') && isspace(*ptr)) + { + ptr++; + } + + add_define(name, ptr); + sfree(name); + return eCPP_OK; + } + + /* #undef statement */ + if (strcmp(dname, "undef") == 0) + { + snew(name, strlen(dval)+1); + sscanf(dval, "%s", name); + for (i = 0; (i < ndef); i++) + { + if (strcmp(defs[i].name, name) == 0) + { + sfree(defs[i].name); + sfree(defs[i].def); + break; + } + } + sfree(name); + for (; (i < ndef-1); i++) + { + defs[i].name = defs[i+1].name; + defs[i].def = defs[i+1].def; + } + ndef--; + + return eCPP_OK; + } + + /* If we haven't matched anything, this is an unknown directive */ + return eCPP_SYNTAX; } /* Return one whole line from the file into buf which holds at most n @@ -447,194 +540,241 @@ process_directive(gmx_cpp_t *handlep, const char *dname, const char *dval) routine also does all the "intelligent" work like processing cpp directives and so on. Note that often the routine is called recursively and no cpp directives are printed. */ -int cpp_read_line(gmx_cpp_t *handlep,int n,char buf[]) +int cpp_read_line(gmx_cpp_t *handlep, int n, char buf[]) { - gmx_cpp_t handle = (gmx_cpp_t)*handlep; - int i,nn,len,status; - const char *ptr, *ptr2; - char *name; - char *dname, *dval; - gmx_bool bEOF; - - if (!handle) - return eCPP_INVALID_HANDLE; - if (!handle->fp) - return eCPP_FILE_NOT_OPEN; - - bEOF = feof(handle->fp); - if (!bEOF) { - /* Read the actual line now. */ - if (fgets2(buf,n-1,handle->fp) == NULL) { - /* Recheck EOF, since we could have been at the end before - * the fgets2 call, but we need to read past the end to know. - */ - bEOF = feof(handle->fp); - if (!bEOF) { - /* Something strange happened, fgets returned NULL, - * but we are not at EOF. - */ - return eCPP_UNKNOWN; - } - } - } - - if (bEOF) { - if (handle->parent == NULL) { - return eCPP_EOF; - } - cpp_close_file(handlep); - *handlep = handle->parent; - handle->child = NULL; - return cpp_read_line(handlep,n,buf); - } - else { - if (n > handle->line_len) { - handle->line_len = n; - srenew(handle->line,n); - } - strcpy(handle->line,buf); - handle->line_nr++; - } - /* Now we've read a line! */ - if (debug) - fprintf(debug,"%s : %4d : %s\n",handle->fn,handle->line_nr,buf); - - /* Process directives if this line contains one */ - if (find_directive(buf, &dname, &dval)) - { - status = process_directive(handlep, dname, dval); - if (status != eCPP_OK) - return status; + gmx_cpp_t handle = (gmx_cpp_t)*handlep; + int i, nn, len, status; + const char *ptr, *ptr2; + char *name; + char *dname, *dval; + gmx_bool bEOF; + + if (!handle) + { + return eCPP_INVALID_HANDLE; + } + if (!handle->fp) + { + return eCPP_FILE_NOT_OPEN; + } + + bEOF = feof(handle->fp); + if (!bEOF) + { + /* Read the actual line now. */ + if (fgets2(buf, n-1, handle->fp) == NULL) + { + /* Recheck EOF, since we could have been at the end before + * the fgets2 call, but we need to read past the end to know. + */ + bEOF = feof(handle->fp); + if (!bEOF) + { + /* Something strange happened, fgets returned NULL, + * but we are not at EOF. + */ + return eCPP_UNKNOWN; + } + } + } + + if (bEOF) + { + if (handle->parent == NULL) + { + return eCPP_EOF; + } + cpp_close_file(handlep); + *handlep = handle->parent; + handle->child = NULL; + return cpp_read_line(handlep, n, buf); + } + else + { + if (n > handle->line_len) + { + handle->line_len = n; + srenew(handle->line, n); + } + strcpy(handle->line, buf); + handle->line_nr++; + } + /* Now we've read a line! */ + if (debug) + { + fprintf(debug, "%s : %4d : %s\n", handle->fn, handle->line_nr, buf); + } + + /* Process directives if this line contains one */ + if (find_directive(buf, &dname, &dval)) + { + status = process_directive(handlep, dname, dval); + if (status != eCPP_OK) + { + return status; + } /* Don't print lines with directives, go on to the next */ - return cpp_read_line(handlep,n,buf); - } - - /* Check whether we're not ifdeffed out. The order of this statement - is important. It has to come after #ifdef, #else and #endif, but - anything else should be ignored. */ - if (is_ifdeffed_out(handle)) { - return cpp_read_line(handlep,n,buf); - } - - /* Check whether we have any defines that need to be replaced. Note - that we have to use a best fit algorithm, rather than first come - first go. We do this by sorting the defines on length first, and - then on alphabetical order. */ - for(i=0; (i 0) { - len = strlen(buf) + nn*max(4,4+strlen(defs[i].def)-strlen(defs[i].name)); - snew(name,len); - ptr = buf; - while ((ptr2 = strstrw(ptr,defs[i].name)) != NULL) { - strncat(name,ptr,(int)(ptr2-ptr)); - strcat(name,defs[i].def); - ptr = ptr2 + strlen(defs[i].name); - } - strcat(name,ptr); - strcpy(buf,name); - sfree(name); - } - } - } - - return eCPP_OK; + return cpp_read_line(handlep, n, buf); + } + + /* Check whether we're not ifdeffed out. The order of this statement + is important. It has to come after #ifdef, #else and #endif, but + anything else should be ignored. */ + if (is_ifdeffed_out(handle)) + { + return cpp_read_line(handlep, n, buf); + } + + /* Check whether we have any defines that need to be replaced. Note + that we have to use a best fit algorithm, rather than first come + first go. We do this by sorting the defines on length first, and + then on alphabetical order. */ + for (i = 0; (i < ndef); i++) + { + if (defs[i].def) + { + nn = 0; + ptr = buf; + while ((ptr = strstrw(ptr, defs[i].name)) != NULL) + { + nn++; + ptr += strlen(defs[i].name); + } + if (nn > 0) + { + len = strlen(buf) + nn*max(4, 4+strlen(defs[i].def)-strlen(defs[i].name)); + snew(name, len); + ptr = buf; + while ((ptr2 = strstrw(ptr, defs[i].name)) != NULL) + { + strncat(name, ptr, (int)(ptr2-ptr)); + strcat(name, defs[i].def); + ptr = ptr2 + strlen(defs[i].name); + } + strcat(name, ptr); + strcpy(buf, name); + sfree(name); + } + } + } + + return eCPP_OK; } char *cpp_cur_file(const gmx_cpp_t *handlep) { - return (*handlep)->fn; + return (*handlep)->fn; } int cpp_cur_linenr(const gmx_cpp_t *handlep) { - return (*handlep)->line_nr; + return (*handlep)->line_nr; } /* Close the file! Return integer status. */ int cpp_close_file(gmx_cpp_t *handlep) { - int i; - gmx_cpp_t handle = (gmx_cpp_t)*handlep; - - if (!handle) - return eCPP_INVALID_HANDLE; - if (!handle->fp) - return eCPP_FILE_NOT_OPEN; - if (debug) - fprintf(debug,"GMXCPP: closing file %s\n",handle->fn); - fclose(handle->fp); - if (NULL != handle->cwd) { - if (NULL != debug) - fprintf(debug,"GMXCPP: chdir to %s\n",handle->cwd); - gmx_chdir(handle->cwd); - } - - if (0) - switch(errno) { - case 0: - break; - case ENOENT: - return eCPP_FILE_NOT_FOUND; - case EBADF: - return eCPP_FILE_NOT_OPEN; - case EINTR: - return eCPP_INTERRUPT; - default: + int i; + gmx_cpp_t handle = (gmx_cpp_t)*handlep; + + if (!handle) + { + return eCPP_INVALID_HANDLE; + } + if (!handle->fp) + { + return eCPP_FILE_NOT_OPEN; + } if (debug) - fprintf(debug,"Strange stuff closing file, errno = %d",errno); - return eCPP_UNKNOWN; - } - handle->fp = NULL; - handle->line_nr = 0; - if (NULL != handle->fn) { - sfree(handle->fn); - handle->fn = NULL; - } - if (NULL != handle->line) { - sfree(handle->line); - handle->line = NULL; - } - if (NULL != handle->ifdefs) - sfree(handle->ifdefs); - handle->nifdef = 0; - if (NULL != handle->path) - sfree(handle->path); - if (NULL != handle->cwd) - sfree(handle->cwd); - - return eCPP_OK; + { + fprintf(debug, "GMXCPP: closing file %s\n", handle->fn); + } + fclose(handle->fp); + if (NULL != handle->cwd) + { + if (NULL != debug) + { + fprintf(debug, "GMXCPP: chdir to %s\n", handle->cwd); + } + gmx_chdir(handle->cwd); + } + + if (0) + { + switch (errno) + { + case 0: + break; + case ENOENT: + return eCPP_FILE_NOT_FOUND; + case EBADF: + return eCPP_FILE_NOT_OPEN; + case EINTR: + return eCPP_INTERRUPT; + default: + if (debug) + { + fprintf(debug, "Strange stuff closing file, errno = %d", errno); + } + return eCPP_UNKNOWN; + } + } + handle->fp = NULL; + handle->line_nr = 0; + if (NULL != handle->fn) + { + sfree(handle->fn); + handle->fn = NULL; + } + if (NULL != handle->line) + { + sfree(handle->line); + handle->line = NULL; + } + if (NULL != handle->ifdefs) + { + sfree(handle->ifdefs); + } + handle->nifdef = 0; + if (NULL != handle->path) + { + sfree(handle->path); + } + if (NULL != handle->cwd) + { + sfree(handle->cwd); + } + + return eCPP_OK; } /* Return a string containing the error message coresponding to status variable */ -char *cpp_error(gmx_cpp_t *handlep,int status) +char *cpp_error(gmx_cpp_t *handlep, int status) { - char buf[256]; - const char *ecpp[] = { - "OK", "File not found", "End of file", "Syntax error", "Interrupted", - "Invalid file handle", - "File not open", "Unknown error", "Error status out of range" - }; - gmx_cpp_t handle = (gmx_cpp_t)*handlep; - - if (!handle) - return (char *)ecpp[eCPP_INVALID_HANDLE]; - - if ((status < 0) || (status >= eCPP_NR)) - status = eCPP_NR; - - sprintf(buf,"%s - File %s, line %d\nLast line read:\n'%s'", - ecpp[status], - (handle && handle->fn) ? handle->fn : "unknown", - (handle) ? handle->line_nr : -1, - handle->line ? handle->line : ""); - - return strdup(buf); + char buf[256]; + const char *ecpp[] = { + "OK", "File not found", "End of file", "Syntax error", "Interrupted", + "Invalid file handle", + "File not open", "Unknown error", "Error status out of range" + }; + gmx_cpp_t handle = (gmx_cpp_t)*handlep; + + if (!handle) + { + return (char *)ecpp[eCPP_INVALID_HANDLE]; + } + + if ((status < 0) || (status >= eCPP_NR)) + { + status = eCPP_NR; + } + + sprintf(buf, "%s - File %s, line %d\nLast line read:\n'%s'", + ecpp[status], + (handle && handle->fn) ? handle->fn : "unknown", + (handle) ? handle->line_nr : -1, + handle->line ? handle->line : ""); + + return strdup(buf); } diff --git a/src/gromacs/gmxlib/gmxfio.c b/src/gromacs/gmxlib/gmxfio.c index f6fd787248..8784fc0545 100644 --- a/src/gromacs/gmxlib/gmxfio.c +++ b/src/gromacs/gmxlib/gmxfio.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -66,72 +66,77 @@ -/* the list of open files is a linked list, with a dummy element at its head; +/* the list of open files is a linked list, with a dummy element at its head; it is initialized when the first file is opened. */ static t_fileio *open_files = NULL; #ifdef GMX_THREAD_MPI -/* this mutex locks the open_files structure so that no two threads can - modify it. +/* this mutex locks the open_files structure so that no two threads can + modify it. - For now, we use this as a coarse grained lock on all file - insertion/deletion operations because it makes avoiding deadlocks + For now, we use this as a coarse grained lock on all file + insertion/deletion operations because it makes avoiding deadlocks easier, and adds almost no overhead: the only overhead is during opening and closing of files, or during global operations like iterating along all open files. All these cases should be rare during the simulation. */ -static tMPI_Thread_mutex_t open_file_mutex=TMPI_THREAD_MUTEX_INITIALIZER; +static tMPI_Thread_mutex_t open_file_mutex = TMPI_THREAD_MUTEX_INITIALIZER; #endif /* These simple lists define the I/O type for these files */ static const int ftpXDR[] = - { efTPR, efTRR, efEDR, efXTC, efMTX, efCPT }; +{ efTPR, efTRR, efEDR, efXTC, efMTX, efCPT }; static const int ftpASC[] = - { efTPA, efGRO, efPDB }; +{ efTPA, efGRO, efPDB }; static const int ftpBIN[] = - { efTPB, efTRJ }; +{ efTPB, efTRJ }; #ifdef HAVE_XML static const int ftpXML[] = - { efXML}; +{ efXML}; #endif const char *itemstr[eitemNR] = - { "[header]", "[inputrec]", "[box]", "[topology]", "[coordinates]", - "[velocities]", "[forces]" }; +{ + "[header]", "[inputrec]", "[box]", "[topology]", "[coordinates]", + "[velocities]", "[forces]" +}; const char *eioNames[eioNR] = - { "REAL", "INT", "GMX_STE_T", "UCHAR", "NUCHAR", "USHORT", "RVEC", "NRVEC", - "IVEC", "STRING" }; +{ + "REAL", "INT", "GMX_STE_T", "UCHAR", "NUCHAR", "USHORT", "RVEC", "NRVEC", + "IVEC", "STRING" +}; /* Comment strings for TPA only */ const char *comment_str[eitemNR] = { -"; The header holds information on the number of atoms etc. and on whether\n" -"; certain items are present in the file or not.\n" -"; \n" -"; WARNING\n" -"; DO NOT EDIT THIS FILE BY HAND\n" -"; The GROMACS preprocessor performs a lot of checks on your input that\n" -"; you ignore when editing this. Your simulation may crash because of this\n", -"; The inputrec holds the parameters for MD such as the number of steps,\n" -"; the timestep and the cut-offs.\n", -"; The simulation box in nm.\n", -"; The topology section describes the topology of the molecules\n" -"; i.e. bonds, angles and dihedrals etc. and also holds the force field\n" -"; parameters.\n", -"; The atomic coordinates in nm\n", -"; The atomic velocities in nm/ps\n", -"; The forces on the atoms in nm/ps^2\n" }; + "; The header holds information on the number of atoms etc. and on whether\n" + "; certain items are present in the file or not.\n" + "; \n" + "; WARNING\n" + "; DO NOT EDIT THIS FILE BY HAND\n" + "; The GROMACS preprocessor performs a lot of checks on your input that\n" + "; you ignore when editing this. Your simulation may crash because of this\n", + "; The inputrec holds the parameters for MD such as the number of steps,\n" + "; the timestep and the cut-offs.\n", + "; The simulation box in nm.\n", + "; The topology section describes the topology of the molecules\n" + "; i.e. bonds, angles and dihedrals etc. and also holds the force field\n" + "; parameters.\n", + "; The atomic coordinates in nm\n", + "; The atomic velocities in nm/ps\n", + "; The forces on the atoms in nm/ps^2\n" +}; /****************************************************************** * - * Internal functions: + * Internal functions: * ******************************************************************/ @@ -154,13 +159,17 @@ static int gmx_fio_int_flush(t_fileio* fio) /* returns TRUE if the file type ftp is in the set set */ static gmx_bool in_ftpset(int ftp, int nset, const int set[]) { - int i; + int i; gmx_bool bResult; bResult = FALSE; for (i = 0; (i < nset); i++) + { if (ftp == set[i]) + { bResult = TRUE; + } + } return bResult; } @@ -169,12 +178,12 @@ static gmx_bool in_ftpset(int ftp, int nset, const int set[]) extern void gmx_fio_set_comment(t_fileio *fio, const char *comment) { - fio->comment=comment; + fio->comment = comment; } extern void gmx_fio_unset_comment(t_fileio *fio) { - fio->comment=NULL; + fio->comment = NULL; } @@ -183,7 +192,7 @@ const char *gmx_fio_dbgstr(t_fileio *fio, const char *desc, char *buf) if (!fio->bDebug) { /* set to empty string */ - buf[0]=0; + buf[0] = 0; } else { @@ -194,26 +203,28 @@ const char *gmx_fio_dbgstr(t_fileio *fio, const char *desc, char *buf) /* check the number of items given against the type */ -void gmx_fio_check_nitem(t_fileio *fio, int eio, int nitem, const char *file, +void gmx_fio_check_nitem(t_fileio *fio, int eio, int nitem, const char *file, int line) { if ((nitem != 1) && !((eio == eioNRVEC) || (eio == eioNUCHAR))) - gmx_fatal(FARGS, + { + gmx_fatal(FARGS, "nitem (%d) may differ from 1 only for %s or %s, not for %s" - "(%s, %d)",nitem,eioNames[eioNUCHAR],eioNames[eioNRVEC], - eioNames[eio],file,line); + "(%s, %d)", nitem, eioNames[eioNUCHAR], eioNames[eioNRVEC], + eioNames[eio], file, line); + } } /* output a data type error. */ -void gmx_fio_fe(t_fileio *fio, int eio, const char *desc, +void gmx_fio_fe(t_fileio *fio, int eio, const char *desc, const char *srcfile, int line) { gmx_fatal(FARGS, "Trying to %s %s type %d (%s), src %s, line %d", - fio->bRead ? "read" : "write",desc,eio, + fio->bRead ? "read" : "write", desc, eio, ((eio >= 0) && (eio < eioNR)) ? eioNames[eio] : "unknown", - srcfile,line); + srcfile, line); } @@ -222,28 +233,30 @@ static void gmx_fio_set_iotype(t_fileio *fio) { if (in_ftpset(fio->iFTP, asize(ftpXDR), ftpXDR)) { -#ifdef USE_XDR - fio->iotp=&xdr_iotype; +#ifdef USE_XDR + fio->iotp = &xdr_iotype; #else - gmx_fatal(FARGS,"Sorry, no XDR"); + gmx_fatal(FARGS, "Sorry, no XDR"); #endif } else if (in_ftpset(fio->iFTP, asize(ftpASC), ftpASC)) { - fio->iotp=&asc_iotype; + fio->iotp = &asc_iotype; } else if (in_ftpset(fio->iFTP, asize(ftpBIN), ftpBIN)) { - fio->iotp=&bin_iotype; + fio->iotp = &bin_iotype; } #ifdef HAVE_XMl - else if (in_ftpset(fio->iFTP,asize(ftpXML),ftpXML)) + else if (in_ftpset(fio->iFTP, asize(ftpXML), ftpXML)) { - fio->iotp=&dummy_iotype; + fio->iotp = &dummy_iotype; } #endif else - fio->iotp=&dummy_iotype; + { + fio->iotp = &dummy_iotype; + } } @@ -268,11 +281,11 @@ static void gmx_fio_make_dummy(void) { if (!open_files) { - snew(open_files,1); - open_files->fp=NULL; - open_files->fn=NULL; - open_files->next=open_files; - open_files->prev=open_files; + snew(open_files, 1); + open_files->fp = NULL; + open_files->fn = NULL; + open_files->next = open_files; + open_files->prev = open_files; #ifdef GMX_THREAD_MPI tMPI_Lock_init(&(open_files->mtx)); #endif @@ -289,7 +302,7 @@ static void gmx_fio_make_dummy(void) * * FILE LIST OPERATIONS * -***********************************************************************/ + ***********************************************************************/ /* insert a new t_fileio into the list */ @@ -300,14 +313,14 @@ static void gmx_fio_insert(t_fileio *fio) /* first lock the big open_files mutex. */ tMPI_Thread_mutex_lock(&open_file_mutex); #endif - /* now check whether the dummy element has been allocated, + /* now check whether the dummy element has been allocated, and allocate it if it hasn't */ gmx_fio_make_dummy(); /* and lock the fio we got and the list's head **/ gmx_fio_lock(fio); gmx_fio_lock(open_files); - prev=open_files->prev; + prev = open_files->prev; /* lock the element after the current one */ if (prev != open_files) { @@ -315,10 +328,10 @@ static void gmx_fio_insert(t_fileio *fio) } /* now do the actual insertion: */ - fio->next=open_files; - open_files->prev=fio; - prev->next=fio; - fio->prev=prev; + fio->next = open_files; + open_files->prev = fio; + prev->next = fio; + fio->prev = prev; /* now unlock all our locks */ if (prev != open_files) @@ -334,31 +347,31 @@ static void gmx_fio_insert(t_fileio *fio) #endif } -/* remove a t_fileio into the list. We assume the fio is locked, and we leave - it locked. +/* remove a t_fileio into the list. We assume the fio is locked, and we leave + it locked. NOTE: We also assume that the open_file_mutex has been locked */ static void gmx_fio_remove(t_fileio *fio) -{ +{ t_fileio *prev; - /* lock prev, because we're changing it */ + /* lock prev, because we're changing it */ gmx_fio_lock(fio->prev); /* now set the prev's pointer */ - fio->prev->next=fio->next; + fio->prev->next = fio->next; gmx_fio_unlock(fio->prev); /* with the next ptr, we can simply lock while the original was locked */ gmx_fio_lock(fio->next); - fio->next->prev=fio->prev; + fio->next->prev = fio->prev; gmx_fio_unlock(fio->next); /* and make sure we point nowhere in particular */ - fio->next=fio->prev=fio; + fio->next = fio->prev = fio; } -/* get the first open file, or NULL if there is none. +/* get the first open file, or NULL if there is none. Returns a locked fio. */ static t_fileio *gmx_fio_get_first(void) { @@ -372,14 +385,14 @@ static t_fileio *gmx_fio_get_first(void) gmx_fio_make_dummy(); gmx_fio_lock(open_files); - ret=open_files->next; + ret = open_files->next; /* check whether there were any to begin with */ - if (ret==open_files) + if (ret == open_files) { /* after this, the open_file pointer should never change */ - ret=NULL; + ret = NULL; } else { @@ -391,17 +404,17 @@ static t_fileio *gmx_fio_get_first(void) return ret; } -/* get the next open file, or NULL if there is none. +/* get the next open file, or NULL if there is none. Unlocks the previous fio and locks the next one. */ static t_fileio *gmx_fio_get_next(t_fileio *fio) { t_fileio *ret; - ret=fio->next; + ret = fio->next; /* check if that was the last one */ - if (fio->next==open_files) + if (fio->next == open_files) { - ret=NULL; + ret = NULL; #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&open_file_mutex); #endif @@ -435,10 +448,10 @@ static void gmx_fio_stop_getting_next(t_fileio *fio) t_fileio *gmx_fio_open(const char *fn, const char *mode) { t_fileio *fio = NULL; - int i; - char newmode[5]; - gmx_bool bRead, bReadWrite; - int xdrid; + int i; + char newmode[5]; + gmx_bool bRead, bReadWrite; + int xdrid; if (fn2ftp(fn) == efTPA) { @@ -473,17 +486,17 @@ t_fileio *gmx_fio_open(const char *fn, const char *mode) } else { - gmx_fatal(FARGS, "DEATH HORROR in gmx_fio_open, mode is '%s'",mode); + gmx_fatal(FARGS, "DEATH HORROR in gmx_fio_open, mode is '%s'", mode); } } /* Check if it should be opened as a binary file */ - if (strncmp(ftp2ftype(fn2ftp(fn)),"ASCII",5)) + if (strncmp(ftp2ftype(fn2ftp(fn)), "ASCII", 5)) { /* Not ascii, add b to file mode */ - if ((strchr(newmode,'b')==NULL) && (strchr(newmode,'B')==NULL)) + if ((strchr(newmode, 'b') == NULL) && (strchr(newmode, 'B') == NULL)) { - strcat(newmode,"b"); + strcat(newmode, "b"); } } @@ -491,30 +504,30 @@ t_fileio *gmx_fio_open(const char *fn, const char *mode) #ifdef GMX_THREAD_MPI tMPI_Lock_init(&(fio->mtx)); #endif - bRead = (newmode[0]=='r' && newmode[1]!='+'); - bReadWrite = (newmode[1]=='+'); - fio->fp = NULL; - fio->xdr = NULL; + bRead = (newmode[0] == 'r' && newmode[1] != '+'); + bReadWrite = (newmode[1] == '+'); + fio->fp = NULL; + fio->xdr = NULL; if (fn) { - fio->iFTP = fn2ftp(fn); - fio->fn = strdup(fn); + fio->iFTP = fn2ftp(fn); + fio->fn = strdup(fn); fio->bStdio = FALSE; /* If this file type is in the list of XDR files, open it like that */ - if (in_ftpset(fio->iFTP,asize(ftpXDR),ftpXDR)) + if (in_ftpset(fio->iFTP, asize(ftpXDR), ftpXDR)) { /* First check whether we have to make a backup, * only for writing, not for read or append. */ - if (newmode[0]=='w') + if (newmode[0] == 'w') { #ifndef GMX_FAHCORE /* only make backups for normal gromacs */ make_backup(fn); #endif } - else + else { /* Check whether file exists */ if (!gmx_fexist(fn)) @@ -523,30 +536,30 @@ t_fileio *gmx_fio_open(const char *fn, const char *mode) } } /* Open the file */ - fio->fp = ffopen(fn,newmode); + fio->fp = ffopen(fn, newmode); /* determine the XDR direction */ - if (newmode[0] == 'w' || newmode[0]=='a') + if (newmode[0] == 'w' || newmode[0] == 'a') { - fio->xdrmode=XDR_ENCODE; + fio->xdrmode = XDR_ENCODE; } else { - fio->xdrmode=XDR_DECODE; + fio->xdrmode = XDR_DECODE; } - snew(fio->xdr,1); + snew(fio->xdr, 1); xdrstdio_create(fio->xdr, fio->fp, fio->xdrmode); } else { /* If it is not, open it as a regular file */ - fio->fp = ffopen(fn,newmode); + fio->fp = ffopen(fn, newmode); } /* for appending seek to end of file to make sure ftell gives correct position * important for checkpointing */ - if (newmode[0]=='a') + if (newmode[0] == 'a') { gmx_fseek(fio->fp, 0, SEEK_END); } @@ -559,11 +572,11 @@ t_fileio *gmx_fio_open(const char *fn, const char *mode) fio->fn = strdup("STDIO"); fio->bStdio = TRUE; } - fio->bRead = bRead; - fio->bReadWrite = bReadWrite; - fio->bDouble= (sizeof(real) == sizeof(double)); - fio->bDebug = FALSE; - fio->bOpen = TRUE; + fio->bRead = bRead; + fio->bReadWrite = bReadWrite; + fio->bDouble = (sizeof(real) == sizeof(double)); + fio->bDebug = FALSE; + fio->bOpen = TRUE; fio->bLargerThan_off_t = FALSE; /* set the reader/writer functions */ @@ -580,7 +593,7 @@ static int gmx_fio_close_locked(t_fileio *fio) if (!fio->bOpen) { - gmx_fatal(FARGS,"File %s closed twice!\n", fio->fn); + gmx_fatal(FARGS, "File %s closed twice!\n", fio->fn); } if (in_ftpset(fio->iFTP, asize(ftpXDR), ftpXDR)) @@ -590,9 +603,11 @@ static int gmx_fio_close_locked(t_fileio *fio) } /* Don't close stdin and stdout! */ - if (!fio->bStdio && fio->fp!=NULL) + if (!fio->bStdio && fio->fp != NULL) + { rc = ffclose(fio->fp); /* fclose returns 0 if happy */ + } fio->bOpen = FALSE; return rc; @@ -611,7 +626,7 @@ int gmx_fio_close(t_fileio *fio) gmx_fio_lock(fio); /* first remove it from the list */ gmx_fio_remove(fio); - rc=gmx_fio_close_locked(fio); + rc = gmx_fio_close_locked(fio); gmx_fio_unlock(fio); sfree(fio->fn); @@ -627,12 +642,12 @@ int gmx_fio_close(t_fileio *fio) /* close only fp but keep FIO entry. */ int gmx_fio_fp_close(t_fileio *fio) { - int rc=0; + int rc = 0; gmx_fio_lock(fio); - if (!in_ftpset(fio->iFTP,asize(ftpXDR),ftpXDR) && !fio->bStdio) + if (!in_ftpset(fio->iFTP, asize(ftpXDR), ftpXDR) && !fio->bStdio) { - rc = ffclose(fio->fp); /* fclose returns 0 if happy */ - fio->fp = NULL; + rc = ffclose(fio->fp); /* fclose returns 0 if happy */ + fio->fp = NULL; } gmx_fio_unlock(fio); @@ -641,7 +656,7 @@ int gmx_fio_fp_close(t_fileio *fio) FILE * gmx_fio_fopen(const char *fn, const char *mode) { - FILE *fp, *ret; + FILE *fp, *ret; t_fileio *fio; fio = gmx_fio_open(fn, mode); @@ -655,38 +670,38 @@ FILE * gmx_fio_fopen(const char *fn, const char *mode) int gmx_fio_fclose(FILE *fp) { t_fileio *cur; - t_fileio *found=NULL; - int rc=-1; + t_fileio *found = NULL; + int rc = -1; - cur=gmx_fio_get_first(); - while(cur) + cur = gmx_fio_get_first(); + while (cur) { if (cur->fp == fp) { - rc=gmx_fio_close_locked(cur); + rc = gmx_fio_close_locked(cur); gmx_fio_remove(cur); gmx_fio_stop_getting_next(cur); sfree(cur->fn); sfree(cur); break; } - cur=gmx_fio_get_next(cur); + cur = gmx_fio_get_next(cur); } return rc; } /* internal variant of get_file_md5 that operates on a locked file */ -static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset, +static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset, unsigned char digest[]) { /*1MB: large size important to catch almost identical files */ -#define CPT_CHK_LEN 1048576 - md5_state_t state; +#define CPT_CHK_LEN 1048576 + md5_state_t state; unsigned char buf[CPT_CHK_LEN]; - gmx_off_t read_len; - gmx_off_t seek_offset; - int ret = -1; + gmx_off_t read_len; + gmx_off_t seek_offset; + int ret = -1; seek_offset = offset - CPT_CHK_LEN; if (seek_offset < 0) @@ -698,7 +713,7 @@ static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset, if (fio->fp && fio->bReadWrite) { - ret=gmx_fseek(fio->fp, seek_offset, SEEK_SET); + ret = gmx_fseek(fio->fp, seek_offset, SEEK_SET); if (ret) { gmx_fseek(fio->fp, 0, SEEK_END); @@ -727,7 +742,7 @@ static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset, * infrequently we don't want to issue lots of warnings before we * have written anything to the log. */ - if(0) + if (0) { fprintf(stderr, "\nTrying to get md5sum: EOF: %s\n", fio->fn); } @@ -735,17 +750,17 @@ static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset, else { fprintf( - stderr, - "\nTrying to get md5sum: Unknown reason for short read: %s\n", - fio->fn); + stderr, + "\nTrying to get md5sum: Unknown reason for short read: %s\n", + fio->fn); } gmx_fseek(fio->fp, 0, SEEK_END); ret = -1; } - gmx_fseek(fio->fp, 0, SEEK_END); /*is already at end, but under windows - it gives problems otherwise*/ + gmx_fseek(fio->fp, 0, SEEK_END); /*is already at end, but under windows + it gives problems otherwise*/ if (debug) { @@ -769,15 +784,15 @@ static int gmx_fio_int_get_file_md5(t_fileio *fio, gmx_off_t offset, /* * fio: file to compute md5 for * offset: starting pointer of region to use for md5 - * digest: return array of md5 sum + * digest: return array of md5 sum */ -int gmx_fio_get_file_md5(t_fileio *fio, gmx_off_t offset, +int gmx_fio_get_file_md5(t_fileio *fio, gmx_off_t offset, unsigned char digest[]) { int ret; gmx_fio_lock(fio); - ret=gmx_fio_int_get_file_md5(fio, offset, digest); + ret = gmx_fio_int_get_file_md5(fio, offset, digest); gmx_fio_unlock(fio); return ret; @@ -793,19 +808,19 @@ static int gmx_fio_int_get_file_position(t_fileio *fio, gmx_off_t *offset) { char buf[STRLEN]; sprintf( - buf, - "Cannot write file '%s'; maybe you are out of disk space?", - fio->fn); + buf, + "Cannot write file '%s'; maybe you are out of disk space?", + fio->fn); gmx_file(buf); } - /* We cannot count on XDR being able to write 64-bit integers, - so separate into high/low 32-bit values. - In case the filesystem has 128-bit offsets we only care - about the first 64 bits - we'll have to fix - this when exabyte-size output files are common... + /* We cannot count on XDR being able to write 64-bit integers, + so separate into high/low 32-bit values. + In case the filesystem has 128-bit offsets we only care + about the first 64 bits - we'll have to fix + this when exabyte-size output files are common... */ - *offset=gmx_ftell(fio->fp); + *offset = gmx_ftell(fio->fp); return 0; } @@ -819,7 +834,7 @@ int gmx_fio_check_file_position(t_fileio *fio) gmx_off_t offset; gmx_fio_lock(fio); - gmx_fio_int_get_file_position(fio,&offset); + gmx_fio_int_get_file_position(fio, &offset); /* We have a 4 byte offset, * make sure that we will detect out of range for all possible cases. */ @@ -834,31 +849,31 @@ int gmx_fio_check_file_position(t_fileio *fio) } int gmx_fio_get_output_file_positions(gmx_file_position_t **p_outputfiles, - int *p_nfiles) + int *p_nfiles) { - int i, nfiles, rc, nalloc; - int pos_hi, pos_lo; - long pos; + int i, nfiles, rc, nalloc; + int pos_hi, pos_lo; + long pos; gmx_file_position_t * outputfiles; - char buf[STRLEN]; - t_fileio *cur; + char buf[STRLEN]; + t_fileio *cur; nfiles = 0; /* pre-allocate 100 files */ nalloc = 100; - snew(outputfiles,nalloc); + snew(outputfiles, nalloc); - cur=gmx_fio_get_first(); - while(cur) + cur = gmx_fio_get_first(); + while (cur) { - /* Skip the checkpoint files themselves, since they could be open when + /* Skip the checkpoint files themselves, since they could be open when we call this routine... */ /* also skip debug files (shoud be the only iFTP==efNR) */ - if (cur->bOpen && - !cur->bRead && - !cur->bStdio && - cur->iFTP != efCPT && + if (cur->bOpen && + !cur->bRead && + !cur->bStdio && + cur->iFTP != efCPT && cur->iFTP != efNR) { int ret; @@ -866,7 +881,7 @@ int gmx_fio_get_output_file_positions(gmx_file_position_t **p_outputfiles, if (nfiles == nalloc) { nalloc += 100; - srenew(outputfiles,nalloc); + srenew(outputfiles, nalloc); } strncpy(outputfiles[nfiles].filename, cur->fn, STRLEN - 1); @@ -875,7 +890,7 @@ int gmx_fio_get_output_file_positions(gmx_file_position_t **p_outputfiles, if (cur->bLargerThan_off_t) { /* -1 signals out of range */ - outputfiles[nfiles].offset = -1; + outputfiles[nfiles].offset = -1; outputfiles[nfiles].chksum_size = -1; } else @@ -883,7 +898,7 @@ int gmx_fio_get_output_file_positions(gmx_file_position_t **p_outputfiles, gmx_fio_int_get_file_position(cur, &outputfiles[nfiles].offset); #ifndef GMX_FAHCORE outputfiles[nfiles].chksum_size - = gmx_fio_int_get_file_md5(cur, + = gmx_fio_int_get_file_md5(cur, outputfiles[nfiles].offset, outputfiles[nfiles].chksum); #endif @@ -892,9 +907,9 @@ int gmx_fio_get_output_file_positions(gmx_file_position_t **p_outputfiles, nfiles++; } - cur=gmx_fio_get_next(cur); + cur = gmx_fio_get_next(cur); } - *p_nfiles = nfiles; + *p_nfiles = nfiles; *p_outputfiles = outputfiles; return 0; @@ -916,14 +931,16 @@ void gmx_fio_checktype(t_fileio *fio) return; } #ifdef HAVE_XMl - else if (in_ftpset(fio->iFTP,asize(ftpXML),ftpXML)) + else if (in_ftpset(fio->iFTP, asize(ftpXML), ftpXML)) { return; } #endif else + { gmx_fatal(FARGS, "Can not read/write topologies to file type %s", ftp2ext(fio->iFTP)); + } } @@ -997,7 +1014,7 @@ int gmx_fio_flush(t_fileio* fio) int ret; gmx_fio_lock(fio); - ret=gmx_fio_int_flush(fio); + ret = gmx_fio_int_flush(fio); gmx_fio_unlock(fio); return ret; @@ -1007,18 +1024,18 @@ int gmx_fio_flush(t_fileio* fio) static int gmx_fio_int_fsync(t_fileio *fio) { - int rc = 0; - int filen=-1; + int rc = 0; + int filen = -1; if (fio->fp) { - rc=gmx_fsync(fio->fp); + rc = gmx_fsync(fio->fp); } else if (fio->xdr) /* this should normally not happen */ { - rc=gmx_fsync((FILE*) fio->xdr->x_private); - /* ^ is this actually OK? */ + rc = gmx_fsync((FILE*) fio->xdr->x_private); + /* ^ is this actually OK? */ } return rc; @@ -1030,7 +1047,7 @@ int gmx_fio_fsync(t_fileio *fio) int rc; gmx_fio_lock(fio); - rc=gmx_fio_int_fsync(fio); + rc = gmx_fio_int_fsync(fio); gmx_fio_unlock(fio); return rc; @@ -1040,26 +1057,26 @@ int gmx_fio_fsync(t_fileio *fio) t_fileio *gmx_fio_all_output_fsync(void) { - t_fileio *ret=NULL; + t_fileio *ret = NULL; t_fileio *cur; - cur=gmx_fio_get_first(); - while(cur) + cur = gmx_fio_get_first(); + while (cur) { /* skip debug files (shoud be the only iFTP==efNR) */ - if (cur->bOpen && - !cur->bRead && - !cur->bStdio && + if (cur->bOpen && + !cur->bRead && + !cur->bStdio && cur->iFTP != efNR) { /* if any of them fails, return failure code */ - int rc=gmx_fio_int_fsync(cur); - if (rc != 0 && !ret) + int rc = gmx_fio_int_fsync(cur); + if (rc != 0 && !ret) { - ret=cur; + ret = cur; } } - cur=gmx_fio_get_next(cur); + cur = gmx_fio_get_next(cur); } /* in addition, we force these to be written out too, if they're being @@ -1083,7 +1100,9 @@ gmx_off_t gmx_fio_ftell(t_fileio* fio) gmx_fio_lock(fio); if (fio->fp) + { ret = gmx_ftell(fio->fp); + } gmx_fio_unlock(fio); return ret; } @@ -1112,7 +1131,9 @@ FILE *gmx_fio_getfp(t_fileio *fio) gmx_fio_lock(fio); if (fio->fp) + { ret = fio->fp; + } gmx_fio_unlock(fio); return ret; } @@ -1123,7 +1144,9 @@ XDR *gmx_fio_getxdr(t_fileio* fio) gmx_fio_lock(fio); if (fio->xdr) + { ret = fio->xdr; + } gmx_fio_unlock(fio); return ret; @@ -1145,21 +1168,19 @@ int xtc_seek_frame(t_fileio *fio, int frame, int natoms) int ret; gmx_fio_lock(fio); - ret=xdr_xtc_seek_frame(frame, fio->fp, fio->xdr, natoms); + ret = xdr_xtc_seek_frame(frame, fio->fp, fio->xdr, natoms); gmx_fio_unlock(fio); return ret; } -int xtc_seek_time(t_fileio *fio, real time, int natoms,gmx_bool bSeekForwardOnly) +int xtc_seek_time(t_fileio *fio, real time, int natoms, gmx_bool bSeekForwardOnly) { int ret; gmx_fio_lock(fio); - ret=xdr_xtc_seek_time(time, fio->fp, fio->xdr, natoms, bSeekForwardOnly); + ret = xdr_xtc_seek_time(time, fio->fp, fio->xdr, natoms, bSeekForwardOnly); gmx_fio_unlock(fio); return ret; } - - diff --git a/src/gromacs/gmxlib/gmxfio_asc.c b/src/gromacs/gmxlib/gmxfio_asc.c index 42245f6933..fe6c696c52 100644 --- a/src/gromacs/gmxlib/gmxfio_asc.c +++ b/src/gromacs/gmxlib/gmxfio_asc.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -68,18 +68,18 @@ /* file type functions */ -static gmx_bool do_ascread(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line); -static gmx_bool do_ascwrite(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line); +static gmx_bool do_ascread(t_fileio *fio, void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line); +static gmx_bool do_ascwrite(t_fileio *fio, const void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line); static gmx_bool do_dummyread(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line); + const char *desc, const char *srcfile, int line); static gmx_bool do_dummywrite(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line); + const char *desc, const char *srcfile, int line); -const t_iotype asc_iotype={do_ascread, do_ascwrite}; -const t_iotype dummy_iotype={do_dummyread, do_dummywrite}; +const t_iotype asc_iotype = {do_ascread, do_ascwrite}; +const t_iotype dummy_iotype = {do_dummyread, do_dummywrite}; @@ -87,14 +87,14 @@ const t_iotype dummy_iotype={do_dummyread, do_dummywrite}; static gmx_bool do_dummyread(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_fatal(FARGS, "File type not set!"); return FALSE; } static gmx_bool do_dummywrite(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_fatal(FARGS, "File type not set!"); return FALSE; @@ -107,14 +107,22 @@ static void encode_string(int maxlen, char dst[], const char src[]) int i; for (i = 0; (src[i] != '\0') && (i < maxlen - 1); i++) + { if ((src[i] == ' ') || (src[i] == '\t')) + { dst[i] = '_'; + } else + { dst[i] = src[i]; + } + } dst[i] = '\0'; if (i == maxlen) + { fprintf(stderr, "String '%s' truncated to '%s'\n", src, dst); + } } static void decode_string(int maxlen, char dst[], const char src[]) @@ -140,79 +148,83 @@ static void decode_string(int maxlen, char dst[], const char src[]) } } -static gmx_bool do_ascwrite(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) +static gmx_bool do_ascwrite(t_fileio *fio, const void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line) { - int i; - int res = 0, *iptr; - real *ptr; - char strbuf[256]; - char buf[GMX_FIO_BUFLEN]; + int i; + int res = 0, *iptr; + real *ptr; + char strbuf[256]; + char buf[GMX_FIO_BUFLEN]; unsigned char *ucptr; - FILE *fp=fio->fp; + FILE *fp = fio->fp; gmx_fio_check_nitem(fio, eio, nitem, srcfile, line); switch (eio) { - case eioREAL: - case eioFLOAT: - case eioDOUBLE: - res = fprintf(fp, "%18.10e%s\n", *((real *) item), - gmx_fio_dbgstr(fio, desc, buf)); - break; - case eioINT: - res = fprintf(fp, "%18d%s\n", *((int *) item), gmx_fio_dbgstr(fio, - desc, - buf)); - break; - case eioGMX_LARGE_INT: - sprintf(strbuf, "%s%s%s", "%", gmx_large_int_fmt, "\n"); - res = fprintf(fp, strbuf, *((gmx_large_int_t *) item), - gmx_fio_dbgstr(fio, desc, buf)); - break; - case eioUCHAR: - res = fprintf(fp, "%4d%s\n", *((unsigned char *) item), - gmx_fio_dbgstr(fio, desc, buf)); - break; - case eioNUCHAR: - ucptr = (unsigned char *) item; - for (i = 0; (i < nitem); i++) - res = fprintf(fp, "%4d", (int) ucptr[i]); - fprintf(fio->fp, "%s\n", gmx_fio_dbgstr(fio, desc, buf)); - break; - case eioUSHORT: - res = fprintf(fp, "%18d%s\n", *((unsigned short *) item), - gmx_fio_dbgstr(fio, desc, buf)); - break; - case eioRVEC: - ptr = (real *) item; - res = fprintf(fp, "%18.10e%18.10e%18.10e%s\n", ptr[XX], - ptr[YY], ptr[ZZ], gmx_fio_dbgstr(fio, desc, buf)); - break; - case eioNRVEC: - for (i = 0; (i < nitem); i++) - { - ptr = ((rvec *) item)[i]; + case eioREAL: + case eioFLOAT: + case eioDOUBLE: + res = fprintf(fp, "%18.10e%s\n", *((real *) item), + gmx_fio_dbgstr(fio, desc, buf)); + break; + case eioINT: + res = fprintf(fp, "%18d%s\n", *((int *) item), gmx_fio_dbgstr(fio, + desc, + buf)); + break; + case eioGMX_LARGE_INT: + sprintf(strbuf, "%s%s%s", "%", gmx_large_int_fmt, "\n"); + res = fprintf(fp, strbuf, *((gmx_large_int_t *) item), + gmx_fio_dbgstr(fio, desc, buf)); + break; + case eioUCHAR: + res = fprintf(fp, "%4d%s\n", *((unsigned char *) item), + gmx_fio_dbgstr(fio, desc, buf)); + break; + case eioNUCHAR: + ucptr = (unsigned char *) item; + for (i = 0; (i < nitem); i++) + { + res = fprintf(fp, "%4d", (int) ucptr[i]); + } + fprintf(fio->fp, "%s\n", gmx_fio_dbgstr(fio, desc, buf)); + break; + case eioUSHORT: + res = fprintf(fp, "%18d%s\n", *((unsigned short *) item), + gmx_fio_dbgstr(fio, desc, buf)); + break; + case eioRVEC: + ptr = (real *) item; res = fprintf(fp, "%18.10e%18.10e%18.10e%s\n", ptr[XX], ptr[YY], ptr[ZZ], gmx_fio_dbgstr(fio, desc, buf)); - } - break; - case eioIVEC: - iptr = (int *) item; - res = fprintf(fp, "%18d%18d%18d%s\n", iptr[XX], iptr[YY], - iptr[ZZ], gmx_fio_dbgstr(fio, desc, buf)); - break; - case eioSTRING: - encode_string(256, strbuf, (char *) item); - res = fprintf(fp, "%-18s%s\n", strbuf, gmx_fio_dbgstr(fio, desc, buf)); - break; - default: - gmx_fio_fe(fio, eio, desc, srcfile, line); + break; + case eioNRVEC: + for (i = 0; (i < nitem); i++) + { + ptr = ((rvec *) item)[i]; + res = fprintf(fp, "%18.10e%18.10e%18.10e%s\n", ptr[XX], + ptr[YY], ptr[ZZ], gmx_fio_dbgstr(fio, desc, buf)); + } + break; + case eioIVEC: + iptr = (int *) item; + res = fprintf(fp, "%18d%18d%18d%s\n", iptr[XX], iptr[YY], + iptr[ZZ], gmx_fio_dbgstr(fio, desc, buf)); + break; + case eioSTRING: + encode_string(256, strbuf, (char *) item); + res = fprintf(fp, "%-18s%s\n", strbuf, gmx_fio_dbgstr(fio, desc, buf)); + break; + default: + gmx_fio_fe(fio, eio, desc, srcfile, line); } if ((res <= 0) && fio->bDebug) + { fprintf(stderr, "Error writing %s %s to file %s (source %s, line %d)\n", eioNames[eio], desc, fio->fn, srcfile, line); + } return (res > 0); } @@ -220,27 +232,33 @@ static gmx_bool do_ascwrite(t_fileio *fio, const void *item, int nitem, int eio, static char *next_item(FILE *fp, char *buf, int buflen) { - int rd; + int rd; gmx_bool in_comment = FALSE; - gmx_bool in_token = FALSE; - int i = 0; + gmx_bool in_token = FALSE; + int i = 0; /* This routine reads strings from the file fp, strips comment * and buffers. For thread-safety reasons, It reads through getc() */ rd = getc(fp); if (rd == EOF) + { gmx_file("End of file"); + } do { if (in_comment) { if (rd == '\n') + { in_comment = FALSE; + } } else if (in_token) { if (isspace(rd) || rd == ';') + { break; + } buf[i++] = (char) rd; } else @@ -248,7 +266,9 @@ static char *next_item(FILE *fp, char *buf, int buflen) if (!isspace(rd)) { if (rd == ';') + { in_comment = TRUE; + } else { in_token = TRUE; @@ -257,8 +277,11 @@ static char *next_item(FILE *fp, char *buf, int buflen) } } if (i >= buflen - 2) + { break; - } while ((rd = getc(fp)) != EOF); + } + } + while ((rd = getc(fp)) != EOF); fprintf(stderr, "WARNING, ftpASC file type not tested!\n"); @@ -267,106 +290,123 @@ static char *next_item(FILE *fp, char *buf, int buflen) return buf; } -static gmx_bool do_ascread(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) +static gmx_bool do_ascread(t_fileio *fio, void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line) { - FILE *fp = fio->fp; - int i, m, res = 0, *iptr, ix; + FILE *fp = fio->fp; + int i, m, res = 0, *iptr, ix; gmx_large_int_t s; - double d, x; - real *ptr; - unsigned char uc, *ucptr; - char *cptr; + double d, x; + real *ptr; + unsigned char uc, *ucptr; + char *cptr; #define NEXT_ITEM_BUF_LEN 128 - char ni_buf[NEXT_ITEM_BUF_LEN]; + char ni_buf[NEXT_ITEM_BUF_LEN]; gmx_fio_check_nitem(fio, eio, nitem, srcfile, line); switch (eio) { - case eioREAL: - case eioFLOAT: - case eioDOUBLE: - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%lf", &d); - if (item) - *((real *) item) = d; - break; - case eioINT: - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%d", &i); - if (item) - *((int *) item) = i; - break; - case eioGMX_LARGE_INT: - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), - gmx_large_int_pfmt, &s); - if (item) - *((gmx_large_int_t *) item) = s; - break; - case eioUCHAR: - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%c", &uc); - if (item) - *((unsigned char *) item) = uc; - break; - case eioNUCHAR: - ucptr = (unsigned char *) item; - for (i = 0; (i < nitem); i++) - { - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%d", &ix); + case eioREAL: + case eioFLOAT: + case eioDOUBLE: + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%lf", &d); if (item) - ucptr[i] = ix; - } - break; - case eioUSHORT: - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%d", &i); - if (item) - *((unsigned short *) item) = i; - break; - case eioRVEC: - ptr = (real *) item; - for (m = 0; (m < DIM); m++) - { - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%lf\n", &x); - ptr[m] = x; - } - break; - case eioNRVEC: - for (i = 0; (i < nitem); i++) - { - ptr = ((rvec *) item)[i]; + { + *((real *) item) = d; + } + break; + case eioINT: + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%d", &i); + if (item) + { + *((int *) item) = i; + } + break; + case eioGMX_LARGE_INT: + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), + gmx_large_int_pfmt, &s); + if (item) + { + *((gmx_large_int_t *) item) = s; + } + break; + case eioUCHAR: + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%c", &uc); + if (item) + { + *((unsigned char *) item) = uc; + } + break; + case eioNUCHAR: + ucptr = (unsigned char *) item; + for (i = 0; (i < nitem); i++) + { + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%d", &ix); + if (item) + { + ucptr[i] = ix; + } + } + break; + case eioUSHORT: + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%d", &i); + if (item) + { + *((unsigned short *) item) = i; + } + break; + case eioRVEC: + ptr = (real *) item; + for (m = 0; (m < DIM); m++) + { + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%lf\n", &x); + ptr[m] = x; + } + break; + case eioNRVEC: + for (i = 0; (i < nitem); i++) + { + ptr = ((rvec *) item)[i]; + for (m = 0; (m < DIM); m++) + { + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%lf\n", + &x); + if (item) + { + ptr[m] = x; + } + } + } + break; + case eioIVEC: + iptr = (int *) item; for (m = 0; (m < DIM); m++) { - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%lf\n", - &x); + res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%d\n", &ix); if (item) - ptr[m] = x; + { + iptr[m] = ix; + } } - } - break; - case eioIVEC: - iptr = (int *) item; - for (m = 0; (m < DIM); m++) - { - res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%d\n", &ix); + break; + case eioSTRING: + cptr = next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN); if (item) - iptr[m] = ix; - } - break; - case eioSTRING: - cptr = next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN); - if (item) - { - decode_string(strlen(cptr) + 1, (char *) item, cptr); - /* res = sscanf(cptr,"%s",(char *)item);*/ - res = 1; - } - break; - default: - gmx_fio_fe(fio, eio, desc, srcfile, line); + { + decode_string(strlen(cptr) + 1, (char *) item, cptr); + /* res = sscanf(cptr,"%s",(char *)item);*/ + res = 1; + } + break; + default: + gmx_fio_fe(fio, eio, desc, srcfile, line); } if ((res <= 0) && fio->bDebug) + { fprintf(stderr, "Error reading %s %s from file %s (source %s, line %d)\n", eioNames[eio], desc, fio->fn, srcfile, line); + } return (res > 0); } - diff --git a/src/gromacs/gmxlib/gmxfio_bin.c b/src/gromacs/gmxlib/gmxfio_bin.c index 307704f736..641897e250 100644 --- a/src/gromacs/gmxlib/gmxfio_bin.c +++ b/src/gromacs/gmxlib/gmxfio_bin.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -62,63 +62,63 @@ /* This is the part that reads dummy and ascii files. */ -static gmx_bool do_binread(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line); -static gmx_bool do_binwrite(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line); +static gmx_bool do_binread(t_fileio *fio, void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line); +static gmx_bool do_binwrite(t_fileio *fio, const void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line); -const t_iotype bin_iotype={do_binread, do_binwrite}; +const t_iotype bin_iotype = {do_binread, do_binwrite}; -static gmx_bool do_binwrite(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) +static gmx_bool do_binwrite(t_fileio *fio, const void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line) { size_t size = 0, wsize; - int ssize; + int ssize; gmx_fio_check_nitem(fio, eio, nitem, srcfile, line); switch (eio) { - case eioREAL: - size = sizeof(real); - break; - case eioFLOAT: - size = sizeof(float); - break; - case eioDOUBLE: - size = sizeof(double); - break; - case eioINT: - size = sizeof(int); - break; - case eioGMX_LARGE_INT: - size = sizeof(gmx_large_int_t); - break; - case eioUCHAR: - size = sizeof(unsigned char); - break; - case eioNUCHAR: - size = sizeof(unsigned char); - break; - case eioUSHORT: - size = sizeof(unsigned short); - break; - case eioRVEC: - size = sizeof(rvec); - break; - case eioNRVEC: - size = sizeof(rvec); - break; - case eioIVEC: - size = sizeof(ivec); - break; - case eioSTRING: - size = ssize = strlen((char *) item) + 1; - do_binwrite(fio, &ssize, 1, eioINT, desc, srcfile, line); - break; - default: - gmx_fio_fe(fio, eio, desc, srcfile, line); + case eioREAL: + size = sizeof(real); + break; + case eioFLOAT: + size = sizeof(float); + break; + case eioDOUBLE: + size = sizeof(double); + break; + case eioINT: + size = sizeof(int); + break; + case eioGMX_LARGE_INT: + size = sizeof(gmx_large_int_t); + break; + case eioUCHAR: + size = sizeof(unsigned char); + break; + case eioNUCHAR: + size = sizeof(unsigned char); + break; + case eioUSHORT: + size = sizeof(unsigned short); + break; + case eioRVEC: + size = sizeof(rvec); + break; + case eioNRVEC: + size = sizeof(rvec); + break; + case eioIVEC: + size = sizeof(ivec); + break; + case eioSTRING: + size = ssize = strlen((char *) item) + 1; + do_binwrite(fio, &ssize, 1, eioINT, desc, srcfile, line); + break; + default: + gmx_fio_fe(fio, eio, desc, srcfile, line); } wsize = fwrite(item, size, nitem, fio->fp); @@ -134,61 +134,71 @@ static gmx_bool do_binwrite(t_fileio *fio, const void *item, int nitem, int eio, return (wsize == nitem); } -static gmx_bool do_binread(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) +static gmx_bool do_binread(t_fileio *fio, void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line) { size_t size = 0, rsize; - int ssize; + int ssize; gmx_fio_check_nitem(fio, eio, nitem, srcfile, line); switch (eio) { - case eioREAL: - if (fio->bDouble) - size = sizeof(double); - else + case eioREAL: + if (fio->bDouble) + { + size = sizeof(double); + } + else + { + size = sizeof(float); + } + break; + case eioFLOAT: size = sizeof(float); - break; - case eioFLOAT: - size = sizeof(float); - break; - case eioDOUBLE: - size = sizeof(double); - break; - case eioINT: - size = sizeof(int); - break; - case eioGMX_LARGE_INT: - size = sizeof(gmx_large_int_t); - break; - case eioUCHAR: - size = sizeof(unsigned char); - break; - case eioNUCHAR: - size = sizeof(unsigned char); - break; - case eioUSHORT: - size = sizeof(unsigned short); - break; - case eioRVEC: - case eioNRVEC: - if (fio->bDouble) - size = sizeof(double) * DIM; - else - size = sizeof(float) * DIM; - break; - case eioIVEC: - size = sizeof(ivec); - break; - case eioSTRING: - do_binread(fio, &ssize, 1, eioINT, desc, srcfile, line); - size = ssize; - break; - default: - gmx_fio_fe(fio, eio, desc, srcfile, line); + break; + case eioDOUBLE: + size = sizeof(double); + break; + case eioINT: + size = sizeof(int); + break; + case eioGMX_LARGE_INT: + size = sizeof(gmx_large_int_t); + break; + case eioUCHAR: + size = sizeof(unsigned char); + break; + case eioNUCHAR: + size = sizeof(unsigned char); + break; + case eioUSHORT: + size = sizeof(unsigned short); + break; + case eioRVEC: + case eioNRVEC: + if (fio->bDouble) + { + size = sizeof(double) * DIM; + } + else + { + size = sizeof(float) * DIM; + } + break; + case eioIVEC: + size = sizeof(ivec); + break; + case eioSTRING: + do_binread(fio, &ssize, 1, eioINT, desc, srcfile, line); + size = ssize; + break; + default: + gmx_fio_fe(fio, eio, desc, srcfile, line); } if (item) + { rsize = fread(item, size, nitem, fio->fp); + } else { /* Skip over it if we have a NULL pointer here */ @@ -196,11 +206,11 @@ static gmx_bool do_binread(t_fileio *fio, void *item, int nitem, int eio, rsize = nitem; } if ((rsize != nitem) && (fio->bDebug)) + { fprintf(stderr, "Error reading %s %s from file %s (source %s, line %d)\n", eioNames[eio], desc, fio->fn, srcfile, line); + } return (rsize == nitem); } - - diff --git a/src/gromacs/gmxlib/gmxfio_int.h b/src/gromacs/gmxlib/gmxfio_int.h index a43091f024..38783eb999 100644 --- a/src/gromacs/gmxlib/gmxfio_int.h +++ b/src/gromacs/gmxlib/gmxfio_int.h @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -41,16 +41,16 @@ /* WARNING WARNING WARNING WARNING The data types used here are PRIVATE to gmxfio routines. DO NOT use them - directly in your own code, but use the external functions provided in - include/gmxfio.h + directly in your own code, but use the external functions provided in + include/gmxfio.h - If you don't heed this warning, your code will suddenly stop working - at some point in the not-so-distant future. + If you don't heed this warning, your code will suddenly stop working + at some point in the not-so-distant future. WARNING WARNING WARNING WARNING */ -/* XDR should be available on all platforms now, +/* XDR should be available on all platforms now, * but we keep the possibility of turning it off... */ #define USE_XDR @@ -58,16 +58,16 @@ /* the reader/writer functions for t_iotype */ -typedef gmx_bool read_func(t_fileio *fio, void *item, int nitem, int eio, - const char *desc,const char *srcfile,int line); -typedef gmx_bool write_func(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc,const char *srcfile,int line); +typedef gmx_bool read_func (t_fileio *fio, void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line); +typedef gmx_bool write_func (t_fileio *fio, const void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line); /* these are pointers to the actual reading & writing functions */ typedef struct { - read_func *nread; + read_func *nread; write_func *nwrite; } t_iotype; @@ -75,32 +75,32 @@ typedef struct struct t_fileio { - FILE *fp; /* the file pointer */ - const t_iotype *iotp; /* file type */ - gmx_bool bOpen, /* the file is open */ - bRead, /* the file is open for reading */ - bDouble, /* write doubles instead of floats */ - bDebug, /* the file ops should come with debug info */ - bStdio, /* the file is actually stdin or stdout */ - bLargerThan_off_t, /* if the file position is largen than off_t - could hold */ - bReadWrite; /* the file is open for reading and writing */ - char *fn; /* the file name */ - XDR *xdr; /* the xdr data pointer */ - enum xdr_op xdrmode; /* the xdr mode */ - int iFTP; /* the file type identifier */ - - const char *comment; /* a comment string for debugging */ - - t_fileio *next, *prev; /* next and previous file pointers in the - linked list */ + FILE *fp; /* the file pointer */ + const t_iotype *iotp; /* file type */ + gmx_bool bOpen, /* the file is open */ + bRead, /* the file is open for reading */ + bDouble, /* write doubles instead of floats */ + bDebug, /* the file ops should come with debug info */ + bStdio, /* the file is actually stdin or stdout */ + bLargerThan_off_t, /* if the file position is largen than off_t + could hold */ + bReadWrite; /* the file is open for reading and writing */ + char *fn; /* the file name */ + XDR *xdr; /* the xdr data pointer */ + enum xdr_op xdrmode; /* the xdr mode */ + int iFTP; /* the file type identifier */ + + const char *comment; /* a comment string for debugging */ + + t_fileio *next, *prev; /* next and previous file pointers in the + linked list */ #ifdef GMX_THREAD_MPI - 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 */ + 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 -}; +}; @@ -109,7 +109,7 @@ extern const t_iotype bin_iotype; extern const t_iotype xdr_iotype; extern const t_iotype dummy_iotype; -extern const char *eioNames[eioNR]; +extern const char *eioNames[eioNR]; @@ -118,15 +118,12 @@ extern const char *eioNames[eioNR]; /* make a debug string if that is requested in the fio */ const char *gmx_fio_dbgstr(t_fileio *fio, const char *desc, char *buf); /* check the number of items against the allowed number of items */ -void gmx_fio_check_nitem(t_fileio *fio, int eio, int nitem, const char *file, +void gmx_fio_check_nitem(t_fileio *fio, int eio, int nitem, const char *file, int line); /* check the output type against allowed values */ -void gmx_fio_fe(t_fileio *fio, int eio, const char *desc, const char *srcfile, +void gmx_fio_fe(t_fileio *fio, int eio, const char *desc, const char *srcfile, int line); /* lock/unlock the mutex associated with a fio */ void gmx_fio_lock(t_fileio *fio); void gmx_fio_unlock(t_fileio *fio); - - - diff --git a/src/gromacs/gmxlib/gmxfio_rw.c b/src/gromacs/gmxlib/gmxfio_rw.c index 5185472863..3fade5a428 100644 --- a/src/gromacs/gmxlib/gmxfio_rw.c +++ b/src/gromacs/gmxlib/gmxfio_rw.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -62,108 +62,108 @@ /******************************************************************* * - * READ/WRITE FUNCTIONS + * READ/WRITE FUNCTIONS * -*******************************************************************/ + *******************************************************************/ gmx_bool gmx_fio_reade_real(t_fileio *fio, real *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioREAL, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioREAL, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_float(t_fileio *fio, float *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioFLOAT, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioFLOAT, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_double(t_fileio *fio, double *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioDOUBLE, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioDOUBLE, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_int(t_fileio *fio, int *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioINT, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioINT, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_gmx_large_int(t_fileio *fio, gmx_large_int_t *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioGMX_LARGE_INT, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioGMX_LARGE_INT, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_uchar(t_fileio *fio, unsigned char *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioUCHAR, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioUCHAR, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_ushort(t_fileio *fio, unsigned short *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioUSHORT, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioUSHORT, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_rvec(t_fileio *fio, rvec *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioRVEC, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioRVEC, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_ivec(t_fileio *fio, ivec *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioIVEC, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioIVEC, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_reade_string(t_fileio *fio, char *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, 1, eioSTRING, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, 1, eioSTRING, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } @@ -172,102 +172,102 @@ gmx_bool gmx_fio_reade_string(t_fileio *fio, char *item, /* Write */ gmx_bool gmx_fio_writee_real(t_fileio *fio, real item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, &item, 1, eioREAL, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, &item, 1, eioREAL, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_float(t_fileio *fio, float item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, &item, 1, eioFLOAT, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, &item, 1, eioFLOAT, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_double(t_fileio *fio, double item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, &item, 1, eioDOUBLE, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, &item, 1, eioDOUBLE, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_int(t_fileio *fio, int item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, &item, 1, eioINT, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, &item, 1, eioINT, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_gmx_large_int(t_fileio *fio, gmx_large_int_t item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, &item, 1, eioGMX_LARGE_INT, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, &item, 1, eioGMX_LARGE_INT, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_uchar(t_fileio *fio, unsigned char item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, &item, 1, eioUCHAR, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, &item, 1, eioUCHAR, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_ushort(t_fileio *fio, unsigned short item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, &item, 1, eioUSHORT, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, &item, 1, eioUSHORT, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_rvec(t_fileio *fio, rvec *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, item, 1, eioRVEC, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, item, 1, eioRVEC, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_ivec(t_fileio *fio, ivec *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, item, 1, eioIVEC, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, item, 1, eioIVEC, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_writee_string(t_fileio *fio, const char *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, item, 1, eioSTRING, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, item, 1, eioSTRING, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } @@ -277,154 +277,194 @@ gmx_bool gmx_fio_writee_string(t_fileio *fio, const char *item, /* Read/write functions */ gmx_bool gmx_fio_doe_real(t_fileio *fio, real *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioREAL, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioREAL, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioREAL, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioREAL, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_float(t_fileio *fio, float *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioFLOAT, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioFLOAT, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioFLOAT, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioFLOAT, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_double(t_fileio *fio, double *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioDOUBLE, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioDOUBLE, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioDOUBLE, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioDOUBLE, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_gmx_bool(t_fileio *fio, gmx_bool *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; - int itmp; - + int itmp; + gmx_fio_lock(fio); if (fio->bRead) { - ret=fio->iotp->nread(fio, &itmp, 1, eioINT, desc, srcfile, line); + ret = fio->iotp->nread(fio, &itmp, 1, eioINT, desc, srcfile, line); *item = itmp; } else { itmp = *item; - ret=fio->iotp->nwrite(fio, &itmp, 1, eioINT, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, &itmp, 1, eioINT, desc, srcfile, line); } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_int(t_fileio *fio, int *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioINT, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioINT, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioINT, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioINT, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_gmx_large_int(t_fileio *fio, gmx_large_int_t *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioGMX_LARGE_INT, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioGMX_LARGE_INT, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioGMX_LARGE_INT, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioGMX_LARGE_INT, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_uchar(t_fileio *fio, unsigned char *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioUCHAR, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioUCHAR, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioUCHAR, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioUCHAR, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_ushort(t_fileio *fio, unsigned short *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioUSHORT, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioUSHORT, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioUSHORT, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioUSHORT, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_rvec(t_fileio *fio, rvec *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioRVEC, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioRVEC, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioRVEC, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioRVEC, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_ivec(t_fileio *fio, ivec *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioIVEC, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioIVEC, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioIVEC, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioIVEC, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_doe_string(t_fileio *fio, char *item, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); if (fio->bRead) - ret=fio->iotp->nread(fio, item, 1, eioSTRING, desc, srcfile, line); + { + ret = fio->iotp->nread(fio, item, 1, eioSTRING, desc, srcfile, line); + } else - ret=fio->iotp->nwrite(fio, item, 1, eioSTRING, desc, srcfile, line); + { + ret = fio->iotp->nwrite(fio, item, 1, eioSTRING, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } @@ -438,123 +478,139 @@ gmx_bool gmx_fio_doe_string(t_fileio *fio, char *item, /* Array reading & writing */ gmx_bool gmx_fio_nreade_real(t_fileio *fio, real *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nread(fio, &(item[i]), 1, eioREAL, desc, srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioREAL, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_float(t_fileio *fio, float *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nread(fio, &(item[i]), 1, eioFLOAT, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioFLOAT, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_double(t_fileio *fio, double *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nread(fio, &(item[i]), 1, eioDOUBLE, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioDOUBLE, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_int(t_fileio *fio, int *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nread(fio, &(item[i]), 1, eioINT, desc, srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioINT, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_gmx_large_int(t_fileio *fio, gmx_large_int_t *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nread(fio, &(item[i]), 1, eioGMX_LARGE_INT, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioGMX_LARGE_INT, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_uchar(t_fileio *fio, unsigned char *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, n, eioNUCHAR, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, n, eioNUCHAR, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_ushort(t_fileio *fio, unsigned short *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nread(fio, &(item[i]), 1, eioUSHORT, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioUSHORT, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_rvec(t_fileio *fio, rvec *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nread(fio, item, n, eioNRVEC, desc, srcfile, line); + ret = fio->iotp->nread(fio, item, n, eioNRVEC, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_ivec(t_fileio *fio, ivec *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nread(fio, item[i], 1, eioIVEC, desc, srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nread(fio, item[i], 1, eioIVEC, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nreade_string(t_fileio *fio, char *item[], int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nread(fio, item[i], 1, eioSTRING, desc, srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nread(fio, item[i], 1, eioSTRING, desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } @@ -565,128 +621,144 @@ gmx_bool gmx_fio_nreade_string(t_fileio *fio, char *item[], int n, /* Array writing */ gmx_bool gmx_fio_nwritee_real(t_fileio *fio, const real *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nwrite(fio, &(item[i]), 1, eioREAL, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioREAL, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nwritee_float(t_fileio *fio, const float *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nwrite(fio, &(item[i]), 1, eioFLOAT, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioFLOAT, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nwritee_double(t_fileio *fio, const double *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nwrite(fio, &(item[i]), 1, eioDOUBLE, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioDOUBLE, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nwritee_int(t_fileio *fio, const int *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nwrite(fio, &(item[i]), 1, eioINT, desc, srcfile, - line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioINT, desc, srcfile, + line); + } gmx_fio_unlock(fio); return ret; } -gmx_bool gmx_fio_nwritee_gmx_large_int(t_fileio *fio, - const gmx_large_int_t *item, int n, - const char *desc, const char *srcfile, int line) +gmx_bool gmx_fio_nwritee_gmx_large_int(t_fileio *fio, + const gmx_large_int_t *item, int n, + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nwrite(fio, &(item[i]), 1, eioGMX_LARGE_INT, - desc, srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioGMX_LARGE_INT, + desc, srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nwritee_uchar(t_fileio *fio, const unsigned char *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, item, n, eioNUCHAR, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, item, n, eioNUCHAR, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nwritee_ushort(t_fileio *fio, const unsigned short *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nwrite(fio, &(item[i]), 1, eioUSHORT, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioUSHORT, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nwritee_rvec(t_fileio *fio, const rvec *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { gmx_bool ret; gmx_fio_lock(fio); - ret=fio->iotp->nwrite(fio, item, n, eioNRVEC, desc, srcfile, line); + ret = fio->iotp->nwrite(fio, item, n, eioNRVEC, desc, srcfile, line); gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nwritee_ivec(t_fileio *fio, const ivec *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nwrite(fio, &(item[i]), 1, eioIVEC, desc, - srcfile, line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioIVEC, desc, + srcfile, line); + } gmx_fio_unlock(fio); return ret; } gmx_bool gmx_fio_nwritee_string(t_fileio *fio, const char *item[], int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;iiotp->nwrite(fio, &(item[i]), 1, eioSTRING, desc, srcfile, - line); + for (i = 0; i < n; i++) + { + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioSTRING, desc, srcfile, + line); + } gmx_fio_unlock(fio); return ret; } @@ -696,22 +768,22 @@ gmx_bool gmx_fio_nwritee_string(t_fileio *fio, const char *item[], int n, /* array read/write functions */ gmx_bool gmx_fio_ndoe_real(t_fileio *fio, real *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &(item[i]), 1, eioREAL, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioREAL, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioREAL, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioREAL, desc, + srcfile, line); } } gmx_fio_unlock(fio); @@ -721,22 +793,22 @@ gmx_bool gmx_fio_ndoe_real(t_fileio *fio, real *item, int n, gmx_bool gmx_fio_ndoe_float(t_fileio *fio, float *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &(item[i]), 1, eioFLOAT, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioFLOAT, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioFLOAT, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioFLOAT, desc, + srcfile, line); } } gmx_fio_unlock(fio); @@ -746,22 +818,22 @@ gmx_bool gmx_fio_ndoe_float(t_fileio *fio, float *item, int n, gmx_bool gmx_fio_ndoe_double(t_fileio *fio, double *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &(item[i]), 1, eioDOUBLE, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioDOUBLE, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioDOUBLE, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioDOUBLE, desc, + srcfile, line); } } gmx_fio_unlock(fio); @@ -771,25 +843,25 @@ gmx_bool gmx_fio_ndoe_double(t_fileio *fio, double *item, int n, gmx_bool gmx_fio_ndoe_gmx_bool(t_fileio *fio, gmx_bool *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i,itmp; - + gmx_bool ret = TRUE; + int i, itmp; + gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &itmp, 1, eioINT, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &itmp, 1, eioINT, desc, + srcfile, line); item[i] = itmp; } else { itmp = item[i]; - ret=ret && fio->iotp->nwrite(fio, &itmp, 1, eioINT, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &itmp, 1, eioINT, desc, + srcfile, line); } } gmx_fio_unlock(fio); @@ -797,22 +869,22 @@ gmx_bool gmx_fio_ndoe_gmx_bool(t_fileio *fio, gmx_bool *item, int n, } gmx_bool gmx_fio_ndoe_int(t_fileio *fio, int *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &(item[i]), 1, eioINT, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioINT, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioINT, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioINT, desc, + srcfile, line); } } gmx_fio_unlock(fio); @@ -822,22 +894,22 @@ gmx_bool gmx_fio_ndoe_int(t_fileio *fio, int *item, int n, gmx_bool gmx_fio_ndoe_gmx_large_int(t_fileio *fio, gmx_large_int_t *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &(item[i]), 1, eioGMX_LARGE_INT, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioGMX_LARGE_INT, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioGMX_LARGE_INT, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioGMX_LARGE_INT, desc, + srcfile, line); } } gmx_fio_unlock(fio); @@ -847,19 +919,19 @@ gmx_bool gmx_fio_ndoe_gmx_large_int(t_fileio *fio, gmx_large_int_t *item, int n, gmx_bool gmx_fio_ndoe_uchar(t_fileio *fio, unsigned char *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; + gmx_bool ret = TRUE; gmx_fio_lock(fio); if (fio->bRead) { - ret=ret && fio->iotp->nread(fio, item, n, eioNUCHAR, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, item, n, eioNUCHAR, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, item, n, eioNUCHAR, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, item, n, eioNUCHAR, desc, + srcfile, line); } gmx_fio_unlock(fio); return ret; @@ -868,22 +940,22 @@ gmx_bool gmx_fio_ndoe_uchar(t_fileio *fio, unsigned char *item, int n, gmx_bool gmx_fio_ndoe_ushort(t_fileio *fio, unsigned short *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &(item[i]), 1, eioUSHORT, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioUSHORT, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioUSHORT, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioUSHORT, desc, + srcfile, line); } } gmx_fio_unlock(fio); @@ -893,18 +965,18 @@ gmx_bool gmx_fio_ndoe_ushort(t_fileio *fio, unsigned short *item, int n, gmx_bool gmx_fio_ndoe_rvec(t_fileio *fio, rvec *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; + gmx_bool ret = TRUE; gmx_fio_lock(fio); if (fio->bRead) { - ret=ret && fio->iotp->nread(fio, item, n, eioNRVEC, desc, srcfile, line); + ret = ret && fio->iotp->nread(fio, item, n, eioNRVEC, desc, srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, item, n, eioNRVEC, desc, srcfile, - line); + ret = ret && fio->iotp->nwrite(fio, item, n, eioNRVEC, desc, srcfile, + line); } gmx_fio_unlock(fio); return ret; @@ -913,22 +985,22 @@ gmx_bool gmx_fio_ndoe_rvec(t_fileio *fio, rvec *item, int n, gmx_bool gmx_fio_ndoe_ivec(t_fileio *fio, ivec *item, int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &(item[i]), 1, eioIVEC, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioIVEC, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioIVEC, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioIVEC, desc, + srcfile, line); } } gmx_fio_unlock(fio); @@ -938,29 +1010,24 @@ gmx_bool gmx_fio_ndoe_ivec(t_fileio *fio, ivec *item, int n, gmx_bool gmx_fio_ndoe_string(t_fileio *fio, char *item[], int n, - const char *desc, const char *srcfile, int line) + const char *desc, const char *srcfile, int line) { - gmx_bool ret=TRUE; - int i; + gmx_bool ret = TRUE; + int i; gmx_fio_lock(fio); - for(i=0;ibRead) { - ret=ret && fio->iotp->nread(fio, &(item[i]), 1, eioSTRING, desc, - srcfile, line); + ret = ret && fio->iotp->nread(fio, &(item[i]), 1, eioSTRING, desc, + srcfile, line); } else { - ret=ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioSTRING, desc, - srcfile, line); + ret = ret && fio->iotp->nwrite(fio, &(item[i]), 1, eioSTRING, desc, + srcfile, line); } } gmx_fio_unlock(fio); return ret; } - - - - - diff --git a/src/gromacs/gmxlib/gmxfio_xdr.c b/src/gromacs/gmxlib/gmxfio_xdr.c index 88ba918c0f..a13c545747 100644 --- a/src/gromacs/gmxlib/gmxfio_xdr.c +++ b/src/gromacs/gmxlib/gmxfio_xdr.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -63,208 +63,280 @@ /* file type functions */ -static gmx_bool do_xdrread(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line); -static gmx_bool do_xdrwrite(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line); +static gmx_bool do_xdrread(t_fileio *fio, void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line); +static gmx_bool do_xdrwrite(t_fileio *fio, const void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line); -const t_iotype xdr_iotype={do_xdrread, do_xdrwrite}; +const t_iotype xdr_iotype = {do_xdrread, do_xdrwrite}; #ifdef USE_XDR -static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) +static gmx_bool do_xdr(t_fileio *fio, void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line) { - unsigned char ucdum, *ucptr; - bool_t res = 0; - float fvec[DIM]; - double dvec[DIM]; - int j, m, *iptr, idum; + unsigned char ucdum, *ucptr; + bool_t res = 0; + float fvec[DIM]; + double dvec[DIM]; + int j, m, *iptr, idum; gmx_large_int_t sdum; - real *ptr; - unsigned short us; - double d = 0; - float f = 0; + real *ptr; + unsigned short us; + double d = 0; + float f = 0; gmx_fio_check_nitem(fio, eio, nitem, srcfile, line); switch (eio) { - case eioREAL: - if (fio->bDouble) - { + case eioREAL: + if (fio->bDouble) + { + if (item && !fio->bRead) + { + d = *((real *) item); + } + res = xdr_double(fio->xdr, &d); + if (item) + { + *((real *) item) = d; + } + } + else + { + if (item && !fio->bRead) + { + f = *((real *) item); + } + res = xdr_float(fio->xdr, &f); + if (item) + { + *((real *) item) = f; + } + } + break; + case eioFLOAT: if (item && !fio->bRead) - d = *((real *) item); - res = xdr_double(fio->xdr, &d); + { + f = *((float *) item); + } + res = xdr_float(fio->xdr, &f); if (item) - *((real *) item) = d; - } - else - { + { + *((float *) item) = f; + } + break; + case eioDOUBLE: if (item && !fio->bRead) - f = *((real *) item); - res = xdr_float(fio->xdr, &f); + { + d = *((double *) item); + } + res = xdr_double(fio->xdr, &d); if (item) - *((real *) item) = f; - } - break; - case eioFLOAT: - if (item && !fio->bRead) - f = *((float *) item); - res = xdr_float(fio->xdr, &f); - if (item) - *((float *) item) = f; - break; - case eioDOUBLE: - if (item && !fio->bRead) - d = *((double *) item); - res = xdr_double(fio->xdr, &d); - if (item) - *((double *) item) = d; - break; - case eioINT: - if (item && !fio->bRead) - idum = *(int *) item; - res = xdr_int(fio->xdr, &idum); - if (item) - *(int *) item = idum; - break; - case eioGMX_LARGE_INT: - /* do_xdr will not generate a warning when a 64bit gmx_large_int_t - * value that is out of 32bit range is read into a 32bit gmx_large_int_t. - */ - if (item && !fio->bRead) - sdum = *(gmx_large_int_t *) item; - res = xdr_gmx_large_int(fio->xdr, &sdum, NULL); - if (item) - *(gmx_large_int_t *) item = sdum; - break; - case eioUCHAR: - if (item && !fio->bRead) - ucdum = *(unsigned char *) item; - res = xdr_u_char(fio->xdr, &ucdum); - if (item) - *(unsigned char *) item = ucdum; - break; - case eioNUCHAR: - ucptr = (unsigned char *) item; - res = 1; - for (j = 0; (j < nitem) && res; j++) - { - res = xdr_u_char(fio->xdr, &(ucptr[j])); - } - break; - case eioUSHORT: - if (item && !fio->bRead) - us = *(unsigned short *) item; - res = xdr_u_short(fio->xdr, (unsigned short *) &us); - if (item) - *(unsigned short *) item = us; - break; - case eioRVEC: - if (fio->bDouble) - { + { + *((double *) item) = d; + } + break; + case eioINT: if (item && !fio->bRead) - for (m = 0; (m < DIM); m++) - dvec[m] = ((real *) item)[m]; - res = xdr_vector(fio->xdr, (char *) dvec, DIM, - (unsigned int) sizeof(double), - (xdrproc_t) xdr_double); + { + idum = *(int *) item; + } + res = xdr_int(fio->xdr, &idum); if (item) - for (m = 0; (m < DIM); m++) - ((real *) item)[m] = dvec[m]; - } - else - { + { + *(int *) item = idum; + } + break; + case eioGMX_LARGE_INT: + /* do_xdr will not generate a warning when a 64bit gmx_large_int_t + * value that is out of 32bit range is read into a 32bit gmx_large_int_t. + */ if (item && !fio->bRead) - for (m = 0; (m < DIM); m++) - fvec[m] = ((real *) item)[m]; - res = xdr_vector(fio->xdr, (char *) fvec, DIM, - (unsigned int) sizeof(float), - (xdrproc_t) xdr_float); + { + sdum = *(gmx_large_int_t *) item; + } + res = xdr_gmx_large_int(fio->xdr, &sdum, NULL); if (item) - for (m = 0; (m < DIM); m++) - ((real *) item)[m] = fvec[m]; - } - break; - case eioNRVEC: - ptr = NULL; - res = 1; - for (j = 0; (j < nitem) && res; j++) - { + { + *(gmx_large_int_t *) item = sdum; + } + break; + case eioUCHAR: + if (item && !fio->bRead) + { + ucdum = *(unsigned char *) item; + } + res = xdr_u_char(fio->xdr, &ucdum); if (item) - ptr = ((rvec *) item)[j]; - res = do_xdr(fio, ptr, 1, eioRVEC, desc, srcfile, line); - } - break; - case eioIVEC: - iptr = (int *) item; - res = 1; - for (m = 0; (m < DIM) && res; m++) - { + { + *(unsigned char *) item = ucdum; + } + break; + case eioNUCHAR: + ucptr = (unsigned char *) item; + res = 1; + for (j = 0; (j < nitem) && res; j++) + { + res = xdr_u_char(fio->xdr, &(ucptr[j])); + } + break; + case eioUSHORT: if (item && !fio->bRead) - idum = iptr[m]; - res = xdr_int(fio->xdr, &idum); + { + us = *(unsigned short *) item; + } + res = xdr_u_short(fio->xdr, (unsigned short *) &us); if (item) - iptr[m] = idum; - } - break; - case eioSTRING: - { - char *cptr; - int slen; - - if (item) + { + *(unsigned short *) item = us; + } + break; + case eioRVEC: + if (fio->bDouble) + { + if (item && !fio->bRead) + { + for (m = 0; (m < DIM); m++) + { + dvec[m] = ((real *) item)[m]; + } + } + res = xdr_vector(fio->xdr, (char *) dvec, DIM, + (unsigned int) sizeof(double), + (xdrproc_t) xdr_double); + if (item) + { + for (m = 0; (m < DIM); m++) + { + ((real *) item)[m] = dvec[m]; + } + } + } + else + { + if (item && !fio->bRead) + { + for (m = 0; (m < DIM); m++) + { + fvec[m] = ((real *) item)[m]; + } + } + res = xdr_vector(fio->xdr, (char *) fvec, DIM, + (unsigned int) sizeof(float), + (xdrproc_t) xdr_float); + if (item) + { + for (m = 0; (m < DIM); m++) + { + ((real *) item)[m] = fvec[m]; + } + } + } + break; + case eioNRVEC: + ptr = NULL; + res = 1; + for (j = 0; (j < nitem) && res; j++) + { + if (item) + { + ptr = ((rvec *) item)[j]; + } + res = do_xdr(fio, ptr, 1, eioRVEC, desc, srcfile, line); + } + break; + case eioIVEC: + iptr = (int *) item; + res = 1; + for (m = 0; (m < DIM) && res; m++) + { + if (item && !fio->bRead) + { + idum = iptr[m]; + } + res = xdr_int(fio->xdr, &idum); + if (item) + { + iptr[m] = idum; + } + } + break; + case eioSTRING: { - if (!fio->bRead) - slen = strlen((char *) item) + 1; + char *cptr; + int slen; + + if (item) + { + if (!fio->bRead) + { + slen = strlen((char *) item) + 1; + } + else + { + slen = 0; + } + } else + { slen = 0; - } - else - slen = 0; + } - if (xdr_int(fio->xdr, &slen) <= 0) - gmx_fatal(FARGS, "wrong string length %d for string %s" - " (source %s, line %d)",slen,desc,srcfile,line); - if (!item && fio->bRead) - snew(cptr,slen); - else - cptr=(char *)item; - if (cptr) - res = xdr_string(fio->xdr,&cptr,slen); - else - res = 1; - if (!item && fio->bRead) - sfree(cptr); - break; - } - default: - gmx_fio_fe(fio, eio, desc, srcfile, line); + if (xdr_int(fio->xdr, &slen) <= 0) + { + gmx_fatal(FARGS, "wrong string length %d for string %s" + " (source %s, line %d)", slen, desc, srcfile, line); + } + if (!item && fio->bRead) + { + snew(cptr, slen); + } + else + { + cptr = (char *)item; + } + if (cptr) + { + res = xdr_string(fio->xdr, &cptr, slen); + } + else + { + res = 1; + } + if (!item && fio->bRead) + { + sfree(cptr); + } + break; + } + default: + gmx_fio_fe(fio, eio, desc, srcfile, line); } if ((res == 0) && (fio->bDebug)) - fprintf(stderr,"Error in xdr I/O %s %s to file %s (source %s, line %d)\n", - eioNames[eio],desc,fio->fn,srcfile,line); + { + fprintf(stderr, "Error in xdr I/O %s %s to file %s (source %s, line %d)\n", + eioNames[eio], desc, fio->fn, srcfile, line); + } return (res != 0); } -static gmx_bool do_xdrread(t_fileio *fio, void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) +static gmx_bool do_xdrread(t_fileio *fio, void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line) { return do_xdr(fio, item, nitem, eio, desc, srcfile, line); } -static gmx_bool do_xdrwrite(t_fileio *fio, const void *item, int nitem, int eio, - const char *desc, const char *srcfile, int line) +static gmx_bool do_xdrwrite(t_fileio *fio, const void *item, int nitem, int eio, + const char *desc, const char *srcfile, int line) { - void *it=(void*)item; /* ugh.. */ + void *it = (void*)item; /* ugh.. */ return do_xdr(fio, it, nitem, eio, desc, srcfile, line); } #endif - - diff --git a/src/gromacs/gmxlib/gpu_utils/memtestG80_core.h b/src/gromacs/gmxlib/gpu_utils/memtestG80_core.h index 079a67fcb5..cbacbdf465 100644 --- a/src/gromacs/gmxlib/gpu_utils/memtestG80_core.h +++ b/src/gromacs/gmxlib/gpu_utils/memtestG80_core.h @@ -16,18 +16,20 @@ #if defined (WINDOWS) || defined (WINNV) #include - inline unsigned int getTimeMilliseconds(void) { - return GetTickCount(); - } +inline unsigned int getTimeMilliseconds(void) +{ + return GetTickCount(); +} #include - #define SLEEPMS(x) Sleep(x) + #define SLEEPMS(x) Sleep(x) #elif defined (LINUX) || defined (OSX) #include - inline unsigned int getTimeMilliseconds(void) { - struct timeval tv; - gettimeofday(&tv,NULL); - return tv.tv_sec*1000 + tv.tv_usec/1000; - } +inline unsigned int getTimeMilliseconds(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec*1000 + tv.tv_usec/1000; +} #include #define SLEEPMS(x) usleep(x*1000) #else @@ -37,17 +39,22 @@ // By default the driver will spinwait when blocked on a kernel call // Use the SOFTWAIT macro to replace this with a thread sleep and occasional poll // limit expresses the max time we're willing to stay in the sleep loop - default = 15sec -inline int _pollStatus(unsigned length=1,unsigned limit=15000) { +inline int _pollStatus(unsigned length = 1, unsigned limit = 15000) +{ //while (cudaStreamQuery(0) != cudaSuccess) {SLEEPMS(length);} unsigned startTime = getTimeMilliseconds(); - while (cudaStreamQuery(0) == cudaErrorNotReady) { - if ((getTimeMilliseconds() - startTime) > limit) return -1; + while (cudaStreamQuery(0) == cudaErrorNotReady) + { + if ((getTimeMilliseconds() - startTime) > limit) + { + return -1; + } SLEEPMS(length); } return 0; } -#define SOFTWAIT() if (_pollStatus() != 0) {return 0xFFFFFFFE;} // -2 -#define SOFTWAIT_LIM(lim) if (_pollStatus(1,lim) != 0) {return 0xFFFFFFFE;} // -2 +#define SOFTWAIT() if (_pollStatus() != 0) {return 0xFFFFFFFE; } // -2 +#define SOFTWAIT_LIM(lim) if (_pollStatus(1, lim) != 0) {return 0xFFFFFFFE; } // -2 //#define SOFTWAIT() //#define SOFTWAIT(delay) if (_pollStatus(delay) != 0) return -2; //#define SOFTWAIT(delay,limit) if (_pollStatus(delay,limit) != 0) return -2; @@ -62,73 +69,74 @@ inline int _pollStatus(unsigned length=1,unsigned limit=15000) { typedef unsigned int uint; // OO interface to MemtestG80 functions -class memtestState { -protected: - const uint nBlocks; - const uint nThreads; - uint loopIters; - uint megsToTest; - int lcgPeriod; - uint* devTestMem; - uint* devTempMem; - uint* hostTempMem; - bool allocated; -public: - uint initTime; - memtestState() : nBlocks(1024), nThreads(512), loopIters(0), megsToTest(0), allocated(false), devTestMem(NULL),devTempMem(NULL),hostTempMem(NULL), initTime(0),lcgPeriod(1024) {}; - ~memtestState() {deallocate();} - - uint allocate(uint mbToTest); - void deallocate(); - bool isAllocated() const {return allocated;} - uint size() const {return megsToTest;} - void setLCGPeriod(int period) {lcgPeriod = period;} - int getLCGPeriod() const {return lcgPeriod;} - - bool gpuMemoryBandwidth(double& bandwidth,uint mbToTest,uint iters=5); - bool gpuWriteConstant(const uint constant) const; - bool gpuVerifyConstant(uint& errorCount,const uint constant) const; - bool gpuShortLCG0(uint& errorCount,const uint repeats) const; - bool gpuShortLCG0Shmem(uint& errorCount,const uint repeats) const; - bool gpuMovingInversionsOnesZeros(uint& errorCount) const; - bool gpuWalking8BitM86(uint& errorCount,const uint shift) const; - bool gpuWalking8Bit(uint& errorCount,const bool ones,const uint shift) const; - bool gpuMovingInversionsRandom(uint& errorCount) const; - bool gpuWalking32Bit(uint& errorCount,const bool ones,const uint shift) const; - bool gpuRandomBlocks(uint& errorCount,const uint seed) const; - bool gpuModuloX(uint& errorCount,const uint shift,const uint pattern,const uint modulus,const uint overwriteIters) const; +class memtestState +{ + protected: + const uint nBlocks; + const uint nThreads; + uint loopIters; + uint megsToTest; + int lcgPeriod; + uint * devTestMem; + uint * devTempMem; + uint * hostTempMem; + bool allocated; + public: + uint initTime; + memtestState() : nBlocks(1024), nThreads(512), loopIters(0), megsToTest(0), allocated(false), devTestMem(NULL), devTempMem(NULL), hostTempMem(NULL), initTime(0), lcgPeriod(1024) {}; + ~memtestState() {deallocate(); } + + uint allocate(uint mbToTest); + void deallocate(); + bool isAllocated() const {return allocated; } + uint size() const {return megsToTest; } + void setLCGPeriod(int period) {lcgPeriod = period; } + int getLCGPeriod() const {return lcgPeriod; } + + bool gpuMemoryBandwidth(double &bandwidth, uint mbToTest, uint iters = 5); + bool gpuWriteConstant(const uint constant) const; + bool gpuVerifyConstant(uint &errorCount, const uint constant) const; + bool gpuShortLCG0(uint &errorCount, const uint repeats) const; + bool gpuShortLCG0Shmem(uint &errorCount, const uint repeats) const; + bool gpuMovingInversionsOnesZeros(uint &errorCount) const; + bool gpuWalking8BitM86(uint &errorCount, const uint shift) const; + bool gpuWalking8Bit(uint &errorCount, const bool ones, const uint shift) const; + bool gpuMovingInversionsRandom(uint &errorCount) const; + bool gpuWalking32Bit(uint &errorCount, const bool ones, const uint shift) const; + bool gpuRandomBlocks(uint &errorCount, const uint seed) const; + bool gpuModuloX(uint &errorCount, const uint shift, const uint pattern, const uint modulus, const uint overwriteIters) const; }; // Utility functions -__host__ double gpuMemoryBandwidth(uint* src,uint* dst,uint mbToTest,uint iters); -__host__ void gpuWriteConstant(const uint nBlocks,const uint nThreads,uint* base,uint N,const uint constant); -__host__ uint gpuVerifyConstant(const uint nBlocks,const uint nThreads,uint* base,uint N,const uint constant,uint* blockErrorCount,uint* errorCounts); +__host__ double gpuMemoryBandwidth(uint* src, uint* dst, uint mbToTest, uint iters); +__host__ void gpuWriteConstant(const uint nBlocks, const uint nThreads, uint* base, uint N, const uint constant); +__host__ uint gpuVerifyConstant(const uint nBlocks, const uint nThreads, uint* base, uint N, const uint constant, uint* blockErrorCount, uint* errorCounts); -__host__ void cpuWriteConstant(const uint nBlocks,const uint nThreads,uint* base,uint N,const uint constant); -__host__ uint cpuVerifyConstant(const uint nBlocks,const uint nThreads,uint* base,uint N,const uint constant); +__host__ void cpuWriteConstant(const uint nBlocks, const uint nThreads, uint* base, uint N, const uint constant); +__host__ uint cpuVerifyConstant(const uint nBlocks, const uint nThreads, uint* base, uint N, const uint constant); // Logic tests -__host__ uint gpuShortLCG0(const uint nBlocks,const uint nThreads,uint* base,uint N,const uint repeats,const int period,uint* blockErrorCounts,uint* errorCounts); -__host__ uint gpuShortLCG0Shmem(const uint nBlocks,const uint nThreads,uint* base,uint N,const uint repeats,const int period,uint* blockErrorCounts,uint* errorCounts); +__host__ uint gpuShortLCG0(const uint nBlocks, const uint nThreads, uint* base, uint N, const uint repeats, const int period, uint* blockErrorCounts, uint* errorCounts); +__host__ uint gpuShortLCG0Shmem(const uint nBlocks, const uint nThreads, uint* base, uint N, const uint repeats, const int period, uint* blockErrorCounts, uint* errorCounts); // Memtest86 Test 2: tseq=0,4 -__host__ uint gpuMovingInversionsOnesZeros(const uint nBlocks,const uint nThreads,uint* base,uint N,uint* blockErrorCounts,uint* errorCounts); +__host__ uint gpuMovingInversionsOnesZeros(const uint nBlocks, const uint nThreads, uint* base, uint N, uint* blockErrorCounts, uint* errorCounts); // Memtest86 Test 3: tseq=1 -__host__ uint gpuWalking8BitM86(const uint nBlocks,const uint nThreads,uint* base,uint N,uint shift,uint* blockErrorCounts,uint* errorCounts); -__host__ uint cpuWalking8BitM86(const uint nBlocks,const uint nThreads,uint* base,uint N,uint shift); -__host__ uint gpuWalking8Bit(const uint nBlocks,const uint nThreads,uint* base,uint N,bool ones,uint shift,uint* blockErrorCount,uint* errorCounts); +__host__ uint gpuWalking8BitM86(const uint nBlocks, const uint nThreads, uint* base, uint N, uint shift, uint* blockErrorCounts, uint* errorCounts); +__host__ uint cpuWalking8BitM86(const uint nBlocks, const uint nThreads, uint* base, uint N, uint shift); +__host__ uint gpuWalking8Bit(const uint nBlocks, const uint nThreads, uint* base, uint N, bool ones, uint shift, uint* blockErrorCount, uint* errorCounts); // Memtest86 Test 4: tseq=10 -__host__ uint gpuMovingInversionsRandom(const uint nBlocks,const uint nThreads,uint* base,uint N,uint* blockErrorCounts,uint* errorCounts); +__host__ uint gpuMovingInversionsRandom(const uint nBlocks, const uint nThreads, uint* base, uint N, uint* blockErrorCounts, uint* errorCounts); // Memtest86 Test 6: tseq=2 -__host__ uint gpuWalking32Bit(const uint nBlocks,const uint nThreads,uint* base,uint N,bool ones,uint shift,uint* blockErrorCount,uint* errorCounts); +__host__ uint gpuWalking32Bit(const uint nBlocks, const uint nThreads, uint* base, uint N, bool ones, uint shift, uint* blockErrorCount, uint* errorCounts); // // Memtest86 Test 7: tseq=9 -__host__ uint gpuRandomBlocks(const uint nBlocks,const uint nThreads,uint* base,uint N,uint seed,uint* blockErrorCount,uint* errorCounts); +__host__ uint gpuRandomBlocks(const uint nBlocks, const uint nThreads, uint* base, uint N, uint seed, uint* blockErrorCount, uint* errorCounts); // Memtest86 Test 8: tseq=3 (M86 uses modulus = 20) -__host__ uint gpuModuloX(const uint nBlocks,const uint nThreads,uint* base,const uint N,uint shift,uint pattern1,const uint modulus,const uint iters,uint* blockErrorCount,uint* errorCounts); +__host__ uint gpuModuloX(const uint nBlocks, const uint nThreads, uint* base, const uint N, uint shift, uint pattern1, const uint modulus, const uint iters, uint* blockErrorCount, uint* errorCounts); #endif diff --git a/src/gromacs/gmxlib/ifunc.c b/src/gromacs/gmxlib/ifunc.c index d5473499fa..e7a23c7aa0 100644 --- a/src/gromacs/gmxlib/ifunc.c +++ b/src/gromacs/gmxlib/ifunc.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -45,136 +45,136 @@ #include "genborn.h" -#define def_bonded(str,lstr,nra,nrpa,nrpb,ind,func)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_BOND, (ind),(func)} +#define def_bonded(str, lstr, nra, nrpa, nrpb, ind, func) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_BOND, (ind), (func)} -#define def_bondedz(str,lstr,nra,nrpa,nrpb,ind,func)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_BOND | IF_LIMZERO, (ind),(func)} +#define def_bondedz(str, lstr, nra, nrpa, nrpb, ind, func) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_BOND | IF_LIMZERO, (ind), (func)} -#define def_bondedt(str,lstr,nra,nrpa,nrpb,ind,func)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_BOND | IF_TABULATED, (ind),(func)} +#define def_bondedt(str, lstr, nra, nrpa, nrpb, ind, func) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_BOND | IF_TABULATED, (ind), (func)} -#define def_bondedtz(str,lstr,nra,nrpa,nrpb,ind,func)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_BOND | IF_TABULATED | IF_LIMZERO,(ind),(func)} +#define def_bondedtz(str, lstr, nra, nrpa, nrpb, ind, func) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_BOND | IF_TABULATED | IF_LIMZERO, (ind), (func)} -#define def_angle(str,lstr,nra,nrpa,nrpb,ind,func)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_BOND | IF_ATYPE,(ind),(func)} - -#define def_bond(str,lstr,nra,nrpa,nrpb,ind,func)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_BOND | IF_CHEMBOND | IF_BTYPE,(ind),(func)} +#define def_angle(str, lstr, nra, nrpa, nrpb, ind, func) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_BOND | IF_ATYPE, (ind), (func)} -#define def_bondt(str,lstr,nra,nrpa,nrpb,ind,func)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_BOND | IF_CHEMBOND | IF_TABULATED,(ind),(func)} +#define def_bond(str, lstr, nra, nrpa, nrpb, ind, func) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_BOND | IF_CHEMBOND | IF_BTYPE, (ind), (func)} -#define def_bondnb(str,lstr,nra,nrpa,nrpb,ind,func)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_BOND | IF_CHEMBOND,(ind),(func)} +#define def_bondt(str, lstr, nra, nrpa, nrpb, ind, func) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_BOND | IF_CHEMBOND | IF_TABULATED, (ind), (func)} -#define def_vsite(str,lstr,nra,nrpa)\ - {str,lstr,(nra),(nrpa), 0,IF_VSITE, -1, unimplemented} +#define def_bondnb(str, lstr, nra, nrpa, nrpb, ind, func) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_BOND | IF_CHEMBOND, (ind), (func)} -#define def_shk(str,lstr,nra,nrpa,nrpb)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_CONSTRAINT, -1, unimplemented} +#define def_vsite(str, lstr, nra, nrpa) \ + {str, lstr, (nra), (nrpa), 0, IF_VSITE, -1, unimplemented} -#define def_shkcb(str,lstr,nra,nrpa,nrpb)\ - {str,lstr,(nra),(nrpa),(nrpb),IF_CONSTRAINT | IF_CHEMBOND,-1, unimplemented} - -#define def_nb(str,lstr,nra, nrp)\ - {str,lstr,(nra), (nrp), 0,IF_NULL, -1,unimplemented} - -#define def_nofc(str,lstr)\ - {str,lstr, 0, 0, 0,IF_NULL, -1,unimplemented} +#define def_shk(str, lstr, nra, nrpa, nrpb) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_CONSTRAINT, -1, unimplemented} + +#define def_shkcb(str, lstr, nra, nrpa, nrpb) \ + {str, lstr, (nra), (nrpa), (nrpb), IF_CONSTRAINT | IF_CHEMBOND, -1, unimplemented} + +#define def_nb(str, lstr, nra, nrp) \ + {str, lstr, (nra), (nrp), 0, IF_NULL, -1, unimplemented} + +#define def_nofc(str, lstr) \ + {str, lstr, 0, 0, 0, IF_NULL, -1, unimplemented} /* this MUST correspond to the enum in include/types/idef.h */ -const t_interaction_function interaction_function[F_NRE]= +const t_interaction_function interaction_function[F_NRE] = { - def_bond ("BONDS", "Bond", 2, 2, 2, eNR_BONDS, bonds ), - def_bond ("G96BONDS", "G96Bond", 2, 2, 2, eNR_BONDS, g96bonds ), - def_bond ("MORSE", "Morse", 2, 3, 3, eNR_MORSE, morse_bonds ), - def_bond ("CUBICBONDS","Cubic Bonds", 2, 3, 0, eNR_CUBICBONDS, cubic_bonds), - def_bondnb ("CONNBONDS","Connect Bonds", 2, 0, 0, 0, unimplemented ), - def_bonded ("HARMONIC", "Harmonic Pot.", 2, 2, 2, eNR_BONDS, bonds ), - def_bondnb ("FENEBONDS", "FENE Bonds", 2, 2, 0, eNR_FENEBONDS, FENE_bonds ), - def_bondt ("TABBONDS", "Tab. Bonds", 2, 2, 2, eNR_TABBONDS, tab_bonds ), - def_bondedtz("TABBONDSNC", "Tab. Bonds NC", 2, 2, 2, eNR_TABBONDS, tab_bonds ), - def_bonded ("RESTRAINTPOT", "Restraint Pot.", 2, 4, 4, eNR_RESTRBONDS, restraint_bonds ), - def_angle ("ANGLES", "Angle", 3, 2, 2, eNR_ANGLES, angles ), - def_angle ("G96ANGLES","G96Angle", 3, 2, 2, eNR_ANGLES, g96angles ), - def_angle ("LINEAR_ANGLES", "Lin. Angle", 3, 2, 2, eNR_LINEAR_ANGLES, linear_angles ), - def_bonded ("CROSS_BOND_BOND", "Bond-Cross", 3, 3, 0,0, cross_bond_bond ), - def_bonded ("CROSS_BOND_ANGLE","BA-Cross", 3, 4, 0,0, cross_bond_angle ), - def_angle ("UREY_BRADLEY","U-B", 3, 4, 4, 0, urey_bradley ), - def_angle ("QANGLES","Quartic Angles", 3, 6, 0, eNR_QANGLES, quartic_angles ), - def_bondedt ("TABANGLES", "Tab. Angles", 3, 2, 2, eNR_TABANGLES, tab_angles ), - def_bonded ("PDIHS", "Proper Dih.", 4, 3, 3, eNR_PROPER, pdihs ), - def_bonded ("RBDIHS", "Ryckaert-Bell.", 4, 6, 6, eNR_RB, rbdihs ), - def_bonded ("FOURDIHS", "Fourier Dih.", 4, 4, 4, eNR_FOURDIH, rbdihs ), - def_bonded ("IDIHS", "Improper Dih.", 4, 2, 2, eNR_IMPROPER,idihs ), - def_bonded ("PIDIHS", "Improper Dih.", 4, 3, 3, eNR_IMPROPER, 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, 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_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 ), - def_bondedz ("LJC_NB", "LJC Pairs NB", 2, 4, 0, eNR_NB14, unimplemented ), - def_nb ("LJ_SR", "LJ (SR)", 2, 2 ), - def_nb ("BHAM", "Buck.ham (SR)", 2, 3 ), - def_nofc ("LJ_LR", "LJ (LR)" ), - def_nofc ("BHAM_LR", "Buck.ham (LR)" ), - def_nofc ("DISPCORR", "Disper. corr." ), - def_nofc ("COUL_SR", "Coulomb (SR)" ), - def_nofc ("COUL_LR", "Coulomb (LR)" ), - def_nofc ("RF_EXCL", "RF excl." ), - def_nofc ("COUL_RECIP", "Coul. recip." ), - def_nofc ("DPD", "DPD" ), - def_bondnb ("POLARIZATION", "Polarization",2, 1, 0, 0, polarize ), - def_bonded ("WATERPOL", "Water Pol.", 5, 6, 0, eNR_WPOL, water_pol ), - def_bonded ("THOLE", "Thole Pol.", 4, 3, 0, eNR_THOLE, thole_pol ), - def_bondnb ("ANHARM_POL", "Anharm. Pol.",2, 3, 0, 0, anharm_polarize ), - def_bonded ("POSRES", "Position Rest.", 1, 3, 3, eNR_POSRES, unimplemented ), - def_bonded ("FBPOSRES","Flat-bottom posres", 1, 3, 0, eNR_FBPOSRES, unimplemented ), - def_bonded ("DISRES", "Dis. Rest.", 2, 6, 0, eNR_DISRES, ta_disres ), - def_nofc ("DISRESVIOL", "D.R.Viol. (nm)" ), - def_bonded ("ORIRES", "Orient. Rest.", 2, 6, 0, eNR_ORIRES, orires ), - def_nofc ("ORDEV", "Ori. R. RMSD" ), - def_bonded ("ANGRES", "Angle Rest.", 4, 3, 3, eNR_ANGRES, angres ), - def_bonded ("ANGRESZ", "Angle Rest. Z", 2, 3, 3, eNR_ANGRESZ,angresz ), - def_bonded ("DIHRES", "Dih. Rest.", 4, 3, 3, eNR_DIHRES, dihres ), - def_nofc ("DIHRESVIOL", "Dih. Rest. Viol." ), /* obsolete */ - def_shkcb ("CONSTR", "Constraint", 2, 1, 1 ), - def_shk ("CONSTRNC", "Constr. No Conn.",2, 1, 1 ), - def_shkcb ("SETTLE", "Settle", 3, 2, 0 ), - def_vsite ("VSITE2", "Virtual site 2", 3, 1 ), - def_vsite ("VSITE3", "Virtual site 3", 4, 2 ), - def_vsite ("VSITE3FD", "Virtual site 3fd",4, 2 ), - def_vsite ("VSITE3FAD","Virtual site 3fad",4, 2 ), - def_vsite ("VSITE3OUT","Virtual site 3out",4, 3 ), - def_vsite ("VSITE4FD", "Virtual site 4fd", 5, 3 ), - def_vsite ("VSITE4FDN","Virtual site 4fdn",5, 3 ), - def_vsite ("VSITEN", "Virtual site N", 2, 2 ), - def_nofc ("COM_PULL", "COM Pull En." ), - def_nofc ("EQM", "Quantum En." ), - def_nofc ("EPOT", "Potential" ), - def_nofc ("EKIN", "Kinetic En." ), - def_nofc ("ETOT", "Total Energy" ), - def_nofc ("ECONS", "Conserved En." ), - def_nofc ("TEMP", "Temperature" ), - def_nofc ("VTEMP", "Vir. Temp. (not used)" ), - /* Note that pressure names can not be more than 8 char's, - * because " (bar)" is appended to them. - */ - def_nofc ("PDISPCORR","Pres. DC" ), - def_nofc ("PRES", "Pressure" ), - def_nofc ("DH/DL_CON","dH/dl constr." ), /* obsolete */ - def_nofc ("DV/DL", "dVremain/dl" ), - def_nofc ("DK/DL", "dEkin/dl" ), - def_nofc ("DVC/DL", "dVcoul/dl" ), - def_nofc ("DVV/DL", "dVvdw/dl" ), - def_nofc ("DVB/DL", "dVbonded/dl" ), - def_nofc ("DVR/DL", "dVrestraint/dl" ), - def_nofc ("DVT/DL", "dVtemperature/dl" ) + def_bond ("BONDS", "Bond", 2, 2, 2, eNR_BONDS, bonds ), + def_bond ("G96BONDS", "G96Bond", 2, 2, 2, eNR_BONDS, g96bonds ), + def_bond ("MORSE", "Morse", 2, 3, 3, eNR_MORSE, morse_bonds ), + def_bond ("CUBICBONDS", "Cubic Bonds", 2, 3, 0, eNR_CUBICBONDS, cubic_bonds), + def_bondnb ("CONNBONDS", "Connect Bonds", 2, 0, 0, 0, unimplemented ), + def_bonded ("HARMONIC", "Harmonic Pot.", 2, 2, 2, eNR_BONDS, bonds ), + def_bondnb ("FENEBONDS", "FENE Bonds", 2, 2, 0, eNR_FENEBONDS, FENE_bonds ), + def_bondt ("TABBONDS", "Tab. Bonds", 2, 2, 2, eNR_TABBONDS, tab_bonds ), + def_bondedtz("TABBONDSNC", "Tab. Bonds NC", 2, 2, 2, eNR_TABBONDS, tab_bonds ), + def_bonded ("RESTRAINTPOT", "Restraint Pot.", 2, 4, 4, eNR_RESTRBONDS, restraint_bonds ), + def_angle ("ANGLES", "Angle", 3, 2, 2, eNR_ANGLES, angles ), + def_angle ("G96ANGLES", "G96Angle", 3, 2, 2, eNR_ANGLES, g96angles ), + def_angle ("LINEAR_ANGLES", "Lin. Angle", 3, 2, 2, eNR_LINEAR_ANGLES, linear_angles ), + def_bonded ("CROSS_BOND_BOND", "Bond-Cross", 3, 3, 0, 0, cross_bond_bond ), + def_bonded ("CROSS_BOND_ANGLE", "BA-Cross", 3, 4, 0, 0, cross_bond_angle ), + def_angle ("UREY_BRADLEY", "U-B", 3, 4, 4, 0, urey_bradley ), + def_angle ("QANGLES", "Quartic Angles", 3, 6, 0, eNR_QANGLES, quartic_angles ), + def_bondedt ("TABANGLES", "Tab. Angles", 3, 2, 2, eNR_TABANGLES, tab_angles ), + def_bonded ("PDIHS", "Proper Dih.", 4, 3, 3, eNR_PROPER, pdihs ), + def_bonded ("RBDIHS", "Ryckaert-Bell.", 4, 6, 6, eNR_RB, rbdihs ), + def_bonded ("FOURDIHS", "Fourier Dih.", 4, 4, 4, eNR_FOURDIH, rbdihs ), + def_bonded ("IDIHS", "Improper Dih.", 4, 2, 2, eNR_IMPROPER, idihs ), + def_bonded ("PIDIHS", "Improper Dih.", 4, 3, 3, eNR_IMPROPER, 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, 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_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 ), + def_bondedz ("LJC_NB", "LJC Pairs NB", 2, 4, 0, eNR_NB14, unimplemented ), + def_nb ("LJ_SR", "LJ (SR)", 2, 2 ), + def_nb ("BHAM", "Buck.ham (SR)", 2, 3 ), + def_nofc ("LJ_LR", "LJ (LR)" ), + def_nofc ("BHAM_LR", "Buck.ham (LR)" ), + def_nofc ("DISPCORR", "Disper. corr." ), + def_nofc ("COUL_SR", "Coulomb (SR)" ), + def_nofc ("COUL_LR", "Coulomb (LR)" ), + def_nofc ("RF_EXCL", "RF excl." ), + def_nofc ("COUL_RECIP", "Coul. recip." ), + def_nofc ("DPD", "DPD" ), + def_bondnb ("POLARIZATION", "Polarization", 2, 1, 0, 0, polarize ), + def_bonded ("WATERPOL", "Water Pol.", 5, 6, 0, eNR_WPOL, water_pol ), + def_bonded ("THOLE", "Thole Pol.", 4, 3, 0, eNR_THOLE, thole_pol ), + def_bondnb ("ANHARM_POL", "Anharm. Pol.", 2, 3, 0, 0, anharm_polarize ), + def_bonded ("POSRES", "Position Rest.", 1, 3, 3, eNR_POSRES, unimplemented ), + def_bonded ("FBPOSRES", "Flat-bottom posres", 1, 3, 0, eNR_FBPOSRES, unimplemented ), + def_bonded ("DISRES", "Dis. Rest.", 2, 6, 0, eNR_DISRES, ta_disres ), + def_nofc ("DISRESVIOL", "D.R.Viol. (nm)" ), + def_bonded ("ORIRES", "Orient. Rest.", 2, 6, 0, eNR_ORIRES, orires ), + def_nofc ("ORDEV", "Ori. R. RMSD" ), + def_bonded ("ANGRES", "Angle Rest.", 4, 3, 3, eNR_ANGRES, angres ), + def_bonded ("ANGRESZ", "Angle Rest. Z", 2, 3, 3, eNR_ANGRESZ, angresz ), + def_bonded ("DIHRES", "Dih. Rest.", 4, 3, 3, eNR_DIHRES, dihres ), + def_nofc ("DIHRESVIOL", "Dih. Rest. Viol." ), /* obsolete */ + def_shkcb ("CONSTR", "Constraint", 2, 1, 1 ), + def_shk ("CONSTRNC", "Constr. No Conn.", 2, 1, 1 ), + def_shkcb ("SETTLE", "Settle", 3, 2, 0 ), + def_vsite ("VSITE2", "Virtual site 2", 3, 1 ), + def_vsite ("VSITE3", "Virtual site 3", 4, 2 ), + def_vsite ("VSITE3FD", "Virtual site 3fd", 4, 2 ), + def_vsite ("VSITE3FAD", "Virtual site 3fad", 4, 2 ), + def_vsite ("VSITE3OUT", "Virtual site 3out", 4, 3 ), + def_vsite ("VSITE4FD", "Virtual site 4fd", 5, 3 ), + def_vsite ("VSITE4FDN", "Virtual site 4fdn", 5, 3 ), + def_vsite ("VSITEN", "Virtual site N", 2, 2 ), + def_nofc ("COM_PULL", "COM Pull En." ), + def_nofc ("EQM", "Quantum En." ), + def_nofc ("EPOT", "Potential" ), + def_nofc ("EKIN", "Kinetic En." ), + def_nofc ("ETOT", "Total Energy" ), + def_nofc ("ECONS", "Conserved En." ), + def_nofc ("TEMP", "Temperature" ), + def_nofc ("VTEMP", "Vir. Temp. (not used)" ), + /* Note that pressure names can not be more than 8 char's, + * because " (bar)" is appended to them. + */ + def_nofc ("PDISPCORR", "Pres. DC" ), + def_nofc ("PRES", "Pressure" ), + def_nofc ("DH/DL_CON", "dH/dl constr." ), /* obsolete */ + def_nofc ("DV/DL", "dVremain/dl" ), + def_nofc ("DK/DL", "dEkin/dl" ), + def_nofc ("DVC/DL", "dVcoul/dl" ), + def_nofc ("DVV/DL", "dVvdw/dl" ), + def_nofc ("DVB/DL", "dVbonded/dl" ), + def_nofc ("DVR/DL", "dVrestraint/dl" ), + def_nofc ("DVT/DL", "dVtemperature/dl" ) }; diff --git a/src/gromacs/gmxlib/index.c b/src/gromacs/gmxlib/index.c index c186a6fe60..b39abd386d 100644 --- a/src/gromacs/gmxlib/index.c +++ b/src/gromacs/gmxlib/index.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -59,125 +59,146 @@ -const char gmx_residuetype_undefined[]="Other"; +const char gmx_residuetype_undefined[] = "Other"; struct gmx_residuetype { - int n; + int n; char ** resname; char ** restype; - + }; static gmx_bool gmx_ask_yesno(gmx_bool bASK) { - char c; + char c; - if (bASK) { - do { - c=toupper(fgetc(stdin)); - } while ((c != 'Y') && (c != 'N')); + if (bASK) + { + do + { + c = toupper(fgetc(stdin)); + } + while ((c != 'Y') && (c != 'N')); - return (c == 'Y'); - } - else - return FALSE; + return (c == 'Y'); + } + else + { + return FALSE; + } } t_blocka *new_blocka(void) { - t_blocka *block; + t_blocka *block; - snew(block,1); - snew(block->index,1); + snew(block, 1); + snew(block->index, 1); - return block; + return block; } -void write_index(const char *outf, t_blocka *b,char **gnames) +void write_index(const char *outf, t_blocka *b, char **gnames) { - FILE *out; - int i,j,k; - - out=gmx_fio_fopen(outf,"w"); - /* fprintf(out,"%5d %5d\n",b->nr,b->nra); */ - for(i=0; (inr); i++) { - fprintf(out,"[ %s ]\n",gnames[i]); - for(k=0,j=b->index[i]; jindex[i+1]; j++,k++) { - fprintf(out,"%4d ",b->a[j]+1); - if ((k % 15) == 14) - fprintf(out,"\n"); + FILE *out; + int i, j, k; + + out = gmx_fio_fopen(outf, "w"); + /* fprintf(out,"%5d %5d\n",b->nr,b->nra); */ + for (i = 0; (i < b->nr); i++) + { + fprintf(out, "[ %s ]\n", gnames[i]); + for (k = 0, j = b->index[i]; j < b->index[i+1]; j++, k++) + { + fprintf(out, "%4d ", b->a[j]+1); + if ((k % 15) == 14) + { + fprintf(out, "\n"); + } + } + fprintf(out, "\n"); } - fprintf(out,"\n"); - } - gmx_fio_fclose(out); + gmx_fio_fclose(out); } -void add_grp(t_blocka *b,char ***gnames,int nra,atom_id a[],const char *name) +void add_grp(t_blocka *b, char ***gnames, int nra, atom_id a[], const char *name) { - int i; + int i; - srenew(b->index,b->nr+2); - srenew(*gnames,b->nr+1); - (*gnames)[b->nr]=strdup(name); + srenew(b->index, b->nr+2); + srenew(*gnames, b->nr+1); + (*gnames)[b->nr] = strdup(name); - srenew(b->a,b->nra+nra); - for(i=0; (ia[b->nra++]=a[i]; - b->nr++; - b->index[b->nr]=b->nra; + srenew(b->a, b->nra+nra); + for (i = 0; (i < nra); i++) + { + b->a[b->nra++] = a[i]; + } + b->nr++; + b->index[b->nr] = b->nra; } -/* compare index in `a' with group in `b' at `index', +/* compare index in `a' with group in `b' at `index', when `index'<0 it is relative to end of `b' */ static gmx_bool grp_cmp(t_blocka *b, int nra, atom_id a[], int index) { - int i; - - if (index < 0) - index = b->nr-1+index; - if (index >= b->nr) - gmx_fatal(FARGS,"no such index group %d in t_blocka (nr=%d)",index,b->nr); - /* compare sizes */ - if ( nra != b->index[index+1] - b->index[index] ) - return FALSE; - for(i=0; ia[b->index[index]+i] ) - return FALSE; - return TRUE; + int i; + + if (index < 0) + { + index = b->nr-1+index; + } + if (index >= b->nr) + { + gmx_fatal(FARGS, "no such index group %d in t_blocka (nr=%d)", index, b->nr); + } + /* compare sizes */ + if (nra != b->index[index+1] - b->index[index]) + { + return FALSE; + } + for (i = 0; i < nra; i++) + { + if (a[i] != b->a[b->index[index]+i]) + { + return FALSE; + } + } + return TRUE; } -static void +static void p_status(const char **restype, int nres, const char **typenames, int ntypes) { - int i,j; - int found; - + int i, j; + int found; + int * counter; - - snew(counter,ntypes); - for(i=0;i 0) { - printf("There are: %5d %10s residues\n",counter[i],typenames[i]); + printf("There are: %5d %10s residues\n", counter[i], typenames[i]); } } @@ -186,125 +207,150 @@ p_status(const char **restype, int nres, const char **typenames, int ntypes) atom_id * -mk_aid(t_atoms *atoms,const char ** restype,const char * typestring,int *nra,gmx_bool bMatch) +mk_aid(t_atoms *atoms, const char ** restype, const char * typestring, int *nra, gmx_bool bMatch) /* Make an array of atom_ids for all atoms with residuetypes matching typestring, or the opposite if bMatch is false */ { atom_id *a; - int i; - int res; - - snew(a,atoms->nr); - *nra=0; - for(i=0; (inr); i++) + int i; + int res; + + snew(a, atoms->nr); + *nra = 0; + for (i = 0; (i < atoms->nr); i++) { - res=!gmx_strcasecmp(restype[atoms->atom[i].resind],typestring); - if(bMatch==FALSE) + res = !gmx_strcasecmp(restype[atoms->atom[i].resind], typestring); + if (bMatch == FALSE) { - res=!res; + res = !res; } - if(res) + if (res) { - a[(*nra)++]=i; + a[(*nra)++] = i; } } - + return a; } typedef struct { - char *rname; - gmx_bool bNeg; - char *gname; + char *rname; + gmx_bool bNeg; + char *gname; } restp_t; -static void analyse_other(const char ** restype,t_atoms *atoms, - t_blocka *gb,char ***gn,gmx_bool bASK,gmx_bool bVerb) +static void analyse_other(const char ** restype, t_atoms *atoms, + t_blocka *gb, char ***gn, gmx_bool bASK, gmx_bool bVerb) { - restp_t *restp=NULL; - char **attp=NULL; - char *rname,*aname; - atom_id *other_ndx,*aid,*aaid; - int i,j,k,l,resind,naid,naaid,natp,nrestp=0; - - for(i=0; (inres); i++) + restp_t *restp = NULL; + char **attp = NULL; + char *rname, *aname; + atom_id *other_ndx, *aid, *aaid; + int i, j, k, l, resind, naid, naaid, natp, nrestp = 0; + + for (i = 0; (i < atoms->nres); i++) { - if (gmx_strcasecmp(restype[i],"Protein") && gmx_strcasecmp(restype[i],"DNA") && gmx_strcasecmp(restype[i],"RNA") && gmx_strcasecmp(restype[i],"Water")) + if (gmx_strcasecmp(restype[i], "Protein") && gmx_strcasecmp(restype[i], "DNA") && gmx_strcasecmp(restype[i], "RNA") && gmx_strcasecmp(restype[i], "Water")) { break; } } - if (i < atoms->nres) { - /* we have others */ - if (bVerb) - printf("Analysing residues not classified as Protein/DNA/RNA/Water and splitting into groups...\n"); - snew(other_ndx,atoms->nr); - for(k=0; (knr); k++) { - resind = atoms->atom[k].resind; - rname = *atoms->resinfo[resind].name; - if (gmx_strcasecmp(restype[resind],"Protein") && gmx_strcasecmp(restype[resind],"DNA") && - gmx_strcasecmp(restype[resind],"RNA") && gmx_strcasecmp(restype[resind],"Water")) + if (i < atoms->nres) + { + /* we have others */ + if (bVerb) + { + printf("Analysing residues not classified as Protein/DNA/RNA/Water and splitting into groups...\n"); + } + snew(other_ndx, atoms->nr); + for (k = 0; (k < atoms->nr); k++) { + resind = atoms->atom[k].resind; + rname = *atoms->resinfo[resind].name; + if (gmx_strcasecmp(restype[resind], "Protein") && gmx_strcasecmp(restype[resind], "DNA") && + gmx_strcasecmp(restype[resind], "RNA") && gmx_strcasecmp(restype[resind], "Water")) + { - for(l=0; (lnr); - naid=0; - for(j=0; (jnr); j++) { - rname = *atoms->resinfo[atoms->atom[j].resind].name; - if ((strcmp(restp[i].rname,rname) == 0 && !restp[i].bNeg) || - (strcmp(restp[i].rname,rname) != 0 && restp[i].bNeg)) { - aid[naid++] = j; - } - } - add_grp(gb,gn,naid,aid,restp[i].gname); - if (bASK) { - printf("split %s into atoms (y/n) ? ",restp[i].gname); - fflush(stdout); - if (gmx_ask_yesno(bASK)) { - natp=0; - for(k=0; (katomname[aid[k]]; - for(l=0; (l 1) { - for(l=0; (latomname[aid[k]]; - if (strcmp(aname,attp[l])==0) - aaid[naaid++]=aid[k]; - } - add_grp(gb,gn,naaid,aaid,attp[l]); - sfree(aaid); - } - } - sfree(attp); - attp=NULL; - } - sfree(aid); - } + for (l = 0; (l < nrestp); l++) + { + if (strcmp(restp[l].rname, rname) == 0) + { + break; + } + } + if (l == nrestp) + { + srenew(restp, nrestp+1); + restp[nrestp].rname = strdup(rname); + restp[nrestp].bNeg = FALSE; + restp[nrestp].gname = strdup(rname); + nrestp++; + + } + } + } + for (i = 0; (i < nrestp); i++) + { + snew(aid, atoms->nr); + naid = 0; + for (j = 0; (j < atoms->nr); j++) + { + rname = *atoms->resinfo[atoms->atom[j].resind].name; + if ((strcmp(restp[i].rname, rname) == 0 && !restp[i].bNeg) || + (strcmp(restp[i].rname, rname) != 0 && restp[i].bNeg)) + { + aid[naid++] = j; + } + } + add_grp(gb, gn, naid, aid, restp[i].gname); + if (bASK) + { + printf("split %s into atoms (y/n) ? ", restp[i].gname); + fflush(stdout); + if (gmx_ask_yesno(bASK)) + { + natp = 0; + for (k = 0; (k < naid); k++) + { + aname = *atoms->atomname[aid[k]]; + for (l = 0; (l < natp); l++) + { + if (strcmp(aname, attp[l]) == 0) + { + break; + } + } + if (l == natp) + { + srenew(attp, ++natp); + attp[natp-1] = aname; + } + } + if (natp > 1) + { + for (l = 0; (l < natp); l++) + { + snew(aaid, naid); + naaid = 0; + for (k = 0; (k < naid); k++) + { + aname = *atoms->atomname[aid[k]]; + if (strcmp(aname, attp[l]) == 0) + { + aaid[naaid++] = aid[k]; + } + } + add_grp(gb, gn, naaid, aaid, attp[l]); + sfree(aaid); + } + } + sfree(attp); + attp = NULL; + } + sfree(aid); + } + } + sfree(other_ndx); } - sfree(other_ndx); - } } /*! /brief Instances of this struct contain the data necessary to @@ -312,42 +358,46 @@ static void analyse_other(const char ** restype,t_atoms *atoms, * analyse_prot(). */ typedef struct gmx_help_make_index_group { - /** The set of atom names that will be used to form this index group */ - const char **defining_atomnames; - /** Size of the defining_atomnames array */ - const int num_defining_atomnames; - /** Name of this index group */ - const char *group_name; - /** Whether the above atom names name the atoms in the group, or - those not in the group */ - gmx_bool bTakeComplement; - /** The index in wholename gives the first item in the arrays of - atomnames that should be tested with 'gmx_strncasecmp' in stead of - gmx_strcasecmp, or -1 if all items should be tested with strcasecmp - This is comparable to using a '*' wildcard at the end of specific - atom names, but that is more involved to implement... - */ - int wholename; - /** Only create this index group if it differs from the one specified in compareto, - where -1 means to always create this group. */ - int compareto; + /** The set of atom names that will be used to form this index group */ + const char **defining_atomnames; + /** Size of the defining_atomnames array */ + const int num_defining_atomnames; + /** Name of this index group */ + const char *group_name; + /** Whether the above atom names name the atoms in the group, or + those not in the group */ + gmx_bool bTakeComplement; + /** The index in wholename gives the first item in the arrays of + atomnames that should be tested with 'gmx_strncasecmp' in stead of + gmx_strcasecmp, or -1 if all items should be tested with strcasecmp + This is comparable to using a '*' wildcard at the end of specific + atom names, but that is more involved to implement... + */ + int wholename; + /** Only create this index group if it differs from the one specified in compareto, + where -1 means to always create this group. */ + int compareto; } t_gmx_help_make_index_group; -static void analyse_prot(const char ** restype,t_atoms *atoms, - t_blocka *gb,char ***gn,gmx_bool bASK,gmx_bool bVerb) +static void analyse_prot(const char ** restype, t_atoms *atoms, + t_blocka *gb, char ***gn, gmx_bool bASK, gmx_bool bVerb) { - /* lists of atomnames to be used in constructing index groups: */ - static const char *pnoh[] = { "H", "HN" }; - static const char *pnodum[] = { "MN1", "MN2", "MCB1", "MCB2", "MCG1", "MCG2", - "MCD1", "MCD2", "MCE1", "MCE2", "MNZ1", "MNZ2" }; - static const char *calpha[] = { "CA" }; - static const char *bb[] = { "N","CA","C" }; - static const char *mc[] = { "N","CA","C","O","O1","O2","OC1","OC2","OT","OXT" }; - static const char *mcb[] = { "N","CA","CB","C","O","O1","O2","OC1","OC2","OT","OXT" }; - static const char *mch[] = { "N","CA","C","O","O1","O2","OC1","OC2","OT","OXT", - "H1","H2","H3","H","HN" }; - - static const t_gmx_help_make_index_group constructing_data[] = + /* lists of atomnames to be used in constructing index groups: */ + static const char *pnoh[] = { "H", "HN" }; + static const char *pnodum[] = { + "MN1", "MN2", "MCB1", "MCB2", "MCG1", "MCG2", + "MCD1", "MCD2", "MCE1", "MCE2", "MNZ1", "MNZ2" + }; + static const char *calpha[] = { "CA" }; + static const char *bb[] = { "N", "CA", "C" }; + static const char *mc[] = { "N", "CA", "C", "O", "O1", "O2", "OC1", "OC2", "OT", "OXT" }; + static const char *mcb[] = { "N", "CA", "CB", "C", "O", "O1", "O2", "OC1", "OC2", "OT", "OXT" }; + static const char *mch[] = { + "N", "CA", "C", "O", "O1", "O2", "OC1", "OC2", "OT", "OXT", + "H1", "H2", "H3", "H", "HN" + }; + + static const t_gmx_help_make_index_group constructing_data[] = {{ NULL, 0, "Protein", TRUE, -1, -1}, { pnoh, asize(pnoh), "Protein-H", TRUE, 0, -1}, { calpha, asize(calpha), "C-alpha", FALSE, -1, -1}, @@ -357,134 +407,174 @@ static void analyse_prot(const char ** restype,t_atoms *atoms, { mch, asize(mch), "MainChain+H", FALSE, -1, -1}, { mch, asize(mch), "SideChain", TRUE, -1, -1}, { mch, asize(mch), "SideChain-H", TRUE, 11, -1}, - { pnodum, asize(pnodum), "Prot-Masses", TRUE, -1, 0}, - }; - const int num_index_groups = asize(constructing_data); - - int n,j; - atom_id *aid; - int nra,nnpres,npres; - gmx_bool match; - char ndx_name[STRLEN],*atnm; - int i; - - if (bVerb) - { - printf("Analysing Protein...\n"); - } - snew(aid,atoms->nr); - - /* calculate the number of protein residues */ - npres=0; - for(i=0; (inres); i++) { - if (0 == gmx_strcasecmp(restype[i],"Protein")) { - npres++; - } - } - /* find matching or complement atoms */ - for(i=0; (i<(int)num_index_groups); i++) { - nra=0; - for(n=0; (nnr); n++) { - if (0 == gmx_strcasecmp(restype[atoms->atom[n].resind],"Protein")) { - match=FALSE; - for(j=0; (jatomname[n]; - while (isdigit(atnm[0])) { - atnm++; - } - if ( (constructing_data[i].wholename==-1) || (jnr); + + /* calculate the number of protein residues */ + npres = 0; + for (i = 0; (i < atoms->nres); i++) + { + if (0 == gmx_strcasecmp(restype[i], "Protein")) + { + npres++; + } } - } - - if (bASK) { - for(i=0; (i<(int)num_index_groups); i++) { - printf("Split %12s into %5d residues (y/n) ? ",constructing_data[i].group_name,npres); - if (gmx_ask_yesno(bASK)) { - int resind; - nra = 0; - for(n=0;((atoms->atom[n].resind < npres) && (nnr));) { - resind = atoms->atom[n].resind; - for(;((atoms->atom[n].resind==resind) && (nnr));n++) { - match=FALSE; - for(j=0;(jatomname[n])) { - match=TRUE; - } - } - if (constructing_data[i].bTakeComplement != match) { - aid[nra++]=n; - } - } - /* copy the residuename to the tail of the groupname */ - if (nra > 0) { - t_resinfo *ri; - ri = &atoms->resinfo[resind]; - sprintf(ndx_name,"%s_%s%d%c", - constructing_data[i].group_name,*ri->name,ri->nr,ri->ic==' ' ? '\0' : ri->ic); - add_grp(gb,gn,nra,aid,ndx_name); - nra = 0; - } - } - } + /* find matching or complement atoms */ + for (i = 0; (i < (int)num_index_groups); i++) + { + nra = 0; + for (n = 0; (n < atoms->nr); n++) + { + if (0 == gmx_strcasecmp(restype[atoms->atom[n].resind], "Protein")) + { + match = FALSE; + for (j = 0; (j < constructing_data[i].num_defining_atomnames); j++) + { + /* skip digits at beginning of atomname, e.g. 1H */ + atnm = *atoms->atomname[n]; + while (isdigit(atnm[0])) + { + atnm++; + } + if ( (constructing_data[i].wholename == -1) || (j < constructing_data[i].wholename) ) + { + if (0 == gmx_strcasecmp(constructing_data[i].defining_atomnames[j], atnm)) + { + match = TRUE; + } + } + else + { + if (0 == gmx_strncasecmp(constructing_data[i].defining_atomnames[j], atnm, strlen(constructing_data[i].defining_atomnames[j]))) + { + match = TRUE; + } + } + } + if (constructing_data[i].bTakeComplement != match) + { + aid[nra++] = n; + } + } + } + /* if we want to add this group always or it differs from previous + group, add it: */ + if (-1 == constructing_data[i].compareto || !grp_cmp(gb, nra, aid, constructing_data[i].compareto-i) ) + { + add_grp(gb, gn, nra, aid, constructing_data[i].group_name); + } } - printf("Make group with sidechain and C=O swapped (y/n) ? "); - if (gmx_ask_yesno(bASK)) { - /* Make swap sidechain C=O index */ - int resind,hold; - nra = 0; - for(n=0;((atoms->atom[n].resind < npres) && (nnr));) { - resind = atoms->atom[n].resind; - hold = -1; - for(;((atoms->atom[n].resind==resind) && (nnr));n++) - if (strcmp("CA",*atoms->atomname[n]) == 0) { - aid[nra++]=n; - hold=nra; - nra+=2; - } else if (strcmp("C",*atoms->atomname[n]) == 0) { - if (hold == -1) { - gmx_incons("Atom naming problem"); - } - aid[hold]=n; - } else if (strcmp("O",*atoms->atomname[n]) == 0) { - if (hold == -1) { - gmx_incons("Atom naming problem"); - } - aid[hold+1]=n; - } else if (strcmp("O1",*atoms->atomname[n]) == 0) { - if (hold == -1) { - gmx_incons("Atom naming problem"); - } - aid[hold+1]=n; - } else - aid[nra++]=n; - } - /* copy the residuename to the tail of the groupname */ - if (nra > 0) { - add_grp(gb,gn,nra,aid,"SwapSC-CO"); - nra = 0; - } + + if (bASK) + { + for (i = 0; (i < (int)num_index_groups); i++) + { + printf("Split %12s into %5d residues (y/n) ? ", constructing_data[i].group_name, npres); + if (gmx_ask_yesno(bASK)) + { + int resind; + nra = 0; + for (n = 0; ((atoms->atom[n].resind < npres) && (n < atoms->nr)); ) + { + resind = atoms->atom[n].resind; + for (; ((atoms->atom[n].resind == resind) && (n < atoms->nr)); n++) + { + match = FALSE; + for (j = 0; (j < constructing_data[i].num_defining_atomnames); j++) + { + if (0 == gmx_strcasecmp(constructing_data[i].defining_atomnames[j], *atoms->atomname[n])) + { + match = TRUE; + } + } + if (constructing_data[i].bTakeComplement != match) + { + aid[nra++] = n; + } + } + /* copy the residuename to the tail of the groupname */ + if (nra > 0) + { + t_resinfo *ri; + ri = &atoms->resinfo[resind]; + sprintf(ndx_name, "%s_%s%d%c", + constructing_data[i].group_name, *ri->name, ri->nr, ri->ic == ' ' ? '\0' : ri->ic); + add_grp(gb, gn, nra, aid, ndx_name); + nra = 0; + } + } + } + } + printf("Make group with sidechain and C=O swapped (y/n) ? "); + if (gmx_ask_yesno(bASK)) + { + /* Make swap sidechain C=O index */ + int resind, hold; + nra = 0; + for (n = 0; ((atoms->atom[n].resind < npres) && (n < atoms->nr)); ) + { + resind = atoms->atom[n].resind; + hold = -1; + for (; ((atoms->atom[n].resind == resind) && (n < atoms->nr)); n++) + { + if (strcmp("CA", *atoms->atomname[n]) == 0) + { + aid[nra++] = n; + hold = nra; + nra += 2; + } + else if (strcmp("C", *atoms->atomname[n]) == 0) + { + if (hold == -1) + { + gmx_incons("Atom naming problem"); + } + aid[hold] = n; + } + else if (strcmp("O", *atoms->atomname[n]) == 0) + { + if (hold == -1) + { + gmx_incons("Atom naming problem"); + } + aid[hold+1] = n; + } + else if (strcmp("O1", *atoms->atomname[n]) == 0) + { + if (hold == -1) + { + gmx_incons("Atom naming problem"); + } + aid[hold+1] = n; + } + else + { + aid[nra++] = n; + } + } + } + /* copy the residuename to the tail of the groupname */ + if (nra > 0) + { + add_grp(gb, gn, nra, aid, "SwapSC-CO"); + nra = 0; + } + } } - } - sfree(aid); + sfree(aid); } @@ -494,45 +584,45 @@ static void analyse_prot(const char ** restype,t_atoms *atoms, * p_restype is set to a pointer to the type name, or 'Other' if we did not find it. */ int -gmx_residuetype_get_type(gmx_residuetype_t rt,const char * resname, const char ** p_restype) +gmx_residuetype_get_type(gmx_residuetype_t rt, const char * resname, const char ** p_restype) { - int i,rc; - - rc=-1; - for(i=0;in && rc;i++) + int i, rc; + + rc = -1; + for (i = 0; i < rt->n && rc; i++) { - rc=gmx_strcasecmp(rt->resname[i],resname); + rc = gmx_strcasecmp(rt->resname[i], resname); } - - *p_restype = (rc==0) ? rt->restype[i-1] : gmx_residuetype_undefined; - + + *p_restype = (rc == 0) ? rt->restype[i-1] : gmx_residuetype_undefined; + return rc; } int -gmx_residuetype_add(gmx_residuetype_t rt,const char *newresname, const char *newrestype) +gmx_residuetype_add(gmx_residuetype_t rt, const char *newresname, const char *newrestype) { - int i; - int found; + int i; + int found; const char * p_oldtype; - - found = !gmx_residuetype_get_type(rt,newresname,&p_oldtype); - - if(found && gmx_strcasecmp(p_oldtype,newrestype)) + + found = !gmx_residuetype_get_type(rt, newresname, &p_oldtype); + + if (found && gmx_strcasecmp(p_oldtype, newrestype)) { - fprintf(stderr,"Warning: Residue '%s' already present with type '%s' in database, ignoring new type '%s'.", - newresname,p_oldtype,newrestype); + fprintf(stderr, "Warning: Residue '%s' already present with type '%s' in database, ignoring new type '%s'.", + newresname, p_oldtype, newrestype); } - - if(found==0) + + if (found == 0) { - srenew(rt->resname,rt->n+1); - srenew(rt->restype,rt->n+1); - rt->resname[rt->n]=strdup(newresname); - rt->restype[rt->n]=strdup(newrestype); + srenew(rt->resname, rt->n+1); + srenew(rt->restype, rt->n+1); + rt->resname[rt->n] = strdup(newresname); + rt->restype[rt->n] = strdup(newrestype); rt->n++; } - + return 0; } @@ -540,38 +630,38 @@ gmx_residuetype_add(gmx_residuetype_t rt,const char *newresname, const char *new int gmx_residuetype_init(gmx_residuetype_t *prt) { - FILE * db; - char line[STRLEN]; - char resname[STRLEN],restype[STRLEN],dum[STRLEN]; - char * p; - int i; + FILE * db; + char line[STRLEN]; + char resname[STRLEN], restype[STRLEN], dum[STRLEN]; + char * p; + int i; struct gmx_residuetype *rt; - - snew(rt,1); - *prt=rt; - + + snew(rt, 1); + *prt = rt; + rt->n = 0; rt->resname = NULL; - rt->restype = NULL; - - db=libopen("residuetypes.dat"); - - while(get_a_line(db,line,STRLEN)) + rt->restype = NULL; + + db = libopen("residuetypes.dat"); + + while (get_a_line(db, line, STRLEN)) { strip_comment(line); trim(line); - if(line[0]!='\0') + if (line[0] != '\0') { - if(sscanf(line,"%s %s %s",resname,restype,dum)!=2) + if (sscanf(line, "%s %s %s", resname, restype, dum) != 2) { - gmx_fatal(FARGS,"Incorrect number of columns (2 expected) for line in residuetypes.dat"); + gmx_fatal(FARGS, "Incorrect number of columns (2 expected) for line in residuetypes.dat"); } - gmx_residuetype_add(rt,resname,restype); + gmx_residuetype_add(rt, resname, restype); } } - + fclose(db); - + return 0; } @@ -581,8 +671,8 @@ int gmx_residuetype_destroy(gmx_residuetype_t rt) { int i; - - for(i=0;in;i++) + + for (i = 0; i < rt->n; i++) { sfree(rt->resname[i]); sfree(rt->restype[i]); @@ -590,7 +680,7 @@ gmx_residuetype_destroy(gmx_residuetype_t rt) sfree(rt->resname); sfree(rt->restype); sfree(rt); - + return 0; } @@ -599,88 +689,88 @@ gmx_residuetype_get_alltypes(gmx_residuetype_t rt, const char *** p_typenames, int * ntypes) { - int i,j,n; - int found; + int i, j, n; + int found; const char ** my_typename; - char * p; - - n=0; - - my_typename=NULL; - for(i=0;in;i++) + char * p; + + n = 0; + + my_typename = NULL; + for (i = 0; i < rt->n; i++) { - p=rt->restype[i]; - found=0; - for(j=0;jrestype[i]; + found = 0; + for (j = 0; j < n && !found; j++) { - found=!gmx_strcasecmp(p,my_typename[j]); + found = !gmx_strcasecmp(p, my_typename[j]); } - - if(!found) + + if (!found) { - srenew(my_typename,n+1); - my_typename[n]=p; + srenew(my_typename, n+1); + my_typename[n] = p; n++; } } - *ntypes=n; - *p_typenames=my_typename; - + *ntypes = n; + *p_typenames = my_typename; + return 0; } - -gmx_bool + +gmx_bool gmx_residuetype_is_protein(gmx_residuetype_t rt, const char *resnm) { - gmx_bool rc; + gmx_bool rc; const char *p_type; - - if(gmx_residuetype_get_type(rt,resnm,&p_type)==0 && - gmx_strcasecmp(p_type,"Protein")==0) + + if (gmx_residuetype_get_type(rt, resnm, &p_type) == 0 && + gmx_strcasecmp(p_type, "Protein") == 0) { - rc=TRUE; + rc = TRUE; } else { - rc=FALSE; + rc = FALSE; } return rc; } -gmx_bool +gmx_bool gmx_residuetype_is_dna(gmx_residuetype_t rt, const char *resnm) { - gmx_bool rc; + gmx_bool rc; const char *p_type; - if(gmx_residuetype_get_type(rt,resnm,&p_type)==0 && - gmx_strcasecmp(p_type,"DNA")==0) + if (gmx_residuetype_get_type(rt, resnm, &p_type) == 0 && + gmx_strcasecmp(p_type, "DNA") == 0) { - rc=TRUE; + rc = TRUE; } else { - rc=FALSE; + rc = FALSE; } return rc; } -gmx_bool +gmx_bool gmx_residuetype_is_rna(gmx_residuetype_t rt, const char *resnm) { - gmx_bool rc; + gmx_bool rc; const char *p_type; - if(gmx_residuetype_get_type(rt,resnm,&p_type)==0 && - gmx_strcasecmp(p_type,"RNA")==0) + if (gmx_residuetype_get_type(rt, resnm, &p_type) == 0 && + gmx_strcasecmp(p_type, "RNA") == 0) { - rc=TRUE; + rc = TRUE; } else { - rc=FALSE; + rc = FALSE; } return rc; } @@ -699,12 +789,12 @@ gmx_residuetype_get_size(gmx_residuetype_t rt) int gmx_residuetype_get_index(gmx_residuetype_t rt, const char *resnm) { - int i,rc; + int i, rc; - rc=-1; - for(i=0;in && rc;i++) + rc = -1; + for (i = 0; i < rt->n && rc; i++) { - rc=gmx_strcasecmp(rt->resname[i],resnm); + rc = gmx_strcasecmp(rt->resname[i], resnm); } return (0 == rc) ? i-1 : -1; @@ -715,448 +805,538 @@ gmx_residuetype_get_index(gmx_residuetype_t rt, const char *resnm) 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; - } + if (index >= 0 && index < rt->n) + { + return rt->resname[index]; + } + else + { + return NULL; + } } -void analyse(t_atoms *atoms,t_blocka *gb,char ***gn,gmx_bool bASK,gmx_bool bVerb) +void analyse(t_atoms *atoms, t_blocka *gb, char ***gn, gmx_bool bASK, gmx_bool bVerb) { - gmx_residuetype_t rt=NULL; - char *resnm; - atom_id *aid; - const char ** restype; - int nra; - int i,k; - size_t j; - int ntypes; - char * p; - const char ** p_typename; - int iwater,iion; - int nwater,nion; - int found; - + gmx_residuetype_t rt = NULL; + char *resnm; + atom_id *aid; + const char ** restype; + int nra; + int i, k; + size_t j; + int ntypes; + char * p; + const char ** p_typename; + int iwater, iion; + int nwater, nion; + int found; + if (bVerb) { printf("Analysing residue names:\n"); } /* Create system group, every single atom */ - snew(aid,atoms->nr); - for(i=0;inr;i++) + snew(aid, atoms->nr); + for (i = 0; i < atoms->nr; i++) { - aid[i]=i; + aid[i] = i; } - add_grp(gb,gn,atoms->nr,aid,"System"); + add_grp(gb, gn, atoms->nr, aid, "System"); sfree(aid); /* For every residue, get a pointer to the residue type name */ gmx_residuetype_init(&rt); assert(rt); - snew(restype,atoms->nres); - ntypes = 0; + snew(restype, atoms->nres); + ntypes = 0; p_typename = NULL; - for(i=0;inres;i++) + for (i = 0; i < atoms->nres; i++) { resnm = *atoms->resinfo[i].name; - gmx_residuetype_get_type(rt,resnm,&(restype[i])); + gmx_residuetype_get_type(rt, resnm, &(restype[i])); /* Note that this does not lead to a N*N loop, but N*K, where * K is the number of residue _types_, which is small and independent of N. */ found = 0; - for(k=0;knres,p_typename,ntypes); + p_status(restype, atoms->nres, p_typename, ntypes); } - for(k=0;k0) + + if (!gmx_strcasecmp(p_typename[k], "Protein") && nra > 0) { sfree(aid); /* PROTEIN */ - analyse_prot(restype,atoms,gb,gn,bASK,bVerb); - + analyse_prot(restype, atoms, gb, gn, bASK, bVerb); + /* Create a Non-Protein group */ - aid=mk_aid(atoms,restype,"Protein",&nra,FALSE); + aid = mk_aid(atoms, restype, "Protein", &nra, FALSE); if ((nra > 0) && (nra < atoms->nr)) { - add_grp(gb,gn,nra,aid,"non-Protein"); + add_grp(gb, gn, nra, aid, "non-Protein"); } sfree(aid); } - else if(!gmx_strcasecmp(p_typename[k],"Water") && nra>0) + else if (!gmx_strcasecmp(p_typename[k], "Water") && nra > 0) { - add_grp(gb,gn,nra,aid,p_typename[k]); + add_grp(gb, gn, nra, aid, p_typename[k]); /* Add this group as 'SOL' too, for backward compatibility with older gromacs versions */ - add_grp(gb,gn,nra,aid,"SOL"); + add_grp(gb, gn, nra, aid, "SOL"); sfree(aid); /* Solvent, create a negated group too */ - aid=mk_aid(atoms,restype,"Water",&nra,FALSE); + aid = mk_aid(atoms, restype, "Water", &nra, FALSE); if ((nra > 0) && (nra < atoms->nr)) { - add_grp(gb,gn,nra,aid,"non-Water"); + add_grp(gb, gn, nra, aid, "non-Water"); } sfree(aid); } - else if(nra>0) + else if (nra > 0) { /* Other groups */ - add_grp(gb,gn,nra,aid,p_typename[k]); + add_grp(gb, gn, nra, aid, p_typename[k]); sfree(aid); - analyse_other(restype,atoms,gb,gn,bASK,bVerb); + analyse_other(restype, atoms, gb, gn, bASK, bVerb); } } - + sfree(p_typename); sfree(restype); - gmx_residuetype_destroy(rt); - + gmx_residuetype_destroy(rt); + /* Create a merged water_and_ions group */ iwater = -1; iion = -1; nwater = 0; nion = 0; - - for(i=0;inr;i++) - { - if(!gmx_strcasecmp((*gn)[i],"Water")) + + for (i = 0; i < gb->nr; i++) + { + if (!gmx_strcasecmp((*gn)[i], "Water")) { iwater = i; nwater = gb->index[i+1]-gb->index[i]; } - else if(!gmx_strcasecmp((*gn)[i],"Ion")) + else if (!gmx_strcasecmp((*gn)[i], "Ion")) { iion = i; nion = gb->index[i+1]-gb->index[i]; } } - - if(nwater>0 && nion>0) + + if (nwater > 0 && nion > 0) { - srenew(gb->index,gb->nr+2); - srenew(*gn,gb->nr+1); + srenew(gb->index, gb->nr+2); + srenew(*gn, gb->nr+1); (*gn)[gb->nr] = strdup("Water_and_ions"); - srenew(gb->a,gb->nra+nwater+nion); - if(nwater>0) + srenew(gb->a, gb->nra+nwater+nion); + if (nwater > 0) { - for(i=gb->index[iwater];iindex[iwater+1];i++) + for (i = gb->index[iwater]; i < gb->index[iwater+1]; i++) { gb->a[gb->nra++] = gb->a[i]; } } - if(nion>0) + if (nion > 0) { - for(i=gb->index[iion];iindex[iion+1];i++) + for (i = gb->index[iion]; i < gb->index[iion+1]; i++) { gb->a[gb->nra++] = gb->a[i]; } } gb->nr++; - gb->index[gb->nr]=gb->nra; + gb->index[gb->nr] = gb->nra; } } -void check_index(char *gname,int n,atom_id index[],char *traj,int natoms) +void check_index(char *gname, int n, atom_id index[], char *traj, int natoms) { - int i; - - for(i=0; i= natoms) - gmx_fatal(FARGS,"%s atom number (index[%d]=%d) is larger than the number of atoms in %s (%d)", - gname ? gname : "Index",i+1, index[i]+1, - traj ? traj : "the trajectory",natoms); - else if (index[i] < 0) - gmx_fatal(FARGS,"%s atom number (index[%d]=%d) is less than zero", - gname ? gname : "Index",i+1, index[i]+1); + int i; + + for (i = 0; i < n; i++) + { + if (index[i] >= natoms) + { + gmx_fatal(FARGS, "%s atom number (index[%d]=%d) is larger than the number of atoms in %s (%d)", + gname ? gname : "Index", i+1, index[i]+1, + traj ? traj : "the trajectory", natoms); + } + else if (index[i] < 0) + { + gmx_fatal(FARGS, "%s atom number (index[%d]=%d) is less than zero", + gname ? gname : "Index", i+1, index[i]+1); + } + } } t_blocka *init_index(const char *gfile, char ***grpname) { - FILE *in; - t_blocka *b; - int a,maxentries; - int i,j,ng,nread; - char line[STRLEN],*pt,str[STRLEN]; - - in=gmx_fio_fopen(gfile,"r"); - snew(b,1); - get_a_line(in,line,STRLEN); - if ( line[0]=='[' ) { - /* new format */ - b->nr=0; - b->index=NULL; - b->nra=0; - b->a=NULL; - *grpname=NULL; - maxentries=0; - do { - if (get_header(line,str)) { - b->nr++; - srenew(b->index,b->nr+1); - srenew(*grpname,b->nr); - if (b->nr==1) - b->index[0]=0; - b->index[b->nr]=b->index[b->nr-1]; - (*grpname)[b->nr-1]=strdup(str); - } else { - if (b->nr==0) - { - gmx_fatal(FARGS,"The first header of your indexfile is invalid"); - } - pt=line; - while (sscanf(pt,"%s",str) == 1) { - i=b->index[b->nr]; - if (i>=maxentries) { - maxentries+=1024; - srenew(b->a,maxentries); - } - b->a[i]=strtol(str, NULL, 10)-1; - b->index[b->nr]++; - (b->nra)++; - pt=strstr(pt,str)+strlen(str); - } - } - } while (get_a_line(in,line,STRLEN)); - } - else { - /* old format */ - sscanf(line,"%d%d",&b->nr,&b->nra); - snew(b->index,b->nr+1); - snew(*grpname,b->nr); - b->index[0]=0; - snew(b->a,b->nra); - for (i=0; (inr); i++) { - nread=fscanf(in,"%s%d",str,&ng); - (*grpname)[i]=strdup(str); - b->index[i+1]=b->index[i]+ng; - if (b->index[i+1] > b->nra) - gmx_fatal(FARGS,"Something wrong in your indexfile at group %s",str); - for(j=0; (ja[b->index[i]+j]=a; - } + FILE *in; + t_blocka *b; + int a, maxentries; + int i, j, ng, nread; + char line[STRLEN], *pt, str[STRLEN]; + + in = gmx_fio_fopen(gfile, "r"); + snew(b, 1); + get_a_line(in, line, STRLEN); + if (line[0] == '[') + { + /* new format */ + b->nr = 0; + b->index = NULL; + b->nra = 0; + b->a = NULL; + *grpname = NULL; + maxentries = 0; + do + { + if (get_header(line, str)) + { + b->nr++; + srenew(b->index, b->nr+1); + srenew(*grpname, b->nr); + if (b->nr == 1) + { + b->index[0] = 0; + } + b->index[b->nr] = b->index[b->nr-1]; + (*grpname)[b->nr-1] = strdup(str); + } + else + { + if (b->nr == 0) + { + gmx_fatal(FARGS, "The first header of your indexfile is invalid"); + } + pt = line; + while (sscanf(pt, "%s", str) == 1) + { + i = b->index[b->nr]; + if (i >= maxentries) + { + maxentries += 1024; + srenew(b->a, maxentries); + } + b->a[i] = strtol(str, NULL, 10)-1; + b->index[b->nr]++; + (b->nra)++; + pt = strstr(pt, str)+strlen(str); + } + } + } + while (get_a_line(in, line, STRLEN)); } - } - gmx_fio_fclose(in); - - for(i=0; (inr); i++) { - for(j=b->index[i]; (jindex[i+1]); j++) { - if (b->a[j] < 0) - fprintf(stderr,"\nWARNING: negative index %d in group %s\n\n", - b->a[j],(*grpname)[i]); + else + { + /* old format */ + sscanf(line, "%d%d", &b->nr, &b->nra); + snew(b->index, b->nr+1); + snew(*grpname, b->nr); + b->index[0] = 0; + snew(b->a, b->nra); + for (i = 0; (i < b->nr); i++) + { + nread = fscanf(in, "%s%d", str, &ng); + (*grpname)[i] = strdup(str); + b->index[i+1] = b->index[i]+ng; + if (b->index[i+1] > b->nra) + { + gmx_fatal(FARGS, "Something wrong in your indexfile at group %s", str); + } + for (j = 0; (j < ng); j++) + { + nread = fscanf(in, "%d", &a); + b->a[b->index[i]+j] = a; + } + } + } + gmx_fio_fclose(in); + + for (i = 0; (i < b->nr); i++) + { + for (j = b->index[i]; (j < b->index[i+1]); j++) + { + if (b->a[j] < 0) + { + fprintf(stderr, "\nWARNING: negative index %d in group %s\n\n", + b->a[j], (*grpname)[i]); + } + } } - } - - return b; + + return b; } static void minstring(char *str) { - int i; + int i; - for (i=0; (i < (int)strlen(str)); i++) - if (str[i]=='-') - str[i]='_'; + for (i = 0; (i < (int)strlen(str)); i++) + { + if (str[i] == '-') + { + str[i] = '_'; + } + } } int find_group(char s[], int ngrps, char **grpname) { - int aa, i, n; - char string[STRLEN]; - gmx_bool bMultiple; - - bMultiple = FALSE; - n = strlen(s); - aa=NOTSET; - /* first look for whole name match */ - if (aa==NOTSET) - for(i=0; i= 0 && aa < ngrps); if (!bInRange) + { printf("Error: No such group '%s'\n", s); - } while (!bInRange); + } + } + while (!bInRange); printf("Selected %d: '%s'\n", aa, grpname[aa]); *a = aa; return aa; } -static void rd_groups(t_blocka *grps,char **grpname,char *gnames[], - int ngrps,int isize[],atom_id *index[],int grpnr[]) +static void rd_groups(t_blocka *grps, char **grpname, char *gnames[], + int ngrps, int isize[], atom_id *index[], int grpnr[]) { - int i,j,gnr1; - - if (grps->nr==0) - gmx_fatal(FARGS,"Error: no groups in indexfile"); - for(i=0; (inr); i++) - fprintf(stderr,"Group %5d (%15s) has %5d elements\n",i,grpname[i], - grps->index[i+1]-grps->index[i]); - for(i=0; (inr > 1) - do { - gnr1=qgroup(&grpnr[i], grps->nr, grpname); - if ((gnr1<0) || (gnr1>=grps->nr)) - fprintf(stderr,"Select between %d and %d.\n",0,grps->nr-1); - } while ((gnr1<0) || (gnr1>=grps->nr)); - else { - fprintf(stderr,"There is one group in the index\n"); - gnr1=0; + int i, j, gnr1; + + if (grps->nr == 0) + { + gmx_fatal(FARGS, "Error: no groups in indexfile"); + } + for (i = 0; (i < grps->nr); i++) + { + fprintf(stderr, "Group %5d (%15s) has %5d elements\n", i, grpname[i], + grps->index[i+1]-grps->index[i]); + } + for (i = 0; (i < ngrps); i++) + { + if (grps->nr > 1) + { + do + { + gnr1 = qgroup(&grpnr[i], grps->nr, grpname); + if ((gnr1 < 0) || (gnr1 >= grps->nr)) + { + fprintf(stderr, "Select between %d and %d.\n", 0, grps->nr-1); + } + } + while ((gnr1 < 0) || (gnr1 >= grps->nr)); + } + else + { + fprintf(stderr, "There is one group in the index\n"); + gnr1 = 0; + } + gnames[i] = strdup(grpname[gnr1]); + isize[i] = grps->index[gnr1+1]-grps->index[gnr1]; + snew(index[i], isize[i]); + for (j = 0; (j < isize[i]); j++) + { + index[i][j] = grps->a[grps->index[gnr1]+j]; + } } - gnames[i]=strdup(grpname[gnr1]); - isize[i]=grps->index[gnr1+1]-grps->index[gnr1]; - snew(index[i],isize[i]); - for(j=0; (ja[grps->index[gnr1]+j]; - } } -void rd_index(const char *statfile,int ngrps,int isize[], - atom_id *index[],char *grpnames[]) +void rd_index(const char *statfile, int ngrps, int isize[], + atom_id *index[], char *grpnames[]) { - char **gnames; - t_blocka *grps; - int *grpnr; - - snew(grpnr,ngrps); - if (!statfile) - gmx_fatal(FARGS,"No index file specified"); - grps=init_index(statfile,&gnames); - rd_groups(grps,gnames,grpnames,ngrps,isize,index,grpnr); + char **gnames; + t_blocka *grps; + int *grpnr; + + snew(grpnr, ngrps); + if (!statfile) + { + gmx_fatal(FARGS, "No index file specified"); + } + grps = init_index(statfile, &gnames); + rd_groups(grps, gnames, grpnames, ngrps, isize, index, grpnr); } -void rd_index_nrs(char *statfile,int ngrps,int isize[], - atom_id *index[],char *grpnames[],int grpnr[]) +void rd_index_nrs(char *statfile, int ngrps, int isize[], + atom_id *index[], char *grpnames[], int grpnr[]) { - char **gnames; - t_blocka *grps; - - if (!statfile) - gmx_fatal(FARGS,"No index file specified"); - grps=init_index(statfile,&gnames); - - rd_groups(grps,gnames,grpnames,ngrps,isize,index,grpnr); + char **gnames; + t_blocka *grps; + + if (!statfile) + { + gmx_fatal(FARGS, "No index file specified"); + } + grps = init_index(statfile, &gnames); + + rd_groups(grps, gnames, grpnames, ngrps, isize, index, grpnr); } void get_index(t_atoms *atoms, const char *fnm, int ngrps, - int isize[], atom_id *index[],char *grpnames[]) + int isize[], atom_id *index[], char *grpnames[]) { - char ***gnames; - t_blocka *grps = NULL; - int *grpnr; - - snew(grpnr,ngrps); - snew(gnames,1); - if (fnm != NULL) { - grps=init_index(fnm,gnames); - } - else if (atoms) { - snew(grps,1); - snew(grps->index,1); - analyse(atoms,grps,gnames,FALSE,FALSE); - } - else - gmx_incons("You need to supply a valid atoms structure or a valid index file name"); - - rd_groups(grps,*gnames,grpnames,ngrps,isize,index,grpnr); + char ***gnames; + t_blocka *grps = NULL; + int *grpnr; + + snew(grpnr, ngrps); + snew(gnames, 1); + if (fnm != NULL) + { + grps = init_index(fnm, gnames); + } + else if (atoms) + { + snew(grps, 1); + snew(grps->index, 1); + analyse(atoms, grps, gnames, FALSE, FALSE); + } + else + { + gmx_incons("You need to supply a valid atoms structure or a valid index file name"); + } + + rd_groups(grps, *gnames, grpnames, ngrps, isize, index, grpnr); } -t_cluster_ndx *cluster_index(FILE *fplog,const char *ndx) +t_cluster_ndx *cluster_index(FILE *fplog, const char *ndx) { - t_cluster_ndx *c; - int i; - - snew(c,1); - c->clust = init_index(ndx,&c->grpname); - c->maxframe = -1; - for(i=0; (iclust->nra); i++) - c->maxframe = max(c->maxframe,c->clust->a[i]); - fprintf(fplog ? fplog : stdout, - "There are %d clusters containing %d structures, highest framenr is %d\n", - c->clust->nr,c->clust->nra,c->maxframe); - if (debug) { - pr_blocka(debug,0,"clust",c->clust,TRUE); - for(i=0; (iclust->nra); i++) - if ((c->clust->a[i] < 0) || (c->clust->a[i] > c->maxframe)) - gmx_fatal(FARGS,"Range check error for c->clust->a[%d] = %d\n" - "should be within 0 and %d",i,c->clust->a[i],c->maxframe+1); - } - c->inv_clust=make_invblocka(c->clust,c->maxframe); - - return c; -} + t_cluster_ndx *c; + int i; + + snew(c, 1); + c->clust = init_index(ndx, &c->grpname); + c->maxframe = -1; + for (i = 0; (i < c->clust->nra); i++) + { + c->maxframe = max(c->maxframe, c->clust->a[i]); + } + fprintf(fplog ? fplog : stdout, + "There are %d clusters containing %d structures, highest framenr is %d\n", + c->clust->nr, c->clust->nra, c->maxframe); + if (debug) + { + pr_blocka(debug, 0, "clust", c->clust, TRUE); + for (i = 0; (i < c->clust->nra); i++) + { + if ((c->clust->a[i] < 0) || (c->clust->a[i] > c->maxframe)) + { + gmx_fatal(FARGS, "Range check error for c->clust->a[%d] = %d\n" + "should be within 0 and %d", i, c->clust->a[i], c->maxframe+1); + } + } + } + c->inv_clust = make_invblocka(c->clust, c->maxframe); + return c; +} diff --git a/src/gromacs/gmxlib/inputrec.c b/src/gromacs/gmxlib/inputrec.c index f6640328d4..103c516894 100644 --- a/src/gromacs/gmxlib/inputrec.c +++ b/src/gromacs/gmxlib/inputrec.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 4.5 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -74,27 +74,27 @@ int tcouple_min_integration_steps(int etc) switch (etc) { - case etcNO: - n = 0; - break; - case etcBERENDSEN: - case etcYES: - n = nstmin_berendsen_tcouple; - break; - case etcVRESCALE: - /* V-rescale supports instantaneous rescaling */ - n = 0; - break; - case etcNOSEHOOVER: - n = nstmin_harmonic; - break; - case etcANDERSEN: - case etcANDERSENMASSIVE: - n = 1; - break; - default: - gmx_incons("Unknown etc value"); - n = 0; + case etcNO: + n = 0; + break; + case etcBERENDSEN: + case etcYES: + n = nstmin_berendsen_tcouple; + break; + case etcVRESCALE: + /* V-rescale supports instantaneous rescaling */ + n = 0; + break; + case etcNOSEHOOVER: + n = nstmin_harmonic; + break; + case etcANDERSEN: + case etcANDERSENMASSIVE: + n = 1; + break; + default: + gmx_incons("Unknown etc value"); + n = 0; } return n; @@ -102,7 +102,7 @@ int tcouple_min_integration_steps(int etc) int ir_optimal_nsttcouple(const t_inputrec *ir) { - int nmin,nwanted,n; + int nmin, nwanted, n; real tau_min; int g; @@ -113,11 +113,11 @@ int ir_optimal_nsttcouple(const t_inputrec *ir) tau_min = 1e20; if (ir->etc != etcNO) { - for(g=0; gopts.ngtc; g++) + for (g = 0; g < ir->opts.ngtc; g++) { if (ir->opts.tau_t[g] > 0) { - tau_min = min(tau_min,ir->opts.tau_t[g]); + tau_min = min(tau_min, ir->opts.tau_t[g]); } } } @@ -148,20 +148,20 @@ int pcouple_min_integration_steps(int epc) switch (epc) { - case epcNO: - n = 0; - break; - case etcBERENDSEN: - case epcISOTROPIC: - n = nstmin_berendsen_pcouple; - break; - case epcPARRINELLORAHMAN: - case epcMTTK: - n = nstmin_harmonic; - break; - default: - gmx_incons("Unknown epc value"); - n = 0; + case epcNO: + n = 0; + break; + case etcBERENDSEN: + case epcISOTROPIC: + n = nstmin_berendsen_pcouple; + break; + case epcPARRINELLORAHMAN: + case epcMTTK: + n = nstmin_harmonic; + break; + default: + gmx_incons("Unknown epc value"); + n = 0; } return n; @@ -169,7 +169,7 @@ int pcouple_min_integration_steps(int epc) int ir_optimal_nstpcouple(const t_inputrec *ir) { - int nmin,nwanted,n; + int nmin, nwanted, n; nmin = pcouple_min_integration_steps(ir->epc); diff --git a/src/gromacs/gmxlib/invblock.c b/src/gromacs/gmxlib/invblock.c index e57b7f5ffa..0b71d49371 100644 --- a/src/gromacs/gmxlib/invblock.c +++ b/src/gromacs/gmxlib/invblock.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -42,43 +42,62 @@ #include "invblock.h" #include "gmx_fatal.h" -atom_id *make_invblock(const t_block *block,int nr) +atom_id *make_invblock(const t_block *block, int nr) { - int i,j; - atom_id *invblock; - - snew(invblock,nr+1); - /* Mark unused numbers */ - for (i=0; i<=nr; i++) - invblock[i]=NO_ATID; - for (i=0; (inr); i++) - for (j=block->index[i]; (jindex[i+1]); j++) - if (invblock[j] == NO_ATID) - invblock[j]=i; - else - gmx_fatal(FARGS,"Double entries in block structure. Item %d is in blocks %d and %d\n" - " Cannot make an unambiguous inverse block.", - j,i,invblock[j]); - return invblock; + int i, j; + atom_id *invblock; + + snew(invblock, nr+1); + /* Mark unused numbers */ + for (i = 0; i <= nr; i++) + { + invblock[i] = NO_ATID; + } + for (i = 0; (i < block->nr); i++) + { + for (j = block->index[i]; (j < block->index[i+1]); j++) + { + if (invblock[j] == NO_ATID) + { + invblock[j] = i; + } + else + { + gmx_fatal(FARGS, "Double entries in block structure. Item %d is in blocks %d and %d\n" + " Cannot make an unambiguous inverse block.", + j, i, invblock[j]); + } + } + } + return invblock; } -atom_id *make_invblocka(const t_blocka *block,int nr) +atom_id *make_invblocka(const t_blocka *block, int nr) { - int i,j; - atom_id *invblock; - - snew(invblock,nr+1); - /* Mark unused numbers */ - for (i=0; i<=nr; i++) - invblock[i]=NO_ATID; - for (i=0; (inr); i++) - for (j=block->index[i]; (jindex[i+1]); j++) - if (invblock[block->a[j]] == NO_ATID) - invblock[block->a[j]]=i; - else - gmx_fatal(FARGS,"Double entries in block structure. Item %d is in blocks %d and %d\n" - " Cannot make an unambiguous inverse block.", - j,i,invblock[block->a[j]]); - return invblock; -} + int i, j; + atom_id *invblock; + snew(invblock, nr+1); + /* Mark unused numbers */ + for (i = 0; i <= nr; i++) + { + invblock[i] = NO_ATID; + } + for (i = 0; (i < block->nr); i++) + { + for (j = block->index[i]; (j < block->index[i+1]); j++) + { + if (invblock[block->a[j]] == NO_ATID) + { + invblock[block->a[j]] = i; + } + else + { + gmx_fatal(FARGS, "Double entries in block structure. Item %d is in blocks %d and %d\n" + " Cannot make an unambiguous inverse block.", + j, i, invblock[block->a[j]]); + } + } + } + return invblock; +} diff --git a/src/gromacs/gmxlib/invsqrt_test.c b/src/gromacs/gmxlib/invsqrt_test.c index 1313442a3f..e4d74e3572 100644 --- a/src/gromacs/gmxlib/invsqrt_test.c +++ b/src/gromacs/gmxlib/invsqrt_test.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -39,19 +39,20 @@ #include "vec.h" -int main(int argc,char *argv[]) +int main(int argc, char *argv[]) { - real x,y,z,diff,av; - int i; + real x, y, z, diff, av; + int i; - printf("%12s %12s %12s %12s %12s\n","X","invsqrt(X)","1/sqrt(X)","Abs. Diff.","Rel. Diff."); - for(i=1; (i<1000); i++) { - x = i*1.0; - y = gmx_invsqrt(x); - z = 1.0/sqrt(x); - diff = y-z; - av = 0.5*(y+z); - printf("%12.5e %12.5e %12.5e %12.5e %12.5e\n",x,y,z,diff,diff/z); - } - return 0; + printf("%12s %12s %12s %12s %12s\n", "X", "invsqrt(X)", "1/sqrt(X)", "Abs. Diff.", "Rel. Diff."); + for (i = 1; (i < 1000); i++) + { + x = i*1.0; + y = gmx_invsqrt(x); + z = 1.0/sqrt(x); + diff = y-z; + av = 0.5*(y+z); + printf("%12.5e %12.5e %12.5e %12.5e %12.5e\n", x, y, z, diff, diff/z); + } + return 0; } diff --git a/src/gromacs/gmxlib/libxdrf.c b/src/gromacs/gmxlib/libxdrf.c index b76cac81fe..38d97680e2 100644 --- a/src/gromacs/gmxlib/libxdrf.c +++ b/src/gromacs/gmxlib/libxdrf.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -50,11 +50,11 @@ #if 0 #ifdef HAVE_FSEEKO -# define gmx_fseek(A,B,C) fseeko(A,B,C) +# define gmx_fseek(A, B, C) fseeko(A, B, C) # define gmx_ftell(A) ftello(A) # define gmx_off_t off_t #else -# define gmx_fseek(A,B,C) fseek(A,B,C) +# define gmx_fseek(A, B, C) fseek(A, B, C) # define gmx_ftell(A) ftell(A) # define gmx_off_t int #endif @@ -81,14 +81,14 @@ const char *xdr_datatype_names[] = | what follows are the C routine to read/write compressed coordinates together | with some routines to assist in this task (those are marked | static and cannot be called from user programs) -*/ + */ #define MAXABS INT_MAX-2 #ifndef MIN -#define MIN(x,y) ((x) < (y) ? (x):(y)) +#define MIN(x, y) ((x) < (y) ? (x) : (y)) #endif #ifndef MAX -#define MAX(x,y) ((x) > (y) ? (x):(y)) +#define MAX(x, y) ((x) > (y) ? (x) : (y)) #endif #ifndef SQR #define SQR(x) ((x)*(x)) @@ -101,7 +101,8 @@ static const int magicints[] = { 8192, 10321, 13003, 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031, 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561, 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021, 4194304, 5284491, 6658042, - 8388607, 10568983, 13316085, 16777216 }; + 8388607, 10568983, 13316085, 16777216 +}; #define FIRSTIDX 9 /* note that magicints[FIRSTIDX-1] == 0 */ @@ -117,36 +118,41 @@ static const int magicints[] = { | better make sure that this number of bits is enough to hold the value | Also num must be positive. | -*/ + */ -static void sendbits(int buf[], int num_of_bits, int num) { - - unsigned int cnt, lastbyte; - int lastbits; +static void sendbits(int buf[], int num_of_bits, int num) +{ + + unsigned int cnt, lastbyte; + int lastbits; unsigned char * cbuf; - - cbuf = ((unsigned char *)buf) + 3 * sizeof(*buf); - cnt = (unsigned int) buf[0]; + + cbuf = ((unsigned char *)buf) + 3 * sizeof(*buf); + cnt = (unsigned int) buf[0]; lastbits = buf[1]; - lastbyte =(unsigned int) buf[2]; - while (num_of_bits >= 8) { - lastbyte = (lastbyte << 8) | ((num >> (num_of_bits -8)) /* & 0xff*/); - cbuf[cnt++] = lastbyte >> lastbits; - num_of_bits -= 8; + lastbyte = (unsigned int) buf[2]; + while (num_of_bits >= 8) + { + lastbyte = (lastbyte << 8) | ((num >> (num_of_bits -8)) /* & 0xff*/); + cbuf[cnt++] = lastbyte >> lastbits; + num_of_bits -= 8; } - if (num_of_bits > 0) { - lastbyte = (lastbyte << num_of_bits) | num; - lastbits += num_of_bits; - if (lastbits >= 8) { - lastbits -= 8; - cbuf[cnt++] = lastbyte >> lastbits; - } + if (num_of_bits > 0) + { + lastbyte = (lastbyte << num_of_bits) | num; + lastbits += num_of_bits; + if (lastbits >= 8) + { + lastbits -= 8; + cbuf[cnt++] = lastbyte >> lastbits; + } } buf[0] = cnt; buf[1] = lastbits; buf[2] = lastbyte; - if (lastbits>0) { - cbuf[cnt] = lastbyte << (8 - lastbits); + if (lastbits > 0) + { + cbuf[cnt] = lastbyte << (8 - lastbits); } } @@ -156,15 +162,17 @@ static void sendbits(int buf[], int num_of_bits, int num) { | | return the number of bits needed to store an integer with given max size | -*/ + */ -static int sizeofint(const int size) { - int num = 1; +static int sizeofint(const int size) +{ + int num = 1; int num_of_bits = 0; - - while (size >= num && num_of_bits < 32) { - num_of_bits++; - num <<= 1; + + while (size >= num && num_of_bits < 32) + { + num_of_bits++; + num <<= 1; } return num_of_bits; } @@ -179,44 +187,49 @@ static int sizeofint(const int size) { | calling these routines. Note that for many calls I can use | the variable 'smallidx' which is exactly the number of bits, and | So I don't need to call 'sizeofints for those calls. -*/ + */ -static int sizeofints( const int num_of_ints, unsigned int sizes[]) { - int i, num; - int bytes[32]; +static int sizeofints( const int num_of_ints, unsigned int sizes[]) +{ + int i, num; + int bytes[32]; unsigned int num_of_bytes, num_of_bits, bytecnt, tmp; num_of_bytes = 1; - bytes[0] = 1; - num_of_bits = 0; - for (i=0; i < num_of_ints; i++) { - tmp = 0; - for (bytecnt = 0; bytecnt < num_of_bytes; bytecnt++) { - tmp = bytes[bytecnt] * sizes[i] + tmp; - bytes[bytecnt] = tmp & 0xff; - tmp >>= 8; - } - while (tmp != 0) { - bytes[bytecnt++] = tmp & 0xff; - tmp >>= 8; - } - num_of_bytes = bytecnt; + bytes[0] = 1; + num_of_bits = 0; + for (i = 0; i < num_of_ints; i++) + { + tmp = 0; + for (bytecnt = 0; bytecnt < num_of_bytes; bytecnt++) + { + tmp = bytes[bytecnt] * sizes[i] + tmp; + bytes[bytecnt] = tmp & 0xff; + tmp >>= 8; + } + while (tmp != 0) + { + bytes[bytecnt++] = tmp & 0xff; + tmp >>= 8; + } + num_of_bytes = bytecnt; } num = 1; num_of_bytes--; - while (bytes[num_of_bytes] >= num) { - num_of_bits++; - num *= 2; + while (bytes[num_of_bytes] >= num) + { + num_of_bits++; + num *= 2; } return num_of_bits + num_of_bytes * 8; } - + /*____________________________________________________________________________ | | sendints - send a small set of small integers in compressed format | | this routine is used internally by xdr3dfcoord, to send a set of - | small integers to the buffer. + | small integers to the buffer. | Multiplication with fixed (specified maximum ) sizes is used to get | to one big, multibyte integer. Allthough the routine could be | modified to handle sizes bigger than 16777216, or more than just @@ -225,49 +238,61 @@ static int sizeofints( const int num_of_ints, unsigned int sizes[]) { | or the byte buffer (32 bytes) is unchecked and causes bad results. | */ - + static void sendints(int buf[], const int num_of_ints, const int num_of_bits, - unsigned int sizes[], unsigned int nums[]) { + unsigned int sizes[], unsigned int nums[]) +{ - int i, num_of_bytes, bytecnt; + int i, num_of_bytes, bytecnt; unsigned int bytes[32], tmp; - tmp = nums[0]; + tmp = nums[0]; num_of_bytes = 0; - do { - bytes[num_of_bytes++] = tmp & 0xff; - tmp >>= 8; - } while (tmp != 0); - - for (i = 1; i < num_of_ints; i++) { - if (nums[i] >= sizes[i]) { - fprintf(stderr,"major breakdown in sendints num %u doesn't " - "match size %u\n", nums[i], sizes[i]); - exit(1); - } - /* use one step multiply */ - tmp = nums[i]; - for (bytecnt = 0; bytecnt < num_of_bytes; bytecnt++) { - tmp = bytes[bytecnt] * sizes[i] + tmp; - bytes[bytecnt] = tmp & 0xff; - tmp >>= 8; - } - while (tmp != 0) { - bytes[bytecnt++] = tmp & 0xff; - tmp >>= 8; - } - num_of_bytes = bytecnt; + do + { + bytes[num_of_bytes++] = tmp & 0xff; + tmp >>= 8; } - if (num_of_bits >= num_of_bytes * 8) { - for (i = 0; i < num_of_bytes; i++) { - sendbits(buf, 8, bytes[i]); - } - sendbits(buf, num_of_bits - num_of_bytes * 8, 0); - } else { - for (i = 0; i < num_of_bytes-1; i++) { - sendbits(buf, 8, bytes[i]); - } - sendbits(buf, num_of_bits- (num_of_bytes -1) * 8, bytes[i]); + while (tmp != 0); + + for (i = 1; i < num_of_ints; i++) + { + if (nums[i] >= sizes[i]) + { + fprintf(stderr, "major breakdown in sendints num %u doesn't " + "match size %u\n", nums[i], sizes[i]); + exit(1); + } + /* use one step multiply */ + tmp = nums[i]; + for (bytecnt = 0; bytecnt < num_of_bytes; bytecnt++) + { + tmp = bytes[bytecnt] * sizes[i] + tmp; + bytes[bytecnt] = tmp & 0xff; + tmp >>= 8; + } + while (tmp != 0) + { + bytes[bytecnt++] = tmp & 0xff; + tmp >>= 8; + } + num_of_bytes = bytecnt; + } + if (num_of_bits >= num_of_bytes * 8) + { + for (i = 0; i < num_of_bytes; i++) + { + sendbits(buf, 8, bytes[i]); + } + sendbits(buf, num_of_bits - num_of_bytes * 8, 0); + } + else + { + for (i = 0; i < num_of_bytes-1; i++) + { + sendbits(buf, 8, bytes[i]); + } + sendbits(buf, num_of_bits- (num_of_bytes -1) * 8, bytes[i]); } } @@ -275,43 +300,47 @@ static void sendints(int buf[], const int num_of_ints, const int num_of_bits, /*___________________________________________________________________________ | | receivebits - decode number from buf using specified number of bits - | + | | extract the number of bits from the array buf and construct an integer | from it. Return that value. | -*/ + */ -static int receivebits(int buf[], int num_of_bits) { +static int receivebits(int buf[], int num_of_bits) +{ - int cnt, num, lastbits; - unsigned int lastbyte; + int cnt, num, lastbits; + unsigned int lastbyte; unsigned char * cbuf; - int mask = (1 << num_of_bits) -1; + int mask = (1 << num_of_bits) -1; - cbuf = ((unsigned char *)buf) + 3 * sizeof(*buf); - cnt = buf[0]; + cbuf = ((unsigned char *)buf) + 3 * sizeof(*buf); + cnt = buf[0]; lastbits = (unsigned int) buf[1]; lastbyte = (unsigned int) buf[2]; - + num = 0; - while (num_of_bits >= 8) { - lastbyte = ( lastbyte << 8 ) | cbuf[cnt++]; - num |= (lastbyte >> lastbits) << (num_of_bits - 8); - num_of_bits -=8; + while (num_of_bits >= 8) + { + lastbyte = ( lastbyte << 8 ) | cbuf[cnt++]; + num |= (lastbyte >> lastbits) << (num_of_bits - 8); + num_of_bits -= 8; } - if (num_of_bits > 0) { - if (lastbits < num_of_bits) { - lastbits += 8; - lastbyte = (lastbyte << 8) | cbuf[cnt++]; - } - lastbits -= num_of_bits; - num |= (lastbyte >> lastbits) & ((1 << num_of_bits) -1); + if (num_of_bits > 0) + { + if (lastbits < num_of_bits) + { + lastbits += 8; + lastbyte = (lastbyte << 8) | cbuf[cnt++]; + } + lastbits -= num_of_bits; + num |= (lastbyte >> lastbits) & ((1 << num_of_bits) -1); } - num &= mask; + num &= mask; buf[0] = cnt; buf[1] = lastbits; buf[2] = lastbyte; - return num; + return num; } /*____________________________________________________________________________ @@ -323,35 +352,40 @@ static int receivebits(int buf[], int num_of_bits) { | the given sizes[]. You need to specify the total number of bits to be | used from buf in num_of_bits. | -*/ + */ static void receiveints(int buf[], const int num_of_ints, int num_of_bits, - unsigned int sizes[], int nums[]) { + unsigned int sizes[], int nums[]) +{ int bytes[32]; int i, j, num_of_bytes, p, num; - - bytes[0] = bytes[1] = bytes[2] = bytes[3] = 0; + + bytes[0] = bytes[1] = bytes[2] = bytes[3] = 0; num_of_bytes = 0; - while (num_of_bits > 8) { - bytes[num_of_bytes++] = receivebits(buf, 8); - num_of_bits -= 8; + while (num_of_bits > 8) + { + bytes[num_of_bytes++] = receivebits(buf, 8); + num_of_bits -= 8; } - if (num_of_bits > 0) { - bytes[num_of_bytes++] = receivebits(buf, num_of_bits); + if (num_of_bits > 0) + { + bytes[num_of_bytes++] = receivebits(buf, num_of_bits); } - for (i = num_of_ints-1; i > 0; i--) { - num = 0; - for (j = num_of_bytes-1; j >=0; j--) { - num = (num << 8) | bytes[j]; - p = num / sizes[i]; - bytes[j] = p; - num = num - p * sizes[i]; - } - nums[i] = num; + for (i = num_of_ints-1; i > 0; i--) + { + num = 0; + for (j = num_of_bytes-1; j >= 0; j--) + { + num = (num << 8) | bytes[j]; + p = num / sizes[i]; + bytes[j] = p; + num = num - p * sizes[i]; + } + nums[i] = num; } nums[0] = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24); } - + /*____________________________________________________________________________ | | xdr3dfcoord - read or write compressed 3d coordinates to xdr file. @@ -378,174 +412,220 @@ static void receiveints(int buf[], const int num_of_ints, int num_of_bits, | it shouldn't harm in the general case. | */ - -int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) + +int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) { - int *ip = NULL; - int *buf = NULL; + int *ip = NULL; + int *buf = NULL; gmx_bool bRead; - + /* preallocate a small buffer and ip on the stack - if we need more we can always malloc(). This is faster for small values of size: */ - unsigned prealloc_size=3*16; - int prealloc_ip[3*16], prealloc_buf[3*20]; - int we_should_free=0; - - int minint[3], maxint[3], mindiff, *lip, diff; - int lint1, lint2, lint3, oldlint1, oldlint2, oldlint3, smallidx; - int minidx, maxidx; - unsigned sizeint[3], sizesmall[3], bitsizeint[3], size3, *luip; - int flag, k; - int smallnum, smaller, larger, i, is_small, is_smaller, run, prevrun; - float *lfp, lf; - int tmp, *thiscoord, prevcoord[3]; + unsigned prealloc_size = 3*16; + int prealloc_ip[3*16], prealloc_buf[3*20]; + int we_should_free = 0; + + int minint[3], maxint[3], mindiff, *lip, diff; + int lint1, lint2, lint3, oldlint1, oldlint2, oldlint3, smallidx; + int minidx, maxidx; + unsigned sizeint[3], sizesmall[3], bitsizeint[3], size3, *luip; + int flag, k; + int smallnum, smaller, larger, i, is_small, is_smaller, run, prevrun; + float *lfp, lf; + int tmp, *thiscoord, prevcoord[3]; unsigned int tmpcoord[30]; - int bufsize, xdrid, lsize; + int bufsize, xdrid, lsize; unsigned int bitsize; - float inv_precision; - int errval = 1; - int rc; - - bRead = (xdrs->x_op == XDR_DECODE); + float inv_precision; + int errval = 1; + int rc; + + bRead = (xdrs->x_op == XDR_DECODE); bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0; prevcoord[0] = prevcoord[1] = prevcoord[2] = 0; - + if (!bRead) { - /* xdrs is open for writing */ - - if (xdr_int(xdrs, size) == 0) - return 0; - size3 = *size * 3; - /* when the number of coordinates is small, don't try to compress; just - * write them as floats using xdr_vector - */ - if (*size <= 9 ) { - return (xdr_vector(xdrs, (char *) fp, (unsigned int)size3, - (unsigned int)sizeof(*fp), (xdrproc_t)xdr_float)); - } - - if(xdr_float(xdrs, precision) == 0) + /* xdrs is open for writing */ + + if (xdr_int(xdrs, size) == 0) + { + return 0; + } + size3 = *size * 3; + /* when the number of coordinates is small, don't try to compress; just + * write them as floats using xdr_vector + */ + if (*size <= 9) + { + return (xdr_vector(xdrs, (char *) fp, (unsigned int)size3, + (unsigned int)sizeof(*fp), (xdrproc_t)xdr_float)); + } + + if (xdr_float(xdrs, precision) == 0) + { return 0; + } if (size3 <= prealloc_size) { - ip=prealloc_ip; - buf=prealloc_buf; + ip = prealloc_ip; + buf = prealloc_buf; } else { - we_should_free=1; - bufsize = size3 * 1.2; - ip = (int *)malloc((size_t)(size3 * sizeof(*ip))); - buf = (int *)malloc((size_t)(bufsize * sizeof(*buf))); - if (ip == NULL || buf==NULL) - { - fprintf(stderr,"malloc failed\n"); - exit(1); - } + we_should_free = 1; + bufsize = size3 * 1.2; + ip = (int *)malloc((size_t)(size3 * sizeof(*ip))); + buf = (int *)malloc((size_t)(bufsize * sizeof(*buf))); + if (ip == NULL || buf == NULL) + { + fprintf(stderr, "malloc failed\n"); + exit(1); + } } - /* buf[0-2] are special and do not contain actual data */ - buf[0] = buf[1] = buf[2] = 0; - minint[0] = minint[1] = minint[2] = INT_MAX; - maxint[0] = maxint[1] = maxint[2] = INT_MIN; - prevrun = -1; - lfp = fp; - lip = ip; - mindiff = INT_MAX; - oldlint1 = oldlint2 = oldlint3 = 0; - while(lfp < fp + size3 ) { - /* find nearest integer */ - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint1 = lf; - if (lint1 < minint[0]) minint[0] = lint1; - if (lint1 > maxint[0]) maxint[0] = lint1; - *lip++ = lint1; - lfp++; - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint2 = lf; - if (lint2 < minint[1]) minint[1] = lint2; - if (lint2 > maxint[1]) maxint[1] = lint2; - *lip++ = lint2; - lfp++; - if (*lfp >= 0.0) - lf = *lfp * *precision + 0.5; - else - lf = *lfp * *precision - 0.5; - if (fabs(lf) > MAXABS) { - /* scaling would cause overflow */ - errval = 0; - } - lint3 = lf; - if (lint3 < minint[2]) minint[2] = lint3; - if (lint3 > maxint[2]) maxint[2] = lint3; - *lip++ = lint3; - lfp++; - diff = abs(oldlint1-lint1)+abs(oldlint2-lint2)+abs(oldlint3-lint3); - if (diff < mindiff && lfp > fp + 3) - mindiff = diff; - oldlint1 = lint1; - oldlint2 = lint2; - oldlint3 = lint3; - } - if ( (xdr_int(xdrs, &(minint[0])) == 0) || - (xdr_int(xdrs, &(minint[1])) == 0) || - (xdr_int(xdrs, &(minint[2])) == 0) || - (xdr_int(xdrs, &(maxint[0])) == 0) || - (xdr_int(xdrs, &(maxint[1])) == 0) || - (xdr_int(xdrs, &(maxint[2])) == 0)) - { + /* buf[0-2] are special and do not contain actual data */ + buf[0] = buf[1] = buf[2] = 0; + minint[0] = minint[1] = minint[2] = INT_MAX; + maxint[0] = maxint[1] = maxint[2] = INT_MIN; + prevrun = -1; + lfp = fp; + lip = ip; + mindiff = INT_MAX; + oldlint1 = oldlint2 = oldlint3 = 0; + while (lfp < fp + size3) + { + /* find nearest integer */ + if (*lfp >= 0.0) + { + lf = *lfp * *precision + 0.5; + } + else + { + lf = *lfp * *precision - 0.5; + } + if (fabs(lf) > MAXABS) + { + /* scaling would cause overflow */ + errval = 0; + } + lint1 = lf; + if (lint1 < minint[0]) + { + minint[0] = lint1; + } + if (lint1 > maxint[0]) + { + maxint[0] = lint1; + } + *lip++ = lint1; + lfp++; + if (*lfp >= 0.0) + { + lf = *lfp * *precision + 0.5; + } + else + { + lf = *lfp * *precision - 0.5; + } + if (fabs(lf) > MAXABS) + { + /* scaling would cause overflow */ + errval = 0; + } + lint2 = lf; + if (lint2 < minint[1]) + { + minint[1] = lint2; + } + if (lint2 > maxint[1]) + { + maxint[1] = lint2; + } + *lip++ = lint2; + lfp++; + if (*lfp >= 0.0) + { + lf = *lfp * *precision + 0.5; + } + else + { + lf = *lfp * *precision - 0.5; + } + if (fabs(lf) > MAXABS) + { + /* scaling would cause overflow */ + errval = 0; + } + lint3 = lf; + if (lint3 < minint[2]) + { + minint[2] = lint3; + } + if (lint3 > maxint[2]) + { + maxint[2] = lint3; + } + *lip++ = lint3; + lfp++; + diff = abs(oldlint1-lint1)+abs(oldlint2-lint2)+abs(oldlint3-lint3); + if (diff < mindiff && lfp > fp + 3) + { + mindiff = diff; + } + oldlint1 = lint1; + oldlint2 = lint2; + oldlint3 = lint3; + } + if ( (xdr_int(xdrs, &(minint[0])) == 0) || + (xdr_int(xdrs, &(minint[1])) == 0) || + (xdr_int(xdrs, &(minint[2])) == 0) || + (xdr_int(xdrs, &(maxint[0])) == 0) || + (xdr_int(xdrs, &(maxint[1])) == 0) || + (xdr_int(xdrs, &(maxint[2])) == 0)) + { if (we_should_free) { free(ip); free(buf); } return 0; - } - - if ((float)maxint[0] - (float)minint[0] >= MAXABS || - (float)maxint[1] - (float)minint[1] >= MAXABS || - (float)maxint[2] - (float)minint[2] >= MAXABS) { - /* turning value in unsigned by subtracting minint - * would cause overflow - */ - errval = 0; - } - sizeint[0] = maxint[0] - minint[0]+1; - sizeint[1] = maxint[1] - minint[1]+1; - sizeint[2] = maxint[2] - minint[2]+1; - - /* check if one of the sizes is to big to be multiplied */ - if ((sizeint[0] | sizeint[1] | sizeint[2] ) > 0xffffff) { - bitsizeint[0] = sizeofint(sizeint[0]); - bitsizeint[1] = sizeofint(sizeint[1]); - bitsizeint[2] = sizeofint(sizeint[2]); - bitsize = 0; /* flag the use of large sizes */ - } else { - bitsize = sizeofints(3, sizeint); - } - lip = ip; - luip = (unsigned int *) ip; - smallidx = FIRSTIDX; - while (smallidx < LASTIDX && magicints[smallidx] < mindiff) { - smallidx++; - } - if(xdr_int(xdrs, &smallidx) == 0) + } + + if ((float)maxint[0] - (float)minint[0] >= MAXABS || + (float)maxint[1] - (float)minint[1] >= MAXABS || + (float)maxint[2] - (float)minint[2] >= MAXABS) + { + /* turning value in unsigned by subtracting minint + * would cause overflow + */ + errval = 0; + } + sizeint[0] = maxint[0] - minint[0]+1; + sizeint[1] = maxint[1] - minint[1]+1; + sizeint[2] = maxint[2] - minint[2]+1; + + /* check if one of the sizes is to big to be multiplied */ + if ((sizeint[0] | sizeint[1] | sizeint[2] ) > 0xffffff) + { + bitsizeint[0] = sizeofint(sizeint[0]); + bitsizeint[1] = sizeofint(sizeint[1]); + bitsizeint[2] = sizeofint(sizeint[2]); + bitsize = 0; /* flag the use of large sizes */ + } + else + { + bitsize = sizeofints(3, sizeint); + } + lip = ip; + luip = (unsigned int *) ip; + smallidx = FIRSTIDX; + while (smallidx < LASTIDX && magicints[smallidx] < mindiff) + { + smallidx++; + } + if (xdr_int(xdrs, &smallidx) == 0) { if (we_should_free) { @@ -554,114 +634,141 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) } return 0; } - - maxidx = MIN(LASTIDX, smallidx + 8) ; - minidx = maxidx - 8; /* often this equal smallidx */ - smaller = magicints[MAX(FIRSTIDX, smallidx-1)] / 2; - smallnum = magicints[smallidx] / 2; - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; - larger = magicints[maxidx] / 2; - i = 0; - while (i < *size) { - is_small = 0; - thiscoord = (int *)(luip) + i * 3; - if (smallidx < maxidx && i >= 1 && - abs(thiscoord[0] - prevcoord[0]) < larger && - abs(thiscoord[1] - prevcoord[1]) < larger && - abs(thiscoord[2] - prevcoord[2]) < larger) { - is_smaller = 1; - } else if (smallidx > minidx) { - is_smaller = -1; - } else { - is_smaller = 0; - } - if (i + 1 < *size) { - if (abs(thiscoord[0] - thiscoord[3]) < smallnum && - abs(thiscoord[1] - thiscoord[4]) < smallnum && - abs(thiscoord[2] - thiscoord[5]) < smallnum) { - /* interchange first with second atom for better - * compression of water molecules - */ - tmp = thiscoord[0]; thiscoord[0] = thiscoord[3]; - thiscoord[3] = tmp; - tmp = thiscoord[1]; thiscoord[1] = thiscoord[4]; - thiscoord[4] = tmp; - tmp = thiscoord[2]; thiscoord[2] = thiscoord[5]; - thiscoord[5] = tmp; - is_small = 1; - } - - } - tmpcoord[0] = thiscoord[0] - minint[0]; - tmpcoord[1] = thiscoord[1] - minint[1]; - tmpcoord[2] = thiscoord[2] - minint[2]; - if (bitsize == 0) { - sendbits(buf, bitsizeint[0], tmpcoord[0]); - sendbits(buf, bitsizeint[1], tmpcoord[1]); - sendbits(buf, bitsizeint[2], tmpcoord[2]); - } else { - sendints(buf, 3, bitsize, sizeint, tmpcoord); - } - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - thiscoord = thiscoord + 3; - i++; - - run = 0; - if (is_small == 0 && is_smaller == -1) - is_smaller = 0; - while (is_small && run < 8*3) { - if (is_smaller == -1 && ( - SQR(thiscoord[0] - prevcoord[0]) + - SQR(thiscoord[1] - prevcoord[1]) + - SQR(thiscoord[2] - prevcoord[2]) >= smaller * smaller)) { - is_smaller = 0; - } - - tmpcoord[run++] = thiscoord[0] - prevcoord[0] + smallnum; - tmpcoord[run++] = thiscoord[1] - prevcoord[1] + smallnum; - tmpcoord[run++] = thiscoord[2] - prevcoord[2] + smallnum; - - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - - i++; - thiscoord = thiscoord + 3; - is_small = 0; - if (i < *size && - abs(thiscoord[0] - prevcoord[0]) < smallnum && - abs(thiscoord[1] - prevcoord[1]) < smallnum && - abs(thiscoord[2] - prevcoord[2]) < smallnum) { - is_small = 1; - } - } - if (run != prevrun || is_smaller != 0) { - prevrun = run; - sendbits(buf, 1, 1); /* flag the change in run-length */ - sendbits(buf, 5, run+is_smaller+1); - } else { - sendbits(buf, 1, 0); /* flag the fact that runlength did not change */ - } - for (k=0; k < run; k+=3) { - sendints(buf, 3, smallidx, sizesmall, &tmpcoord[k]); - } - if (is_smaller != 0) { - smallidx += is_smaller; - if (is_smaller < 0) { - smallnum = smaller; - smaller = magicints[smallidx-1] / 2; - } else { - smaller = smallnum; - smallnum = magicints[smallidx] / 2; - } - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; - } - } - if (buf[1] != 0) buf[0]++; - /* buf[0] holds the length in bytes */ - if(xdr_int(xdrs, &(buf[0])) == 0) + + maxidx = MIN(LASTIDX, smallidx + 8); + minidx = maxidx - 8; /* often this equal smallidx */ + smaller = magicints[MAX(FIRSTIDX, smallidx-1)] / 2; + smallnum = magicints[smallidx] / 2; + sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; + larger = magicints[maxidx] / 2; + i = 0; + while (i < *size) + { + is_small = 0; + thiscoord = (int *)(luip) + i * 3; + if (smallidx < maxidx && i >= 1 && + abs(thiscoord[0] - prevcoord[0]) < larger && + abs(thiscoord[1] - prevcoord[1]) < larger && + abs(thiscoord[2] - prevcoord[2]) < larger) + { + is_smaller = 1; + } + else if (smallidx > minidx) + { + is_smaller = -1; + } + else + { + is_smaller = 0; + } + if (i + 1 < *size) + { + if (abs(thiscoord[0] - thiscoord[3]) < smallnum && + abs(thiscoord[1] - thiscoord[4]) < smallnum && + abs(thiscoord[2] - thiscoord[5]) < smallnum) + { + /* interchange first with second atom for better + * compression of water molecules + */ + tmp = thiscoord[0]; thiscoord[0] = thiscoord[3]; + thiscoord[3] = tmp; + tmp = thiscoord[1]; thiscoord[1] = thiscoord[4]; + thiscoord[4] = tmp; + tmp = thiscoord[2]; thiscoord[2] = thiscoord[5]; + thiscoord[5] = tmp; + is_small = 1; + } + + } + tmpcoord[0] = thiscoord[0] - minint[0]; + tmpcoord[1] = thiscoord[1] - minint[1]; + tmpcoord[2] = thiscoord[2] - minint[2]; + if (bitsize == 0) + { + sendbits(buf, bitsizeint[0], tmpcoord[0]); + sendbits(buf, bitsizeint[1], tmpcoord[1]); + sendbits(buf, bitsizeint[2], tmpcoord[2]); + } + else + { + sendints(buf, 3, bitsize, sizeint, tmpcoord); + } + prevcoord[0] = thiscoord[0]; + prevcoord[1] = thiscoord[1]; + prevcoord[2] = thiscoord[2]; + thiscoord = thiscoord + 3; + i++; + + run = 0; + if (is_small == 0 && is_smaller == -1) + { + is_smaller = 0; + } + while (is_small && run < 8*3) + { + if (is_smaller == -1 && ( + SQR(thiscoord[0] - prevcoord[0]) + + SQR(thiscoord[1] - prevcoord[1]) + + SQR(thiscoord[2] - prevcoord[2]) >= smaller * smaller)) + { + is_smaller = 0; + } + + tmpcoord[run++] = thiscoord[0] - prevcoord[0] + smallnum; + tmpcoord[run++] = thiscoord[1] - prevcoord[1] + smallnum; + tmpcoord[run++] = thiscoord[2] - prevcoord[2] + smallnum; + + prevcoord[0] = thiscoord[0]; + prevcoord[1] = thiscoord[1]; + prevcoord[2] = thiscoord[2]; + + i++; + thiscoord = thiscoord + 3; + is_small = 0; + if (i < *size && + abs(thiscoord[0] - prevcoord[0]) < smallnum && + abs(thiscoord[1] - prevcoord[1]) < smallnum && + abs(thiscoord[2] - prevcoord[2]) < smallnum) + { + is_small = 1; + } + } + if (run != prevrun || is_smaller != 0) + { + prevrun = run; + sendbits(buf, 1, 1); /* flag the change in run-length */ + sendbits(buf, 5, run+is_smaller+1); + } + else + { + sendbits(buf, 1, 0); /* flag the fact that runlength did not change */ + } + for (k = 0; k < run; k += 3) + { + sendints(buf, 3, smallidx, sizesmall, &tmpcoord[k]); + } + if (is_smaller != 0) + { + smallidx += is_smaller; + if (is_smaller < 0) + { + smallnum = smaller; + smaller = magicints[smallidx-1] / 2; + } + else + { + smaller = smallnum; + smallnum = magicints[smallidx] / 2; + } + sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; + } + } + if (buf[1] != 0) + { + buf[0]++; + } + /* buf[0] holds the length in bytes */ + if (xdr_int(xdrs, &(buf[0])) == 0) { if (we_should_free) { @@ -671,85 +778,96 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) return 0; } - - rc=errval * (xdr_opaque(xdrs, (char *)&(buf[3]), (unsigned int)buf[0])); + + rc = errval * (xdr_opaque(xdrs, (char *)&(buf[3]), (unsigned int)buf[0])); if (we_should_free) { free(ip); free(buf); } return rc; - - } else { - - /* xdrs is open for reading */ - - if (xdr_int(xdrs, &lsize) == 0) - return 0; - if (*size != 0 && lsize != *size) { - fprintf(stderr, "wrong number of coordinates in xdr3dfcoord; " - "%d arg vs %d in file", *size, lsize); - } - *size = lsize; - size3 = *size * 3; - if (*size <= 9) { - *precision = -1; - return (xdr_vector(xdrs, (char *) fp, (unsigned int)size3, - (unsigned int)sizeof(*fp), (xdrproc_t)xdr_float)); - } - if(xdr_float(xdrs, precision) == 0) - return 0; + + } + else + { + + /* xdrs is open for reading */ + + if (xdr_int(xdrs, &lsize) == 0) + { + return 0; + } + if (*size != 0 && lsize != *size) + { + fprintf(stderr, "wrong number of coordinates in xdr3dfcoord; " + "%d arg vs %d in file", *size, lsize); + } + *size = lsize; + size3 = *size * 3; + if (*size <= 9) + { + *precision = -1; + return (xdr_vector(xdrs, (char *) fp, (unsigned int)size3, + (unsigned int)sizeof(*fp), (xdrproc_t)xdr_float)); + } + if (xdr_float(xdrs, precision) == 0) + { + return 0; + } if (size3 <= prealloc_size) { - ip=prealloc_ip; - buf=prealloc_buf; + ip = prealloc_ip; + buf = prealloc_buf; } else { - we_should_free=1; - bufsize = size3 * 1.2; - ip = (int *)malloc((size_t)(size3 * sizeof(*ip))); - buf = (int *)malloc((size_t)(bufsize * sizeof(*buf))); - if (ip == NULL || buf==NULL) - { - fprintf(stderr,"malloc failed\n"); - exit(1); - } + we_should_free = 1; + bufsize = size3 * 1.2; + ip = (int *)malloc((size_t)(size3 * sizeof(*ip))); + buf = (int *)malloc((size_t)(bufsize * sizeof(*buf))); + if (ip == NULL || buf == NULL) + { + fprintf(stderr, "malloc failed\n"); + exit(1); + } } - buf[0] = buf[1] = buf[2] = 0; - - if ( (xdr_int(xdrs, &(minint[0])) == 0) || - (xdr_int(xdrs, &(minint[1])) == 0) || - (xdr_int(xdrs, &(minint[2])) == 0) || - (xdr_int(xdrs, &(maxint[0])) == 0) || - (xdr_int(xdrs, &(maxint[1])) == 0) || - (xdr_int(xdrs, &(maxint[2])) == 0)) - { + buf[0] = buf[1] = buf[2] = 0; + + if ( (xdr_int(xdrs, &(minint[0])) == 0) || + (xdr_int(xdrs, &(minint[1])) == 0) || + (xdr_int(xdrs, &(minint[2])) == 0) || + (xdr_int(xdrs, &(maxint[0])) == 0) || + (xdr_int(xdrs, &(maxint[1])) == 0) || + (xdr_int(xdrs, &(maxint[2])) == 0)) + { if (we_should_free) { free(ip); free(buf); } return 0; - } - - sizeint[0] = maxint[0] - minint[0]+1; - sizeint[1] = maxint[1] - minint[1]+1; - sizeint[2] = maxint[2] - minint[2]+1; - - /* check if one of the sizes is to big to be multiplied */ - if ((sizeint[0] | sizeint[1] | sizeint[2] ) > 0xffffff) { - bitsizeint[0] = sizeofint(sizeint[0]); - bitsizeint[1] = sizeofint(sizeint[1]); - bitsizeint[2] = sizeofint(sizeint[2]); - bitsize = 0; /* flag the use of large sizes */ - } else { - bitsize = sizeofints(3, sizeint); - } - - if (xdr_int(xdrs, &smallidx) == 0) + } + + sizeint[0] = maxint[0] - minint[0]+1; + sizeint[1] = maxint[1] - minint[1]+1; + sizeint[2] = maxint[2] - minint[2]+1; + + /* check if one of the sizes is to big to be multiplied */ + if ((sizeint[0] | sizeint[1] | sizeint[2] ) > 0xffffff) + { + bitsizeint[0] = sizeofint(sizeint[0]); + bitsizeint[1] = sizeofint(sizeint[1]); + bitsizeint[2] = sizeofint(sizeint[2]); + bitsize = 0; /* flag the use of large sizes */ + } + else + { + bitsize = sizeofints(3, sizeint); + } + + if (xdr_int(xdrs, &smallidx) == 0) { if (we_should_free) { @@ -759,16 +877,16 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) return 0; } - maxidx = MIN(LASTIDX, smallidx + 8) ; - minidx = maxidx - 8; /* often this equal smallidx */ - smaller = magicints[MAX(FIRSTIDX, smallidx-1)] / 2; - smallnum = magicints[smallidx] / 2; - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ; - larger = magicints[maxidx]; + maxidx = MIN(LASTIDX, smallidx + 8); + minidx = maxidx - 8; /* often this equal smallidx */ + smaller = magicints[MAX(FIRSTIDX, smallidx-1)] / 2; + smallnum = magicints[smallidx] / 2; + sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; + larger = magicints[maxidx]; - /* buf[0] holds the length in bytes */ + /* buf[0] holds the length in bytes */ - if (xdr_int(xdrs, &(buf[0])) == 0) + if (xdr_int(xdrs, &(buf[0])) == 0) { if (we_should_free) { @@ -779,7 +897,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) } - if (xdr_opaque(xdrs, (char *)&(buf[3]), (unsigned int)buf[0]) == 0) + if (xdr_opaque(xdrs, (char *)&(buf[3]), (unsigned int)buf[0]) == 0) { if (we_should_free) { @@ -791,91 +909,109 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) - buf[0] = buf[1] = buf[2] = 0; - - lfp = fp; - inv_precision = 1.0 / * precision; - run = 0; - i = 0; - lip = ip; - while ( i < lsize ) { - thiscoord = (int *)(lip) + i * 3; - - if (bitsize == 0) { - thiscoord[0] = receivebits(buf, bitsizeint[0]); - thiscoord[1] = receivebits(buf, bitsizeint[1]); - thiscoord[2] = receivebits(buf, bitsizeint[2]); - } else { - receiveints(buf, 3, bitsize, sizeint, thiscoord); - } - - i++; - thiscoord[0] += minint[0]; - thiscoord[1] += minint[1]; - thiscoord[2] += minint[2]; - - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - - - flag = receivebits(buf, 1); - is_smaller = 0; - if (flag == 1) { - run = receivebits(buf, 5); - is_smaller = run % 3; - run -= is_smaller; - is_smaller--; - } - if (run > 0) { - thiscoord += 3; - for (k = 0; k < run; k+=3) { - receiveints(buf, 3, smallidx, sizesmall, thiscoord); - i++; - thiscoord[0] += prevcoord[0] - smallnum; - thiscoord[1] += prevcoord[1] - smallnum; - thiscoord[2] += prevcoord[2] - smallnum; - if (k == 0) { - /* interchange first with second atom for better - * compression of water molecules - */ - tmp = thiscoord[0]; thiscoord[0] = prevcoord[0]; - prevcoord[0] = tmp; - tmp = thiscoord[1]; thiscoord[1] = prevcoord[1]; - prevcoord[1] = tmp; - tmp = thiscoord[2]; thiscoord[2] = prevcoord[2]; - prevcoord[2] = tmp; - *lfp++ = prevcoord[0] * inv_precision; - *lfp++ = prevcoord[1] * inv_precision; - *lfp++ = prevcoord[2] * inv_precision; - } else { - prevcoord[0] = thiscoord[0]; - prevcoord[1] = thiscoord[1]; - prevcoord[2] = thiscoord[2]; - } - *lfp++ = thiscoord[0] * inv_precision; - *lfp++ = thiscoord[1] * inv_precision; - *lfp++ = thiscoord[2] * inv_precision; - } - } else { - *lfp++ = thiscoord[0] * inv_precision; - *lfp++ = thiscoord[1] * inv_precision; - *lfp++ = thiscoord[2] * inv_precision; - } - smallidx += is_smaller; - if (is_smaller < 0) { - smallnum = smaller; - if (smallidx > FIRSTIDX) { - smaller = magicints[smallidx - 1] /2; - } else { - smaller = 0; - } - } else if (is_smaller > 0) { - smaller = smallnum; - smallnum = magicints[smallidx] / 2; - } - sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx] ; - } + buf[0] = buf[1] = buf[2] = 0; + + lfp = fp; + inv_precision = 1.0 / *precision; + run = 0; + i = 0; + lip = ip; + while (i < lsize) + { + thiscoord = (int *)(lip) + i * 3; + + if (bitsize == 0) + { + thiscoord[0] = receivebits(buf, bitsizeint[0]); + thiscoord[1] = receivebits(buf, bitsizeint[1]); + thiscoord[2] = receivebits(buf, bitsizeint[2]); + } + else + { + receiveints(buf, 3, bitsize, sizeint, thiscoord); + } + + i++; + thiscoord[0] += minint[0]; + thiscoord[1] += minint[1]; + thiscoord[2] += minint[2]; + + prevcoord[0] = thiscoord[0]; + prevcoord[1] = thiscoord[1]; + prevcoord[2] = thiscoord[2]; + + + flag = receivebits(buf, 1); + is_smaller = 0; + if (flag == 1) + { + run = receivebits(buf, 5); + is_smaller = run % 3; + run -= is_smaller; + is_smaller--; + } + if (run > 0) + { + thiscoord += 3; + for (k = 0; k < run; k += 3) + { + receiveints(buf, 3, smallidx, sizesmall, thiscoord); + i++; + thiscoord[0] += prevcoord[0] - smallnum; + thiscoord[1] += prevcoord[1] - smallnum; + thiscoord[2] += prevcoord[2] - smallnum; + if (k == 0) + { + /* interchange first with second atom for better + * compression of water molecules + */ + tmp = thiscoord[0]; thiscoord[0] = prevcoord[0]; + prevcoord[0] = tmp; + tmp = thiscoord[1]; thiscoord[1] = prevcoord[1]; + prevcoord[1] = tmp; + tmp = thiscoord[2]; thiscoord[2] = prevcoord[2]; + prevcoord[2] = tmp; + *lfp++ = prevcoord[0] * inv_precision; + *lfp++ = prevcoord[1] * inv_precision; + *lfp++ = prevcoord[2] * inv_precision; + } + else + { + prevcoord[0] = thiscoord[0]; + prevcoord[1] = thiscoord[1]; + prevcoord[2] = thiscoord[2]; + } + *lfp++ = thiscoord[0] * inv_precision; + *lfp++ = thiscoord[1] * inv_precision; + *lfp++ = thiscoord[2] * inv_precision; + } + } + else + { + *lfp++ = thiscoord[0] * inv_precision; + *lfp++ = thiscoord[1] * inv_precision; + *lfp++ = thiscoord[2] * inv_precision; + } + smallidx += is_smaller; + if (is_smaller < 0) + { + smallnum = smaller; + if (smallidx > FIRSTIDX) + { + smaller = magicints[smallidx - 1] /2; + } + else + { + smaller = 0; + } + } + else if (is_smaller > 0) + { + smaller = smallnum; + smallnum = magicints[smallidx] / 2; + } + sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; + } } if (we_should_free) { @@ -889,18 +1025,18 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) /****************************************************************** - XTC files have a relatively simple structure. - They have a header of 16 bytes and the rest are - the compressed coordinates of the files. Due to the - compression 00 is not present in the coordinates. - The first 4 bytes of the header are the magic number - 1995 (0x000007CB). If we find this number we are guaranteed - to be in the header, due to the presence of so many zeros. - The second 4 bytes are the number of atoms in the frame, and is - assumed to be constant. The third 4 bytes are the frame number. - The last 4 bytes are a floating point representation of the time. + XTC files have a relatively simple structure. + They have a header of 16 bytes and the rest are + the compressed coordinates of the files. Due to the + compression 00 is not present in the coordinates. + The first 4 bytes of the header are the magic number + 1995 (0x000007CB). If we find this number we are guaranteed + to be in the header, due to the presence of so many zeros. + The second 4 bytes are the number of atoms in the frame, and is + assumed to be constant. The third 4 bytes are the frame number. + The last 4 bytes are a floating point representation of the time. -********************************************************************/ + ********************************************************************/ /* Must match definition in xtcio.c */ #ifndef XTC_MAGIC @@ -912,84 +1048,102 @@ static const int header_size = 16; /* Check if we are at the header start. At the same time it will also read 1 int */ static int xtc_at_header_start(FILE *fp, XDR *xdrs, - int natoms, int * timestep, float * time){ - int i_inp[3]; - float f_inp[10]; - int i; - gmx_off_t off; + int natoms, int * timestep, float * time) +{ + int i_inp[3]; + float f_inp[10]; + int i; + gmx_off_t off; - if((off = gmx_ftell(fp)) < 0){ - return -1; - } - /* read magic natoms and timestep */ - for(i = 0;i<3;i++){ - if(!xdr_int(xdrs, &(i_inp[i]))){ - gmx_fseek(fp,off+XDR_INT_SIZE,SEEK_SET); - return -1; - } - } - /* quick return */ - if(i_inp[0] != XTC_MAGIC){ - if(gmx_fseek(fp,off+XDR_INT_SIZE,SEEK_SET)){ - return -1; + if ((off = gmx_ftell(fp)) < 0) + { + return -1; } - return 0; - } - /* read time and box */ - for(i = 0;i<10;i++){ - if(!xdr_float(xdrs, &(f_inp[i]))){ - gmx_fseek(fp,off+XDR_INT_SIZE,SEEK_SET); - return -1; - } - } - /* Make a rigourous check to see if we are in the beggining of a header - Hopefully there are no ambiguous cases */ - /* This check makes use of the fact that the box matrix has 3 zeroes on the upper - right triangle and that the first element must be nonzero unless the entire matrix is zero - */ - if(i_inp[1] == natoms && - ((f_inp[1] != 0 && f_inp[6] == 0) || - (f_inp[1] == 0 && f_inp[5] == 0 && f_inp[9] == 0))){ - if(gmx_fseek(fp,off+XDR_INT_SIZE,SEEK_SET)){ - return -1; + /* read magic natoms and timestep */ + for (i = 0; i < 3; i++) + { + if (!xdr_int(xdrs, &(i_inp[i]))) + { + gmx_fseek(fp, off+XDR_INT_SIZE, SEEK_SET); + return -1; + } } - *time = f_inp[0]; - *timestep = i_inp[2]; - return 1; - } - if(gmx_fseek(fp,off+XDR_INT_SIZE,SEEK_SET)){ - return -1; - } - return 0; + /* quick return */ + if (i_inp[0] != XTC_MAGIC) + { + if (gmx_fseek(fp, off+XDR_INT_SIZE, SEEK_SET)) + { + return -1; + } + return 0; + } + /* read time and box */ + for (i = 0; i < 10; i++) + { + if (!xdr_float(xdrs, &(f_inp[i]))) + { + gmx_fseek(fp, off+XDR_INT_SIZE, SEEK_SET); + return -1; + } + } + /* Make a rigourous check to see if we are in the beggining of a header + Hopefully there are no ambiguous cases */ + /* This check makes use of the fact that the box matrix has 3 zeroes on the upper + right triangle and that the first element must be nonzero unless the entire matrix is zero + */ + if (i_inp[1] == natoms && + ((f_inp[1] != 0 && f_inp[6] == 0) || + (f_inp[1] == 0 && f_inp[5] == 0 && f_inp[9] == 0))) + { + if (gmx_fseek(fp, off+XDR_INT_SIZE, SEEK_SET)) + { + return -1; + } + *time = f_inp[0]; + *timestep = i_inp[2]; + return 1; + } + if (gmx_fseek(fp, off+XDR_INT_SIZE, SEEK_SET)) + { + return -1; + } + return 0; } -static int +static int xtc_get_next_frame_number(FILE *fp, XDR *xdrs, int natoms) { gmx_off_t off; - int step; - float time; - int ret; + int step; + float time; + int ret; - if((off = gmx_ftell(fp)) < 0){ - return -1; + if ((off = gmx_ftell(fp)) < 0) + { + return -1; } /* read one int just to make sure we dont read this frame but the next */ - xdr_int(xdrs,&step); - while(1){ - ret = xtc_at_header_start(fp,xdrs,natoms,&step,&time); - if(ret == 1){ - if(gmx_fseek(fp,off,SEEK_SET)){ - return -1; - } - return step; - }else if(ret == -1){ - if(gmx_fseek(fp,off,SEEK_SET)){ - return -1; - } - } + xdr_int(xdrs, &step); + while (1) + { + ret = xtc_at_header_start(fp, xdrs, natoms, &step, &time); + if (ret == 1) + { + if (gmx_fseek(fp, off, SEEK_SET)) + { + return -1; + } + return step; + } + else if (ret == -1) + { + if (gmx_fseek(fp, off, SEEK_SET)) + { + return -1; + } + } } return -1; } @@ -999,9 +1153,9 @@ static float xtc_get_next_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) { gmx_off_t off; - float time; - int step; - int ret; + float time; + int step; + int ret; *bOK = 0; if ((off = gmx_ftell(fp)) < 0) @@ -1016,7 +1170,7 @@ static float xtc_get_next_frame_time(FILE *fp, XDR *xdrs, int natoms, if (ret == 1) { *bOK = 1; - if (gmx_fseek(fp,off,SEEK_SET)) + if (gmx_fseek(fp, off, SEEK_SET)) { *bOK = 0; return -1; @@ -1025,7 +1179,7 @@ static float xtc_get_next_frame_time(FILE *fp, XDR *xdrs, int natoms, } else if (ret == -1) { - if (gmx_fseek(fp,off,SEEK_SET)) + if (gmx_fseek(fp, off, SEEK_SET)) { return -1; } @@ -1036,13 +1190,13 @@ static float xtc_get_next_frame_time(FILE *fp, XDR *xdrs, int natoms, } -static float +static float xtc_get_current_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) { gmx_off_t off; - int step; - float time; - int ret; + int step; + float time; + int ret; *bOK = 0; if ((off = gmx_ftell(fp)) < 0) @@ -1056,7 +1210,7 @@ xtc_get_current_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) if (ret == 1) { *bOK = 1; - if (gmx_fseek(fp,off,SEEK_SET)) + if (gmx_fseek(fp, off, SEEK_SET)) { *bOK = 0; return -1; @@ -1065,7 +1219,7 @@ xtc_get_current_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) } else if (ret == -1) { - if (gmx_fseek(fp,off,SEEK_SET)) + if (gmx_fseek(fp, off, SEEK_SET)) { return -1; } @@ -1074,7 +1228,7 @@ xtc_get_current_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) else if (ret == 0) { /*Go back.*/ - if (gmx_fseek(fp,-2*XDR_INT_SIZE,SEEK_CUR)) + if (gmx_fseek(fp, -2*XDR_INT_SIZE, SEEK_CUR)) { return -1; } @@ -1084,41 +1238,51 @@ xtc_get_current_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) } /* Currently not used, just for completeness */ -static int -xtc_get_current_frame_number(FILE *fp,XDR *xdrs,int natoms, gmx_bool * bOK) +static int +xtc_get_current_frame_number(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) { gmx_off_t off; - int ret; - int step; - float time; + int ret; + int step; + float time; *bOK = 0; - - if((off = gmx_ftell(fp)) < 0){ - return -1; + + if ((off = gmx_ftell(fp)) < 0) + { + return -1; } - while(1){ - ret = xtc_at_header_start(fp,xdrs,natoms,&step,&time); - if(ret == 1){ - *bOK = 1; - if(gmx_fseek(fp,off,SEEK_SET)){ - *bOK = 0; - return -1; - } - return step; - }else if(ret == -1){ - if(gmx_fseek(fp,off,SEEK_SET)){ - return -1; - } - return -1; - - }else if(ret == 0){ - /*Go back.*/ - if(gmx_fseek(fp,-2*XDR_INT_SIZE,SEEK_CUR)){ - return -1; - } - } + while (1) + { + ret = xtc_at_header_start(fp, xdrs, natoms, &step, &time); + if (ret == 1) + { + *bOK = 1; + if (gmx_fseek(fp, off, SEEK_SET)) + { + *bOK = 0; + return -1; + } + return step; + } + else if (ret == -1) + { + if (gmx_fseek(fp, off, SEEK_SET)) + { + return -1; + } + return -1; + + } + else if (ret == 0) + { + /*Go back.*/ + if (gmx_fseek(fp, -2*XDR_INT_SIZE, SEEK_CUR)) + { + return -1; + } + } } return -1; } @@ -1127,160 +1291,175 @@ xtc_get_current_frame_number(FILE *fp,XDR *xdrs,int natoms, gmx_bool * bOK) static gmx_off_t xtc_get_next_frame_start(FILE *fp, XDR *xdrs, int natoms) { - int inp; + int inp; gmx_off_t res; - int ret; - int step; - float time; + int ret; + int step; + float time; /* read one int just to make sure we dont read this frame but the next */ - xdr_int(xdrs,&step); - while(1) + xdr_int(xdrs, &step); + while (1) { - ret = xtc_at_header_start(fp,xdrs,natoms,&step,&time); - if(ret == 1){ - if((res = gmx_ftell(fp)) >= 0){ - return res - XDR_INT_SIZE; - }else{ - return res; - } - }else if(ret == -1){ - return -1; - } + ret = xtc_at_header_start(fp, xdrs, natoms, &step, &time); + if (ret == 1) + { + if ((res = gmx_ftell(fp)) >= 0) + { + return res - XDR_INT_SIZE; + } + else + { + return res; + } + } + else if (ret == -1) + { + return -1; + } } return -1; } static -float +float xdr_xtc_estimate_dt(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) { - float res; - float tinit; - gmx_off_t off; - - *bOK = 0; - if((off = gmx_ftell(fp)) < 0){ - return -1; - } - - tinit = xtc_get_current_frame_time(fp,xdrs,natoms,bOK); - - if(!(*bOK)) + float res; + float tinit; + gmx_off_t off; + + *bOK = 0; + if ((off = gmx_ftell(fp)) < 0) { return -1; } - - res = xtc_get_next_frame_time(fp,xdrs,natoms,bOK); - - if(!(*bOK)) + + tinit = xtc_get_current_frame_time(fp, xdrs, natoms, bOK); + + if (!(*bOK)) { return -1; } - + + res = xtc_get_next_frame_time(fp, xdrs, natoms, bOK); + + if (!(*bOK)) + { + return -1; + } + res -= tinit; - if (0 != gmx_fseek(fp,off,SEEK_SET)) { - *bOK = 0; - return -1; + if (0 != gmx_fseek(fp, off, SEEK_SET)) + { + *bOK = 0; + return -1; } return res; } -int +int xdr_xtc_seek_frame(int frame, FILE *fp, XDR *xdrs, int natoms) { gmx_off_t low = 0; - gmx_off_t high,pos; + gmx_off_t high, pos; + - /* round to 4 bytes */ - int fr; + int fr; gmx_off_t offset; - if(gmx_fseek(fp,0,SEEK_END)){ - return -1; + if (gmx_fseek(fp, 0, SEEK_END)) + { + return -1; } - if((high = gmx_ftell(fp)) < 0){ - return -1; + if ((high = gmx_ftell(fp)) < 0) + { + return -1; } - + /* round to 4 bytes */ - high /= XDR_INT_SIZE; - high *= XDR_INT_SIZE; + high /= XDR_INT_SIZE; + high *= XDR_INT_SIZE; offset = ((high/2)/XDR_INT_SIZE)*XDR_INT_SIZE; - - if(gmx_fseek(fp,offset,SEEK_SET)){ - return -1; + + if (gmx_fseek(fp, offset, SEEK_SET)) + { + return -1; } - - while(1) + + while (1) { - fr = xtc_get_next_frame_number(fp,xdrs,natoms); - if(fr < 0) + fr = xtc_get_next_frame_number(fp, xdrs, natoms); + if (fr < 0) { return -1; } - if(fr != frame && abs(low-high) > header_size) + if (fr != frame && abs(low-high) > header_size) { - if(fr < frame) + if (fr < frame) { - low = offset; + low = offset; } else { - high = offset; + high = offset; } /* round to 4 bytes */ offset = (((high+low)/2)/4)*4; - - if(gmx_fseek(fp,offset,SEEK_SET)){ - return -1; - } + + if (gmx_fseek(fp, offset, SEEK_SET)) + { + return -1; + } } else { break; } } - if(offset <= header_size) + if (offset <= header_size) { offset = low; } - - if(gmx_fseek(fp,offset,SEEK_SET)){ - return -1; + + if (gmx_fseek(fp, offset, SEEK_SET)) + { + return -1; } - if((pos = xtc_get_next_frame_start(fp,xdrs,natoms))< 0){ - /* we probably hit an end of file */ - return -1; + if ((pos = xtc_get_next_frame_start(fp, xdrs, natoms)) < 0) + { + /* we probably hit an end of file */ + return -1; } - - if(gmx_fseek(fp,pos,SEEK_SET)){ - return -1; + + if (gmx_fseek(fp, pos, SEEK_SET)) + { + return -1; } - + return 0; } - -int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekForwardOnly) + +int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms, gmx_bool bSeekForwardOnly) { - float t; - float dt; - gmx_bool bOK = FALSE; + float t; + float dt; + gmx_bool bOK = FALSE; gmx_off_t low = 0; gmx_off_t high, offset, pos; - int res; - int dt_sign = 0; + int res; + int dt_sign = 0; if (bSeekForwardOnly) { low = gmx_ftell(fp); } - if (gmx_fseek(fp,0,SEEK_END)) + if (gmx_fseek(fp, 0, SEEK_END)) { return -1; } @@ -1290,25 +1469,25 @@ int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekF return -1; } /* round to int */ - high /= XDR_INT_SIZE; - high *= XDR_INT_SIZE; + high /= XDR_INT_SIZE; + high *= XDR_INT_SIZE; offset = (((high-low) / 2) / XDR_INT_SIZE) * XDR_INT_SIZE; - if (gmx_fseek(fp,offset,SEEK_SET)) + if (gmx_fseek(fp, offset, SEEK_SET)) { return -1; } - + /* * No need to call xdr_xtc_estimate_dt here - since xdr_xtc_estimate_dt is called first thing in the loop - dt = xdr_xtc_estimate_dt(fp, xdrs, natoms, &bOK); + dt = xdr_xtc_estimate_dt(fp, xdrs, natoms, &bOK); - if (!bOK) - { + if (!bOK) + { return -1; - } - */ + } + */ while (1) { @@ -1324,7 +1503,7 @@ int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekF if (dt_sign == -1) { /* Found a place in the trajectory that has positive time step while - other has negative time step */ + other has negative time step */ return -2; } dt_sign = 1; @@ -1334,7 +1513,7 @@ int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekF if (dt_sign == 1) { /* Found a place in the trajectory that has positive time step while - other has negative time step */ + other has negative time step */ return -2; } dt_sign = -1; @@ -1347,14 +1526,14 @@ int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekF } /* If we are before the target time and the time step is positive or 0, or we have - after the target time and the time step is negative, or the difference between - the current time and the target time is bigger than dt and above all the distance between high - and low is bigger than 1 frame, then do another step of binary search. Otherwise stop and check - if we reached the solution */ + after the target time and the time step is negative, or the difference between + the current time and the target time is bigger than dt and above all the distance between high + and low is bigger than 1 frame, then do another step of binary search. Otherwise stop and check + if we reached the solution */ if ((((t < time && dt_sign >= 0) || (t > time && dt_sign == -1)) || ((t - - time) >= dt && dt_sign >= 0) - || ((time - t) >= -dt && dt_sign < 0)) && (abs(low - high) - > header_size)) + - time) >= dt && dt_sign >= 0) + || ((time - t) >= -dt && dt_sign < 0)) && (abs(low - high) + > header_size)) { if (dt >= 0 && dt_sign != -1) { @@ -1385,7 +1564,7 @@ int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekF } /* round to 4 bytes and subtract header*/ offset = (((high + low) / 2) / XDR_INT_SIZE) * XDR_INT_SIZE; - if (gmx_fseek(fp,offset,SEEK_SET)) + if (gmx_fseek(fp, offset, SEEK_SET)) { return -1; } @@ -1416,47 +1595,51 @@ int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekF offset = low; } - gmx_fseek(fp,offset,SEEK_SET); + gmx_fseek(fp, offset, SEEK_SET); if ((pos = xtc_get_next_frame_start(fp, xdrs, natoms)) < 0) { return -1; } - if (gmx_fseek(fp,pos,SEEK_SET)) + if (gmx_fseek(fp, pos, SEEK_SET)) { return -1; } return 0; } -float +float xdr_xtc_get_last_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) { - float time; + float time; gmx_off_t off; - int res; + int res; *bOK = 1; - off = gmx_ftell(fp); - if(off < 0){ - *bOK = 0; - return -1; + off = gmx_ftell(fp); + if (off < 0) + { + *bOK = 0; + return -1; } - - if( (res = gmx_fseek(fp,-3*XDR_INT_SIZE,SEEK_END)) != 0){ - *bOK = 0; - return -1; + + if ( (res = gmx_fseek(fp, -3*XDR_INT_SIZE, SEEK_END)) != 0) + { + *bOK = 0; + return -1; } time = xtc_get_current_frame_time(fp, xdrs, natoms, bOK); - if(!(*bOK)){ - return -1; + if (!(*bOK)) + { + return -1; + } + + if ( (res = gmx_fseek(fp, off, SEEK_SET)) != 0) + { + *bOK = 0; + return -1; } - - if( (res = gmx_fseek(fp,off,SEEK_SET)) != 0){ - *bOK = 0; - return -1; - } return time; } @@ -1464,32 +1647,36 @@ xdr_xtc_get_last_frame_time(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) int xdr_xtc_get_last_frame_number(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) { - int frame; + int frame; gmx_off_t off; - int res; + int res; *bOK = 1; - - if((off = gmx_ftell(fp)) < 0){ - *bOK = 0; - return -1; + + if ((off = gmx_ftell(fp)) < 0) + { + *bOK = 0; + return -1; } - - if(gmx_fseek(fp,-3*XDR_INT_SIZE,SEEK_END)){ - *bOK = 0; - return -1; + + if (gmx_fseek(fp, -3*XDR_INT_SIZE, SEEK_END)) + { + *bOK = 0; + return -1; } frame = xtc_get_current_frame_number(fp, xdrs, natoms, bOK); - if(!bOK){ - return -1; + if (!bOK) + { + return -1; } - if(gmx_fseek(fp,off,SEEK_SET)){ - *bOK = 0; - return -1; - } + if (gmx_fseek(fp, off, SEEK_SET)) + { + *bOK = 0; + return -1; + } return frame; } diff --git a/src/gromacs/gmxlib/main.c b/src/gromacs/gmxlib/main.c index baf41cdcd6..750731866a 100644 --- a/src/gromacs/gmxlib/main.c +++ b/src/gromacs/gmxlib/main.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -63,7 +63,7 @@ #include "thread_mpi.h" #endif -/* The source code in this file should be thread-safe. +/* The source code in this file should be thread-safe. Please keep it that way. */ @@ -78,133 +78,155 @@ /* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */ char * -gmx_ctime_r(const time_t *clock,char *buf, int n); +gmx_ctime_r(const time_t *clock, char *buf, int n); -#define BUFSIZE 1024 +#define BUFSIZE 1024 -static void par_fn(char *base,int ftp,const t_commrec *cr, - gmx_bool bAppendSimId,gmx_bool bAppendNodeId, - char buf[],int bufsize) +static void par_fn(char *base, int ftp, const t_commrec *cr, + gmx_bool bAppendSimId, gmx_bool bAppendNodeId, + char buf[], int bufsize) { - int n; - - if((size_t)bufsize<(strlen(base)+10)) - gmx_mem("Character buffer too small!"); - - /* Copy to buf, and strip extension */ - strcpy(buf,base); - buf[strlen(base) - strlen(ftp2ext(fn2ftp(base))) - 1] = '\0'; - - if (bAppendSimId) { - sprintf(buf+strlen(buf),"%d",cr->ms->sim); - } - if (bAppendNodeId) { - strcat(buf,"_node"); - sprintf(buf+strlen(buf),"%d",cr->nodeid); - } - strcat(buf,"."); - - /* Add extension again */ - strcat(buf,(ftp == efTPX) ? "tpr" : (ftp == efEDR) ? "edr" : ftp2ext(ftp)); - if (debug) - { - fprintf(debug, "node %d par_fn '%s'\n",cr->nodeid,buf); - if (fn2ftp(buf) == efLOG) - { - fprintf(debug,"log\n"); - } - } + int n; + + if ((size_t)bufsize < (strlen(base)+10)) + { + gmx_mem("Character buffer too small!"); + } + + /* Copy to buf, and strip extension */ + strcpy(buf, base); + buf[strlen(base) - strlen(ftp2ext(fn2ftp(base))) - 1] = '\0'; + + if (bAppendSimId) + { + sprintf(buf+strlen(buf), "%d", cr->ms->sim); + } + if (bAppendNodeId) + { + strcat(buf, "_node"); + sprintf(buf+strlen(buf), "%d", cr->nodeid); + } + strcat(buf, "."); + + /* Add extension again */ + strcat(buf, (ftp == efTPX) ? "tpr" : (ftp == efEDR) ? "edr" : ftp2ext(ftp)); + if (debug) + { + fprintf(debug, "node %d par_fn '%s'\n", cr->nodeid, buf); + if (fn2ftp(buf) == efLOG) + { + fprintf(debug, "log\n"); + } + } } -void check_multi_int(FILE *log,const gmx_multisim_t *ms,int val, +void check_multi_int(FILE *log, const gmx_multisim_t *ms, int val, const char *name, gmx_bool bQuiet) { - int *ibuf,p; - gmx_bool bCompatible; - - if (NULL != log && !bQuiet) - fprintf(log,"Multi-checking %s ... ",name); - - if (ms == NULL) - gmx_fatal(FARGS, - "check_multi_int called with a NULL communication pointer"); - - snew(ibuf,ms->nsim); - ibuf[ms->sim] = val; - gmx_sumi_sim(ms->nsim,ibuf,ms); - - bCompatible = TRUE; - for(p=1; pnsim; p++) - bCompatible = bCompatible && (ibuf[p-1] == ibuf[p]); - - if (bCompatible) - { - if (NULL != log && !bQuiet) - fprintf(log,"OK\n"); - } - else - { - if (NULL != log) - { - fprintf(log,"\n%s is not equal for all subsystems\n",name); - for(p=0; pnsim; p++) - fprintf(log," subsystem %d: %d\n",p,ibuf[p]); - } - gmx_fatal(FARGS,"The %d subsystems are not compatible\n",ms->nsim); - } - - sfree(ibuf); + int *ibuf, p; + gmx_bool bCompatible; + + if (NULL != log && !bQuiet) + { + fprintf(log, "Multi-checking %s ... ", name); + } + + if (ms == NULL) + { + gmx_fatal(FARGS, + "check_multi_int called with a NULL communication pointer"); + } + + snew(ibuf, ms->nsim); + ibuf[ms->sim] = val; + gmx_sumi_sim(ms->nsim, ibuf, ms); + + bCompatible = TRUE; + for (p = 1; p < ms->nsim; p++) + { + bCompatible = bCompatible && (ibuf[p-1] == ibuf[p]); + } + + if (bCompatible) + { + if (NULL != log && !bQuiet) + { + fprintf(log, "OK\n"); + } + } + else + { + if (NULL != log) + { + fprintf(log, "\n%s is not equal for all subsystems\n", name); + for (p = 0; p < ms->nsim; p++) + { + fprintf(log, " subsystem %d: %d\n", p, ibuf[p]); + } + } + gmx_fatal(FARGS, "The %d subsystems are not compatible\n", ms->nsim); + } + + sfree(ibuf); } -void check_multi_large_int(FILE *log,const gmx_multisim_t *ms, +void check_multi_large_int(FILE *log, const gmx_multisim_t *ms, gmx_large_int_t val, const char *name, gmx_bool bQuiet) { - gmx_large_int_t *ibuf; - int p; - gmx_bool bCompatible; - - if (NULL != log && !bQuiet) - fprintf(log,"Multi-checking %s ... ",name); - - if (ms == NULL) - gmx_fatal(FARGS, - "check_multi_int called with a NULL communication pointer"); - - snew(ibuf,ms->nsim); - ibuf[ms->sim] = val; - gmx_sumli_sim(ms->nsim,ibuf,ms); - - bCompatible = TRUE; - for(p=1; pnsim; p++) - bCompatible = bCompatible && (ibuf[p-1] == ibuf[p]); - - if (bCompatible) - { - if (NULL != log && !bQuiet) - fprintf(log,"OK\n"); - } - else - { - if (NULL != log) - { - fprintf(log,"\n%s is not equal for all subsystems\n",name); - for(p=0; pnsim; p++) - { - char strbuf[255]; - /* first make the format string */ - snprintf(strbuf, 255, " subsystem %%d: %s\n", - gmx_large_int_pfmt); - fprintf(log,strbuf,p,ibuf[p]); - } - } - gmx_fatal(FARGS,"The %d subsystems are not compatible\n",ms->nsim); - } - - sfree(ibuf); + gmx_large_int_t *ibuf; + int p; + gmx_bool bCompatible; + + if (NULL != log && !bQuiet) + { + fprintf(log, "Multi-checking %s ... ", name); + } + + if (ms == NULL) + { + gmx_fatal(FARGS, + "check_multi_int called with a NULL communication pointer"); + } + + snew(ibuf, ms->nsim); + ibuf[ms->sim] = val; + gmx_sumli_sim(ms->nsim, ibuf, ms); + + bCompatible = TRUE; + for (p = 1; p < ms->nsim; p++) + { + bCompatible = bCompatible && (ibuf[p-1] == ibuf[p]); + } + + if (bCompatible) + { + if (NULL != log && !bQuiet) + { + fprintf(log, "OK\n"); + } + } + else + { + if (NULL != log) + { + fprintf(log, "\n%s is not equal for all subsystems\n", name); + for (p = 0; p < ms->nsim; p++) + { + char strbuf[255]; + /* first make the format string */ + snprintf(strbuf, 255, " subsystem %%d: %s\n", + gmx_large_int_pfmt); + fprintf(log, strbuf, p, ibuf[p]); + } + } + gmx_fatal(FARGS, "The %d subsystems are not compatible\n", ms->nsim); + } + + sfree(ibuf); } @@ -217,28 +239,28 @@ char *gmx_gethostname(char *name, size_t len) #ifdef HAVE_UNISTD_H if (gethostname(name, len-1) != 0) { - strncpy(name, "unknown",8); + strncpy(name, "unknown", 8); } #else - strncpy(name, "unknown",8); + strncpy(name, "unknown", 8); #endif return name; } -void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly, +void gmx_log_open(const char *lognm, const t_commrec *cr, gmx_bool bMasterOnly, gmx_bool bAppendFiles, FILE** fplog) { - int len,testlen,pid; - char buf[256],host[256]; + int len, testlen, pid; + char buf[256], host[256]; time_t t; - char timebuf[STRLEN]; - FILE *fp=*fplog; - char *tmpnm; - + char timebuf[STRLEN]; + FILE *fp = *fplog; + char *tmpnm; + debug_gmx(); - + /* Communicate the filename for logfile */ if (cr->nnodes > 1 && !bMasterOnly #ifdef GMX_THREAD_MPI @@ -253,28 +275,28 @@ void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly, { len = strlen(lognm) + 1; } - gmx_bcast(sizeof(len),&len,cr); + gmx_bcast(sizeof(len), &len, cr); if (!MASTER(cr)) { - snew(tmpnm,len+8); + snew(tmpnm, len+8); } else { - tmpnm=gmx_strdup(lognm); + tmpnm = gmx_strdup(lognm); } - gmx_bcast(len*sizeof(*tmpnm),tmpnm,cr); + gmx_bcast(len*sizeof(*tmpnm), tmpnm, cr); } else { - tmpnm=gmx_strdup(lognm); + tmpnm = gmx_strdup(lognm); } - + debug_gmx(); if (!bMasterOnly && !MASTER(cr)) { /* Since log always ends with '.log' let's use this info */ - par_fn(tmpnm,efLOG,cr,FALSE,!bMasterOnly,buf,255); + par_fn(tmpnm, efLOG, cr, FALSE, !bMasterOnly, buf, 255); fp = gmx_fio_fopen(buf, bAppendFiles ? "a+" : "w+" ); } else if (!bAppendFiles) @@ -285,9 +307,9 @@ void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly, sfree(tmpnm); gmx_fatal_set_log_file(fp); - + /* Get some machine parameters */ - gmx_gethostname(host,256); + gmx_gethostname(host, 256); time(&t); @@ -298,7 +320,7 @@ void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly, pid = getpid(); # endif #else - pid = 0; + pid = 0; #endif if (bAppendFiles) @@ -309,15 +331,15 @@ void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly, "-----------------------------------------------------------\n" "Restarting from checkpoint, appending to previous log file.\n" "\n" - ); + ); } - - gmx_ctime_r(&t,timebuf,STRLEN); + + gmx_ctime_r(&t, timebuf, STRLEN); fprintf(fp, "Log file opened on %s" "Host: %s pid: %d nodeid: %d nnodes: %d\n", - timebuf,host,pid,cr->nodeid,cr->nnodes); + timebuf, host, pid, cr->nodeid, cr->nnodes); gmx_print_version_info(fp); fprintf(fp, "\n\n"); @@ -329,119 +351,129 @@ void gmx_log_open(const char *lognm,const t_commrec *cr,gmx_bool bMasterOnly, void gmx_log_close(FILE *fp) { - if (fp) { - gmx_fatal_set_log_file(NULL); - gmx_fio_fclose(fp); - } + if (fp) + { + gmx_fatal_set_log_file(NULL); + gmx_fio_fclose(fp); + } } -static void comm_args(const t_commrec *cr,int *argc,char ***argv) +static void comm_args(const t_commrec *cr, int *argc, char ***argv) { - int i,len; - - if (PAR(cr)) - gmx_bcast(sizeof(*argc),argc,cr); - - if (!MASTER(cr)) - snew(*argv,*argc+1); - if (debug) - { - fprintf(debug,"NODEID=%d argc=%d\n",cr->nodeid,*argc); - } - for(i=0; (i<*argc); i++) { - if (MASTER(cr)) - len = strlen((*argv)[i])+1; - gmx_bcast(sizeof(len),&len,cr); + int i, len; + + if (PAR(cr)) + { + gmx_bcast(sizeof(*argc), argc, cr); + } + if (!MASTER(cr)) - snew((*argv)[i],len); - /*gmx_bcast(len*sizeof((*argv)[i][0]),(*argv)[i],cr);*/ - gmx_bcast(len*sizeof(char),(*argv)[i],cr); - } - debug_gmx(); + { + snew(*argv, *argc+1); + } + if (debug) + { + fprintf(debug, "NODEID=%d argc=%d\n", cr->nodeid, *argc); + } + for (i = 0; (i < *argc); i++) + { + if (MASTER(cr)) + { + len = strlen((*argv)[i])+1; + } + gmx_bcast(sizeof(len), &len, cr); + if (!MASTER(cr)) + { + snew((*argv)[i], len); + } + /*gmx_bcast(len*sizeof((*argv)[i][0]),(*argv)[i],cr);*/ + gmx_bcast(len*sizeof(char), (*argv)[i], cr); + } + debug_gmx(); } -void init_multisystem(t_commrec *cr,int nsim, char **multidirs, - int nfile, const t_filenm fnm[],gmx_bool bParFn) +void init_multisystem(t_commrec *cr, int nsim, char **multidirs, + int nfile, const t_filenm fnm[], gmx_bool bParFn) { gmx_multisim_t *ms; - int nnodes,nnodpersim,sim,i,ftp; - char buf[256]; + int nnodes, nnodpersim, sim, i, ftp; + char buf[256]; #ifdef GMX_MPI - MPI_Group mpi_group_world; -#endif - int *rank; + MPI_Group mpi_group_world; +#endif + int *rank; #ifndef GMX_MPI if (nsim > 1) { - gmx_fatal(FARGS,"This binary is compiled without MPI support, can not do multiple simulations."); + gmx_fatal(FARGS, "This binary is compiled without MPI support, can not do multiple simulations."); } #endif nnodes = cr->nnodes; if (nnodes % nsim != 0) { - gmx_fatal(FARGS,"The number of nodes (%d) is not a multiple of the number of simulations (%d)",nnodes,nsim); + gmx_fatal(FARGS, "The number of nodes (%d) is not a multiple of the number of simulations (%d)", nnodes, nsim); } nnodpersim = nnodes/nsim; - sim = cr->nodeid/nnodpersim; + sim = cr->nodeid/nnodpersim; if (debug) { - fprintf(debug,"We have %d simulations, %d nodes per simulation, local simulation is %d\n",nsim,nnodpersim,sim); + fprintf(debug, "We have %d simulations, %d nodes per simulation, local simulation is %d\n", nsim, nnodpersim, sim); } - snew(ms,1); - cr->ms = ms; + snew(ms, 1); + cr->ms = ms; ms->nsim = nsim; ms->sim = sim; #ifdef GMX_MPI /* Create a communicator for the master nodes */ - snew(rank,ms->nsim); - for(i=0; insim; i++) + snew(rank, ms->nsim); + for (i = 0; i < ms->nsim; i++) { rank[i] = i*nnodpersim; } - MPI_Comm_group(MPI_COMM_WORLD,&mpi_group_world); - MPI_Group_incl(mpi_group_world,nsim,rank,&ms->mpi_group_masters); + MPI_Comm_group(MPI_COMM_WORLD, &mpi_group_world); + MPI_Group_incl(mpi_group_world, nsim, rank, &ms->mpi_group_masters); sfree(rank); - MPI_Comm_create(MPI_COMM_WORLD,ms->mpi_group_masters, + MPI_Comm_create(MPI_COMM_WORLD, ms->mpi_group_masters, &ms->mpi_comm_masters); #if !defined(GMX_THREAD_MPI) && !defined(MPI_IN_PLACE_EXISTS) /* initialize the MPI_IN_PLACE replacement buffers */ snew(ms->mpb, 1); - ms->mpb->ibuf=NULL; - ms->mpb->libuf=NULL; - ms->mpb->fbuf=NULL; - ms->mpb->dbuf=NULL; - ms->mpb->ibuf_alloc=0; - ms->mpb->libuf_alloc=0; - ms->mpb->fbuf_alloc=0; - ms->mpb->dbuf_alloc=0; + ms->mpb->ibuf = NULL; + ms->mpb->libuf = NULL; + ms->mpb->fbuf = NULL; + ms->mpb->dbuf = NULL; + ms->mpb->ibuf_alloc = 0; + ms->mpb->libuf_alloc = 0; + ms->mpb->fbuf_alloc = 0; + ms->mpb->dbuf_alloc = 0; #endif #endif /* Reduce the intra-simulation communication */ cr->sim_nodeid = cr->nodeid % nnodpersim; - cr->nnodes = nnodpersim; + cr->nnodes = nnodpersim; #ifdef GMX_MPI - MPI_Comm_split(MPI_COMM_WORLD,sim,cr->sim_nodeid,&cr->mpi_comm_mysim); + MPI_Comm_split(MPI_COMM_WORLD, sim, cr->sim_nodeid, &cr->mpi_comm_mysim); cr->mpi_comm_mygroup = cr->mpi_comm_mysim; - cr->nodeid = cr->sim_nodeid; + cr->nodeid = cr->sim_nodeid; #endif if (debug) { - fprintf(debug,"This is simulation %d",cr->ms->sim); + fprintf(debug, "This is simulation %d", cr->ms->sim); if (PAR(cr)) { - fprintf(debug,", local number of nodes %d, local nodeid %d", - cr->nnodes,cr->sim_nodeid); + fprintf(debug, ", local number of nodes %d, local nodeid %d", + cr->nnodes, cr->sim_nodeid); } - fprintf(debug,"\n\n"); + fprintf(debug, "\n\n"); } if (multidirs) @@ -449,24 +481,24 @@ void init_multisystem(t_commrec *cr,int nsim, char **multidirs, int ret; if (debug) { - fprintf(debug,"Changing to directory %s\n",multidirs[cr->ms->sim]); + fprintf(debug, "Changing to directory %s\n", multidirs[cr->ms->sim]); } gmx_chdir(multidirs[cr->ms->sim]); } else if (bParFn) { /* Patch output and tpx, cpt and rerun input file names */ - for(i=0; (isim_nodeid = gmx_setup(argc,argv,&cr->nnodes); + cr->sim_nodeid = gmx_setup(argc, argv, &cr->nnodes); if (!PAR(cr) && (cr->sim_nodeid != 0)) { @@ -511,22 +543,22 @@ t_commrec *init_par(int *argc,char ***argv_ptr) #ifndef GMX_THREAD_MPI if (PAR(cr)) { - comm_args(cr,argc,argv_ptr); + comm_args(cr, argc, argv_ptr); } #endif /* GMX_THREAD_MPI */ #ifdef GMX_MPI #if !defined(GMX_THREAD_MPI) && !defined(MPI_IN_PLACE_EXISTS) - /* initialize the MPI_IN_PLACE replacement buffers */ - snew(cr->mpb, 1); - cr->mpb->ibuf=NULL; - cr->mpb->libuf=NULL; - cr->mpb->fbuf=NULL; - cr->mpb->dbuf=NULL; - cr->mpb->ibuf_alloc=0; - cr->mpb->libuf_alloc=0; - cr->mpb->fbuf_alloc=0; - cr->mpb->dbuf_alloc=0; + /* initialize the MPI_IN_PLACE replacement buffers */ + snew(cr->mpb, 1); + cr->mpb->ibuf = NULL; + cr->mpb->libuf = NULL; + cr->mpb->fbuf = NULL; + cr->mpb->dbuf = NULL; + cr->mpb->ibuf_alloc = 0; + cr->mpb->libuf_alloc = 0; + cr->mpb->fbuf_alloc = 0; + cr->mpb->dbuf_alloc = 0; #endif #endif @@ -536,14 +568,14 @@ t_commrec *init_par(int *argc,char ***argv_ptr) t_commrec *init_par_threads(const t_commrec *cro) { #ifdef GMX_THREAD_MPI - int initialized; + int initialized; t_commrec *cr; /* make a thread-specific commrec */ - snew(cr,1); + snew(cr, 1); /* now copy the whole thing, so settings like the number of PME nodes get propagated. */ - *cr=*cro; + *cr = *cro; /* and we start setting our own thread-specific values for things */ MPI_Initialized(&initialized); @@ -553,12 +585,12 @@ t_commrec *init_par_threads(const t_commrec *cro) } /* once threads will be used together with MPI, we'll fill the cr structure with distinct data here. This might even work: */ - cr->sim_nodeid = gmx_setup(0,NULL, &cr->nnodes); + cr->sim_nodeid = gmx_setup(0, NULL, &cr->nnodes); - cr->mpi_comm_mysim = MPI_COMM_WORLD; + cr->mpi_comm_mysim = MPI_COMM_WORLD; cr->mpi_comm_mygroup = cr->mpi_comm_mysim; - cr->nodeid = cr->sim_nodeid; - cr->duty = (DUTY_PP | DUTY_PME); + cr->nodeid = cr->sim_nodeid; + cr->duty = (DUTY_PP | DUTY_PME); return cr; #else diff --git a/src/gromacs/gmxlib/maths.c b/src/gromacs/gmxlib/maths.c index 593cd4901a..46b34640a0 100644 --- a/src/gromacs/gmxlib/maths.c +++ b/src/gromacs/gmxlib/maths.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -45,32 +45,36 @@ #endif int gmx_nint(real a) -{ - const real half = .5; - int result; - - result = (a < 0.) ? ((int)(a - half)) : ((int)(a + half)); - return result; +{ + const real half = .5; + int result; + + result = (a < 0.) ? ((int)(a - half)) : ((int)(a + half)); + return result; } -real cuberoot (real x) +real cuberoot (real x) { - if (x < 0) - { - return (-pow(-x,1.0/DIM)); - } - else + if (x < 0) { - return (pow(x,1.0/DIM)); + return (-pow(-x, 1.0/DIM)); + } + else + { + return (pow(x, 1.0/DIM)); } } -real sign(real x,real y) +real sign(real x, real y) { - if (y < 0) - return -fabs(x); - else - return +fabs(x); + if (y < 0) + { + return -fabs(x); + } + else + { + return +fabs(x); + } } /* Double and single precision erf() and erfc() from @@ -84,279 +88,306 @@ real sign(real x,real y) * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice + * software is freely granted, provided that this notice * is preserved. * ==================================================== */ -#if ( (defined SIZEOF_INT && SIZEOF_INT==4) || (SIZEOF_INT_MAX == 2147483647) ) - typedef int erf_int32_t; - typedef unsigned int erf_u_int32_t; +#if ( (defined SIZEOF_INT && SIZEOF_INT == 4) || (SIZEOF_INT_MAX == 2147483647) ) +typedef int erf_int32_t; +typedef unsigned int erf_u_int32_t; #elif (LONG_MAX == 2147483647L) - typedef long erf_int32_t; - typedef unsigned long erf_u_int32_t; +typedef long erf_int32_t; +typedef unsigned long erf_u_int32_t; #elif (SHRT_MAX == 2147483647) - typedef short erf_int32_t; - typedef unsigned short erf_u_int32_t; +typedef short erf_int32_t; +typedef unsigned short erf_u_int32_t; #else # error ERROR: No 32 bit wide integer type found! #endif static const double -tiny = 1e-300, -half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ -two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */ + tiny = 1e-300, + half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ + one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ + two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */ /* c = (float)0.84506291151 */ -erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */ + erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */ /* * Coefficients for approximation to erf on [0,0.84375] */ -efx = 1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */ -efx8= 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */ -pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */ -pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */ -pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */ -pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */ -pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */ -qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */ -qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */ -qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */ -qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */ -qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */ + efx = 1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */ + efx8 = 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */ + pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */ + pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */ + pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */ + pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */ + pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */ + qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */ + qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */ + qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */ + qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */ + qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */ /* - * Coefficients for approximation to erf in [0.84375,1.25] + * Coefficients for approximation to erf in [0.84375,1.25] */ -pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */ -pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */ -pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */ -pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */ -pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */ -pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */ -pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */ -qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */ -qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */ -qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */ -qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */ -qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */ -qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */ + pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */ + pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */ + pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */ + pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */ + pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */ + pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */ + pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */ + qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */ + qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */ + qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */ + qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */ + qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */ + qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */ /* * Coefficients for approximation to erfc in [1.25,1/0.35] */ -ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */ -ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */ -ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */ -ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */ -ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */ -ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */ -ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */ -ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */ -sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */ -sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */ -sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */ -sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */ -sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */ -sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */ -sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */ -sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */ + ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */ + ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */ + ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */ + ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */ + ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */ + ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */ + ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */ + ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */ + sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */ + sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */ + sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */ + sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */ + sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */ + sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */ + sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */ + sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */ /* * Coefficients for approximation to erfc in [1/.35,28] */ -rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */ -rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */ -rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */ -rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */ -rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */ -rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */ -rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */ -sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */ -sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */ -sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */ -sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */ -sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */ -sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */ -sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */ + rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */ + rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */ + rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */ + rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */ + rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */ + rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */ + rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */ + sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */ + sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */ + sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */ + sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */ + sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */ + sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */ + sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */ double gmx_erfd(double x) { - - erf_int32_t hx,ix,i; - double R,S,P,Q,s,y,z,r; - + + erf_int32_t hx, ix, i; + double R, S, P, Q, s, y, z, r; + union { double d; int i[2]; - } + } conv; - - conv.d=x; - - /* In release-4-6 and later branches, only the test for - * GMX_IEEE754_BIG_ENDIAN_WORD_ORDER will be required. */ + + conv.d = x; + + /* In release-4-6 and later branches, only the test for + * GMX_IEEE754_BIG_ENDIAN_WORD_ORDER will be required. */ #if defined(IEEE754_BIG_ENDIAN_WORD_ORDER) || defined(GMX_IEEE754_BIG_ENDIAN_WORD_ORDER) - hx=conv.i[0]; + hx = conv.i[0]; #else - hx=conv.i[1]; + hx = conv.i[1]; #endif - - ix = hx&0x7fffffff; - if(ix>=0x7ff00000) + + ix = hx&0x7fffffff; + if (ix >= 0x7ff00000) { - /* erf(nan)=nan */ - i = ((erf_u_int32_t)hx>>31)<<1; - return (double)(1-i)+one/x; /* erf(+-inf)=+-1 */ - } + /* erf(nan)=nan */ + i = ((erf_u_int32_t)hx>>31)<<1; + return (double)(1-i)+one/x; /* erf(+-inf)=+-1 */ + } - if(ix < 0x3feb0000) + if (ix < 0x3feb0000) { - /* |x|<0.84375 */ - if(ix < 0x3e300000) - { + /* |x|<0.84375 */ + if (ix < 0x3e300000) + { /* |x|<2**-28 */ - if (ix < 0x00800000) + if (ix < 0x00800000) + { return 0.125*(8.0*x+efx8*x); /*avoid underflow */ + } return x + efx*x; - } - z = x*x; - r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); - s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); - y = r/s; - return x + x*y; - } - if(ix < 0x3ff40000) - { - /* 0.84375 <= |x| < 1.25 */ - s = fabs(x)-one; - P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); - Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - if(hx>=0) return erx + P/Q; else return -erx - P/Q; - } - if (ix >= 0x40180000) - { + } + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + return x + x*y; + } + if (ix < 0x3ff40000) + { + /* 0.84375 <= |x| < 1.25 */ + s = fabs(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if (hx >= 0) + { + return erx + P/Q; + } + else + { + return -erx - P/Q; + } + } + if (ix >= 0x40180000) + { /* inf>|x|>=6 */ - if(hx>=0) return one-tiny; else return tiny-one; - } - x = fabs(x); - s = one/(x*x); - if(ix< 0x4006DB6E) + if (hx >= 0) + { + return one-tiny; + } + else + { + return tiny-one; + } + } + x = fabs(x); + s = one/(x*x); + if (ix < 0x4006DB6E) { /* |x| < 1/0.35 */ - R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(ra5+s*(ra6+s*ra7)))))); - S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(sa5+s*(sa6+s*(sa7+s*sa8))))))); - } - else + R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(ra5+s*(ra6+s*ra7)))))); + S = one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(sa5+s*(sa6+s*(sa7+s*sa8))))))); + } + else { /* |x| >= 1/0.35 */ - R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6))))); - S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7)))))); - } + R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6))))); + S = one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7)))))); + } conv.d = x; - /* In release-4-6 and later branches, only the test for - * GMX_IEEE754_BIG_ENDIAN_WORD_ORDER will be required. */ + /* In release-4-6 and later branches, only the test for + * GMX_IEEE754_BIG_ENDIAN_WORD_ORDER will be required. */ #if defined(IEEE754_BIG_ENDIAN_WORD_ORDER) || defined(GMX_IEEE754_BIG_ENDIAN_WORD_ORDER) conv.i[1] = 0; #else conv.i[0] = 0; #endif - + z = conv.d; - r = exp(-z*z-0.5625)*exp((z-x)*(z+x)+R/S); - if(hx>=0) - return one-r/x; - else - return r/x-one; + r = exp(-z*z-0.5625)*exp((z-x)*(z+x)+R/S); + if (hx >= 0) + { + return one-r/x; + } + else + { + return r/x-one; + } } double gmx_erfcd(double x) { - erf_int32_t hx,ix; - double R,S,P,Q,s,y,z,r; - + erf_int32_t hx, ix; + double R, S, P, Q, s, y, z, r; + union { double d; int i[2]; - } + } conv; - + conv.d = x; - - /* In release-4-6 and later branches, only the test for - * GMX_IEEE754_BIG_ENDIAN_WORD_ORDER will be required. */ + + /* In release-4-6 and later branches, only the test for + * GMX_IEEE754_BIG_ENDIAN_WORD_ORDER will be required. */ #if defined(IEEE754_BIG_ENDIAN_WORD_ORDER) || defined(GMX_IEEE754_BIG_ENDIAN_WORD_ORDER) - hx=conv.i[0]; + hx = conv.i[0]; #else - hx=conv.i[1]; + hx = conv.i[1]; #endif - - ix = hx&0x7fffffff; - if(ix>=0x7ff00000) - { + + ix = hx&0x7fffffff; + if (ix >= 0x7ff00000) + { /* erfc(nan)=nan */ /* erfc(+-inf)=0,2 */ - return (double)(((erf_u_int32_t)hx>>31)<<1)+one/x; - } + return (double)(((erf_u_int32_t)hx>>31)<<1)+one/x; + } - if(ix < 0x3feb0000) + if (ix < 0x3feb0000) { - /* |x|<0.84375 */ - double r1,r2,s1,s2,s3,z2,z4; - if(ix < 0x3c700000) /* |x|<2**-56 */ + /* |x|<0.84375 */ + double r1, r2, s1, s2, s3, z2, z4; + if (ix < 0x3c700000) /* |x|<2**-56 */ + { return one-x; - z = x*x; - r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); - s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); - y = r/s; - if(hx < 0x3fd00000) + } + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + if (hx < 0x3fd00000) { /* x<1/4 */ return one-(x+x*y); - } + } else { - r = x*y; + r = x*y; r += (x-half); - return half - r ; - } - } - - if(ix < 0x3ff40000) + return half - r; + } + } + + if (ix < 0x3ff40000) { - /* 0.84375 <= |x| < 1.25 */ + /* 0.84375 <= |x| < 1.25 */ s = fabs(x)-one; P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); - if(hx>=0) { - z = one-erx; return z - P/Q; - } else { + if (hx >= 0) + { + z = one-erx; return z - P/Q; + } + else + { z = erx+P/Q; return one+z; } - } - if (ix < 0x403c0000) - { + } + if (ix < 0x403c0000) + { /* |x|<28 */ - x = fabs(x); - s = one/(x*x); - if(ix< 0x4006DB6D) + x = fabs(x); + s = one/(x*x); + if (ix < 0x4006DB6D) { /* |x| < 1/.35 ~ 2.857143*/ - R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(ra5+s*(ra6+s*ra7)))))); - S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(sa5+s*(sa6+s*(sa7+s*sa8))))))); - } + R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(ra5+s*(ra6+s*ra7)))))); + S = one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else - { + { /* |x| >= 1/.35 ~ 2.857143 */ - if(hx<0&&ix>=0x40180000) + if (hx < 0 && ix >= 0x40180000) + { return two-tiny; /* x < -6 */ - R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6))))); - S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7)))))); - } + } + R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(rb5+s*rb6))))); + S = one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(sb5+s*(sb6+s*sb7)))))); + } conv.d = x; @@ -367,279 +398,338 @@ double gmx_erfcd(double x) #else conv.i[0] = 0; #endif - + z = conv.d; - + r = exp(-z*z-0.5625)*exp((z-x)*(z+x)+R/S); - if(hx>0) + if (hx > 0) + { return r/x; - else + } + else + { return two-r/x; + } } else { - if(hx>0) + if (hx > 0) + { return tiny*tiny; + } else + { return two-tiny; - } + } + } } static const float -tinyf= 1e-30, -halff= 5.0000000000e-01, /* 0x3F000000 */ -onef = 1.0000000000e+00, /* 0x3F800000 */ -twof = 2.0000000000e+00, /* 0x40000000 */ - /* c = (subfloat)0.84506291151 */ -erxf = 8.4506291151e-01, /* 0x3f58560b */ + tinyf = 1e-30, + halff = 5.0000000000e-01, /* 0x3F000000 */ + onef = 1.0000000000e+00, /* 0x3F800000 */ + twof = 2.0000000000e+00, /* 0x40000000 */ +/* c = (subfloat)0.84506291151 */ + erxf = 8.4506291151e-01, /* 0x3f58560b */ /* * Coefficients for approximation to erf on [0,0.84375] */ -efxf = 1.2837916613e-01, /* 0x3e0375d4 */ -efx8f= 1.0270333290e+00, /* 0x3f8375d4 */ -pp0f = 1.2837916613e-01, /* 0x3e0375d4 */ -pp1f = -3.2504209876e-01, /* 0xbea66beb */ -pp2f = -2.8481749818e-02, /* 0xbce9528f */ -pp3f = -5.7702702470e-03, /* 0xbbbd1489 */ -pp4f = -2.3763017452e-05, /* 0xb7c756b1 */ -qq1f = 3.9791721106e-01, /* 0x3ecbbbce */ -qq2f = 6.5022252500e-02, /* 0x3d852a63 */ -qq3f = 5.0813062117e-03, /* 0x3ba68116 */ -qq4f = 1.3249473704e-04, /* 0x390aee49 */ -qq5f = -3.9602282413e-06, /* 0xb684e21a */ + efxf = 1.2837916613e-01, /* 0x3e0375d4 */ + efx8f = 1.0270333290e+00, /* 0x3f8375d4 */ + pp0f = 1.2837916613e-01, /* 0x3e0375d4 */ + pp1f = -3.2504209876e-01, /* 0xbea66beb */ + pp2f = -2.8481749818e-02, /* 0xbce9528f */ + pp3f = -5.7702702470e-03, /* 0xbbbd1489 */ + pp4f = -2.3763017452e-05, /* 0xb7c756b1 */ + qq1f = 3.9791721106e-01, /* 0x3ecbbbce */ + qq2f = 6.5022252500e-02, /* 0x3d852a63 */ + qq3f = 5.0813062117e-03, /* 0x3ba68116 */ + qq4f = 1.3249473704e-04, /* 0x390aee49 */ + qq5f = -3.9602282413e-06, /* 0xb684e21a */ /* - * Coefficients for approximation to erf in [0.84375,1.25] + * Coefficients for approximation to erf in [0.84375,1.25] */ -pa0f = -2.3621185683e-03, /* 0xbb1acdc6 */ -pa1f = 4.1485610604e-01, /* 0x3ed46805 */ -pa2f = -3.7220788002e-01, /* 0xbebe9208 */ -pa3f = 3.1834661961e-01, /* 0x3ea2fe54 */ -pa4f = -1.1089469492e-01, /* 0xbde31cc2 */ -pa5f = 3.5478305072e-02, /* 0x3d1151b3 */ -pa6f = -2.1663755178e-03, /* 0xbb0df9c0 */ -qa1f = 1.0642088205e-01, /* 0x3dd9f331 */ -qa2f = 5.4039794207e-01, /* 0x3f0a5785 */ -qa3f = 7.1828655899e-02, /* 0x3d931ae7 */ -qa4f = 1.2617121637e-01, /* 0x3e013307 */ -qa5f = 1.3637083583e-02, /* 0x3c5f6e13 */ -qa6f = 1.1984500103e-02, /* 0x3c445aa3 */ + pa0f = -2.3621185683e-03, /* 0xbb1acdc6 */ + pa1f = 4.1485610604e-01, /* 0x3ed46805 */ + pa2f = -3.7220788002e-01, /* 0xbebe9208 */ + pa3f = 3.1834661961e-01, /* 0x3ea2fe54 */ + pa4f = -1.1089469492e-01, /* 0xbde31cc2 */ + pa5f = 3.5478305072e-02, /* 0x3d1151b3 */ + pa6f = -2.1663755178e-03, /* 0xbb0df9c0 */ + qa1f = 1.0642088205e-01, /* 0x3dd9f331 */ + qa2f = 5.4039794207e-01, /* 0x3f0a5785 */ + qa3f = 7.1828655899e-02, /* 0x3d931ae7 */ + qa4f = 1.2617121637e-01, /* 0x3e013307 */ + qa5f = 1.3637083583e-02, /* 0x3c5f6e13 */ + qa6f = 1.1984500103e-02, /* 0x3c445aa3 */ /* * Coefficients for approximation to erfc in [1.25,1/0.35] */ -ra0f = -9.8649440333e-03, /* 0xbc21a093 */ -ra1f = -6.9385856390e-01, /* 0xbf31a0b7 */ -ra2f = -1.0558626175e+01, /* 0xc128f022 */ -ra3f = -6.2375331879e+01, /* 0xc2798057 */ -ra4f = -1.6239666748e+02, /* 0xc322658c */ -ra5f = -1.8460508728e+02, /* 0xc3389ae7 */ -ra6f = -8.1287437439e+01, /* 0xc2a2932b */ -ra7f = -9.8143291473e+00, /* 0xc11d077e */ -sa1f = 1.9651271820e+01, /* 0x419d35ce */ -sa2f = 1.3765776062e+02, /* 0x4309a863 */ -sa3f = 4.3456588745e+02, /* 0x43d9486f */ -sa4f = 6.4538726807e+02, /* 0x442158c9 */ -sa5f = 4.2900814819e+02, /* 0x43d6810b */ -sa6f = 1.0863500214e+02, /* 0x42d9451f */ -sa7f = 6.5702495575e+00, /* 0x40d23f7c */ -sa8f = -6.0424413532e-02, /* 0xbd777f97 */ + ra0f = -9.8649440333e-03, /* 0xbc21a093 */ + ra1f = -6.9385856390e-01, /* 0xbf31a0b7 */ + ra2f = -1.0558626175e+01, /* 0xc128f022 */ + ra3f = -6.2375331879e+01, /* 0xc2798057 */ + ra4f = -1.6239666748e+02, /* 0xc322658c */ + ra5f = -1.8460508728e+02, /* 0xc3389ae7 */ + ra6f = -8.1287437439e+01, /* 0xc2a2932b */ + ra7f = -9.8143291473e+00, /* 0xc11d077e */ + sa1f = 1.9651271820e+01, /* 0x419d35ce */ + sa2f = 1.3765776062e+02, /* 0x4309a863 */ + sa3f = 4.3456588745e+02, /* 0x43d9486f */ + sa4f = 6.4538726807e+02, /* 0x442158c9 */ + sa5f = 4.2900814819e+02, /* 0x43d6810b */ + sa6f = 1.0863500214e+02, /* 0x42d9451f */ + sa7f = 6.5702495575e+00, /* 0x40d23f7c */ + sa8f = -6.0424413532e-02, /* 0xbd777f97 */ /* * Coefficients for approximation to erfc in [1/.35,28] */ -rb0f = -9.8649431020e-03, /* 0xbc21a092 */ -rb1f = -7.9928326607e-01, /* 0xbf4c9dd4 */ -rb2f = -1.7757955551e+01, /* 0xc18e104b */ -rb3f = -1.6063638306e+02, /* 0xc320a2ea */ -rb4f = -6.3756646729e+02, /* 0xc41f6441 */ -rb5f = -1.0250950928e+03, /* 0xc480230b */ -rb6f = -4.8351919556e+02, /* 0xc3f1c275 */ -sb1f = 3.0338060379e+01, /* 0x41f2b459 */ -sb2f = 3.2579251099e+02, /* 0x43a2e571 */ -sb3f = 1.5367296143e+03, /* 0x44c01759 */ -sb4f = 3.1998581543e+03, /* 0x4547fdbb */ -sb5f = 2.5530502930e+03, /* 0x451f90ce */ -sb6f = 4.7452853394e+02, /* 0x43ed43a7 */ -sb7f = -2.2440952301e+01; /* 0xc1b38712 */ + rb0f = -9.8649431020e-03, /* 0xbc21a092 */ + rb1f = -7.9928326607e-01, /* 0xbf4c9dd4 */ + rb2f = -1.7757955551e+01, /* 0xc18e104b */ + rb3f = -1.6063638306e+02, /* 0xc320a2ea */ + rb4f = -6.3756646729e+02, /* 0xc41f6441 */ + rb5f = -1.0250950928e+03, /* 0xc480230b */ + rb6f = -4.8351919556e+02, /* 0xc3f1c275 */ + sb1f = 3.0338060379e+01, /* 0x41f2b459 */ + sb2f = 3.2579251099e+02, /* 0x43a2e571 */ + sb3f = 1.5367296143e+03, /* 0x44c01759 */ + sb4f = 3.1998581543e+03, /* 0x4547fdbb */ + sb5f = 2.5530502930e+03, /* 0x451f90ce */ + sb6f = 4.7452853394e+02, /* 0x43ed43a7 */ + sb7f = -2.2440952301e+01; /* 0xc1b38712 */ typedef union { - float value; - erf_u_int32_t word; + float value; + erf_u_int32_t word; } ieee_float_shape_type; -#define GET_FLOAT_WORD(i,d) \ -do { \ - ieee_float_shape_type gf_u; \ - gf_u.value = (d); \ - (i) = gf_u.word; \ -} while (0) +#define GET_FLOAT_WORD(i, d) \ + do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ + } while (0) -#define SET_FLOAT_WORD(d,i) \ -do { \ - ieee_float_shape_type sf_u; \ - sf_u.word = (i); \ - (d) = sf_u.value; \ -} while (0) +#define SET_FLOAT_WORD(d, i) \ + do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ + } while (0) float gmx_erff(float x) { - erf_int32_t hx,ix,i; - float R,S,P,Q,s,y,z,r; + erf_int32_t hx, ix, i; + float R, S, P, Q, s, y, z, r; union { float f; int i; - } + } conv; - - conv.f=x; - hx=conv.i; - - ix = hx&0x7fffffff; - if(ix>=0x7f800000) - { - /* erf(nan)=nan */ - i = ((erf_u_int32_t)hx>>31)<<1; - return (float)(1-i)+onef/x; /* erf(+-inf)=+-1 */ - } - - if(ix < 0x3f580000) - { - /* |x|<0.84375 */ - if(ix < 0x31800000) - { + + conv.f = x; + hx = conv.i; + + ix = hx&0x7fffffff; + if (ix >= 0x7f800000) + { + /* erf(nan)=nan */ + i = ((erf_u_int32_t)hx>>31)<<1; + return (float)(1-i)+onef/x; /* erf(+-inf)=+-1 */ + } + + if (ix < 0x3f580000) + { + /* |x|<0.84375 */ + if (ix < 0x31800000) + { /* |x|<2**-28 */ - if (ix < 0x04000000) - return (float)0.125*((float)8.0*x+efx8f*x); /*avoid underflow */ + if (ix < 0x04000000) + { + return (float)0.125*((float)8.0*x+efx8f*x); /*avoid underflow */ + } return x + efxf*x; - } + } z = x*x; r = pp0f+z*(pp1f+z*(pp2f+z*(pp3f+z*pp4f))); - s = onef+z*(qq1f+z*(qq2f+z*(qq3f+z*(qq4f+z*qq5f)))); - y = r/s; - return x + x*y; - } - if(ix < 0x3fa00000) - { + s = onef+z*(qq1f+z*(qq2f+z*(qq3f+z*(qq4f+z*qq5f)))); + y = r/s; + return x + x*y; + } + if (ix < 0x3fa00000) + { /* 0.84375 <= |x| < 1.25 */ - s = fabs(x)-onef; - P = pa0f+s*(pa1f+s*(pa2f+s*(pa3f+s*(pa4f+s*(pa5f+s*pa6f))))); - Q = onef+s*(qa1f+s*(qa2f+s*(qa3f+s*(qa4f+s*(qa5f+s*qa6f))))); - if(hx>=0) return erxf + P/Q; else return -erxf - P/Q; - } + s = fabs(x)-onef; + P = pa0f+s*(pa1f+s*(pa2f+s*(pa3f+s*(pa4f+s*(pa5f+s*pa6f))))); + Q = onef+s*(qa1f+s*(qa2f+s*(qa3f+s*(qa4f+s*(qa5f+s*qa6f))))); + if (hx >= 0) + { + return erxf + P/Q; + } + else + { + return -erxf - P/Q; + } + } if (ix >= 0x40c00000) { - /* inf>|x|>=6 */ - if(hx>=0) return onef-tinyf; else return tinyf-onef; - } - x = fabs(x); - s = onef/(x*x); - if(ix< 0x4036DB6E) + /* inf>|x|>=6 */ + if (hx >= 0) + { + return onef-tinyf; + } + else + { + return tinyf-onef; + } + } + x = fabs(x); + s = onef/(x*x); + if (ix < 0x4036DB6E) { /* |x| < 1/0.35 */ - R=ra0f+s*(ra1f+s*(ra2f+s*(ra3f+s*(ra4f+s*(ra5f+s*(ra6f+s*ra7f)))))); - S=onef+s*(sa1f+s*(sa2f+s*(sa3f+s*(sa4f+s*(sa5f+s*(sa6f+s*(sa7f+s*sa8f))))))); - } + R = ra0f+s*(ra1f+s*(ra2f+s*(ra3f+s*(ra4f+s*(ra5f+s*(ra6f+s*ra7f)))))); + S = onef+s*(sa1f+s*(sa2f+s*(sa3f+s*(sa4f+s*(sa5f+s*(sa6f+s*(sa7f+s*sa8f))))))); + } else - { + { /* |x| >= 1/0.35 */ - R=rb0f+s*(rb1f+s*(rb2f+s*(rb3f+s*(rb4f+s*(rb5f+s*rb6f))))); - S=onef+s*(sb1f+s*(sb2f+s*(sb3f+s*(sb4f+s*(sb5f+s*(sb6f+s*sb7f)))))); - } - + R = rb0f+s*(rb1f+s*(rb2f+s*(rb3f+s*(rb4f+s*(rb5f+s*rb6f))))); + S = onef+s*(sb1f+s*(sb2f+s*(sb3f+s*(sb4f+s*(sb5f+s*(sb6f+s*sb7f)))))); + } + conv.f = x; conv.i = conv.i & 0xfffff000; - z = conv.f; + z = conv.f; - r = exp(-z*z-(float)0.5625)*exp((z-x)*(z+x)+R/S); - if(hx>=0) return onef-r/x; else return r/x-onef; + r = exp(-z*z-(float)0.5625)*exp((z-x)*(z+x)+R/S); + if (hx >= 0) + { + return onef-r/x; + } + else + { + return r/x-onef; + } } float gmx_erfcf(float x) { - erf_int32_t hx,ix; - float R,S,P,Q,s,y,z,r; - + erf_int32_t hx, ix; + float R, S, P, Q, s, y, z, r; + union { float f; int i; - } + } conv; - - conv.f=x; - hx=conv.i; - - ix = hx&0x7fffffff; - if(ix>=0x7f800000) + + conv.f = x; + hx = conv.i; + + ix = hx&0x7fffffff; + if (ix >= 0x7f800000) { /* erfc(nan)=nan */ /* erfc(+-inf)=0,2 */ - return (float)(((erf_u_int32_t)hx>>31)<<1)+onef/x; - } + return (float)(((erf_u_int32_t)hx>>31)<<1)+onef/x; + } - if(ix < 0x3f580000) + if (ix < 0x3f580000) { - /* |x|<0.84375 */ - if(ix < 0x23800000) - return onef-x; /* |x|<2**-56 */ - z = x*x; - r = pp0f+z*(pp1f+z*(pp2f+z*(pp3f+z*pp4f))); - s = onef+z*(qq1f+z*(qq2f+z*(qq3f+z*(qq4f+z*qq5f)))); - y = r/s; - if(hx < 0x3e800000) + /* |x|<0.84375 */ + if (ix < 0x23800000) + { + return onef-x; /* |x|<2**-56 */ + } + z = x*x; + r = pp0f+z*(pp1f+z*(pp2f+z*(pp3f+z*pp4f))); + s = onef+z*(qq1f+z*(qq2f+z*(qq3f+z*(qq4f+z*qq5f)))); + y = r/s; + if (hx < 0x3e800000) { /* x<1/4 */ return onef-(x+x*y); - } else { - r = x*y; + } + else + { + r = x*y; r += (x-halff); - return halff - r ; - } - } - if(ix < 0x3fa00000) - { + return halff - r; + } + } + if (ix < 0x3fa00000) + { /* 0.84375 <= |x| < 1.25 */ - s = fabs(x)-onef; - P = pa0f+s*(pa1f+s*(pa2f+s*(pa3f+s*(pa4f+s*(pa5f+s*pa6f))))); - Q = onef+s*(qa1f+s*(qa2f+s*(qa3f+s*(qa4f+s*(qa5f+s*qa6f))))); - if(hx>=0) { - z = onef-erxf; return z - P/Q; - } else { + s = fabs(x)-onef; + P = pa0f+s*(pa1f+s*(pa2f+s*(pa3f+s*(pa4f+s*(pa5f+s*pa6f))))); + Q = onef+s*(qa1f+s*(qa2f+s*(qa3f+s*(qa4f+s*(qa5f+s*qa6f))))); + if (hx >= 0) + { + z = onef-erxf; return z - P/Q; + } + else + { z = erxf+P/Q; return onef+z; - } - } - if (ix < 0x41e00000) + } + } + if (ix < 0x41e00000) { - /* |x|<28 */ + /* |x|<28 */ x = fabs(x); - s = onef/(x*x); - if(ix< 0x4036DB6D) + s = onef/(x*x); + if (ix < 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/ - R=ra0f+s*(ra1f+s*(ra2f+s*(ra3f+s*(ra4f+s*(ra5f+s*(ra6f+s*ra7f)))))); - S=onef+s*(sa1f+s*(sa2f+s*(sa3f+s*(sa4f+s*(sa5f+s*(sa6f+s*(sa7f+s*sa8f))))))); - } else { + R = ra0f+s*(ra1f+s*(ra2f+s*(ra3f+s*(ra4f+s*(ra5f+s*(ra6f+s*ra7f)))))); + S = onef+s*(sa1f+s*(sa2f+s*(sa3f+s*(sa4f+s*(sa5f+s*(sa6f+s*(sa7f+s*sa8f))))))); + } + else + { /* |x| >= 1/.35 ~ 2.857143 */ - if(hx<0&&ix>=0x40c00000) return twof-tinyf;/* x < -6 */ - R=rb0f+s*(rb1f+s*(rb2f+s*(rb3f+s*(rb4f+s*(rb5f+s*rb6f))))); - S=onef+s*(sb1f+s*(sb2f+s*(sb3f+s*(sb4f+s*(sb5f+s*(sb6f+s*sb7f)))))); - } - + if (hx < 0 && ix >= 0x40c00000) + { + return twof-tinyf; /* x < -6 */ + } + R = rb0f+s*(rb1f+s*(rb2f+s*(rb3f+s*(rb4f+s*(rb5f+s*rb6f))))); + S = onef+s*(sb1f+s*(sb2f+s*(sb3f+s*(sb4f+s*(sb5f+s*(sb6f+s*sb7f)))))); + } + conv.f = x; conv.i = conv.i & 0xfffff000; - z = conv.f; - - r = exp(-z*z-(float)0.5625)*exp((z-x)*(z+x)+R/S); - if(hx>0) return r/x; else return twof-r/x; - } else { - if(hx>0) return tinyf*tinyf; else return twof-tinyf; - } + z = conv.f; + + r = exp(-z*z-(float)0.5625)*exp((z-x)*(z+x)+R/S); + if (hx > 0) + { + return r/x; + } + else + { + return twof-r/x; + } + } + else + { + if (hx > 0) + { + return tinyf*tinyf; + } + else + { + return twof-tinyf; + } + } } @@ -660,27 +750,27 @@ gmx_bool gmx_isfinite(real x) } gmx_bool -check_int_multiply_for_overflow(gmx_large_int_t a, - gmx_large_int_t b, +check_int_multiply_for_overflow(gmx_large_int_t a, + gmx_large_int_t b, gmx_large_int_t *result) { gmx_large_int_t sign = 1; - if((0 == a) || (0 == b)) + if ((0 == a) || (0 == b)) { *result = 0; return TRUE; } - if(a < 0) + if (a < 0) { - a = -a; + a = -a; sign = -sign; } - if(b < 0) + if (b < 0) { - b = -b; + b = -b; sign = -sign; } - if(GMX_LARGE_INT_MAX / b < a) + if (GMX_LARGE_INT_MAX / b < a) { *result = (sign > 0) ? GMX_LARGE_INT_MAX : GMX_LARGE_INT_MIN; return FALSE; diff --git a/src/gromacs/gmxlib/matio.c b/src/gromacs/gmxlib/matio.c index ebfccd4526..f13351cc2f 100644 --- a/src/gromacs/gmxlib/matio.c +++ b/src/gromacs/gmxlib/matio.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -58,897 +58,1129 @@ static const char mapper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx real **mk_matrix(int nx, int ny, gmx_bool b1D) { - int i; - real **m; - - snew(m,nx); - if (b1D) - snew(m[0], nx*ny); - - for(i=0; (i *llalloc) - { - srenew(*line,llmax+1); - *llalloc=llmax; - } - fg=fgets(*line,llmax,in); - trim(*line); + if (llmax > *llalloc) + { + srenew(*line, llmax+1); + *llalloc = llmax; + } + fg = fgets(*line, llmax, in); + trim(*line); - return fg; + return fg; } void skipstr(char *line) { - int i,c; - - ltrim(line); - c=0; - while((line[c] != ' ') && (line[c] != '\0')) - c++; - i=c; - while(line[c] != '\0') - { - line[c-i] = line[c]; - c++; - } - line[c-i] = '\0'; + int i, c; + + ltrim(line); + c = 0; + while ((line[c] != ' ') && (line[c] != '\0')) + { + c++; + } + i = c; + while (line[c] != '\0') + { + line[c-i] = line[c]; + c++; + } + line[c-i] = '\0'; } char *line2string(char **line) { - int i; - - if (*line != NULL) { - while (((*line)[0] != '\"' ) && ( (*line)[0] != '\0' )) - (*line)++; - - if ((*line)[0] != '\"') - return NULL; - (*line)++; - - i=0; - while (( (*line)[i] != '\"' ) && ( (*line)[i] != '\0' )) - i++; - - if ((*line)[i] != '\"') - *line=NULL; - else - (*line)[i] = 0; - } - - return *line; + int i; + + if (*line != NULL) + { + while (((*line)[0] != '\"' ) && ( (*line)[0] != '\0' )) + { + (*line)++; + } + + if ((*line)[0] != '\"') + { + return NULL; + } + (*line)++; + + i = 0; + while (( (*line)[i] != '\"' ) && ( (*line)[i] != '\0' )) + { + i++; + } + + if ((*line)[i] != '\"') + { + *line = NULL; + } + else + { + (*line)[i] = 0; + } + } + + return *line; } -void parsestring(char *line,const char *label, char *string) +void parsestring(char *line, const char *label, char *string) { - if (strstr(line,label)) { - if (strstr(line,label) < strchr(line,'\"')) { - line2string(&line); - strcpy(string,line); + if (strstr(line, label)) + { + if (strstr(line, label) < strchr(line, '\"')) + { + line2string(&line); + strcpy(string, line); + } } - } } -void read_xpm_entry(FILE *in,t_matrix *mm) +void read_xpm_entry(FILE *in, t_matrix *mm) { - t_mapping *map; - char *line_buf=NULL,*line=NULL,*str,buf[256]={0}; - 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,bSetLine; - t_xpmelmt c; - - mm->flags=0; - mm->title[0]=0; - mm->legend[0]=0; - mm->label_x[0]=0; - mm->label_y[0]=0; - mm->matrix=NULL; - mm->axis_x=NULL; - mm->axis_y=NULL; - mm->bDiscrete=FALSE; - - llmax = STRLEN; - - 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)); - parsestring(line,"y-label",(mm->label_y)); - parsestring(line,"type",buf); - } - - if (!line || strncmp(line,"static",6) != 0) - { - gmx_input("Invalid XPixMap"); - } - - if (buf[0] && (gmx_strcasecmp(buf,"Discrete")==0)) - mm->bDiscrete=TRUE; - - if (debug) - fprintf(debug,"%s %s %s %s\n", - mm->title,mm->legend,mm->label_x,mm->label_y); - - /* Read sizes */ - bGetOnWithIt=FALSE; - while (!bGetOnWithIt && (NULL != fgetline(&line_buf,llmax,&llalloc,in))) { - line = line_buf; - while (( line[0] != '\"' ) && ( line[0] != '\0' )) - line++; - - if ( line[0] == '\"' ) { - line2string(&line); - sscanf(line,"%d %d %d %d",&(mm->nx),&(mm->ny),&(mm->nmap),&nch); - if (nch > 2) - { - gmx_fatal(FARGS,"Sorry can only read xpm's with at most 2 caracters per pixel\n"); - } - if (mm->nx <= 0 || mm->ny <= 0 ) - { - gmx_fatal(FARGS,"Dimensions of xpm-file have to be larger than 0\n"); - } - llmax = max(STRLEN,mm->nx+10); - bGetOnWithIt=TRUE; - } - } - if (debug) - fprintf(debug,"mm->nx %d mm->ny %d mm->nmap %d nch %d\n", - mm->nx,mm->ny,mm->nmap,nch); - - /* Read color map */ - snew(map,mm->nmap); - m=0; - while ((m < mm->nmap) && (NULL != fgetline(&line_buf,llmax,&llalloc,in))) { - line = strchr(line_buf,'\"'); - if (line) { - line++; - /* Read xpm color map entry */ - map[m].code.c1 = line[0]; - if (nch==1) - map[m].code.c2 = 0; - else - map[m].code.c2 = line[1]; - line += nch; - str = strchr(line,'#'); - if (str) { - str++; - col_len = 0; - while (isxdigit(str[col_len])) - col_len++; - if (col_len==6) { - sscanf(line,"%*s #%2x%2x%2x",&r,&g,&b); - map[m].rgb.r=r/255.0; - map[m].rgb.g=g/255.0; - map[m].rgb.b=b/255.0; - } else if (col_len==12) { - sscanf(line,"%*s #%4x%4x%4x",&r,&g,&b); - map[m].rgb.r=r/65535.0; - map[m].rgb.g=g/65535.0; - map[m].rgb.b=b/65535.0; - } else - gmx_file("Unsupported or invalid colormap in X PixMap"); - } else { - str = strchr(line,'c'); - if (str) - str += 2; - else - gmx_file("Unsupported or invalid colormap in X PixMap"); - fprintf(stderr,"Using white for color \"%s",str); - map[m].rgb.r = 1; - map[m].rgb.g = 1; - map[m].rgb.b = 1; - } - line=strchr(line,'\"'); - line++; - line2string(&line); - map[m].desc = strdup(line); - m++; - } - } - if ( m != mm->nmap ) - gmx_fatal(FARGS,"Number of read colors map entries (%d) does not match the number in the header (%d)",m,mm->nmap); - mm->map = map; - - /* Read axes, if there are any */ - 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); - if (mm->axis_x==NULL) - snew(mm->axis_x,mm->nx + 1); - while (sscanf(line,"%lf",&u)==1) { - if (n_axis_x > mm->nx) { - gmx_fatal(FARGS,"Too many x-axis labels in xpm (max %d)",mm->nx); - } else if (n_axis_x == mm->nx) { - mm->flags |= MAT_SPATIAL_X; - } - mm->axis_x[n_axis_x] = u; - n_axis_x++; - skipstr(line); - } - } - else if (strstr(line,"y-axis")) { - line=strstr(line,"y-axis"); - skipstr(line); - if (mm->axis_y==NULL) - snew(mm->axis_y,mm->ny + 1); - while (sscanf(line,"%lf",&u)==1) { - if (n_axis_y > mm->ny) { - gmx_file("Too many y-axis labels in xpm"); - } else if (n_axis_y == mm->ny) { - mm->flags |= MAT_SPATIAL_Y; - } - mm->axis_y[n_axis_y] = u; - n_axis_y++; - skipstr(line); - } - } - } while ((line[0] != '\"') && (NULL != fgetline(&line_buf,llmax,&llalloc,in))); - - /* Read matrix */ - snew(mm->matrix,mm->nx); - for(i=0; inx; 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')) - line++; - if (line[0] != '\"') - gmx_fatal(FARGS,"Not enough caracters in row %d of the matrix\n",m+1); - else { - line++; - for(i=0; inx; i++) { - c.c1=line[nch*i]; - if (nch==1) - c.c2=0; - else - c.c2=line[nch*i+1]; - mm->matrix[i][m]=searchcmap(mm->nmap,mm->map,c); - } - m--; - } - } while ((m>=0) && (NULL != fgetline(&line_buf,llmax,&llalloc,in))); - if (m>=0) - gmx_incons("Not enough rows in the matrix"); - - sfree(line_buf); + t_mapping *map; + char *line_buf = NULL, *line = NULL, *str, buf[256] = {0}; + 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, bSetLine; + t_xpmelmt c; + + mm->flags = 0; + mm->title[0] = 0; + mm->legend[0] = 0; + mm->label_x[0] = 0; + mm->label_y[0] = 0; + mm->matrix = NULL; + mm->axis_x = NULL; + mm->axis_y = NULL; + mm->bDiscrete = FALSE; + + llmax = STRLEN; + + 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)); + parsestring(line, "y-label", (mm->label_y)); + parsestring(line, "type", buf); + } + + if (!line || strncmp(line, "static", 6) != 0) + { + gmx_input("Invalid XPixMap"); + } + + if (buf[0] && (gmx_strcasecmp(buf, "Discrete") == 0)) + { + mm->bDiscrete = TRUE; + } + + if (debug) + { + fprintf(debug, "%s %s %s %s\n", + mm->title, mm->legend, mm->label_x, mm->label_y); + } + + /* Read sizes */ + bGetOnWithIt = FALSE; + while (!bGetOnWithIt && (NULL != fgetline(&line_buf, llmax, &llalloc, in))) + { + line = line_buf; + while (( line[0] != '\"' ) && ( line[0] != '\0' )) + { + line++; + } + + if (line[0] == '\"') + { + line2string(&line); + sscanf(line, "%d %d %d %d", &(mm->nx), &(mm->ny), &(mm->nmap), &nch); + if (nch > 2) + { + gmx_fatal(FARGS, "Sorry can only read xpm's with at most 2 caracters per pixel\n"); + } + if (mm->nx <= 0 || mm->ny <= 0) + { + gmx_fatal(FARGS, "Dimensions of xpm-file have to be larger than 0\n"); + } + llmax = max(STRLEN, mm->nx+10); + bGetOnWithIt = TRUE; + } + } + if (debug) + { + fprintf(debug, "mm->nx %d mm->ny %d mm->nmap %d nch %d\n", + mm->nx, mm->ny, mm->nmap, nch); + } + + /* Read color map */ + snew(map, mm->nmap); + m = 0; + while ((m < mm->nmap) && (NULL != fgetline(&line_buf, llmax, &llalloc, in))) + { + line = strchr(line_buf, '\"'); + if (line) + { + line++; + /* Read xpm color map entry */ + map[m].code.c1 = line[0]; + if (nch == 1) + { + map[m].code.c2 = 0; + } + else + { + map[m].code.c2 = line[1]; + } + line += nch; + str = strchr(line, '#'); + if (str) + { + str++; + col_len = 0; + while (isxdigit(str[col_len])) + { + col_len++; + } + if (col_len == 6) + { + sscanf(line, "%*s #%2x%2x%2x", &r, &g, &b); + map[m].rgb.r = r/255.0; + map[m].rgb.g = g/255.0; + map[m].rgb.b = b/255.0; + } + else if (col_len == 12) + { + sscanf(line, "%*s #%4x%4x%4x", &r, &g, &b); + map[m].rgb.r = r/65535.0; + map[m].rgb.g = g/65535.0; + map[m].rgb.b = b/65535.0; + } + else + { + gmx_file("Unsupported or invalid colormap in X PixMap"); + } + } + else + { + str = strchr(line, 'c'); + if (str) + { + str += 2; + } + else + { + gmx_file("Unsupported or invalid colormap in X PixMap"); + } + fprintf(stderr, "Using white for color \"%s", str); + map[m].rgb.r = 1; + map[m].rgb.g = 1; + map[m].rgb.b = 1; + } + line = strchr(line, '\"'); + line++; + line2string(&line); + map[m].desc = strdup(line); + m++; + } + } + if (m != mm->nmap) + { + gmx_fatal(FARGS, "Number of read colors map entries (%d) does not match the number in the header (%d)", m, mm->nmap); + } + mm->map = map; + + /* Read axes, if there are any */ + 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); + if (mm->axis_x == NULL) + { + snew(mm->axis_x, mm->nx + 1); + } + while (sscanf(line, "%lf", &u) == 1) + { + if (n_axis_x > mm->nx) + { + gmx_fatal(FARGS, "Too many x-axis labels in xpm (max %d)", mm->nx); + } + else if (n_axis_x == mm->nx) + { + mm->flags |= MAT_SPATIAL_X; + } + mm->axis_x[n_axis_x] = u; + n_axis_x++; + skipstr(line); + } + } + else if (strstr(line, "y-axis")) + { + line = strstr(line, "y-axis"); + skipstr(line); + if (mm->axis_y == NULL) + { + snew(mm->axis_y, mm->ny + 1); + } + while (sscanf(line, "%lf", &u) == 1) + { + if (n_axis_y > mm->ny) + { + gmx_file("Too many y-axis labels in xpm"); + } + else if (n_axis_y == mm->ny) + { + mm->flags |= MAT_SPATIAL_Y; + } + mm->axis_y[n_axis_y] = u; + n_axis_y++; + skipstr(line); + } + } + } + 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')) + { + line++; + } + if (line[0] != '\"') + { + gmx_fatal(FARGS, "Not enough caracters in row %d of the matrix\n", m+1); + } + else + { + line++; + for (i = 0; i < mm->nx; i++) + { + c.c1 = line[nch*i]; + if (nch == 1) + { + c.c2 = 0; + } + else + { + c.c2 = line[nch*i+1]; + } + mm->matrix[i][m] = searchcmap(mm->nmap, mm->map, c); + } + m--; + } + } + while ((m >= 0) && (NULL != fgetline(&line_buf, llmax, &llalloc, in))); + if (m >= 0) + { + gmx_incons("Not enough rows in the matrix"); + } + + sfree(line_buf); } -int read_xpm_matrix(const char *fnm,t_matrix **matrix) +int read_xpm_matrix(const char *fnm, t_matrix **matrix) { - FILE *in; - char *line=NULL; - int nmat; - int llalloc=0; + FILE *in; + char *line = NULL; + int nmat; + int llalloc = 0; + + in = gmx_fio_fopen(fnm, "r"); - in=gmx_fio_fopen(fnm,"r"); - - nmat=0; - while (NULL != fgetline(&line,STRLEN,&llalloc,in)) { - if (strstr(line,"/* XPM */")) { - srenew(*matrix,nmat+1); - read_xpm_entry(in,&(*matrix)[nmat]); - nmat++; + nmat = 0; + while (NULL != fgetline(&line, STRLEN, &llalloc, in)) + { + if (strstr(line, "/* XPM */")) + { + srenew(*matrix, nmat+1); + read_xpm_entry(in, &(*matrix)[nmat]); + nmat++; + } } - } - gmx_fio_fclose(in); + gmx_fio_fclose(in); - if (nmat==0) - gmx_file("Invalid XPixMap"); + if (nmat == 0) + { + gmx_file("Invalid XPixMap"); + } - sfree(line); + sfree(line); - return nmat; + return nmat; } -real **matrix2real(t_matrix *matrix,real **mat) +real **matrix2real(t_matrix *matrix, real **mat) { - t_mapping *map; - double tmp; - real *rmap; - int i,j,nmap; - - nmap=matrix->nmap; - map=matrix->map; - snew(rmap,nmap); - - for(i=0; inx); - for(i=0; inx; i++) - snew(mat[i],matrix->ny); - } - for(i=0; inx; i++) - for(j=0; jny; j++) - mat[i][j]=rmap[matrix->matrix[i][j]]; - - sfree(rmap); - - fprintf(stderr,"Converted a %dx%d matrix with %d levels to reals\n", - matrix->nx,matrix->ny,nmap); - - return mat; + t_mapping *map; + double tmp; + real *rmap; + int i, j, nmap; + + nmap = matrix->nmap; + map = matrix->map; + snew(rmap, nmap); + + for (i = 0; i < nmap; i++) + { + if ((map[i].desc == NULL) || (sscanf(map[i].desc, "%lf", &tmp) != 1)) + { + fprintf(stderr, "Could not convert matrix to reals,\n" + "color map entry %d has a non-real description: \"%s\"\n", + i, map[i].desc); + sfree(rmap); + return NULL; + } + rmap[i] = tmp; + } + + if (mat == NULL) + { + snew(mat, matrix->nx); + for (i = 0; i < matrix->nx; i++) + { + snew(mat[i], matrix->ny); + } + } + for (i = 0; i < matrix->nx; i++) + { + for (j = 0; j < matrix->ny; j++) + { + mat[i][j] = rmap[matrix->matrix[i][j]]; + } + } + + sfree(rmap); + + fprintf(stderr, "Converted a %dx%d matrix with %d levels to reals\n", + matrix->nx, matrix->ny, nmap); + + return mat; } void write_xpm_header(FILE *out, - const char *title,const char *legend, - const char *label_x,const char *label_y, - gmx_bool bDiscrete) + const char *title, const char *legend, + const char *label_x, const char *label_y, + gmx_bool bDiscrete) { - fprintf(out, "/* XPM */\n"); - fprintf(out, "/* Generated by %s */\n",Program()); - fprintf(out, "/* This file can be converted to EPS by the GROMACS program xpm2ps */\n"); - fprintf(out, "/* title: \"%s\" */\n",title); - fprintf(out, "/* legend: \"%s\" */\n",legend); - fprintf(out, "/* x-label: \"%s\" */\n",label_x); - fprintf(out, "/* y-label: \"%s\" */\n",label_y); - if (bDiscrete) - fprintf(out,"/* type: \"Discrete\" */\n"); - else - fprintf(out,"/* type: \"Continuous\" */\n"); + fprintf(out, "/* XPM */\n"); + fprintf(out, "/* Generated by %s */\n", Program()); + fprintf(out, "/* This file can be converted to EPS by the GROMACS program xpm2ps */\n"); + fprintf(out, "/* title: \"%s\" */\n", title); + fprintf(out, "/* legend: \"%s\" */\n", legend); + fprintf(out, "/* x-label: \"%s\" */\n", label_x); + fprintf(out, "/* y-label: \"%s\" */\n", label_y); + if (bDiscrete) + { + fprintf(out, "/* type: \"Discrete\" */\n"); + } + else + { + fprintf(out, "/* type: \"Continuous\" */\n"); + } } -static int calc_nmid(int nlevels,real lo,real mid,real hi) +static int calc_nmid(int nlevels, real lo, real mid, real hi) { - /* Take care that we have at least 1 entry in the mid to hi range - */ - return min(max(0,((mid-lo)/(hi-lo))*(nlevels-1)),nlevels-1); + /* Take care that we have at least 1 entry in the mid to hi range + */ + return min(max(0, ((mid-lo)/(hi-lo))*(nlevels-1)), nlevels-1); } -void write_xpm_map3(FILE *out,int n_x,int n_y,int *nlevels, - real lo,real mid,real hi, - t_rgb rlo,t_rgb rmid,t_rgb rhi) +void write_xpm_map3(FILE *out, int n_x, int n_y, int *nlevels, + real lo, real mid, real hi, + t_rgb rlo, t_rgb rmid, t_rgb rhi) { - int i,nmid; - real r,g,b,clev_lo,clev_hi; - - if (*nlevels > NMAP*NMAP) { - fprintf(stderr,"Warning, too many levels (%d) in matrix, using %d only\n", - *nlevels,(int)(NMAP*NMAP)); - *nlevels=NMAP*NMAP; - } - else if (*nlevels < 2) { - fprintf(stderr,"Warning, too few levels (%d) in matrix, using 2 instead\n", - *nlevels); - *nlevels=2; - } - if (!((mid >= lo) && (mid < hi))) - gmx_fatal(FARGS,"Lo: %f, Mid: %f, Hi: %f\n",lo,mid,hi); - - fprintf(out,"static char *gromacs_xpm[] = {\n"); - fprintf(out,"\"%d %d %d %d\",\n", - n_x,n_y,*nlevels,(*nlevels <= NMAP) ? 1 : 2); - - nmid = calc_nmid(*nlevels,lo,mid,hi); - clev_lo = nmid; - clev_hi = (*nlevels - 1 - nmid); - for(i=0; (i NMAP*NMAP) + { + fprintf(stderr, "Warning, too many levels (%d) in matrix, using %d only\n", + *nlevels, (int)(NMAP*NMAP)); + *nlevels = NMAP*NMAP; + } + else if (*nlevels < 2) + { + fprintf(stderr, "Warning, too few levels (%d) in matrix, using 2 instead\n", + *nlevels); + *nlevels = 2; + } + if (!((mid >= lo) && (mid < hi))) + { + gmx_fatal(FARGS, "Lo: %f, Mid: %f, Hi: %f\n", lo, mid, hi); + } + + fprintf(out, "static char *gromacs_xpm[] = {\n"); + fprintf(out, "\"%d %d %d %d\",\n", + n_x, n_y, *nlevels, (*nlevels <= NMAP) ? 1 : 2); + + nmid = calc_nmid(*nlevels, lo, mid, hi); + clev_lo = nmid; + clev_hi = (*nlevels - 1 - nmid); + for (i = 0; (i < nmid); i++) + { + r = rlo.r+(i*(rmid.r-rlo.r)/clev_lo); + g = rlo.g+(i*(rmid.g-rlo.g)/clev_lo); + b = rlo.b+(i*(rmid.b-rlo.b)/clev_lo); + fprintf(out, "\"%c%c c #%02X%02X%02X \" /* \"%.3g\" */,\n", + mapper[i % NMAP], + (*nlevels <= NMAP) ? ' ' : mapper[i/NMAP], + (unsigned int)round(255*r), + (unsigned int)round(255*g), + (unsigned int)round(255*b), + ((nmid - i)*lo + i*mid)/clev_lo); + } + for (i = 0; (i < (*nlevels-nmid)); i++) + { + r = rmid.r+(i*(rhi.r-rmid.r)/clev_hi); + g = rmid.g+(i*(rhi.g-rmid.g)/clev_hi); + b = rmid.b+(i*(rhi.b-rmid.b)/clev_hi); + fprintf(out, "\"%c%c c #%02X%02X%02X \" /* \"%.3g\" */,\n", + mapper[(i+nmid) % NMAP], + (*nlevels <= NMAP) ? ' ' : mapper[(i+nmid)/NMAP], + (unsigned int)round(255*r), + (unsigned int)round(255*g), + (unsigned int)round(255*b), + ((*nlevels - 1 - nmid - i)*mid + i*hi)/clev_hi); + } } -static void pr_simple_cmap(FILE *out,real lo,real hi,int nlevel,t_rgb rlo, - t_rgb rhi,int i0) +static void pr_simple_cmap(FILE *out, real lo, real hi, int nlevel, t_rgb rlo, + t_rgb rhi, int i0) { - int i; - real r,g,b,fac; - - for(i=0; (i NMAP) - gmx_fatal(FARGS,"Warning, too many levels (%d) in matrix",ntot); - - fprintf(out,"static char *gromacs_xpm[] = {\n"); - fprintf(out,"\"%d %d %d %d\",\n",n_x,n_y,ntot,1); - - if (bDiscreteColor) - pr_discrete_cmap(out,nlevel_bot,0); - else - pr_simple_cmap(out,lo_bot,hi_bot,*nlevel_bot,rlo_bot,rhi_bot,0); - - pr_simple_cmap(out,lo_top,hi_top,*nlevel_top,rlo_top,rhi_top,*nlevel_bot); + int i, ntot; + real r, g, b, fac; + + ntot = *nlevel_top + *nlevel_bot; + if (ntot > NMAP) + { + gmx_fatal(FARGS, "Warning, too many levels (%d) in matrix", ntot); + } + + fprintf(out, "static char *gromacs_xpm[] = {\n"); + fprintf(out, "\"%d %d %d %d\",\n", n_x, n_y, ntot, 1); + + if (bDiscreteColor) + { + pr_discrete_cmap(out, nlevel_bot, 0); + } + else + { + pr_simple_cmap(out, lo_bot, hi_bot, *nlevel_bot, rlo_bot, rhi_bot, 0); + } + + pr_simple_cmap(out, lo_top, hi_top, *nlevel_top, rlo_top, rhi_top, *nlevel_bot); } -void write_xpm_map(FILE *out,int n_x, int n_y,int *nlevels,real lo,real hi, - t_rgb rlo,t_rgb rhi) +void write_xpm_map(FILE *out, int n_x, int n_y, int *nlevels, real lo, real hi, + t_rgb rlo, t_rgb rhi) { - int i,nlo; - real invlevel,r,g,b; - - if (*nlevels > NMAP*NMAP) { - fprintf(stderr,"Warning, too many levels (%d) in matrix, using %d only\n", - *nlevels,(int)(NMAP*NMAP)); - *nlevels=NMAP*NMAP; - } - else if (*nlevels < 2) { - fprintf(stderr,"Warning, too few levels (%d) in matrix, using 2 instead\n",*nlevels); - *nlevels=2; - } - - fprintf(out,"static char *gromacs_xpm[] = {\n"); - fprintf(out,"\"%d %d %d %d\",\n", - n_x,n_y,*nlevels,(*nlevels <= NMAP) ? 1 : 2); - - invlevel=1.0/(*nlevels-1); - for(i=0; (i<*nlevels); i++) { - nlo=*nlevels-1-i; - r=(nlo*rlo.r+i*rhi.r)*invlevel; - g=(nlo*rlo.g+i*rhi.g)*invlevel; - b=(nlo*rlo.b+i*rhi.b)*invlevel; - fprintf(out,"\"%c%c c #%02X%02X%02X \" /* \"%.3g\" */,\n", - mapper[i % NMAP],(*nlevels <= NMAP) ? ' ' : mapper[i/NMAP], - (unsigned int)round(255*r), - (unsigned int)round(255*g), - (unsigned int)round(255*b), - (nlo*lo+i*hi)*invlevel); - } + int i, nlo; + real invlevel, r, g, b; + + if (*nlevels > NMAP*NMAP) + { + fprintf(stderr, "Warning, too many levels (%d) in matrix, using %d only\n", + *nlevels, (int)(NMAP*NMAP)); + *nlevels = NMAP*NMAP; + } + else if (*nlevels < 2) + { + fprintf(stderr, "Warning, too few levels (%d) in matrix, using 2 instead\n", *nlevels); + *nlevels = 2; + } + + fprintf(out, "static char *gromacs_xpm[] = {\n"); + fprintf(out, "\"%d %d %d %d\",\n", + n_x, n_y, *nlevels, (*nlevels <= NMAP) ? 1 : 2); + + invlevel = 1.0/(*nlevels-1); + for (i = 0; (i < *nlevels); i++) + { + nlo = *nlevels-1-i; + r = (nlo*rlo.r+i*rhi.r)*invlevel; + g = (nlo*rlo.g+i*rhi.g)*invlevel; + b = (nlo*rlo.b+i*rhi.b)*invlevel; + fprintf(out, "\"%c%c c #%02X%02X%02X \" /* \"%.3g\" */,\n", + mapper[i % NMAP], (*nlevels <= NMAP) ? ' ' : mapper[i/NMAP], + (unsigned int)round(255*r), + (unsigned int)round(255*g), + (unsigned int)round(255*b), + (nlo*lo+i*hi)*invlevel); + } } void write_xpm_axis(FILE *out, const char *axis, gmx_bool bSpatial, int n, real *label) { - int i; - - if (label) { - for(i=0;i<(bSpatial ? n+1 : n);i++) { - if (i % 80 == 0) { - if (i) - fprintf(out,"*/\n"); - fprintf(out,"/* %s-axis: ",axis); - } - fprintf(out,"%g ",label[i]); - } - fprintf(out,"*/\n"); - } + int i; + + if (label) + { + for (i = 0; i < (bSpatial ? n+1 : n); i++) + { + if (i % 80 == 0) + { + if (i) + { + fprintf(out, "*/\n"); + } + fprintf(out, "/* %s-axis: ", axis); + } + fprintf(out, "%g ", label[i]); + } + fprintf(out, "*/\n"); + } } -void write_xpm_data(FILE *out, int n_x, int n_y, real **matrix, - real lo, real hi, int nlevels) +void write_xpm_data(FILE *out, int n_x, int n_y, real **matrix, + real lo, real hi, int nlevels) { - int i,j,c; - real invlevel; - - invlevel=(nlevels-1)/(hi-lo); - for(j=n_y-1; (j>=0); j--) { - if(j%(1+n_y/100)==0) - fprintf(stderr,"%3d%%\b\b\b\b",(100*(n_y-j))/n_y); - fprintf(out,"\""); - for(i=0; (i=nlevels) c=nlevels-1; - if (nlevels <= NMAP) - fprintf(out,"%c",mapper[c]); - else - fprintf(out,"%c%c",mapper[c % NMAP],mapper[c / NMAP]); - } - if (j > 0) - fprintf(out,"\",\n"); - else - fprintf(out,"\"\n"); - } + int i, j, c; + real invlevel; + + invlevel = (nlevels-1)/(hi-lo); + for (j = n_y-1; (j >= 0); j--) + { + if (j%(1+n_y/100) == 0) + { + fprintf(stderr, "%3d%%\b\b\b\b", (100*(n_y-j))/n_y); + } + fprintf(out, "\""); + for (i = 0; (i < n_x); i++) + { + c = gmx_nint((matrix[i][j]-lo)*invlevel); + if (c < 0) + { + c = 0; + } + if (c >= nlevels) + { + c = nlevels-1; + } + if (nlevels <= NMAP) + { + fprintf(out, "%c", mapper[c]); + } + else + { + fprintf(out, "%c%c", mapper[c % NMAP], mapper[c / NMAP]); + } + } + if (j > 0) + { + fprintf(out, "\",\n"); + } + else + { + fprintf(out, "\"\n"); + } + } } -void write_xpm_data3(FILE *out,int n_x,int n_y,real **matrix, - real lo,real mid,real hi,int nlevels) +void write_xpm_data3(FILE *out, int n_x, int n_y, real **matrix, + real lo, real mid, real hi, int nlevels) { - int i,j,c=0,nmid; - real invlev_lo,invlev_hi; - - nmid = calc_nmid(nlevels,lo,mid,hi); - invlev_hi=(nlevels-1-nmid)/(hi-mid); - invlev_lo=(nmid)/(mid-lo); - - for(j=n_y-1; (j>=0); j--) { - if(j%(1+n_y/100)==0) - fprintf(stderr,"%3d%%\b\b\b\b",(100*(n_y-j))/n_y); - fprintf(out,"\""); - for(i=0; (i= mid) - c=nmid+gmx_nint((matrix[i][j]-mid)*invlev_hi); - else if (matrix[i][j] >= lo) - c=gmx_nint((matrix[i][j]-lo)*invlev_lo); - else - c = 0; - - if (c<0) - c=0; - if (c>=nlevels) - c=nlevels-1; - if (nlevels <= NMAP) - fprintf(out,"%c",mapper[c]); - else - fprintf(out,"%c%c",mapper[c % NMAP],mapper[c / NMAP]); - } - if (j > 0) - fprintf(out,"\",\n"); - else - fprintf(out,"\"\n"); - } + int i, j, c = 0, nmid; + real invlev_lo, invlev_hi; + + nmid = calc_nmid(nlevels, lo, mid, hi); + invlev_hi = (nlevels-1-nmid)/(hi-mid); + invlev_lo = (nmid)/(mid-lo); + + for (j = n_y-1; (j >= 0); j--) + { + if (j%(1+n_y/100) == 0) + { + fprintf(stderr, "%3d%%\b\b\b\b", (100*(n_y-j))/n_y); + } + fprintf(out, "\""); + for (i = 0; (i < n_x); i++) + { + if (matrix[i][j] >= mid) + { + c = nmid+gmx_nint((matrix[i][j]-mid)*invlev_hi); + } + else if (matrix[i][j] >= lo) + { + c = gmx_nint((matrix[i][j]-lo)*invlev_lo); + } + else + { + c = 0; + } + + if (c < 0) + { + c = 0; + } + if (c >= nlevels) + { + c = nlevels-1; + } + if (nlevels <= NMAP) + { + fprintf(out, "%c", mapper[c]); + } + else + { + fprintf(out, "%c%c", mapper[c % NMAP], mapper[c / NMAP]); + } + } + if (j > 0) + { + fprintf(out, "\",\n"); + } + else + { + fprintf(out, "\"\n"); + } + } } -void write_xpm_data_split(FILE *out,int n_x,int n_y,real **matrix, - real lo_top,real hi_top,int nlevel_top, - real lo_bot,real hi_bot,int nlevel_bot) +void write_xpm_data_split(FILE *out, int n_x, int n_y, real **matrix, + real lo_top, real hi_top, int nlevel_top, + real lo_bot, real hi_bot, int nlevel_bot) { - int i,j,c; - real invlev_top,invlev_bot; - - invlev_top=(nlevel_top-1)/(hi_top-lo_top); - invlev_bot=(nlevel_bot-1)/(hi_bot-lo_bot); - - for(j=n_y-1; (j>=0); j--) { - if(j % (1+n_y/100)==0) - fprintf(stderr,"%3d%%\b\b\b\b",(100*(n_y-j))/n_y); - fprintf(out,"\""); - for(i=0; (i= nlevel_bot+nlevel_top)) - gmx_fatal(FARGS,"Range checking i = %d, j = %d, c = %d, bot = %d, top = %d matrix[i,j] = %f",i,j,c,nlevel_bot,nlevel_top,matrix[i][j]); - } - else if (i > j) { - c = round((matrix[i][j]-lo_bot)*invlev_bot); - if ((c < 0) || (c >= nlevel_bot+nlevel_bot)) - gmx_fatal(FARGS,"Range checking i = %d, j = %d, c = %d, bot = %d, top = %d matrix[i,j] = %f",i,j,c,nlevel_bot,nlevel_top,matrix[i][j]); - } - else - c = nlevel_bot; - - fprintf(out,"%c",mapper[c]); - } - if (j > 0) - fprintf(out,"\",\n"); - else - fprintf(out,"\"\n"); - } + int i, j, c; + real invlev_top, invlev_bot; + + invlev_top = (nlevel_top-1)/(hi_top-lo_top); + invlev_bot = (nlevel_bot-1)/(hi_bot-lo_bot); + + for (j = n_y-1; (j >= 0); j--) + { + if (j % (1+n_y/100) == 0) + { + fprintf(stderr, "%3d%%\b\b\b\b", (100*(n_y-j))/n_y); + } + fprintf(out, "\""); + for (i = 0; (i < n_x); i++) + { + if (i < j) + { + c = nlevel_bot+round((matrix[i][j]-lo_top)*invlev_top); + if ((c < nlevel_bot) || (c >= nlevel_bot+nlevel_top)) + { + gmx_fatal(FARGS, "Range checking i = %d, j = %d, c = %d, bot = %d, top = %d matrix[i,j] = %f", i, j, c, nlevel_bot, nlevel_top, matrix[i][j]); + } + } + else if (i > j) + { + c = round((matrix[i][j]-lo_bot)*invlev_bot); + if ((c < 0) || (c >= nlevel_bot+nlevel_bot)) + { + gmx_fatal(FARGS, "Range checking i = %d, j = %d, c = %d, bot = %d, top = %d matrix[i,j] = %f", i, j, c, nlevel_bot, nlevel_top, matrix[i][j]); + } + } + else + { + c = nlevel_bot; + } + + fprintf(out, "%c", mapper[c]); + } + if (j > 0) + { + fprintf(out, "\",\n"); + } + else + { + fprintf(out, "\"\n"); + } + } } void write_xpm_m(FILE *out, t_matrix m) { - /* Writes a t_matrix struct to .xpm file */ - - int i,j; - gmx_bool bOneChar; - t_xpmelmt c; - - bOneChar=(m.map[0].code.c2 == 0); - write_xpm_header(out,m.title,m.legend,m.label_x,m.label_y, - m.bDiscrete); - fprintf(out,"static char *gromacs_xpm[] = {\n"); - fprintf(out,"\"%d %d %d %d\",\n",m.nx,m.ny,m.nmap,bOneChar ? 1 : 2); - for(i=0; (i=0); j--) { - if(j%(1+m.ny/100)==0) - fprintf(stderr,"%3d%%\b\b\b\b",(100*(m.ny-j))/m.ny); - fprintf(out,"\""); - if (bOneChar) - for(i=0; (i 0) - fprintf(out,"\",\n"); - else - fprintf(out,"\"\n"); - } + /* Writes a t_matrix struct to .xpm file */ + + int i, j; + gmx_bool bOneChar; + t_xpmelmt c; + + bOneChar = (m.map[0].code.c2 == 0); + write_xpm_header(out, m.title, m.legend, m.label_x, m.label_y, + m.bDiscrete); + fprintf(out, "static char *gromacs_xpm[] = {\n"); + fprintf(out, "\"%d %d %d %d\",\n", m.nx, m.ny, m.nmap, bOneChar ? 1 : 2); + for (i = 0; (i < m.nmap); i++) + { + fprintf(out, "\"%c%c c #%02X%02X%02X \" /* \"%s\" */,\n", + m.map[i].code.c1, + bOneChar ? ' ' : m.map[i].code.c2, + (unsigned int)round(m.map[i].rgb.r*255), + (unsigned int)round(m.map[i].rgb.g*255), + (unsigned int)round(m.map[i].rgb.b*255), m.map[i].desc); + } + write_xpm_axis(out, "x", m.flags & MAT_SPATIAL_X, m.nx, m.axis_x); + write_xpm_axis(out, "y", m.flags & MAT_SPATIAL_Y, m.ny, m.axis_y); + for (j = m.ny-1; (j >= 0); j--) + { + if (j%(1+m.ny/100) == 0) + { + fprintf(stderr, "%3d%%\b\b\b\b", (100*(m.ny-j))/m.ny); + } + fprintf(out, "\""); + if (bOneChar) + { + for (i = 0; (i < m.nx); i++) + { + fprintf(out, "%c", m.map[m.matrix[i][j]].code.c1); + } + } + else + { + for (i = 0; (i < m.nx); i++) + { + c = m.map[m.matrix[i][j]].code; + fprintf(out, "%c%c", c.c1, c.c2); + } + } + if (j > 0) + { + fprintf(out, "\",\n"); + } + else + { + fprintf(out, "\"\n"); + } + } } -void write_xpm3(FILE *out,unsigned int flags, - const char *title,const char *legend, - const char *label_x,const char *label_y, - int n_x,int n_y,real axis_x[],real axis_y[], - real *matrix[],real lo,real mid,real hi, - t_rgb rlo,t_rgb rmid,t_rgb rhi,int *nlevels) +void write_xpm3(FILE *out, unsigned int flags, + const char *title, const char *legend, + const char *label_x, const char *label_y, + int n_x, int n_y, real axis_x[], real axis_y[], + real *matrix[], real lo, real mid, real hi, + t_rgb rlo, t_rgb rmid, t_rgb rhi, int *nlevels) { - /* See write_xpm. - * Writes a colormap varying as rlo -> rmid -> rhi. - */ - - if (hi <= lo) - gmx_fatal(FARGS,"hi (%g) <= lo (%g)",hi,lo); - - write_xpm_header(out,title,legend,label_x,label_y,FALSE); - write_xpm_map3(out,n_x,n_y,nlevels,lo,mid,hi,rlo,rmid,rhi); - write_xpm_axis(out,"x",flags & MAT_SPATIAL_X,n_x,axis_x); - write_xpm_axis(out,"y",flags & MAT_SPATIAL_Y,n_y,axis_y); - write_xpm_data3(out,n_x,n_y,matrix,lo,mid,hi,*nlevels); + /* See write_xpm. + * Writes a colormap varying as rlo -> rmid -> rhi. + */ + + if (hi <= lo) + { + gmx_fatal(FARGS, "hi (%g) <= lo (%g)", hi, lo); + } + + write_xpm_header(out, title, legend, label_x, label_y, FALSE); + write_xpm_map3(out, n_x, n_y, nlevels, lo, mid, hi, rlo, rmid, rhi); + write_xpm_axis(out, "x", flags & MAT_SPATIAL_X, n_x, axis_x); + write_xpm_axis(out, "y", flags & MAT_SPATIAL_Y, n_y, axis_y); + write_xpm_data3(out, n_x, n_y, matrix, lo, mid, hi, *nlevels); } -void write_xpm_split(FILE *out,unsigned int flags, - const char *title,const char *legend, - const char *label_x,const char *label_y, - int n_x,int n_y,real axis_x[],real axis_y[], - real *matrix[], - real lo_top,real hi_top,int *nlevel_top, - t_rgb rlo_top,t_rgb rhi_top, - real lo_bot,real hi_bot,int *nlevel_bot, - gmx_bool bDiscreteColor, - t_rgb rlo_bot,t_rgb rhi_bot) +void write_xpm_split(FILE *out, unsigned int flags, + const char *title, const char *legend, + const char *label_x, const char *label_y, + int n_x, int n_y, real axis_x[], real axis_y[], + real *matrix[], + real lo_top, real hi_top, int *nlevel_top, + t_rgb rlo_top, t_rgb rhi_top, + real lo_bot, real hi_bot, int *nlevel_bot, + gmx_bool bDiscreteColor, + t_rgb rlo_bot, t_rgb rhi_bot) { - /* See write_xpm. - * Writes a colormap varying as rlo -> rmid -> rhi. - */ - - if (hi_top <= lo_top) - gmx_fatal(FARGS,"hi_top (%g) <= lo_top (%g)",hi_top,lo_top); - if (hi_bot <= lo_bot) - gmx_fatal(FARGS,"hi_bot (%g) <= lo_bot (%g)",hi_bot,lo_bot); - if (bDiscreteColor && (*nlevel_bot >= 16)) - gmx_impl("Can not plot more than 16 discrete colors"); - - write_xpm_header(out,title,legend,label_x,label_y,FALSE); - write_xpm_map_split(out,n_x,n_y,nlevel_top,lo_top,hi_top,rlo_top,rhi_top, - bDiscreteColor,nlevel_bot,lo_bot,hi_bot,rlo_bot,rhi_bot); - write_xpm_axis(out,"x",flags & MAT_SPATIAL_X,n_x,axis_x); - write_xpm_axis(out,"y",flags & MAT_SPATIAL_Y,n_y,axis_y); - write_xpm_data_split(out,n_x,n_y,matrix,lo_top,hi_top,*nlevel_top, - lo_bot,hi_bot,*nlevel_bot); + /* See write_xpm. + * Writes a colormap varying as rlo -> rmid -> rhi. + */ + + if (hi_top <= lo_top) + { + gmx_fatal(FARGS, "hi_top (%g) <= lo_top (%g)", hi_top, lo_top); + } + if (hi_bot <= lo_bot) + { + gmx_fatal(FARGS, "hi_bot (%g) <= lo_bot (%g)", hi_bot, lo_bot); + } + if (bDiscreteColor && (*nlevel_bot >= 16)) + { + gmx_impl("Can not plot more than 16 discrete colors"); + } + + write_xpm_header(out, title, legend, label_x, label_y, FALSE); + write_xpm_map_split(out, n_x, n_y, nlevel_top, lo_top, hi_top, rlo_top, rhi_top, + bDiscreteColor, nlevel_bot, lo_bot, hi_bot, rlo_bot, rhi_bot); + write_xpm_axis(out, "x", flags & MAT_SPATIAL_X, n_x, axis_x); + write_xpm_axis(out, "y", flags & MAT_SPATIAL_Y, n_y, axis_y); + write_xpm_data_split(out, n_x, n_y, matrix, lo_top, hi_top, *nlevel_top, + lo_bot, hi_bot, *nlevel_bot); } -void write_xpm(FILE *out,unsigned int flags, - const char *title,const char *legend, - const char *label_x,const char *label_y, - int n_x,int n_y,real axis_x[],real axis_y[], - real *matrix[],real lo,real hi, - t_rgb rlo,t_rgb rhi,int *nlevels) +void write_xpm(FILE *out, unsigned int flags, + const char *title, const char *legend, + const char *label_x, const char *label_y, + int n_x, int n_y, real axis_x[], real axis_y[], + real *matrix[], real lo, real hi, + t_rgb rlo, t_rgb rhi, int *nlevels) { - /* out xpm file - * title matrix title - * legend label for the continuous legend - * label_x label for the x-axis - * label_y label for the y-axis - * n_x, n_y size of the matrix - * axis_x[] the x-ticklabels - * axis_y[] the y-ticklables - * *matrix[] element x,y is matrix[x][y] - * lo output lower than lo is set to lo - * hi output higher than hi is set to hi - * rlo rgb value for level lo - * rhi rgb value for level hi - * nlevels number of color levels for the output - */ - - if (hi <= lo) - gmx_fatal(FARGS,"hi (%f) <= lo (%f)",hi,lo); - - write_xpm_header(out,title,legend,label_x,label_y,FALSE); - write_xpm_map(out,n_x,n_y,nlevels,lo,hi,rlo,rhi); - write_xpm_axis(out,"x",flags & MAT_SPATIAL_X,n_x,axis_x); - write_xpm_axis(out,"y",flags & MAT_SPATIAL_Y,n_y,axis_y); - write_xpm_data(out,n_x,n_y,matrix,lo,hi,*nlevels); -} + /* out xpm file + * title matrix title + * legend label for the continuous legend + * label_x label for the x-axis + * label_y label for the y-axis + * n_x, n_y size of the matrix + * axis_x[] the x-ticklabels + * axis_y[] the y-ticklables + * *matrix[] element x,y is matrix[x][y] + * lo output lower than lo is set to lo + * hi output higher than hi is set to hi + * rlo rgb value for level lo + * rhi rgb value for level hi + * nlevels number of color levels for the output + */ + + if (hi <= lo) + { + gmx_fatal(FARGS, "hi (%f) <= lo (%f)", hi, lo); + } + write_xpm_header(out, title, legend, label_x, label_y, FALSE); + write_xpm_map(out, n_x, n_y, nlevels, lo, hi, rlo, rhi); + write_xpm_axis(out, "x", flags & MAT_SPATIAL_X, n_x, axis_x); + write_xpm_axis(out, "y", flags & MAT_SPATIAL_Y, n_y, axis_y); + write_xpm_data(out, n_x, n_y, matrix, lo, hi, *nlevels); +} diff --git a/src/gromacs/gmxlib/md5.c b/src/gromacs/gmxlib/md5.c index ce195bee2e..db881f5856 100644 --- a/src/gromacs/gmxlib/md5.c +++ b/src/gromacs/gmxlib/md5.c @@ -1,11 +1,11 @@ /* - * + * * This source code is distributed with - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 4.5 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2010, The GROMACS development team, @@ -15,19 +15,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -42,68 +42,68 @@ #endif /* - Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. + Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not + 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be + 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. + 3. This notice may not be removed or altered from any source distribution. - L. Peter Deutsch - ghost@aladdin.com + L. Peter Deutsch + ghost@aladdin.com */ /* - Independent implementation of MD5 (RFC 1321). - - This code implements the MD5 Algorithm defined in RFC 1321, whose - text is available at - http://www.ietf.org/rfc/rfc1321.txt - The code is derived from the text of the RFC, including the test suite - (section A.5) but excluding the rest of Appendix A. It does not include - any code or documentation that is identified in the RFC as being - copyrighted. - - The original and principal author of md5.c is L. Peter Deutsch - . Other authors are noted in the change history - that follows (in reverse chronological order): - - 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order - either statically or dynamically; added missing #include - in library. - 2002-03-11 lpd Corrected argument list for main(), and added int return - type, in test program and T value program. - 2002-02-21 lpd Added missing #include in test program. - 2000-07-03 lpd Patched to eliminate warnings about "constant is - unsigned in ANSI C, signed in traditional"; made test program - self-checking. - 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. - 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). - 1999-05-03 lpd Original version. + Independent implementation of MD5 (RFC 1321). + + This code implements the MD5 Algorithm defined in RFC 1321, whose + text is available at + http://www.ietf.org/rfc/rfc1321.txt + The code is derived from the text of the RFC, including the test suite + (section A.5) but excluding the rest of Appendix A. It does not include + any code or documentation that is identified in the RFC as being + copyrighted. + + The original and principal author of md5.c is L. Peter Deutsch + . Other authors are noted in the change history + that follows (in reverse chronological order): + + 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order + either statically or dynamically; added missing #include + in library. + 2002-03-11 lpd Corrected argument list for main(), and added int return + type, in test program and T value program. + 2002-02-21 lpd Added missing #include in test program. + 2000-07-03 lpd Patched to eliminate warnings about "constant is + unsigned in ANSI C, signed in traditional"; made test program + self-checking. + 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. + 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). + 1999-05-03 lpd Original version. */ #include "md5.h" #include -#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ +#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ #ifdef ARCH_IS_BIG_ENDIAN # define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) #else # define BYTE_ORDER 0 #endif -#define T_MASK ((md5_word_t)~0) +#define T_MASK ((md5_word_t) ~0) #define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) #define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) #define T3 0x242070db @@ -174,66 +174,71 @@ static void md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) { md5_word_t - a = pms->abcd[0], b = pms->abcd[1], - c = pms->abcd[2], d = pms->abcd[3]; + a = pms->abcd[0], b = pms->abcd[1], + c = pms->abcd[2], d = pms->abcd[3]; md5_word_t t; #if BYTE_ORDER > 0 /* Define storage only for big-endian CPUs. */ md5_word_t X[16]; #else /* Define storage for little-endian or both types of CPUs. */ - md5_word_t xbuf[16]; + md5_word_t xbuf[16]; /* cppcheck-suppress unassignedVariable */ const md5_word_t *X; #endif { #if BYTE_ORDER == 0 - /* - * Determine dynamically whether this is a big-endian or - * little-endian machine, since we can use a more efficient - * algorithm on the latter. - */ - static const int w = 1; - - if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ + /* + * Determine dynamically whether this is a big-endian or + * little-endian machine, since we can use a more efficient + * algorithm on the latter. + */ + static const int w = 1; + + if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ #endif -#if BYTE_ORDER <= 0 /* little-endian */ - { - /* - * On little-endian machines, we can process properly aligned - * data without copying it. - */ - if (!((data - (const md5_byte_t *)0) & 3)) { - /* data are properly aligned */ - X = (const md5_word_t *)data; - } else { - /* not aligned */ - memcpy(xbuf, data, 64); - X = xbuf; - } - } +#if BYTE_ORDER <= 0 /* little-endian */ + { + /* + * On little-endian machines, we can process properly aligned + * data without copying it. + */ + if (!((data - (const md5_byte_t *)0) & 3)) + { + /* data are properly aligned */ + X = (const md5_word_t *)data; + } + else + { + /* not aligned */ + memcpy(xbuf, data, 64); + X = xbuf; + } + } #endif #if BYTE_ORDER == 0 - else /* dynamic big-endian */ + else /* dynamic big-endian */ #endif -#if BYTE_ORDER >= 0 /* big-endian */ - { - /* - * On big-endian machines, we must arrange the bytes in the - * right order. - */ - const md5_byte_t *xp = data; - int i; +#if BYTE_ORDER >= 0 /* big-endian */ + { + /* + * On big-endian machines, we must arrange the bytes in the + * right order. + */ + const md5_byte_t *xp = data; + int i; # if BYTE_ORDER == 0 - X = xbuf; /* (dynamic only) */ + X = xbuf; /* (dynamic only) */ # else -# define xbuf X /* (static only) */ +# define xbuf X /* (static only) */ # endif - for (i = 0; i < 16; ++i, xp += 4) - xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); - } + for (i = 0; i < 16; ++i, xp += 4) + { + xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); + } + } #endif } @@ -243,9 +248,9 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) /* Let [abcd k s i] denote the operation a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ #define F(x, y, z) (((x) & (y)) | (~(x) & (z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + F(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b +#define SET(a, b, c, d, k, s, Ti) \ + t = a + F(b, c, d) + X[k] + Ti; \ + a = ROTATE_LEFT(t, s) + b /* Do the following 16 operations. */ SET(a, b, c, d, 0, 7, T1); SET(d, a, b, c, 1, 12, T2); @@ -265,14 +270,14 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) SET(b, c, d, a, 15, 22, T16); #undef SET - /* Round 2. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ + /* Round 2. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ #define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + G(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ +#define SET(a, b, c, d, k, s, Ti) \ + t = a + G(b, c, d) + X[k] + Ti; \ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ SET(a, b, c, d, 1, 5, T17); SET(d, a, b, c, 6, 9, T18); SET(c, d, a, b, 11, 14, T19); @@ -291,14 +296,14 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) SET(b, c, d, a, 12, 20, T32); #undef SET - /* Round 3. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ + /* Round 3. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ #define H(x, y, z) ((x) ^ (y) ^ (z)) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + H(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ +#define SET(a, b, c, d, k, s, Ti) \ + t = a + H(b, c, d) + X[k] + Ti; \ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ SET(a, b, c, d, 5, 4, T33); SET(d, a, b, c, 8, 11, T34); SET(c, d, a, b, 11, 16, T35); @@ -317,14 +322,14 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) SET(b, c, d, a, 2, 23, T48); #undef SET - /* Round 4. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ + /* Round 4. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ #define I(x, y, z) ((y) ^ ((x) | ~(z))) -#define SET(a, b, c, d, k, s, Ti)\ - t = a + I(b,c,d) + X[k] + Ti;\ - a = ROTATE_LEFT(t, s) + b - /* Do the following 16 operations. */ +#define SET(a, b, c, d, k, s, Ti) \ + t = a + I(b, c, d) + X[k] + Ti; \ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ SET(a, b, c, d, 0, 6, T49); SET(d, a, b, c, 7, 10, T50); SET(c, d, a, b, 14, 15, T51); @@ -343,9 +348,9 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) SET(b, c, d, a, 9, 21, T64); #undef SET - /* Then perform the following additions. (That is increment each - of the four registers by the value it had before this block - was started.) */ + /* Then perform the following additions. (That is increment each + of the four registers by the value it had before this block + was started.) */ pms->abcd[0] += a; pms->abcd[1] += b; pms->abcd[2] += c; @@ -356,69 +361,84 @@ void md5_init(md5_state_t *pms) { pms->count[0] = pms->count[1] = 0; - pms->abcd[0] = 0x67452301; - pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; - pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; - pms->abcd[3] = 0x10325476; + pms->abcd[0] = 0x67452301; + pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; + pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; + pms->abcd[3] = 0x10325476; } void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) { const md5_byte_t *p = data; - int left = nbytes; - int offset = (pms->count[0] >> 3) & 63; - md5_word_t nbits = (md5_word_t)(nbytes << 3); + int left = nbytes; + int offset = (pms->count[0] >> 3) & 63; + md5_word_t nbits = (md5_word_t)(nbytes << 3); if (nbytes <= 0) - return; + { + return; + } /* Update the message length. */ pms->count[1] += nbytes >> 29; pms->count[0] += nbits; if (pms->count[0] < nbits) - pms->count[1]++; + { + pms->count[1]++; + } /* Process an initial partial block. */ - if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); - - memcpy(pms->buf + offset, p, copy); - if (offset + copy < 64) - return; - p += copy; - left -= copy; - md5_process(pms, pms->buf); + if (offset) + { + int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + + memcpy(pms->buf + offset, p, copy); + if (offset + copy < 64) + { + return; + } + p += copy; + left -= copy; + md5_process(pms, pms->buf); } /* Process full blocks. */ for (; left >= 64; p += 64, left -= 64) - md5_process(pms, p); + { + md5_process(pms, p); + } /* Process a final partial block. */ if (left) - memcpy(pms->buf, p, left); + { + memcpy(pms->buf, p, left); + } } void md5_finish(md5_state_t *pms, md5_byte_t digest[16]) { static const md5_byte_t pad[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; md5_byte_t data[8]; int i; /* Save the length before padding. */ for (i = 0; i < 8; ++i) - data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); + { + data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); + } /* Pad to 56 bytes mod 64. */ md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); /* Append the length. */ md5_append(pms, data, 8); for (i = 0; i < 16; ++i) - digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); + { + digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); + } } diff --git a/src/gromacs/gmxlib/md_logging.c b/src/gromacs/gmxlib/md_logging.c index a7a87fe5eb..d68cb5dff4 100644 --- a/src/gromacs/gmxlib/md_logging.c +++ b/src/gromacs/gmxlib/md_logging.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon */ @@ -50,17 +50,17 @@ void md_print_info(const t_commrec *cr, FILE *fplog, if (cr == NULL || SIMMASTER(cr)) { - va_start(ap,fmt); + va_start(ap, fmt); + + vfprintf(stderr, fmt, ap); - vfprintf(stderr,fmt,ap); - va_end(ap); } if (fplog != NULL) { - va_start(ap,fmt); + va_start(ap, fmt); - vfprintf(fplog,fmt,ap); + vfprintf(fplog, fmt, ap); va_end(ap); } @@ -73,21 +73,21 @@ void md_print_warn(const t_commrec *cr, FILE *fplog, if (cr == NULL || SIMMASTER(cr)) { - va_start(ap,fmt); + va_start(ap, fmt); - fprintf(stderr,"\n"); - vfprintf(stderr,fmt,ap); - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); va_end(ap); } if (fplog != NULL) { - va_start(ap,fmt); + va_start(ap, fmt); - fprintf(fplog,"\n"); - vfprintf(fplog,fmt,ap); - fprintf(fplog,"\n"); + fprintf(fplog, "\n"); + vfprintf(fplog, fmt, ap); + fprintf(fplog, "\n"); va_end(ap); } diff --git a/src/gromacs/gmxlib/minvert.h b/src/gromacs/gmxlib/minvert.h index e55b4cc15f..8bd6299987 100644 --- a/src/gromacs/gmxlib/minvert.h +++ b/src/gromacs/gmxlib/minvert.h @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -41,18 +41,18 @@ /* A bunch of routines that works on matrices that run from 1 thru n * although they are allocated from 0 thru n */ - -extern void mat_mult(int n,real **A,real **B,real **C); + +extern void mat_mult(int n, real **A, real **B, real **C); extern real **mk_mat(int n); -extern real **mk_mat2(int nrow,int ncol); +extern real **mk_mat2(int nrow, int ncol); -extern void cp_mat(int n,real **src,real **dest); +extern void cp_mat(int n, real **src, real **dest); -extern void print_mat(FILE *fp,char *title,int n,real **a,int *indx); +extern void print_mat(FILE *fp, char *title, int n, real **a, int *indx); /* index may be NULL */ -extern void invert_mat(int n,real **A,real **Ainv); +extern void invert_mat(int n, real **A, real **Ainv); #endif diff --git a/src/gromacs/gmxlib/mshift.c b/src/gromacs/gmxlib/mshift.c index e41e2e9777..d24e39ab82 100644 --- a/src/gromacs/gmxlib/mshift.c +++ b/src/gromacs/gmxlib/mshift.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -52,7 +52,7 @@ * S H I F T U T I L I T I E S * ************************************************************/ - + /************************************************************ * @@ -60,370 +60,442 @@ * ************************************************************/ -static void add_gbond(t_graph *g,atom_id a0,atom_id a1) +static void add_gbond(t_graph *g, atom_id a0, atom_id a1) { - int i; - atom_id inda0,inda1; - gmx_bool bFound; - - inda0 = a0 - g->at_start; - inda1 = a1 - g->at_start; - bFound = FALSE; - /* Search for a direct edge between a0 and a1. - * All egdes are bidirectional, so we only need to search one way. - */ - for(i=0; (inedge[inda0] && !bFound); i++) { - bFound = (g->edge[inda0][i] == a1); - } - - if (!bFound) { - g->edge[inda0][g->nedge[inda0]++] = a1; - g->edge[inda1][g->nedge[inda1]++] = a0; - } + int i; + atom_id inda0, inda1; + gmx_bool bFound; + + inda0 = a0 - g->at_start; + inda1 = a1 - g->at_start; + bFound = FALSE; + /* Search for a direct edge between a0 and a1. + * All egdes are bidirectional, so we only need to search one way. + */ + for (i = 0; (i < g->nedge[inda0] && !bFound); i++) + { + bFound = (g->edge[inda0][i] == a1); + } + + if (!bFound) + { + g->edge[inda0][g->nedge[inda0]++] = a1; + g->edge[inda1][g->nedge[inda1]++] = a0; + } } -static void mk_igraph(t_graph *g,int ftype,t_ilist *il, - int at_start,int at_end, - int *part) +static void mk_igraph(t_graph *g, int ftype, t_ilist *il, + int at_start, int at_end, + int *part) { - t_iatom *ia; - int i,j,np; - int end; - - end=il->nr; - ia=il->iatoms; - - i = 0; - while (i < end) { - np = interaction_function[ftype].nratoms; - - if (ia[1] >= at_start && ia[1] < at_end) { - if (ia[np] >= at_end) - gmx_fatal(FARGS, - "Molecule in topology has atom numbers below and " - "above natoms (%d).\n" - "You are probably trying to use a trajectory which does " - "not match the first %d atoms of the run input file.\n" - "You can make a matching run input file with tpbconv.", - at_end,at_end); - if (ftype == F_SETTLE) { - /* Bond all the atoms in the settle */ - add_gbond(g,ia[1],ia[2]); - add_gbond(g,ia[1],ia[3]); - } else if (part == NULL) { - /* Simply add this bond */ - for(j=1; jnr; + ia = il->iatoms; + + i = 0; + while (i < end) + { + np = interaction_function[ftype].nratoms; + + if (ia[1] >= at_start && ia[1] < at_end) + { + if (ia[np] >= at_end) + { + gmx_fatal(FARGS, + "Molecule in topology has atom numbers below and " + "above natoms (%d).\n" + "You are probably trying to use a trajectory which does " + "not match the first %d atoms of the run input file.\n" + "You can make a matching run input file with tpbconv.", + at_end, at_end); + } + if (ftype == F_SETTLE) + { + /* Bond all the atoms in the settle */ + add_gbond(g, ia[1], ia[2]); + add_gbond(g, ia[1], ia[3]); + } + else if (part == NULL) + { + /* Simply add this bond */ + for (j = 1; j < np; j++) + { + add_gbond(g, ia[j], ia[j+1]); + } + } + else + { + /* Add this bond when it connects two unlinked parts of the graph */ + for (j = 1; j < np; j++) + { + if (part[ia[j]] != part[ia[j+1]]) + { + add_gbond(g, ia[j], ia[j+1]); + } + } + } + } + ia += np+1; + i += np+1; + } } -GMX_ATTRIBUTE_NORETURN static void g_error(int line,const char *file) +GMX_ATTRIBUTE_NORETURN static void g_error(int line, const char *file) { - gmx_fatal(FARGS,"Tring to print non existant graph (file %s, line %d)", - file,line); + gmx_fatal(FARGS, "Tring to print non existant graph (file %s, line %d)", + file, line); } -#define GCHECK(g) if (g == NULL) g_error(__LINE__,__FILE__) +#define GCHECK(g) if (g == NULL) g_error(__LINE__, __FILE__) -void p_graph(FILE *log,const char *title,t_graph *g) +void p_graph(FILE *log, const char *title, t_graph *g) { - int i,j; - const char *cc[egcolNR] = { "W", "G", "B" }; - - GCHECK(g); - fprintf(log,"graph: %s\n",title); - fprintf(log,"nnodes: %d\n",g->nnodes); - fprintf(log,"nbound: %d\n",g->nbound); - fprintf(log,"start: %d\n",g->at_start); - fprintf(log,"end: %d\n",g->at_end); - fprintf(log," atom shiftx shifty shiftz C nedg e1 e2 etc.\n"); - for(i=0; (innodes); i++) - if (g->nedge[i] > 0) { - fprintf(log,"%5d%7d%7d%7d %1s%5d",g->at_start+i+1, - g->ishift[g->at_start+i][XX], - g->ishift[g->at_start+i][YY], - g->ishift[g->at_start+i][ZZ], - (g->negc > 0) ? cc[g->egc[i]] : " ", - g->nedge[i]); - for(j=0; (jnedge[i]); j++) - fprintf(log," %5u",g->edge[i][j]+1); - fprintf(log,"\n"); - } - fflush(log); + int i, j; + const char *cc[egcolNR] = { "W", "G", "B" }; + + GCHECK(g); + fprintf(log, "graph: %s\n", title); + fprintf(log, "nnodes: %d\n", g->nnodes); + fprintf(log, "nbound: %d\n", g->nbound); + fprintf(log, "start: %d\n", g->at_start); + fprintf(log, "end: %d\n", g->at_end); + fprintf(log, " atom shiftx shifty shiftz C nedg e1 e2 etc.\n"); + for (i = 0; (i < g->nnodes); i++) + { + if (g->nedge[i] > 0) + { + fprintf(log, "%5d%7d%7d%7d %1s%5d", g->at_start+i+1, + g->ishift[g->at_start+i][XX], + g->ishift[g->at_start+i][YY], + g->ishift[g->at_start+i][ZZ], + (g->negc > 0) ? cc[g->egc[i]] : " ", + g->nedge[i]); + for (j = 0; (j < g->nedge[i]); j++) + { + fprintf(log, " %5u", g->edge[i][j]+1); + } + fprintf(log, "\n"); + } + } + fflush(log); } -static void calc_1se(t_graph *g,int ftype,t_ilist *il, - int nbond[],int at_start,int at_end) +static void calc_1se(t_graph *g, int ftype, t_ilist *il, + int nbond[], int at_start, int at_end) { - int k,nratoms,end,j; - t_iatom *ia,iaa; - - end=il->nr; - - ia=il->iatoms; - for(j=0; (j= at_start && iaa < at_end) { - nbond[iaa] += 2; - nbond[ia[2]] += 1; - nbond[ia[3]] += 1; - g->at_start = min(g->at_start,iaa); - g->at_end = max(g->at_end,iaa+2+1); - } - } else { - for(k=1; (k<=nratoms); k++) { - iaa=ia[k]; - if (iaa >= at_start && iaa < at_end) { - g->at_start = min(g->at_start,iaa); - g->at_end = max(g->at_end, iaa+1); - /* When making the graph we (might) link all atoms in an interaction - * sequentially. Therefore the end atoms add 1 to the count, - * the middle atoms 2. - */ - if (k == 1 || k == nratoms) { - nbond[iaa] += 1; - } else { - nbond[iaa] += 2; - } - } - } - } - } + int k, nratoms, end, j; + t_iatom *ia, iaa; + + end = il->nr; + + ia = il->iatoms; + for (j = 0; (j < end); j += nratoms+1, ia += nratoms+1) + { + nratoms = interaction_function[ftype].nratoms; + + if (ftype == F_SETTLE) + { + iaa = ia[1]; + if (iaa >= at_start && iaa < at_end) + { + nbond[iaa] += 2; + nbond[ia[2]] += 1; + nbond[ia[3]] += 1; + g->at_start = min(g->at_start, iaa); + g->at_end = max(g->at_end, iaa+2+1); + } + } + else + { + for (k = 1; (k <= nratoms); k++) + { + iaa = ia[k]; + if (iaa >= at_start && iaa < at_end) + { + g->at_start = min(g->at_start, iaa); + g->at_end = max(g->at_end, iaa+1); + /* When making the graph we (might) link all atoms in an interaction + * sequentially. Therefore the end atoms add 1 to the count, + * the middle atoms 2. + */ + if (k == 1 || k == nratoms) + { + nbond[iaa] += 1; + } + else + { + nbond[iaa] += 2; + } + } + } + } + } } -static int calc_start_end(FILE *fplog,t_graph *g,t_ilist il[], - int at_start,int at_end, - int nbond[]) +static int calc_start_end(FILE *fplog, t_graph *g, t_ilist il[], + int at_start, int at_end, + int nbond[]) { - int i,nnb,nbtot; - - g->at_start = at_end; - g->at_end = 0; - - /* First add all the real bonds: they should determine the molecular - * graph. - */ - for(i=0; (iat_start; (iat_end); i++) { - nbtot += nbond[i]; - nnb = max(nnb,nbond[i]); - } - if (fplog) { - fprintf(fplog,"Max number of connections per atom is %d\n",nnb); - fprintf(fplog,"Total number of connections is %d\n",nbtot); - } - return nbtot; + int i, nnb, nbtot; + + g->at_start = at_end; + g->at_end = 0; + + /* First add all the real bonds: they should determine the molecular + * graph. + */ + for (i = 0; (i < F_NRE); i++) + { + if (interaction_function[i].flags & IF_CHEMBOND) + { + calc_1se(g, i, &il[i], nbond, at_start, at_end); + } + } + /* Then add all the other interactions in fixed lists, but first + * check to see what's there already. + */ + for (i = 0; (i < F_NRE); i++) + { + if (!(interaction_function[i].flags & IF_CHEMBOND)) + { + calc_1se(g, i, &il[i], nbond, at_start, at_end); + } + } + + nnb = 0; + nbtot = 0; + for (i = g->at_start; (i < g->at_end); i++) + { + nbtot += nbond[i]; + nnb = max(nnb, nbond[i]); + } + if (fplog) + { + fprintf(fplog, "Max number of connections per atom is %d\n", nnb); + fprintf(fplog, "Total number of connections is %d\n", nbtot); + } + return nbtot; } -static void compact_graph(FILE *fplog,t_graph *g) +static void compact_graph(FILE *fplog, t_graph *g) { - int i,j,n,max_nedge; - atom_id *e; - - max_nedge = 0; - n = 0; - for(i=0; innodes; i++) { - for(j=0; jnedge[i]; j++) { - g->edge[0][n++] = g->edge[i][j]; - } - max_nedge = max(max_nedge,g->nedge[i]); - } - srenew(g->edge[0],n); - /* set pointers after srenew because edge[0] might move */ - for(i=1; innodes; i++) { - g->edge[i] = g->edge[i-1] + g->nedge[i-1]; - } - - if (fplog) { - fprintf(fplog,"Max number of graph edges per atom is %d\n", - max_nedge); - fprintf(fplog,"Total number of graph edges is %d\n",n); - } + int i, j, n, max_nedge; + atom_id *e; + + max_nedge = 0; + n = 0; + for (i = 0; i < g->nnodes; i++) + { + for (j = 0; j < g->nedge[i]; j++) + { + g->edge[0][n++] = g->edge[i][j]; + } + max_nedge = max(max_nedge, g->nedge[i]); + } + srenew(g->edge[0], n); + /* set pointers after srenew because edge[0] might move */ + for (i = 1; i < g->nnodes; i++) + { + g->edge[i] = g->edge[i-1] + g->nedge[i-1]; + } + + if (fplog) + { + fprintf(fplog, "Max number of graph edges per atom is %d\n", + max_nedge); + fprintf(fplog, "Total number of graph edges is %d\n", n); + } } -static gmx_bool determine_graph_parts(t_graph *g,int *part) +static gmx_bool determine_graph_parts(t_graph *g, int *part) { - int i,e; - int nchanged; - atom_id at_i,*at_i2; - gmx_bool bMultiPart; - - /* Initialize the part array with all entries different */ - for(at_i=g->at_start; at_iat_end; at_i++) { - part[at_i] = at_i; - } - - /* Loop over the graph until the part array is fixed */ - do { - bMultiPart = FALSE; - nchanged = 0; - for(i=0; (innodes); i++) { - at_i = g->at_start + i; - at_i2 = g->edge[i]; - for(e=0; enedge[i]; e++) { - /* Set part for both nodes to the minimum */ - if (part[at_i2[e]] > part[at_i]) { - part[at_i2[e]] = part[at_i]; - nchanged++; - } else if (part[at_i2[e]] < part[at_i]) { - part[at_i] = part[at_i2[e]]; - nchanged++; - } - } - if (part[at_i] != part[g->at_start]) { - bMultiPart = TRUE; - } - } - if (debug) { - fprintf(debug,"graph part[] nchanged=%d, bMultiPart=%d\n", - nchanged,bMultiPart); - } - } while (nchanged > 0); - - return bMultiPart; + int i, e; + int nchanged; + atom_id at_i, *at_i2; + gmx_bool bMultiPart; + + /* Initialize the part array with all entries different */ + for (at_i = g->at_start; at_i < g->at_end; at_i++) + { + part[at_i] = at_i; + } + + /* Loop over the graph until the part array is fixed */ + do + { + bMultiPart = FALSE; + nchanged = 0; + for (i = 0; (i < g->nnodes); i++) + { + at_i = g->at_start + i; + at_i2 = g->edge[i]; + for (e = 0; e < g->nedge[i]; e++) + { + /* Set part for both nodes to the minimum */ + if (part[at_i2[e]] > part[at_i]) + { + part[at_i2[e]] = part[at_i]; + nchanged++; + } + else if (part[at_i2[e]] < part[at_i]) + { + part[at_i] = part[at_i2[e]]; + nchanged++; + } + } + if (part[at_i] != part[g->at_start]) + { + bMultiPart = TRUE; + } + } + if (debug) + { + fprintf(debug, "graph part[] nchanged=%d, bMultiPart=%d\n", + nchanged, bMultiPart); + } + } + while (nchanged > 0); + + return bMultiPart; } void mk_graph_ilist(FILE *fplog, - t_ilist *ilist,int at_start,int at_end, - gmx_bool bShakeOnly,gmx_bool bSettle, - t_graph *g) + t_ilist *ilist, int at_start, int at_end, + gmx_bool bShakeOnly, gmx_bool bSettle, + t_graph *g) { - int *nbond; - int i,nbtot; - gmx_bool bMultiPart; - - /* The naming is somewhat confusing, but we need g->at0 and g->at1 - * for shifthing coordinates to a new array (not in place) when - * some atoms are not connected by the graph, which runs from - * g->at_start (>= g->at0) to g->at_end (<= g->at1). - */ - g->at0 = at_start; - g->at1 = at_end; - - snew(nbond,at_end); - nbtot = calc_start_end(fplog,g,ilist,at_start,at_end,nbond); - - if (g->at_start >= g->at_end) { - g->at_start = at_start; - g->at_end = at_end; - g->nnodes = 0; - g->nbound = 0; - } - else { - g->nnodes = g->at_end - g->at_start; - snew(g->nedge,g->nnodes); - snew(g->edge,g->nnodes); - /* Allocate a single array and set pointers into it */ - snew(g->edge[0],nbtot); - for(i=1; (innodes); i++) { - g->edge[i] = g->edge[i-1] + nbond[g->at_start+i-1]; - } - - if (!bShakeOnly) { - /* First add all the real bonds: they should determine the molecular - * graph. - */ - for(i=0; (inbound = 0; - for(i=0; (innodes); i++) - if (g->nedge[i] > 0) - g->nbound++; - } - - g->negc = 0; - g->egc = NULL; - - sfree(nbond); - - snew(g->ishift,g->at1); - - if (gmx_debug_at) - p_graph(debug,"graph",g); + int *nbond; + int i, nbtot; + gmx_bool bMultiPart; + + /* The naming is somewhat confusing, but we need g->at0 and g->at1 + * for shifthing coordinates to a new array (not in place) when + * some atoms are not connected by the graph, which runs from + * g->at_start (>= g->at0) to g->at_end (<= g->at1). + */ + g->at0 = at_start; + g->at1 = at_end; + + snew(nbond, at_end); + nbtot = calc_start_end(fplog, g, ilist, at_start, at_end, nbond); + + if (g->at_start >= g->at_end) + { + g->at_start = at_start; + g->at_end = at_end; + g->nnodes = 0; + g->nbound = 0; + } + else + { + g->nnodes = g->at_end - g->at_start; + snew(g->nedge, g->nnodes); + snew(g->edge, g->nnodes); + /* Allocate a single array and set pointers into it */ + snew(g->edge[0], nbtot); + for (i = 1; (i < g->nnodes); i++) + { + g->edge[i] = g->edge[i-1] + nbond[g->at_start+i-1]; + } + + if (!bShakeOnly) + { + /* First add all the real bonds: they should determine the molecular + * graph. + */ + for (i = 0; (i < F_NRE); i++) + { + if (interaction_function[i].flags & IF_CHEMBOND) + { + mk_igraph(g, i, &(ilist[i]), at_start, at_end, NULL); + } + } + + /* Determine of which separated parts the IF_CHEMBOND graph consists. + * Store the parts in the nbond array. + */ + bMultiPart = determine_graph_parts(g, nbond); + + if (bMultiPart) + { + /* Then add all the other interactions in fixed lists, + * but only when they connect parts of the graph + * that are not connected through IF_CHEMBOND interactions. + */ + for (i = 0; (i < F_NRE); i++) + { + if (!(interaction_function[i].flags & IF_CHEMBOND)) + { + mk_igraph(g, i, &(ilist[i]), at_start, at_end, nbond); + } + } + } + + /* Removed all the unused space from the edge array */ + compact_graph(fplog, g); + } + else + { + /* This is a special thing used in splitter.c to generate shake-blocks */ + mk_igraph(g, F_CONSTR, &(ilist[F_CONSTR]), at_start, at_end, NULL); + if (bSettle) + { + mk_igraph(g, F_SETTLE, &(ilist[F_SETTLE]), at_start, at_end, NULL); + } + } + g->nbound = 0; + for (i = 0; (i < g->nnodes); i++) + { + if (g->nedge[i] > 0) + { + g->nbound++; + } + } + } + + g->negc = 0; + g->egc = NULL; + + sfree(nbond); + + snew(g->ishift, g->at1); + + if (gmx_debug_at) + { + p_graph(debug, "graph", g); + } } t_graph *mk_graph(FILE *fplog, - t_idef *idef,int at_start,int at_end, - gmx_bool bShakeOnly,gmx_bool bSettle) + t_idef *idef, int at_start, int at_end, + gmx_bool bShakeOnly, gmx_bool bSettle) { - t_graph *g; + t_graph *g; - snew(g,1); + snew(g, 1); - mk_graph_ilist(fplog,idef->il,at_start,at_end,bShakeOnly,bSettle,g); + mk_graph_ilist(fplog, idef->il, at_start, at_end, bShakeOnly, bSettle, g); - return g; + return g; } void done_graph(t_graph *g) { - int i; - - GCHECK(g); - if (g->nnodes > 0) { - sfree(g->nedge); - sfree(g->edge[0]); - sfree(g->edge); - sfree(g->egc); - } - sfree(g->ishift); + int i; + + GCHECK(g); + if (g->nnodes > 0) + { + sfree(g->nedge); + sfree(g->edge[0]); + sfree(g->edge); + sfree(g->egc); + } + sfree(g->ishift); } /************************************************************ @@ -432,266 +504,338 @@ void done_graph(t_graph *g) * ************************************************************/ -static void mk_1shift_tric(int npbcdim,matrix box,rvec hbox, - rvec xi,rvec xj,int *mi,int *mj) +static void mk_1shift_tric(int npbcdim, matrix box, rvec hbox, + rvec xi, rvec xj, int *mi, int *mj) { - /* Calculate periodicity for triclinic box... */ - int m,d; - rvec dx; - - rvec_sub(xi,xj,dx); - - mj[ZZ] = 0; - for(m=npbcdim-1; (m>=0); m--) { - /* If dx < hbox, then xj will be reduced by box, so that - * xi - xj will be bigger - */ - if (dx[m] < -hbox[m]) { - mj[m]=mi[m]-1; - for(d=m-1; d>=0; d--) - dx[d]+=box[m][d]; - } else if (dx[m] >= hbox[m]) { - mj[m]=mi[m]+1; - for(d=m-1; d>=0; d--) - dx[d]-=box[m][d]; - } else - mj[m]=mi[m]; - } + /* Calculate periodicity for triclinic box... */ + int m, d; + rvec dx; + + rvec_sub(xi, xj, dx); + + mj[ZZ] = 0; + for (m = npbcdim-1; (m >= 0); m--) + { + /* If dx < hbox, then xj will be reduced by box, so that + * xi - xj will be bigger + */ + if (dx[m] < -hbox[m]) + { + mj[m] = mi[m]-1; + for (d = m-1; d >= 0; d--) + { + dx[d] += box[m][d]; + } + } + else if (dx[m] >= hbox[m]) + { + mj[m] = mi[m]+1; + for (d = m-1; d >= 0; d--) + { + dx[d] -= box[m][d]; + } + } + else + { + mj[m] = mi[m]; + } + } } -static void mk_1shift(int npbcdim,rvec hbox,rvec xi,rvec xj,int *mi,int *mj) +static void mk_1shift(int npbcdim, rvec hbox, rvec xi, rvec xj, int *mi, int *mj) { - /* Calculate periodicity for rectangular box... */ - int m; - rvec dx; - - rvec_sub(xi,xj,dx); - - mj[ZZ] = 0; - for(m=0; (m= hbox[m]) - mj[m]=mi[m]+1; - else - mj[m]=mi[m]; - } + /* Calculate periodicity for rectangular box... */ + int m; + rvec dx; + + rvec_sub(xi, xj, dx); + + mj[ZZ] = 0; + for (m = 0; (m < npbcdim); m++) + { + /* If dx < hbox, then xj will be reduced by box, so that + * xi - xj will be bigger + */ + if (dx[m] < -hbox[m]) + { + mj[m] = mi[m]-1; + } + else if (dx[m] >= hbox[m]) + { + mj[m] = mi[m]+1; + } + else + { + mj[m] = mi[m]; + } + } } -static void mk_1shift_screw(matrix box,rvec hbox, - rvec xi,rvec xj,int *mi,int *mj) +static void mk_1shift_screw(matrix box, rvec hbox, + rvec xi, rvec xj, int *mi, int *mj) { - /* Calculate periodicity for rectangular box... */ - int signi,m; - rvec dx; - - if ((mi[XX] > 0 && mi[XX] % 2 == 1) || - (mi[XX] < 0 && -mi[XX] % 2 == 1)) { - signi = -1; - } else { - signi = 1; - } - - rvec_sub(xi,xj,dx); - - if (dx[XX] < -hbox[XX]) - mj[XX] = mi[XX] - 1; - else if (dx[XX] >= hbox[XX]) - mj[XX] = mi[XX] + 1; - else - mj[XX] = mi[XX]; - if (mj[XX] != mi[XX]) { - /* Rotate */ - dx[YY] = xi[YY] - (box[YY][YY] + box[ZZ][YY] - xj[YY]); - dx[ZZ] = xi[ZZ] - (box[ZZ][ZZ] - xj[ZZ]); - } - for(m=1; (m= hbox[m]) - mj[m] = mi[m] + signi; + /* Calculate periodicity for rectangular box... */ + int signi, m; + rvec dx; + + if ((mi[XX] > 0 && mi[XX] % 2 == 1) || + (mi[XX] < 0 && -mi[XX] % 2 == 1)) + { + signi = -1; + } + else + { + signi = 1; + } + + rvec_sub(xi, xj, dx); + + if (dx[XX] < -hbox[XX]) + { + mj[XX] = mi[XX] - 1; + } + else if (dx[XX] >= hbox[XX]) + { + mj[XX] = mi[XX] + 1; + } else - mj[m] = mi[m]; - } + { + mj[XX] = mi[XX]; + } + if (mj[XX] != mi[XX]) + { + /* Rotate */ + dx[YY] = xi[YY] - (box[YY][YY] + box[ZZ][YY] - xj[YY]); + dx[ZZ] = xi[ZZ] - (box[ZZ][ZZ] - xj[ZZ]); + } + for (m = 1; (m < DIM); m++) + { + /* The signs are taken such that we can first shift x and rotate + * and then shift y and z. + */ + if (dx[m] < -hbox[m]) + { + mj[m] = mi[m] - signi; + } + else if (dx[m] >= hbox[m]) + { + mj[m] = mi[m] + signi; + } + else + { + mj[m] = mi[m]; + } + } } -static int mk_grey(FILE *log,int nnodes,egCol egc[],t_graph *g,int *AtomI, - int npbcdim,matrix box,rvec x[],int *nerror) +static int mk_grey(FILE *log, int nnodes, egCol egc[], t_graph *g, int *AtomI, + int npbcdim, matrix box, rvec x[], int *nerror) { - int m,j,ng,ai,aj,g0; - rvec dx,hbox; - gmx_bool bTriclinic; - ivec is_aj; - t_pbc pbc; - - for(m=0; (mat_start; - ng = 0; - ai = g0 + *AtomI; - - /* Loop over all the bonds */ - for(j=0; (jnedge[ai-g0]); j++) { - aj = g->edge[ai-g0][j]; - /* If there is a white one, make it grey and set pbc */ - if (g->bScrewPBC) - mk_1shift_screw(box,hbox,x[ai],x[aj],g->ishift[ai],is_aj); - else if (bTriclinic) - mk_1shift_tric(npbcdim,box,hbox,x[ai],x[aj],g->ishift[ai],is_aj); - else - mk_1shift(npbcdim,hbox,x[ai],x[aj],g->ishift[ai],is_aj); - - if (egc[aj-g0] == egcolWhite) { - if (aj - g0 < *AtomI) - *AtomI = aj - g0; - egc[aj-g0] = egcolGrey; - - copy_ivec(is_aj,g->ishift[aj]); - - ng++; - } - else if ((is_aj[XX] != g->ishift[aj][XX]) || - (is_aj[YY] != g->ishift[aj][YY]) || - (is_aj[ZZ] != g->ishift[aj][ZZ])) { - if (gmx_debug_at) { - set_pbc(&pbc,-1,box); - pbc_dx(&pbc,x[ai],x[aj],dx); - fprintf(debug,"mk_grey: shifts for atom %d due to atom %d\n" - "are (%d,%d,%d), should be (%d,%d,%d)\n" - "dx = (%g,%g,%g)\n", - aj+1,ai+1,is_aj[XX],is_aj[YY],is_aj[ZZ], - g->ishift[aj][XX],g->ishift[aj][YY],g->ishift[aj][ZZ], - dx[XX],dx[YY],dx[ZZ]); - } - (*nerror)++; - } - } - return ng; + int m, j, ng, ai, aj, g0; + rvec dx, hbox; + gmx_bool bTriclinic; + ivec is_aj; + t_pbc pbc; + + for (m = 0; (m < DIM); m++) + { + hbox[m] = box[m][m]*0.5; + } + bTriclinic = TRICLINIC(box); + + g0 = g->at_start; + ng = 0; + ai = g0 + *AtomI; + + /* Loop over all the bonds */ + for (j = 0; (j < g->nedge[ai-g0]); j++) + { + aj = g->edge[ai-g0][j]; + /* If there is a white one, make it grey and set pbc */ + if (g->bScrewPBC) + { + mk_1shift_screw(box, hbox, x[ai], x[aj], g->ishift[ai], is_aj); + } + else if (bTriclinic) + { + mk_1shift_tric(npbcdim, box, hbox, x[ai], x[aj], g->ishift[ai], is_aj); + } + else + { + mk_1shift(npbcdim, hbox, x[ai], x[aj], g->ishift[ai], is_aj); + } + + if (egc[aj-g0] == egcolWhite) + { + if (aj - g0 < *AtomI) + { + *AtomI = aj - g0; + } + egc[aj-g0] = egcolGrey; + + copy_ivec(is_aj, g->ishift[aj]); + + ng++; + } + else if ((is_aj[XX] != g->ishift[aj][XX]) || + (is_aj[YY] != g->ishift[aj][YY]) || + (is_aj[ZZ] != g->ishift[aj][ZZ])) + { + if (gmx_debug_at) + { + set_pbc(&pbc, -1, box); + pbc_dx(&pbc, x[ai], x[aj], dx); + fprintf(debug, "mk_grey: shifts for atom %d due to atom %d\n" + "are (%d,%d,%d), should be (%d,%d,%d)\n" + "dx = (%g,%g,%g)\n", + aj+1, ai+1, is_aj[XX], is_aj[YY], is_aj[ZZ], + g->ishift[aj][XX], g->ishift[aj][YY], g->ishift[aj][ZZ], + dx[XX], dx[YY], dx[ZZ]); + } + (*nerror)++; + } + } + return ng; } -static int first_colour(int fC,egCol Col,t_graph *g,egCol egc[]) +static int first_colour(int fC, egCol Col, t_graph *g, egCol egc[]) /* Return the first node with colour Col starting at fC. * return -1 if none found. */ { - int i; - - for(i=fC; (innodes); i++) - if ((g->nedge[i] > 0) && (egc[i]==Col)) - return i; - - return -1; + int i; + + for (i = fC; (i < g->nnodes); i++) + { + if ((g->nedge[i] > 0) && (egc[i] == Col)) + { + return i; + } + } + + return -1; } -void mk_mshift(FILE *log,t_graph *g,int ePBC,matrix box,rvec x[]) +void mk_mshift(FILE *log, t_graph *g, int ePBC, matrix box, rvec x[]) { - static int nerror_tot = 0; - int npbcdim; - int ng,nnodes,i; - int nW,nG,nB; /* Number of Grey, Black, White */ - int fW,fG; /* First of each category */ - int nerror=0; - - g->bScrewPBC = (ePBC == epbcSCREW); - - if (ePBC == epbcXY) - npbcdim = 2; - else - npbcdim = 3; - - GCHECK(g); - /* This puts everything in the central box, that is does not move it - * at all. If we return without doing this for a system without bonds - * (i.e. only settles) all water molecules are moved to the opposite octant - */ - for(i=g->at0; (iat1); i++) { - g->ishift[i][XX]=g->ishift[i][YY]=g->ishift[i][ZZ]=0; - } - - if (!g->nbound) - return; - - nnodes=g->nnodes; - if (nnodes > g->negc) { - g->negc = nnodes; - srenew(g->egc,g->negc); - } - memset(g->egc,0,(size_t)(nnodes*sizeof(g->egc[0]))); - - nW=g->nbound; - nG=0; - nB=0; - - fW=0; - - /* We even have a loop invariant: - * nW+nG+nB == g->nbound - */ + static int nerror_tot = 0; + int npbcdim; + int ng, nnodes, i; + int nW, nG, nB; /* Number of Grey, Black, White */ + int fW, fG; /* First of each category */ + int nerror = 0; + + g->bScrewPBC = (ePBC == epbcSCREW); + + if (ePBC == epbcXY) + { + npbcdim = 2; + } + else + { + npbcdim = 3; + } + + GCHECK(g); + /* This puts everything in the central box, that is does not move it + * at all. If we return without doing this for a system without bonds + * (i.e. only settles) all water molecules are moved to the opposite octant + */ + for (i = g->at0; (i < g->at1); i++) + { + g->ishift[i][XX] = g->ishift[i][YY] = g->ishift[i][ZZ] = 0; + } + + if (!g->nbound) + { + return; + } + + nnodes = g->nnodes; + if (nnodes > g->negc) + { + g->negc = nnodes; + srenew(g->egc, g->negc); + } + memset(g->egc, 0, (size_t)(nnodes*sizeof(g->egc[0]))); + + nW = g->nbound; + nG = 0; + nB = 0; + + fW = 0; + + /* We even have a loop invariant: + * nW+nG+nB == g->nbound + */ #ifdef DEBUG2 - fprintf(log,"Starting W loop\n"); + fprintf(log, "Starting W loop\n"); #endif - while (nW > 0) { - /* Find the first white, this will allways be a larger - * number than before, because no nodes are made white - * in the loop - */ - if ((fW=first_colour(fW,egcolWhite,g,g->egc)) == -1) - gmx_fatal(FARGS,"No WHITE nodes found while nW=%d\n",nW); - - /* Make the first white node grey */ - g->egc[fW]=egcolGrey; - nG++; - nW--; - - /* Initial value for the first grey */ - fG=fW; + while (nW > 0) + { + /* Find the first white, this will allways be a larger + * number than before, because no nodes are made white + * in the loop + */ + if ((fW = first_colour(fW, egcolWhite, g, g->egc)) == -1) + { + gmx_fatal(FARGS, "No WHITE nodes found while nW=%d\n", nW); + } + + /* Make the first white node grey */ + g->egc[fW] = egcolGrey; + nG++; + nW--; + + /* Initial value for the first grey */ + fG = fW; #ifdef DEBUG2 - fprintf(log,"Starting G loop (nW=%d, nG=%d, nB=%d, total %d)\n", - nW,nG,nB,nW+nG+nB); + fprintf(log, "Starting G loop (nW=%d, nG=%d, nB=%d, total %d)\n", + nW, nG, nB, nW+nG+nB); #endif - while (nG > 0) { - if ((fG=first_colour(fG,egcolGrey,g,g->egc)) == -1) - gmx_fatal(FARGS,"No GREY nodes found while nG=%d\n",nG); - - /* Make the first grey node black */ - g->egc[fG]=egcolBlack; - nB++; - nG--; - - /* Make all the neighbours of this black node grey - * and set their periodicity - */ - ng=mk_grey(log,nnodes,g->egc,g,&fG,npbcdim,box,x,&nerror); - /* ng is the number of white nodes made grey */ - nG+=ng; - nW-=ng; - } - } - if (nerror > 0) { - nerror_tot++; - if (nerror_tot <= 100) { - fprintf(stderr,"There were %d inconsistent shifts. Check your topology\n", - nerror); - if (log) { - fprintf(log,"There were %d inconsistent shifts. Check your topology\n", - nerror); - } - } - if (nerror_tot == 100) { - fprintf(stderr,"Will stop reporting inconsistent shifts\n"); - if (log) { - fprintf(log,"Will stop reporting inconsistent shifts\n"); - } - } - } + while (nG > 0) + { + if ((fG = first_colour(fG, egcolGrey, g, g->egc)) == -1) + { + gmx_fatal(FARGS, "No GREY nodes found while nG=%d\n", nG); + } + + /* Make the first grey node black */ + g->egc[fG] = egcolBlack; + nB++; + nG--; + + /* Make all the neighbours of this black node grey + * and set their periodicity + */ + ng = mk_grey(log, nnodes, g->egc, g, &fG, npbcdim, box, x, &nerror); + /* ng is the number of white nodes made grey */ + nG += ng; + nW -= ng; + } + } + if (nerror > 0) + { + nerror_tot++; + if (nerror_tot <= 100) + { + fprintf(stderr, "There were %d inconsistent shifts. Check your topology\n", + nerror); + if (log) + { + fprintf(log, "There were %d inconsistent shifts. Check your topology\n", + nerror); + } + } + if (nerror_tot == 100) + { + fprintf(stderr, "Will stop reporting inconsistent shifts\n"); + if (log) + { + fprintf(log, "Will stop reporting inconsistent shifts\n"); + } + } + } } /************************************************************ @@ -700,181 +844,217 @@ void mk_mshift(FILE *log,t_graph *g,int ePBC,matrix box,rvec x[]) * ************************************************************/ -void shift_x(t_graph *g,matrix box,rvec x[],rvec x_s[]) +void shift_x(t_graph *g, matrix box, rvec x[], rvec x_s[]) { - ivec *is; - int g0,g1; - int j,tx,ty,tz; - - GCHECK(g); - g0 = g->at_start; - g1 = g->at_end; - is = g->ishift; - - for(j=g->at0; jbScrewPBC) { - for(j=g0; (j 0 && tx % 2 == 1) || - (tx < 0 && -tx %2 == 1)) { - x_s[j][XX] = x[j][XX] + tx*box[XX][XX]; - x_s[j][YY] = box[YY][YY] + box[ZZ][YY] - x[j][YY]; - x_s[j][ZZ] = box[ZZ][ZZ] - x[j][ZZ]; - } else { - x_s[j][XX] = x[j][XX]; - } - x_s[j][YY] = x[j][YY] + ty*box[YY][YY] + tz*box[ZZ][YY]; - x_s[j][ZZ] = x[j][ZZ] + tz*box[ZZ][ZZ]; - } - } else if (TRICLINIC(box)) { - for(j=g0; (jat1; j++) { - copy_rvec(x[j],x_s[j]); - } + ivec *is; + int g0, g1; + int j, tx, ty, tz; + + GCHECK(g); + g0 = g->at_start; + g1 = g->at_end; + is = g->ishift; + + for (j = g->at0; j < g0; j++) + { + copy_rvec(x[j], x_s[j]); + } + + if (g->bScrewPBC) + { + for (j = g0; (j < g1); j++) + { + tx = is[j][XX]; + ty = is[j][YY]; + tz = is[j][ZZ]; + + if ((tx > 0 && tx % 2 == 1) || + (tx < 0 && -tx %2 == 1)) + { + x_s[j][XX] = x[j][XX] + tx*box[XX][XX]; + x_s[j][YY] = box[YY][YY] + box[ZZ][YY] - x[j][YY]; + x_s[j][ZZ] = box[ZZ][ZZ] - x[j][ZZ]; + } + else + { + x_s[j][XX] = x[j][XX]; + } + x_s[j][YY] = x[j][YY] + ty*box[YY][YY] + tz*box[ZZ][YY]; + x_s[j][ZZ] = x[j][ZZ] + tz*box[ZZ][ZZ]; + } + } + else if (TRICLINIC(box)) + { + for (j = g0; (j < g1); j++) + { + tx = is[j][XX]; + ty = is[j][YY]; + tz = is[j][ZZ]; + + x_s[j][XX] = x[j][XX]+tx*box[XX][XX]+ty*box[YY][XX]+tz*box[ZZ][XX]; + x_s[j][YY] = x[j][YY]+ty*box[YY][YY]+tz*box[ZZ][YY]; + x_s[j][ZZ] = x[j][ZZ]+tz*box[ZZ][ZZ]; + } + } + else + { + for (j = g0; (j < g1); j++) + { + tx = is[j][XX]; + ty = is[j][YY]; + tz = is[j][ZZ]; + + x_s[j][XX] = x[j][XX]+tx*box[XX][XX]; + x_s[j][YY] = x[j][YY]+ty*box[YY][YY]; + x_s[j][ZZ] = x[j][ZZ]+tz*box[ZZ][ZZ]; + } + } + + for (j = g1; j < g->at1; j++) + { + copy_rvec(x[j], x_s[j]); + } } -void shift_self(t_graph *g,matrix box,rvec x[]) +void shift_self(t_graph *g, matrix box, rvec x[]) { - ivec *is; - int g0,g1; - int j,tx,ty,tz; + ivec *is; + int g0, g1; + int j, tx, ty, tz; - if (g->bScrewPBC) - gmx_incons("screw pbc not implemented for shift_self"); + if (g->bScrewPBC) + { + gmx_incons("screw pbc not implemented for shift_self"); + } - g0 = g->at_start; - g1 = g->at_end; - is = g->ishift; + g0 = g->at_start; + g1 = g->at_end; + is = g->ishift; #ifdef DEBUG - fprintf(stderr,"Shifting atoms %d to %d\n",g0,g0+gn); + fprintf(stderr, "Shifting atoms %d to %d\n", g0, g0+gn); #endif - if(TRICLINIC(box)) { - for(j=g0; (jbScrewPBC) - gmx_incons("screw pbc not implemented (yet) for unshift_x"); - - g0 = g->at_start; - g1 = g->at_end; - is = g->ishift; - - for(j=g->at0; jat1; j++) { - copy_rvec(x_s[j],x[j]); - } + ivec *is; + int g0, g1; + int j, tx, ty, tz; + + if (g->bScrewPBC) + { + gmx_incons("screw pbc not implemented (yet) for unshift_x"); + } + + g0 = g->at_start; + g1 = g->at_end; + is = g->ishift; + + for (j = g->at0; j < g0; j++) + { + copy_rvec(x_s[j], x[j]); + } + + if (TRICLINIC(box)) + { + for (j = g0; (j < g1); j++) + { + tx = is[j][XX]; + ty = is[j][YY]; + tz = is[j][ZZ]; + + x[j][XX] = x_s[j][XX]-tx*box[XX][XX]-ty*box[YY][XX]-tz*box[ZZ][XX]; + x[j][YY] = x_s[j][YY]-ty*box[YY][YY]-tz*box[ZZ][YY]; + x[j][ZZ] = x_s[j][ZZ]-tz*box[ZZ][ZZ]; + } + } + else + { + for (j = g0; (j < g1); j++) + { + tx = is[j][XX]; + ty = is[j][YY]; + tz = is[j][ZZ]; + + x[j][XX] = x_s[j][XX]-tx*box[XX][XX]; + x[j][YY] = x_s[j][YY]-ty*box[YY][YY]; + x[j][ZZ] = x_s[j][ZZ]-tz*box[ZZ][ZZ]; + } + } + + for (j = g1; j < g->at1; j++) + { + copy_rvec(x_s[j], x[j]); + } } -void unshift_self(t_graph *g,matrix box,rvec x[]) +void unshift_self(t_graph *g, matrix box, rvec x[]) { - ivec *is; - int g0,g1; - int j,tx,ty,tz; - - if (g->bScrewPBC) - gmx_incons("screw pbc not implemented for unshift_self"); - - g0 = g->at_start; - g1 = g->at_end; - is = g->ishift; - - if(TRICLINIC(box)) { - for(j=g0; (jbScrewPBC) + { + gmx_incons("screw pbc not implemented for unshift_self"); + } + + g0 = g->at_start; + g1 = g->at_end; + is = g->ishift; + + if (TRICLINIC(box)) + { + for (j = g0; (j < g1); j++) + { + tx = is[j][XX]; + ty = is[j][YY]; + tz = is[j][ZZ]; + + x[j][XX] = x[j][XX]-tx*box[XX][XX]-ty*box[YY][XX]-tz*box[ZZ][XX]; + x[j][YY] = x[j][YY]-ty*box[YY][YY]-tz*box[ZZ][YY]; + x[j][ZZ] = x[j][ZZ]-tz*box[ZZ][ZZ]; + } + } + else + { + for (j = g0; (j < g1); j++) + { + tx = is[j][XX]; + ty = is[j][YY]; + tz = is[j][ZZ]; + + x[j][XX] = x[j][XX]-tx*box[XX][XX]; + x[j][YY] = x[j][YY]-ty*box[YY][YY]; + x[j][ZZ] = x[j][ZZ]-tz*box[ZZ][ZZ]; + } + } } #undef GCHECK diff --git a/src/gromacs/gmxlib/mtop_util.c b/src/gromacs/gmxlib/mtop_util.c index bbae1df69c..6eeeacdc0b 100644 --- a/src/gromacs/gmxlib/mtop_util.c +++ b/src/gromacs/gmxlib/mtop_util.c @@ -1,6 +1,6 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This file is part of Gromacs Copyright (c) 1991-2008 * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen. * @@ -11,7 +11,7 @@ * * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org - * + * * And Hey: * Gnomes, ROck Monsters And Chili Sauce */ @@ -28,19 +28,19 @@ #include "symtab.h" #include "gmx_fatal.h" -static int gmx_mtop_maxresnr(const gmx_mtop_t *mtop,int maxres_renum) +static int gmx_mtop_maxresnr(const gmx_mtop_t *mtop, int maxres_renum) { - int maxresnr,mt,r; + int maxresnr, mt, r; const t_atoms *atoms; maxresnr = 0; - for(mt=0; mtnmoltype; mt++) + for (mt = 0; mt < mtop->nmoltype; mt++) { atoms = &mtop->moltype[mt].atoms; if (atoms->nres > maxres_renum) { - for(r=0; rnres; r++) + for (r = 0; r < atoms->nres; r++) { if (atoms->resinfo[r].nr > maxresnr) { @@ -58,11 +58,11 @@ void gmx_mtop_finalize(gmx_mtop_t *mtop) char *env; mtop->maxres_renum = 1; - + env = getenv("GMX_MAXRESRENUM"); if (env != NULL) { - sscanf(env,"%d",&mtop->maxres_renum); + sscanf(env, "%d", &mtop->maxres_renum); } if (mtop->maxres_renum == -1) { @@ -70,39 +70,39 @@ void gmx_mtop_finalize(gmx_mtop_t *mtop) mtop->maxres_renum = INT_MAX; } - mtop->maxresnr = gmx_mtop_maxresnr(mtop,mtop->maxres_renum); + mtop->maxresnr = gmx_mtop_maxresnr(mtop, mtop->maxres_renum); } int ncg_mtop(const gmx_mtop_t *mtop) { int ncg; int mb; - + ncg = 0; - for(mb=0; mbnmolblock; mb++) + for (mb = 0; mb < mtop->nmolblock; mb++) { ncg += mtop->molblock[mb].nmol* mtop->moltype[mtop->molblock[mb].type].cgs.nr; } - + return ncg; } void gmx_mtop_remove_chargegroups(gmx_mtop_t *mtop) { - int mt; + int mt; t_block *cgs; - int i; + int i; - for(mt=0; mtnmoltype; mt++) + for (mt = 0; mt < mtop->nmoltype; mt++) { cgs = &mtop->moltype[mt].cgs; if (cgs->nr < mtop->moltype[mt].atoms.nr) { cgs->nr = mtop->moltype[mt].atoms.nr; - srenew(cgs->index,cgs->nr+1); - for(i=0; inr+1; i++) + srenew(cgs->index, cgs->nr+1); + for (i = 0; i < cgs->nr+1; i++) { cgs->index[i] = i; } @@ -121,9 +121,9 @@ typedef struct typedef struct gmx_mtop_atomlookup { const gmx_mtop_t *mtop; - int nmb; - int mb_start; - mb_at_t *mba; + int nmb; + int mb_start; + mb_at_t *mba; } t_gmx_mtop_atomlookup; @@ -131,18 +131,18 @@ gmx_mtop_atomlookup_t gmx_mtop_atomlookup_init(const gmx_mtop_t *mtop) { t_gmx_mtop_atomlookup *alook; - int mb; - int a_start,a_end,na,na_start=-1; + int mb; + int a_start, a_end, na, na_start = -1; - snew(alook,1); + snew(alook, 1); alook->mtop = mtop; alook->nmb = mtop->nmolblock; alook->mb_start = 0; - snew(alook->mba,alook->nmb); + snew(alook->mba, alook->nmb); a_start = 0; - for(mb=0; mbnmolblock; mb++) + for (mb = 0; mb < mtop->nmolblock; mb++) { na = mtop->molblock[mb].nmol*mtop->molblock[mb].natoms_mol; a_end = a_start + na; @@ -167,37 +167,37 @@ gmx_mtop_atomlookup_init(const gmx_mtop_t *mtop) gmx_mtop_atomlookup_t gmx_mtop_atomlookup_settle_init(const gmx_mtop_t *mtop) { - t_gmx_mtop_atomlookup *alook; - int mb; - int na,na_start=-1; - - alook = gmx_mtop_atomlookup_init(mtop); - - /* Check if the starting molblock has settle */ - if (mtop->moltype[mtop->molblock[alook->mb_start].type].ilist[F_SETTLE].nr == 0) - { - /* Search the largest molblock with settle */ - alook->mb_start = -1; - for(mb=0; mbnmolblock; mb++) - { - if (mtop->moltype[mtop->molblock[mb].type].ilist[F_SETTLE].nr > 0) - { - na = alook->mba[mb].a_end - alook->mba[mb].a_start; - if (alook->mb_start == -1 || na > na_start) - { - alook->mb_start = mb; - na_start = na; - } - } - } - - if (alook->mb_start == -1) - { - gmx_incons("gmx_mtop_atomlookup_settle_init called without settles"); - } - } - - return alook; + t_gmx_mtop_atomlookup *alook; + int mb; + int na, na_start = -1; + + alook = gmx_mtop_atomlookup_init(mtop); + + /* Check if the starting molblock has settle */ + if (mtop->moltype[mtop->molblock[alook->mb_start].type].ilist[F_SETTLE].nr == 0) + { + /* Search the largest molblock with settle */ + alook->mb_start = -1; + for (mb = 0; mb < mtop->nmolblock; mb++) + { + if (mtop->moltype[mtop->molblock[mb].type].ilist[F_SETTLE].nr > 0) + { + na = alook->mba[mb].a_end - alook->mba[mb].a_start; + if (alook->mb_start == -1 || na > na_start) + { + alook->mb_start = mb; + na_start = na; + } + } + } + + if (alook->mb_start == -1) + { + gmx_incons("gmx_mtop_atomlookup_settle_init called without settles"); + } + } + + return alook; } void @@ -208,24 +208,24 @@ gmx_mtop_atomlookup_destroy(gmx_mtop_atomlookup_t alook) } void gmx_mtop_atomnr_to_atom(const gmx_mtop_atomlookup_t alook, - int atnr_global, - t_atom **atom) + int atnr_global, + t_atom **atom) { - int mb0,mb1,mb; - int a_start,atnr_mol; + int mb0, mb1, mb; + int a_start, atnr_mol; #ifdef DEBUG_MTOP if (atnr_global < 0 || atnr_global >= mtop->natoms) { - gmx_fatal(FARGS,"gmx_mtop_atomnr_to_moltype was called with atnr_global=%d which is not in the atom range of this system (%d-%d)", - atnr_global,0,mtop->natoms-1); + gmx_fatal(FARGS, "gmx_mtop_atomnr_to_moltype was called with atnr_global=%d which is not in the atom range of this system (%d-%d)", + atnr_global, 0, mtop->natoms-1); } #endif mb0 = -1; mb1 = alook->nmb; mb = alook->mb_start; - + while (TRUE) { a_start = alook->mba[mb].a_start; @@ -243,7 +243,7 @@ void gmx_mtop_atomnr_to_atom(const gmx_mtop_atomlookup_t alook, } mb = ((mb0 + mb1 + 1)>>1); } - + atnr_mol = (atnr_global - a_start) % alook->mba[mb].na_mol; *atom = &alook->mtop->moltype[alook->mtop->molblock[mb].type].atoms.atom[atnr_mol]; @@ -251,23 +251,23 @@ void gmx_mtop_atomnr_to_atom(const gmx_mtop_atomlookup_t alook, void gmx_mtop_atomnr_to_ilist(const gmx_mtop_atomlookup_t alook, int atnr_global, - t_ilist **ilist_mol,int *atnr_offset) + t_ilist **ilist_mol, int *atnr_offset) { - int mb0,mb1,mb; - int a_start,atnr_local; + int mb0, mb1, mb; + int a_start, atnr_local; #ifdef DEBUG_MTOP if (atnr_global < 0 || atnr_global >= mtop->natoms) { - gmx_fatal(FARGS,"gmx_mtop_atomnr_to_moltype was called with atnr_global=%d which is not in the atom range of this system (%d-%d)", - atnr_global,0,mtop->natoms-1); + gmx_fatal(FARGS, "gmx_mtop_atomnr_to_moltype was called with atnr_global=%d which is not in the atom range of this system (%d-%d)", + atnr_global, 0, mtop->natoms-1); } #endif mb0 = -1; mb1 = alook->nmb; mb = alook->mb_start; - + while (TRUE) { a_start = alook->mba[mb].a_start; @@ -287,7 +287,7 @@ void gmx_mtop_atomnr_to_ilist(const gmx_mtop_atomlookup_t alook, } *ilist_mol = alook->mtop->moltype[alook->mtop->molblock[mb].type].ilist; - + atnr_local = (atnr_global - a_start) % alook->mba[mb].na_mol; *atnr_offset = atnr_global - atnr_local; @@ -295,23 +295,23 @@ void gmx_mtop_atomnr_to_ilist(const gmx_mtop_atomlookup_t alook, void gmx_mtop_atomnr_to_molblock_ind(const gmx_mtop_atomlookup_t alook, int atnr_global, - int *molb,int *molnr,int *atnr_mol) + int *molb, int *molnr, int *atnr_mol) { - int mb0,mb1,mb; + int mb0, mb1, mb; int a_start; #ifdef DEBUG_MTOP if (atnr_global < 0 || atnr_global >= mtop->natoms) { - gmx_fatal(FARGS,"gmx_mtop_atomnr_to_moltype was called with atnr_global=%d which is not in the atom range of this system (%d-%d)", - atnr_global,0,mtop->natoms-1); + gmx_fatal(FARGS, "gmx_mtop_atomnr_to_moltype was called with atnr_global=%d which is not in the atom range of this system (%d-%d)", + atnr_global, 0, mtop->natoms-1); } #endif mb0 = -1; mb1 = alook->nmb; mb = alook->mb_start; - + while (TRUE) { a_start = alook->mba[mb].a_start; @@ -330,26 +330,26 @@ void gmx_mtop_atomnr_to_molblock_ind(const gmx_mtop_atomlookup_t alook, mb = ((mb0 + mb1 + 1)>>1); } - *molb = mb; - *molnr = (atnr_global - a_start) / alook->mba[mb].na_mol; + *molb = mb; + *molnr = (atnr_global - a_start) / alook->mba[mb].na_mol; *atnr_mol = atnr_global - a_start - (*molnr)*alook->mba[mb].na_mol; } -void gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global, - char **atomname,int *resnr,char **resname) +void gmx_mtop_atominfo_global(const gmx_mtop_t *mtop, int atnr_global, + char **atomname, int *resnr, char **resname) { - int mb,a_start,a_end,maxresnr,at_loc; + int mb, a_start, a_end, maxresnr, at_loc; gmx_molblock_t *molb; - t_atoms *atoms=NULL; - + t_atoms *atoms = NULL; + if (atnr_global < 0 || atnr_global >= mtop->natoms) { - gmx_fatal(FARGS,"gmx_mtop_atominfo_global was called with atnr_global=%d which is not in the atom range of this system (%d-%d)", - atnr_global,0,mtop->natoms-1); + gmx_fatal(FARGS, "gmx_mtop_atominfo_global was called with atnr_global=%d which is not in the atom range of this system (%d-%d)", + atnr_global, 0, mtop->natoms-1); } - - mb = -1; - a_end = 0; + + mb = -1; + a_end = 0; maxresnr = mtop->maxresnr; do { @@ -362,13 +362,13 @@ void gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global, } } mb++; - atoms = &mtop->moltype[mtop->molblock[mb].type].atoms; + atoms = &mtop->moltype[mtop->molblock[mb].type].atoms; a_start = a_end; - a_end = a_start + mtop->molblock[mb].nmol*atoms->nr; + a_end = a_start + mtop->molblock[mb].nmol*atoms->nr; } while (atnr_global >= a_end); - at_loc = (atnr_global - a_start) % atoms->nr; + at_loc = (atnr_global - a_start) % atoms->nr; *atomname = *(atoms->atomname[at_loc]); if (atoms->nres > mtop->maxres_renum) { @@ -385,12 +385,12 @@ void gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global, typedef struct gmx_mtop_atomloop_all { const gmx_mtop_t *mtop; - int mblock; - t_atoms *atoms; - int mol; - int maxresnr; - int at_local; - int at_global; + int mblock; + t_atoms *atoms; + int mol; + int maxresnr; + int at_local; + int at_global; } t_gmx_mtop_atomloop_all; gmx_mtop_atomloop_all_t @@ -398,7 +398,7 @@ gmx_mtop_atomloop_all_init(const gmx_mtop_t *mtop) { struct gmx_mtop_atomloop_all *aloop; - snew(aloop,1); + snew(aloop, 1); aloop->mtop = mtop; aloop->mblock = 0; @@ -418,7 +418,7 @@ static void gmx_mtop_atomloop_all_destroy(gmx_mtop_atomloop_all_t aloop) } gmx_bool gmx_mtop_atomloop_all_next(gmx_mtop_atomloop_all_t aloop, - int *at_global,t_atom **atom) + int *at_global, t_atom **atom) { if (aloop == NULL) { @@ -446,7 +446,7 @@ gmx_bool gmx_mtop_atomloop_all_next(gmx_mtop_atomloop_all_t aloop, return FALSE; } aloop->atoms = &aloop->mtop->moltype[aloop->mtop->molblock[aloop->mblock].type].atoms; - aloop->mol = 0; + aloop->mol = 0; } } @@ -457,13 +457,13 @@ gmx_bool gmx_mtop_atomloop_all_next(gmx_mtop_atomloop_all_t aloop, } void gmx_mtop_atomloop_all_names(gmx_mtop_atomloop_all_t aloop, - char **atomname,int *resnr,char **resname) + char **atomname, int *resnr, char **resname) { int resind_mol; - *atomname = *(aloop->atoms->atomname[aloop->at_local]); + *atomname = *(aloop->atoms->atomname[aloop->at_local]); resind_mol = aloop->atoms->atom[aloop->at_local].resind; - *resnr = aloop->atoms->resinfo[resind_mol].nr; + *resnr = aloop->atoms->resinfo[resind_mol].nr; if (aloop->atoms->nres <= aloop->mtop->maxres_renum) { *resnr = aloop->maxresnr + 1 + resind_mol; @@ -472,7 +472,7 @@ void gmx_mtop_atomloop_all_names(gmx_mtop_atomloop_all_t aloop, } void gmx_mtop_atomloop_all_moltype(gmx_mtop_atomloop_all_t aloop, - gmx_moltype_t **moltype,int *at_mol) + gmx_moltype_t **moltype, int *at_mol) { *moltype = &aloop->mtop->moltype[aloop->mtop->molblock[aloop->mblock].type]; *at_mol = aloop->at_local; @@ -481,9 +481,9 @@ void gmx_mtop_atomloop_all_moltype(gmx_mtop_atomloop_all_t aloop, typedef struct gmx_mtop_atomloop_block { const gmx_mtop_t *mtop; - int mblock; - t_atoms *atoms; - int at_local; + int mblock; + t_atoms *atoms; + int at_local; } t_gmx_mtop_atomloop_block; gmx_mtop_atomloop_block_t @@ -491,7 +491,7 @@ gmx_mtop_atomloop_block_init(const gmx_mtop_t *mtop) { struct gmx_mtop_atomloop_block *aloop; - snew(aloop,1); + snew(aloop, 1); aloop->mtop = mtop; aloop->mblock = 0; @@ -507,7 +507,7 @@ static void gmx_mtop_atomloop_block_destroy(gmx_mtop_atomloop_block_t aloop) } gmx_bool gmx_mtop_atomloop_block_next(gmx_mtop_atomloop_block_t aloop, - t_atom **atom,int *nmol) + t_atom **atom, int *nmol) { if (aloop == NULL) { @@ -524,20 +524,20 @@ gmx_bool gmx_mtop_atomloop_block_next(gmx_mtop_atomloop_block_t aloop, gmx_mtop_atomloop_block_destroy(aloop); return FALSE; } - aloop->atoms = &aloop->mtop->moltype[aloop->mtop->molblock[aloop->mblock].type].atoms; + aloop->atoms = &aloop->mtop->moltype[aloop->mtop->molblock[aloop->mblock].type].atoms; aloop->at_local = 0; } - + *atom = &aloop->atoms->atom[aloop->at_local]; *nmol = aloop->mtop->molblock[aloop->mblock].nmol; - + return TRUE; } typedef struct gmx_mtop_ilistloop { const gmx_mtop_t *mtop; - int mblock; + int mblock; } t_gmx_mtop_ilist; gmx_mtop_ilistloop_t @@ -545,7 +545,7 @@ gmx_mtop_ilistloop_init(const gmx_mtop_t *mtop) { struct gmx_mtop_ilistloop *iloop; - snew(iloop,1); + snew(iloop, 1); iloop->mtop = mtop; iloop->mblock = -1; @@ -559,7 +559,7 @@ static void gmx_mtop_ilistloop_destroy(gmx_mtop_ilistloop_t iloop) } gmx_bool gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop, - t_ilist **ilist_mol,int *nmol) + t_ilist **ilist_mol, int *nmol) { if (iloop == NULL) { @@ -583,9 +583,9 @@ gmx_bool gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop, typedef struct gmx_mtop_ilistloop_all { const gmx_mtop_t *mtop; - int mblock; - int mol; - int a_offset; + int mblock; + int mol; + int a_offset; } t_gmx_mtop_ilist_all; gmx_mtop_ilistloop_all_t @@ -593,7 +593,7 @@ gmx_mtop_ilistloop_all_init(const gmx_mtop_t *mtop) { struct gmx_mtop_ilistloop_all *iloop; - snew(iloop,1); + snew(iloop, 1); iloop->mtop = mtop; iloop->mblock = 0; @@ -609,7 +609,7 @@ static void gmx_mtop_ilistloop_all_destroy(gmx_mtop_ilistloop_all_t iloop) } gmx_bool gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop, - t_ilist **ilist_mol,int *atnr_offset) + t_ilist **ilist_mol, int *atnr_offset) { gmx_molblock_t *molb; @@ -617,7 +617,7 @@ gmx_bool gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop, { gmx_incons("gmx_mtop_ilistloop_all_next called without calling gmx_mtop_ilistloop_all_init"); } - + if (iloop->mol >= 0) { iloop->a_offset += iloop->mtop->molblock[iloop->mblock].natoms_mol; @@ -625,7 +625,8 @@ gmx_bool gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop, iloop->mol++; - if (iloop->mol >= iloop->mtop->molblock[iloop->mblock].nmol) { + if (iloop->mol >= iloop->mtop->molblock[iloop->mblock].nmol) + { iloop->mblock++; iloop->mol = 0; if (iloop->mblock == iloop->mtop->nmolblock) @@ -634,7 +635,7 @@ gmx_bool gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop, return FALSE; } } - + *ilist_mol = iloop->mtop->moltype[iloop->mtop->molblock[iloop->mblock].type].ilist; @@ -643,16 +644,16 @@ gmx_bool gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop, return TRUE; } -int gmx_mtop_ftype_count(const gmx_mtop_t *mtop,int ftype) +int gmx_mtop_ftype_count(const gmx_mtop_t *mtop, int ftype) { gmx_mtop_ilistloop_t iloop; - t_ilist *il; - int n,nmol; + t_ilist *il; + int n, nmol; n = 0; iloop = gmx_mtop_ilistloop_init(mtop); - while (gmx_mtop_ilistloop_next(iloop,&il,&nmol)) + while (gmx_mtop_ilistloop_next(iloop, &il, &nmol)) { n += nmol*il[ftype].nr/(1+NRAL(ftype)); } @@ -662,23 +663,23 @@ int gmx_mtop_ftype_count(const gmx_mtop_t *mtop,int ftype) t_block gmx_mtop_global_cgs(const gmx_mtop_t *mtop) { - t_block cgs_gl,*cgs_mol; - int mb,mol,cg; + t_block cgs_gl, *cgs_mol; + int mb, mol, cg; gmx_molblock_t *molb; - t_atoms *atoms; - + t_atoms *atoms; + /* In most cases this is too much, but we realloc at the end */ - snew(cgs_gl.index,mtop->natoms+1); - + snew(cgs_gl.index, mtop->natoms+1); + cgs_gl.nr = 0; cgs_gl.index[0] = 0; - for(mb=0; mbnmolblock; mb++) + for (mb = 0; mb < mtop->nmolblock; mb++) { molb = &mtop->molblock[mb]; cgs_mol = &mtop->moltype[molb->type].cgs; - for(mol=0; molnmol; mol++) + for (mol = 0; mol < molb->nmol; mol++) { - for(cg=0; cgnr; cg++) + for (cg = 0; cg < cgs_mol->nr; cg++) { cgs_gl.index[cgs_gl.nr+1] = cgs_gl.index[cgs_gl.nr] + @@ -688,7 +689,7 @@ t_block gmx_mtop_global_cgs(const gmx_mtop_t *mtop) } } cgs_gl.nalloc_index = cgs_gl.nr + 1; - srenew(cgs_gl.index,cgs_gl.nalloc_index); + srenew(cgs_gl.index, cgs_gl.nalloc_index); return cgs_gl; } @@ -696,103 +697,103 @@ t_block gmx_mtop_global_cgs(const gmx_mtop_t *mtop) static void atomcat(t_atoms *dest, t_atoms *src, int copies, int maxres_renum, int *maxresnr) { - int i,j,l,size; - int srcnr=src->nr; - int destnr=dest->nr; + int i, j, l, size; + int srcnr = src->nr; + int destnr = dest->nr; if (srcnr) { - size=destnr+copies*srcnr; - srenew(dest->atom,size); - srenew(dest->atomname,size); - srenew(dest->atomtype,size); - srenew(dest->atomtypeB,size); + size = destnr+copies*srcnr; + srenew(dest->atom, size); + srenew(dest->atomname, size); + srenew(dest->atomtype, size); + srenew(dest->atomtypeB, size); } if (src->nres) { - size=dest->nres+copies*src->nres; - srenew(dest->resinfo,size); + size = dest->nres+copies*src->nres; + srenew(dest->resinfo, size); } - + /* residue information */ - for (l=dest->nres,j=0; (jnres) + for (l = dest->nres, j = 0; (j < copies); j++, l += src->nres) { - memcpy((char *) &(dest->resinfo[l]),(char *) &(src->resinfo[0]), + memcpy((char *) &(dest->resinfo[l]), (char *) &(src->resinfo[0]), (size_t)(src->nres*sizeof(src->resinfo[0]))); } - - for (l=destnr,j=0; (jatomname[l]),(char *) &(src->atomname[0]), + memcpy((char *) &(dest->atomname[l]), (char *) &(src->atomname[0]), (size_t)(srcnr*sizeof(src->atomname[0]))); - memcpy((char *) &(dest->atomtype[l]),(char *) &(src->atomtype[0]), + memcpy((char *) &(dest->atomtype[l]), (char *) &(src->atomtype[0]), (size_t)(srcnr*sizeof(src->atomtype[0]))); - memcpy((char *) &(dest->atomtypeB[l]),(char *) &(src->atomtypeB[0]), + memcpy((char *) &(dest->atomtypeB[l]), (char *) &(src->atomtypeB[0]), (size_t)(srcnr*sizeof(src->atomtypeB[0]))); - memcpy((char *) &(dest->atom[l]),(char *) &(src->atom[0]), + memcpy((char *) &(dest->atom[l]), (char *) &(src->atom[0]), (size_t)(srcnr*sizeof(src->atom[0]))); } - + /* Increment residue indices */ - for (l=destnr,j=0; (jatom[l].resind = dest->nres+j*src->nres+src->atom[i].resind; } - } - + } + if (src->nres <= maxres_renum) { /* Single residue molecule, continue counting residues */ - for (j=0; (jnres; l++) + for (l = 0; l < src->nres; l++) { (*maxresnr)++; dest->resinfo[dest->nres+j*src->nres+l].nr = *maxresnr; } } } - + dest->nres += copies*src->nres; dest->nr += copies*src->nr; } t_atoms gmx_mtop_global_atoms(const gmx_mtop_t *mtop) { - t_atoms atoms; - int maxresnr,mb; + t_atoms atoms; + int maxresnr, mb; gmx_molblock_t *molb; - init_t_atoms(&atoms,0,FALSE); + init_t_atoms(&atoms, 0, FALSE); maxresnr = mtop->maxresnr; - for(mb=0; mbnmolblock; mb++) + for (mb = 0; mb < mtop->nmolblock; mb++) { molb = &mtop->molblock[mb]; - atomcat(&atoms,&mtop->moltype[molb->type].atoms,molb->nmol, - mtop->maxres_renum,&maxresnr); + atomcat(&atoms, &mtop->moltype[molb->type].atoms, molb->nmol, + mtop->maxres_renum, &maxresnr); } - + return atoms; } void gmx_mtop_make_atomic_charge_groups(gmx_mtop_t *mtop, - gmx_bool bKeepSingleMolCG) + gmx_bool bKeepSingleMolCG) { - int mb,cg; + int mb, cg; t_block *cgs_mol; - - for(mb=0; mbnmolblock; mb++) + + for (mb = 0; mb < mtop->nmolblock; mb++) { cgs_mol = &mtop->moltype[mtop->molblock[mb].type].cgs; if (!(bKeepSingleMolCG && cgs_mol->nr == 1)) { cgs_mol->nr = mtop->molblock[mb].natoms_mol; cgs_mol->nalloc_index = cgs_mol->nr + 1; - srenew(cgs_mol->index,cgs_mol->nalloc_index); - for(cg=0; cgnr+1; cg++) + srenew(cgs_mol->index, cgs_mol->nalloc_index); + for (cg = 0; cg < cgs_mol->nr+1; cg++) { cgs_mol->index[cg] = cg; } @@ -802,86 +803,86 @@ void gmx_mtop_make_atomic_charge_groups(gmx_mtop_t *mtop, /* * The cat routines below are old code from src/kernel/topcat.c - */ + */ -static void blockcat(t_block *dest,t_block *src,int copies, - int dnum,int snum) +static void blockcat(t_block *dest, t_block *src, int copies, + int dnum, int snum) { - int i,j,l,nra,size; - + int i, j, l, nra, size; + if (src->nr) { - size=(dest->nr+copies*src->nr+1); - srenew(dest->index,size); + size = (dest->nr+copies*src->nr+1); + srenew(dest->index, size); } - + nra = dest->index[dest->nr]; - for (l=dest->nr,j=0; (jnr, j = 0; (j < copies); j++) { - for (i=0; (inr); i++) + for (i = 0; (i < src->nr); i++) { dest->index[l++] = nra + src->index[i]; } nra += src->index[src->nr]; } - dest->nr += copies*src->nr; + dest->nr += copies*src->nr; dest->index[dest->nr] = nra; } -static void blockacat(t_blocka *dest,t_blocka *src,int copies, - int dnum,int snum) +static void blockacat(t_blocka *dest, t_blocka *src, int copies, + int dnum, int snum) { - int i,j,l,size; + int i, j, l, size; int destnr = dest->nr; int destnra = dest->nra; - + if (src->nr) { - size=(dest->nr+copies*src->nr+1); - srenew(dest->index,size); + size = (dest->nr+copies*src->nr+1); + srenew(dest->index, size); } if (src->nra) { - size=(dest->nra+copies*src->nra); - srenew(dest->a,size); + size = (dest->nra+copies*src->nra); + srenew(dest->a, size); } - - for (l=destnr,j=0; (jnr); i++) + for (i = 0; (i < src->nr); i++) { dest->index[l++] = dest->nra+src->index[i]; } dest->nra += src->nra; } - for (l=destnra,j=0; (jnra); i++) + for (i = 0; (i < src->nra); i++) { dest->a[l++] = dnum+src->a[i]; } - dnum+=snum; + dnum += snum; dest->nr += src->nr; } dest->index[dest->nr] = dest->nra; } -static void ilistcat(int ftype,t_ilist *dest,t_ilist *src,int copies, - int dnum,int snum) +static void ilistcat(int ftype, t_ilist *dest, t_ilist *src, int copies, + int dnum, int snum) { - int nral,c,i,a; + int nral, c, i, a; nral = NRAL(ftype); dest->nalloc = dest->nr + copies*src->nr; - srenew(dest->iatoms,dest->nalloc); + srenew(dest->iatoms, dest->nalloc); - for(c=0; cnr; ) + for (i = 0; i < src->nr; ) { dest->iatoms[dest->nr++] = src->iatoms[i++]; - for(a=0; aiatoms[dest->nr++] = dnum + src->iatoms[i++]; } @@ -890,18 +891,18 @@ static void ilistcat(int ftype,t_ilist *dest,t_ilist *src,int copies, } } -static void set_posres_params(t_idef *idef,gmx_molblock_t *molb, - int i0,int a_offset) +static void set_posres_params(t_idef *idef, gmx_molblock_t *molb, + int i0, int a_offset) { - t_ilist *il; - int i1,i,a_molb; + t_ilist *il; + int i1, i, a_molb; t_iparams *ip; il = &idef->il[F_POSRES]; i1 = il->nr/2; idef->iparams_posres_nalloc = i1; - srenew(idef->iparams_posres,idef->iparams_posres_nalloc); - for(i=i0; iiparams_posres, idef->iparams_posres_nalloc); + for (i = i0; i < i1; i++) { ip = &idef->iparams_posres[i]; /* Copy the force constants */ @@ -931,18 +932,18 @@ static void set_posres_params(t_idef *idef,gmx_molblock_t *molb, } } -static void set_fbposres_params(t_idef *idef,gmx_molblock_t *molb, - int i0,int a_offset) +static void set_fbposres_params(t_idef *idef, gmx_molblock_t *molb, + int i0, int a_offset) { - t_ilist *il; - int i1,i,a_molb; + t_ilist *il; + int i1, i, a_molb; t_iparams *ip; il = &idef->il[F_FBPOSRES]; i1 = il->nr/2; idef->iparams_fbposres_nalloc = i1; - srenew(idef->iparams_fbposres,idef->iparams_fbposres_nalloc); - for(i=i0; iiparams_fbposres, idef->iparams_fbposres_nalloc); + for (i = i0; i < i1; i++) { ip = &idef->iparams_fbposres[i]; /* Copy the force constants */ @@ -963,40 +964,40 @@ static void set_fbposres_params(t_idef *idef,gmx_molblock_t *molb, } } -static void gen_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir, +static void gen_local_top(const gmx_mtop_t *mtop, const t_inputrec *ir, gmx_bool bMergeConstr, gmx_localtop_t *top) { - int mb,srcnr,destnr,ftype,ftype_dest,mt,natoms,mol,nposre_old,nfbposre_old; - gmx_molblock_t *molb; - gmx_moltype_t *molt; - const gmx_ffparams_t *ffp; - t_idef *idef; - real *qA,*qB; + int mb, srcnr, destnr, ftype, ftype_dest, mt, natoms, mol, nposre_old, nfbposre_old; + gmx_molblock_t *molb; + gmx_moltype_t *molt; + const gmx_ffparams_t *ffp; + t_idef *idef; + real *qA, *qB; gmx_mtop_atomloop_all_t aloop; - int ag; - t_atom *atom; + int ag; + t_atom *atom; top->atomtypes = mtop->atomtypes; - + ffp = &mtop->ffparams; - - idef = &top->idef; - idef->ntypes = ffp->ntypes; - idef->atnr = ffp->atnr; - idef->functype = ffp->functype; - idef->iparams = ffp->iparams; - idef->iparams_posres = NULL; - idef->iparams_posres_nalloc = 0; - idef->iparams_fbposres = NULL; + + idef = &top->idef; + idef->ntypes = ffp->ntypes; + idef->atnr = ffp->atnr; + idef->functype = ffp->functype; + idef->iparams = ffp->iparams; + idef->iparams_posres = NULL; + idef->iparams_posres_nalloc = 0; + idef->iparams_fbposres = NULL; idef->iparams_fbposres_nalloc = 0; - idef->fudgeQQ = ffp->fudgeQQ; - idef->cmap_grid = ffp->cmap_grid; - idef->ilsort = ilsortUNKNOWN; + idef->fudgeQQ = ffp->fudgeQQ; + idef->cmap_grid = ffp->cmap_grid; + idef->ilsort = ilsortUNKNOWN; init_block(&top->cgs); init_blocka(&top->excls); - for(ftype=0; ftypeil[ftype].nr = 0; idef->il[ftype].nalloc = 0; @@ -1004,21 +1005,21 @@ static void gen_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir, } natoms = 0; - for(mb=0; mbnmolblock; mb++) + for (mb = 0; mb < mtop->nmolblock; mb++) { molb = &mtop->molblock[mb]; molt = &mtop->moltype[molb->type]; - + srcnr = molt->atoms.nr; destnr = natoms; - - blockcat(&top->cgs,&molt->cgs,molb->nmol,destnr,srcnr); - blockacat(&top->excls,&molt->excls,molb->nmol,destnr,srcnr); + blockcat(&top->cgs, &molt->cgs, molb->nmol, destnr, srcnr); + + blockacat(&top->excls, &molt->excls, molb->nmol, destnr, srcnr); - nposre_old = idef->il[F_POSRES].nr; + nposre_old = idef->il[F_POSRES].nr; nfbposre_old = idef->il[F_FBPOSRES].nr; - for(ftype=0; ftypeilist[F_CONSTRNC].nr > 0) @@ -1026,28 +1027,29 @@ static void gen_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir, /* Merge all constrains into one ilist. * This simplifies the constraint code. */ - for(mol=0; molnmol; mol++) { - ilistcat(ftype,&idef->il[F_CONSTR],&molt->ilist[F_CONSTR], - 1,destnr+mol*srcnr,srcnr); - ilistcat(ftype,&idef->il[F_CONSTR],&molt->ilist[F_CONSTRNC], - 1,destnr+mol*srcnr,srcnr); + for (mol = 0; mol < molb->nmol; mol++) + { + ilistcat(ftype, &idef->il[F_CONSTR], &molt->ilist[F_CONSTR], + 1, destnr+mol*srcnr, srcnr); + ilistcat(ftype, &idef->il[F_CONSTR], &molt->ilist[F_CONSTRNC], + 1, destnr+mol*srcnr, srcnr); } } else if (!(bMergeConstr && ftype == F_CONSTRNC)) { - ilistcat(ftype,&idef->il[ftype],&molt->ilist[ftype], - molb->nmol,destnr,srcnr); + ilistcat(ftype, &idef->il[ftype], &molt->ilist[ftype], + molb->nmol, destnr, srcnr); } } if (idef->il[F_POSRES].nr > nposre_old) { /* Executing this line line stops gmxdump -sys working * correctly. I'm not aware there's an elegant fix. */ - set_posres_params(idef,molb,nposre_old/2,natoms); + set_posres_params(idef, molb, nposre_old/2, natoms); } if (idef->il[F_FBPOSRES].nr > nfbposre_old) { - set_fbposres_params(idef,molb,nfbposre_old/2,natoms); + set_fbposres_params(idef, molb, nfbposre_old/2, natoms); } natoms += molb->nmol*srcnr; @@ -1061,15 +1063,15 @@ static void gen_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir, { if (ir->efep != efepNO && gmx_mtop_bondeds_free_energy(mtop)) { - snew(qA,mtop->natoms); - snew(qB,mtop->natoms); + snew(qA, mtop->natoms); + snew(qB, mtop->natoms); aloop = gmx_mtop_atomloop_all_init(mtop); - while (gmx_mtop_atomloop_all_next(aloop,&ag,&atom)) + while (gmx_mtop_atomloop_all_next(aloop, &ag, &atom)) { qA[ag] = atom->q; qB[ag] = atom->qB; } - gmx_sort_ilist_fe(&top->idef,qA,qB); + gmx_sort_ilist_fe(&top->idef, qA, qB); sfree(qA); sfree(qB); } @@ -1085,20 +1087,20 @@ gmx_localtop_t *gmx_mtop_generate_local_top(const gmx_mtop_t *mtop, { gmx_localtop_t *top; - snew(top,1); + snew(top, 1); - gen_local_top(mtop,ir,TRUE,top); + gen_local_top(mtop, ir, TRUE, top); return top; } t_topology gmx_mtop_t_to_t_topology(gmx_mtop_t *mtop) { - int mt,mb; + int mt, mb; gmx_localtop_t ltop; - t_topology top; + t_topology top; - gen_local_top(mtop,NULL,FALSE,<op); + gen_local_top(mtop, NULL, FALSE, <op); top.name = mtop->name; top.idef = ltop.idef; @@ -1115,13 +1117,13 @@ t_topology gmx_mtop_t_to_t_topology(gmx_mtop_t *mtop) * Well, except for the group data, but we can't free those, because they * are used somewhere even after a call to this function. */ - for(mt=0; mtnmoltype; mt++) + for (mt = 0; mt < mtop->nmoltype; mt++) { done_moltype(&mtop->moltype[mt]); } sfree(mtop->moltype); - for(mb=0; mbnmolblock; mb++) + for (mb = 0; mb < mtop->nmolblock; mb++) { done_molblock(&mtop->molblock[mb]); } diff --git a/src/gromacs/gmxlib/mvdata.c b/src/gromacs/gmxlib/mvdata.c index 30da1f11b6..80e3b2bd1b 100644 --- a/src/gromacs/gmxlib/mvdata.c +++ b/src/gromacs/gmxlib/mvdata.c @@ -1,11 +1,11 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -49,657 +49,749 @@ #include "vec.h" #include "tgroup.h" -#define block_bc(cr, d) gmx_bcast( sizeof(d), &(d),(cr)) +#define block_bc(cr, d) gmx_bcast( sizeof(d), &(d), (cr)) /* Probably the test for (nr) > 0 in the next macro is only needed * on BlueGene(/L), where IBM's MPI_Bcast will segfault after * dereferencing a null pointer, even when no data is to be transferred. */ -#define nblock_bc(cr,nr,d) { if ((nr) > 0) gmx_bcast((nr)*sizeof((d)[0]), (d),(cr)); } -#define snew_bc(cr,d,nr) { if (!MASTER(cr)) snew((d),(nr)); } +#define nblock_bc(cr, nr, d) { if ((nr) > 0) {gmx_bcast((nr)*sizeof((d)[0]), (d), (cr)); }} +#define snew_bc(cr, d, nr) { if (!MASTER(cr)) {snew((d), (nr)); }} /* Dirty macro with bAlloc not as an argument */ -#define nblock_abc(cr,nr,d) { if (bAlloc) snew((d),(nr)); nblock_bc(cr,(nr),(d)); } +#define nblock_abc(cr, nr, d) { if (bAlloc) {snew((d), (nr)); } nblock_bc(cr, (nr), (d)); } -static void bc_string(const t_commrec *cr,t_symtab *symtab,char ***s) +static void bc_string(const t_commrec *cr, t_symtab *symtab, char ***s) { - int handle; - - if (MASTER(cr)) { - handle = lookup_symtab(symtab,*s); - } - block_bc(cr,handle); - if (!MASTER(cr)) { - *s = get_symtab_handle(symtab,handle); - } + int handle; + + if (MASTER(cr)) + { + handle = lookup_symtab(symtab, *s); + } + block_bc(cr, handle); + if (!MASTER(cr)) + { + *s = get_symtab_handle(symtab, handle); + } } -static void bc_strings(const t_commrec *cr,t_symtab *symtab,int nr,char ****nm) +static void bc_strings(const t_commrec *cr, t_symtab *symtab, int nr, char ****nm) { - int i; - int *handle; - char ***NM; - - snew(handle,nr); - if (MASTER(cr)) { - NM = *nm; - for(i=0; (inr); - nr = symtab->nr; - snew_bc(cr,symtab->symbuf,1); - symbuf = symtab->symbuf; - symbuf->bufsize = nr; - snew_bc(cr,symbuf->buf,nr); - for (i=0; ibuf[i]) + 1; - block_bc(cr,len); - snew_bc(cr,symbuf->buf[i],len); - nblock_bc(cr,len,symbuf->buf[i]); - } + int i, nr, len; + t_symbuf *symbuf; + + block_bc(cr, symtab->nr); + nr = symtab->nr; + snew_bc(cr, symtab->symbuf, 1); + symbuf = symtab->symbuf; + symbuf->bufsize = nr; + snew_bc(cr, symbuf->buf, nr); + for (i = 0; i < nr; i++) + { + if (MASTER(cr)) + { + len = strlen(symbuf->buf[i]) + 1; + } + block_bc(cr, len); + snew_bc(cr, symbuf->buf[i], len); + nblock_bc(cr, len, symbuf->buf[i]); + } } -static void bc_block(const t_commrec *cr,t_block *block) +static void bc_block(const t_commrec *cr, t_block *block) { - block_bc(cr,block->nr); - snew_bc(cr,block->index,block->nr+1); - nblock_bc(cr,block->nr+1,block->index); + block_bc(cr, block->nr); + snew_bc(cr, block->index, block->nr+1); + nblock_bc(cr, block->nr+1, block->index); } -static void bc_blocka(const t_commrec *cr,t_blocka *block) +static void bc_blocka(const t_commrec *cr, t_blocka *block) { - block_bc(cr,block->nr); - snew_bc(cr,block->index,block->nr+1); - nblock_bc(cr,block->nr+1,block->index); - block_bc(cr,block->nra); - if (block->nra) { - snew_bc(cr,block->a,block->nra); - nblock_bc(cr,block->nra,block->a); - } + block_bc(cr, block->nr); + snew_bc(cr, block->index, block->nr+1); + nblock_bc(cr, block->nr+1, block->index); + block_bc(cr, block->nra); + if (block->nra) + { + snew_bc(cr, block->a, block->nra); + nblock_bc(cr, block->nra, block->a); + } } -static void bc_grps(const t_commrec *cr,t_grps grps[]) +static void bc_grps(const t_commrec *cr, t_grps grps[]) { - int i; - - for(i=0; (inr); - snew_bc(cr,atoms->atom,atoms->nr); - nblock_bc(cr,atoms->nr,atoms->atom); - bc_strings(cr,symtab,atoms->nr,&atoms->atomname); - block_bc(cr,atoms->nres); - snew_bc(cr,atoms->resinfo,atoms->nres); - nblock_bc(cr,atoms->nres,atoms->resinfo); - bc_strings_resinfo(cr,symtab,atoms->nres,atoms->resinfo); - /* QMMM requires atomtypes to be known on all nodes as well */ - bc_strings(cr,symtab,atoms->nr,&atoms->atomtype); - bc_strings(cr,symtab,atoms->nr,&atoms->atomtypeB); + int dummy; + + block_bc(cr, atoms->nr); + snew_bc(cr, atoms->atom, atoms->nr); + nblock_bc(cr, atoms->nr, atoms->atom); + bc_strings(cr, symtab, atoms->nr, &atoms->atomname); + block_bc(cr, atoms->nres); + snew_bc(cr, atoms->resinfo, atoms->nres); + nblock_bc(cr, atoms->nres, atoms->resinfo); + bc_strings_resinfo(cr, symtab, atoms->nres, atoms->resinfo); + /* QMMM requires atomtypes to be known on all nodes as well */ + bc_strings(cr, symtab, atoms->nr, &atoms->atomtype); + bc_strings(cr, symtab, atoms->nr, &atoms->atomtypeB); } -static void bc_groups(const t_commrec *cr,t_symtab *symtab, - int natoms,gmx_groups_t *groups) +static void bc_groups(const t_commrec *cr, t_symtab *symtab, + int natoms, gmx_groups_t *groups) { - int dummy; - int g,n; - - bc_grps(cr,groups->grps); - block_bc(cr,groups->ngrpname); - bc_strings(cr,symtab,groups->ngrpname,&groups->grpname); - for(g=0; ggrpnr[g]) { - n = natoms; - } else { - n = 0; - } - } - block_bc(cr,n); - if (n == 0) { - groups->grpnr[g] = NULL; - } else { - snew_bc(cr,groups->grpnr[g],n); - nblock_bc(cr,n,groups->grpnr[g]); - } - } - if (debug) fprintf(debug,"after bc_groups\n"); + int dummy; + int g, n; + + bc_grps(cr, groups->grps); + block_bc(cr, groups->ngrpname); + bc_strings(cr, symtab, groups->ngrpname, &groups->grpname); + for (g = 0; g < egcNR; g++) + { + if (MASTER(cr)) + { + if (groups->grpnr[g]) + { + n = natoms; + } + else + { + n = 0; + } + } + block_bc(cr, n); + if (n == 0) + { + groups->grpnr[g] = NULL; + } + else + { + snew_bc(cr, groups->grpnr[g], n); + nblock_bc(cr, n, groups->grpnr[g]); + } + } + if (debug) + { + fprintf(debug, "after bc_groups\n"); + } } -void bcast_state_setup(const t_commrec *cr,t_state *state) +void bcast_state_setup(const t_commrec *cr, t_state *state) { - block_bc(cr,state->natoms); - block_bc(cr,state->ngtc); - block_bc(cr,state->nnhpres); - block_bc(cr,state->nhchainlength); - block_bc(cr,state->nrng); - block_bc(cr,state->nrngi); - block_bc(cr,state->flags); - if (state->lambda==NULL) - { - snew_bc(cr,state->lambda,efptNR) - } + block_bc(cr, state->natoms); + block_bc(cr, state->ngtc); + block_bc(cr, state->nnhpres); + block_bc(cr, state->nhchainlength); + block_bc(cr, state->nrng); + block_bc(cr, state->nrngi); + block_bc(cr, state->flags); + if (state->lambda == NULL) + { + snew_bc(cr, state->lambda, efptNR) + } } -void bcast_state(const t_commrec *cr,t_state *state,gmx_bool bAlloc) +void bcast_state(const t_commrec *cr, t_state *state, gmx_bool bAlloc) { - int i,nnht,nnhtp; - - bcast_state_setup(cr,state); - - nnht = (state->ngtc)*(state->nhchainlength); - nnhtp = (state->nnhpres)*(state->nhchainlength); - - if (MASTER(cr)) { - bAlloc = FALSE; - } - if (bAlloc) { - state->nalloc = state->natoms; - } - for(i=0; iflags & (1<lambda); break; - case estFEPSTATE: block_bc(cr,state->fep_state); break; - case estBOX: block_bc(cr,state->box); break; - case estBOX_REL: block_bc(cr,state->box_rel); break; - case estBOXV: block_bc(cr,state->boxv); break; - case estPRES_PREV: block_bc(cr,state->pres_prev); break; - case estSVIR_PREV: block_bc(cr,state->svir_prev); break; - case estFVIR_PREV: block_bc(cr,state->fvir_prev); break; - case estNH_XI: nblock_abc(cr,nnht,state->nosehoover_xi); break; - case estNH_VXI: nblock_abc(cr,nnht,state->nosehoover_vxi); break; - case estNHPRES_XI: nblock_abc(cr,nnhtp,state->nhpres_xi); break; - case estNHPRES_VXI: nblock_abc(cr,nnhtp,state->nhpres_vxi); break; - case estTC_INT: nblock_abc(cr,state->ngtc,state->therm_integral); break; - case estVETA: block_bc(cr,state->veta); break; - case estVOL0: block_bc(cr,state->vol0); break; - case estX: nblock_abc(cr,state->natoms,state->x); break; - case estV: nblock_abc(cr,state->natoms,state->v); break; - case estSDX: nblock_abc(cr,state->natoms,state->sd_X); break; - case estCGP: nblock_abc(cr,state->natoms,state->cg_p); break; - case estLD_RNG: if(state->nrngi == 1) nblock_abc(cr,state->nrng,state->ld_rng); break; - case estLD_RNGI: if(state->nrngi == 1) nblock_abc(cr,state->nrngi,state->ld_rngi); break; - case estDISRE_INITF: block_bc(cr,state->hist.disre_initf); break; - case estDISRE_RM3TAV: - block_bc(cr,state->hist.ndisrepairs); - nblock_abc(cr,state->hist.ndisrepairs,state->hist.disre_rm3tav); - break; - case estORIRE_INITF: block_bc(cr,state->hist.orire_initf); break; - case estORIRE_DTAV: - block_bc(cr,state->hist.norire_Dtav); - nblock_abc(cr,state->hist.norire_Dtav,state->hist.orire_Dtav); - break; - default: - gmx_fatal(FARGS, - "Communication is not implemented for %s in bcast_state", - est_names[i]); - } - } - } + int i, nnht, nnhtp; + + bcast_state_setup(cr, state); + + nnht = (state->ngtc)*(state->nhchainlength); + nnhtp = (state->nnhpres)*(state->nhchainlength); + + if (MASTER(cr)) + { + bAlloc = FALSE; + } + if (bAlloc) + { + state->nalloc = state->natoms; + } + for (i = 0; i < estNR; i++) + { + if (state->flags & (1<lambda); break; + case estFEPSTATE: block_bc(cr, state->fep_state); break; + case estBOX: block_bc(cr, state->box); break; + case estBOX_REL: block_bc(cr, state->box_rel); break; + case estBOXV: block_bc(cr, state->boxv); break; + case estPRES_PREV: block_bc(cr, state->pres_prev); break; + case estSVIR_PREV: block_bc(cr, state->svir_prev); break; + case estFVIR_PREV: block_bc(cr, state->fvir_prev); break; + case estNH_XI: nblock_abc(cr, nnht, state->nosehoover_xi); break; + case estNH_VXI: nblock_abc(cr, nnht, state->nosehoover_vxi); break; + case estNHPRES_XI: nblock_abc(cr, nnhtp, state->nhpres_xi); break; + case estNHPRES_VXI: nblock_abc(cr, nnhtp, state->nhpres_vxi); break; + case estTC_INT: nblock_abc(cr, state->ngtc, state->therm_integral); break; + case estVETA: block_bc(cr, state->veta); break; + case estVOL0: block_bc(cr, state->vol0); break; + case estX: nblock_abc(cr, state->natoms, state->x); break; + case estV: nblock_abc(cr, state->natoms, state->v); break; + case estSDX: nblock_abc(cr, state->natoms, state->sd_X); break; + case estCGP: nblock_abc(cr, state->natoms, state->cg_p); break; + case estLD_RNG: if (state->nrngi == 1) + { + nblock_abc(cr, state->nrng, state->ld_rng); + } + break; + case estLD_RNGI: if (state->nrngi == 1) + { + nblock_abc(cr, state->nrngi, state->ld_rngi); + } + break; + case estDISRE_INITF: block_bc(cr, state->hist.disre_initf); break; + case estDISRE_RM3TAV: + block_bc(cr, state->hist.ndisrepairs); + nblock_abc(cr, state->hist.ndisrepairs, state->hist.disre_rm3tav); + break; + case estORIRE_INITF: block_bc(cr, state->hist.orire_initf); break; + case estORIRE_DTAV: + block_bc(cr, state->hist.norire_Dtav); + nblock_abc(cr, state->hist.norire_Dtav, state->hist.orire_Dtav); + break; + default: + gmx_fatal(FARGS, + "Communication is not implemented for %s in bcast_state", + est_names[i]); + } + } + } } -static void bc_ilists(const t_commrec *cr,t_ilist *ilist) +static void bc_ilists(const t_commrec *cr, t_ilist *ilist) { - int ftype; - - /* Here we only communicate the non-zero length ilists */ - if (MASTER(cr)) { - for(ftype=0; ftype 0) { - block_bc(cr,ftype); - block_bc(cr,ilist[ftype].nr); - nblock_bc(cr,ilist[ftype].nr,ilist[ftype].iatoms); - } - } - ftype = -1; - block_bc(cr,ftype); - } else { - for(ftype=0; ftype= 0) { - block_bc(cr,ilist[ftype].nr); - snew_bc(cr,ilist[ftype].iatoms,ilist[ftype].nr); - nblock_bc(cr,ilist[ftype].nr,ilist[ftype].iatoms); - } - } while (ftype >= 0); - } - - if (debug) fprintf(debug,"after bc_ilists\n"); + int ftype; + + /* Here we only communicate the non-zero length ilists */ + if (MASTER(cr)) + { + for (ftype = 0; ftype < F_NRE; ftype++) + { + if (ilist[ftype].nr > 0) + { + block_bc(cr, ftype); + block_bc(cr, ilist[ftype].nr); + nblock_bc(cr, ilist[ftype].nr, ilist[ftype].iatoms); + } + } + ftype = -1; + block_bc(cr, ftype); + } + else + { + for (ftype = 0; ftype < F_NRE; ftype++) + { + ilist[ftype].nr = 0; + } + do + { + block_bc(cr, ftype); + if (ftype >= 0) + { + block_bc(cr, ilist[ftype].nr); + snew_bc(cr, ilist[ftype].iatoms, ilist[ftype].nr); + nblock_bc(cr, ilist[ftype].nr, ilist[ftype].iatoms); + } + } + while (ftype >= 0); + } + + if (debug) + { + fprintf(debug, "after bc_ilists\n"); + } } static void bc_cmap(const t_commrec *cr, gmx_cmap_t *cmap_grid) { - int i,j,nelem,ngrid; - - block_bc(cr,cmap_grid->ngrid); - block_bc(cr,cmap_grid->grid_spacing); - - ngrid = cmap_grid->ngrid; - nelem = cmap_grid->grid_spacing * cmap_grid->grid_spacing; - - if(ngrid>0) - { - snew_bc(cr,cmap_grid->cmapdata,ngrid); - - for(i=0;icmapdata[i].cmap,4*nelem); - nblock_bc(cr,4*nelem,cmap_grid->cmapdata[i].cmap); - } - } + int i, j, nelem, ngrid; + + block_bc(cr, cmap_grid->ngrid); + block_bc(cr, cmap_grid->grid_spacing); + + ngrid = cmap_grid->ngrid; + nelem = cmap_grid->grid_spacing * cmap_grid->grid_spacing; + + if (ngrid > 0) + { + snew_bc(cr, cmap_grid->cmapdata, ngrid); + + for (i = 0; i < ngrid; i++) + { + snew_bc(cr, cmap_grid->cmapdata[i].cmap, 4*nelem); + nblock_bc(cr, 4*nelem, cmap_grid->cmapdata[i].cmap); + } + } } -static void bc_ffparams(const t_commrec *cr,gmx_ffparams_t *ffp) +static void bc_ffparams(const t_commrec *cr, gmx_ffparams_t *ffp) { - int i; - - block_bc(cr,ffp->ntypes); - block_bc(cr,ffp->atnr); - snew_bc(cr,ffp->functype,ffp->ntypes); - snew_bc(cr,ffp->iparams,ffp->ntypes); - nblock_bc(cr,ffp->ntypes,ffp->functype); - nblock_bc(cr,ffp->ntypes,ffp->iparams); - block_bc(cr,ffp->reppow); - block_bc(cr,ffp->fudgeQQ); - bc_cmap(cr,&ffp->cmap_grid); + int i; + + block_bc(cr, ffp->ntypes); + block_bc(cr, ffp->atnr); + snew_bc(cr, ffp->functype, ffp->ntypes); + snew_bc(cr, ffp->iparams, ffp->ntypes); + nblock_bc(cr, ffp->ntypes, ffp->functype); + nblock_bc(cr, ffp->ntypes, ffp->iparams); + block_bc(cr, ffp->reppow); + block_bc(cr, ffp->fudgeQQ); + bc_cmap(cr, &ffp->cmap_grid); } -static void bc_grpopts(const t_commrec *cr,t_grpopts *g) +static void bc_grpopts(const t_commrec *cr, t_grpopts *g) { - int i,n; - - block_bc(cr,g->ngtc); - block_bc(cr,g->ngacc); - block_bc(cr,g->ngfrz); - block_bc(cr,g->ngener); - snew_bc(cr,g->nrdf,g->ngtc); - snew_bc(cr,g->tau_t,g->ngtc); - snew_bc(cr,g->ref_t,g->ngtc); - snew_bc(cr,g->acc,g->ngacc); - snew_bc(cr,g->nFreeze,g->ngfrz); - snew_bc(cr,g->egp_flags,g->ngener*g->ngener); - - nblock_bc(cr,g->ngtc,g->nrdf); - nblock_bc(cr,g->ngtc,g->tau_t); - nblock_bc(cr,g->ngtc,g->ref_t); - nblock_bc(cr,g->ngacc,g->acc); - nblock_bc(cr,g->ngfrz,g->nFreeze); - nblock_bc(cr,g->ngener*g->ngener,g->egp_flags); - snew_bc(cr,g->annealing,g->ngtc); - snew_bc(cr,g->anneal_npoints,g->ngtc); - snew_bc(cr,g->anneal_time,g->ngtc); - snew_bc(cr,g->anneal_temp,g->ngtc); - nblock_bc(cr,g->ngtc,g->annealing); - nblock_bc(cr,g->ngtc,g->anneal_npoints); - for(i=0;(ingtc); i++) { + int i, n; + + block_bc(cr, g->ngtc); + block_bc(cr, g->ngacc); + block_bc(cr, g->ngfrz); + block_bc(cr, g->ngener); + snew_bc(cr, g->nrdf, g->ngtc); + snew_bc(cr, g->tau_t, g->ngtc); + snew_bc(cr, g->ref_t, g->ngtc); + snew_bc(cr, g->acc, g->ngacc); + snew_bc(cr, g->nFreeze, g->ngfrz); + snew_bc(cr, g->egp_flags, g->ngener*g->ngener); + + nblock_bc(cr, g->ngtc, g->nrdf); + nblock_bc(cr, g->ngtc, g->tau_t); + nblock_bc(cr, g->ngtc, g->ref_t); + nblock_bc(cr, g->ngacc, g->acc); + nblock_bc(cr, g->ngfrz, g->nFreeze); + nblock_bc(cr, g->ngener*g->ngener, g->egp_flags); + snew_bc(cr, g->annealing, g->ngtc); + snew_bc(cr, g->anneal_npoints, g->ngtc); + snew_bc(cr, g->anneal_time, g->ngtc); + snew_bc(cr, g->anneal_temp, g->ngtc); + nblock_bc(cr, g->ngtc, g->annealing); + nblock_bc(cr, g->ngtc, g->anneal_npoints); + for (i = 0; (i < g->ngtc); i++) + { n = g->anneal_npoints[i]; - if (n > 0) { - snew_bc(cr,g->anneal_time[i],n); - snew_bc(cr,g->anneal_temp[i],n); - nblock_bc(cr,n,g->anneal_time[i]); - nblock_bc(cr,n,g->anneal_temp[i]); + if (n > 0) + { + snew_bc(cr, g->anneal_time[i], n); + snew_bc(cr, g->anneal_temp[i], n); + nblock_bc(cr, n, g->anneal_time[i]); + nblock_bc(cr, n, g->anneal_temp[i]); } } - + /* QMMM stuff, see inputrec */ - block_bc(cr,g->ngQM); - snew_bc(cr,g->QMmethod,g->ngQM); - snew_bc(cr,g->QMbasis,g->ngQM); - snew_bc(cr,g->QMcharge,g->ngQM); - snew_bc(cr,g->QMmult,g->ngQM); - snew_bc(cr,g->bSH,g->ngQM); - snew_bc(cr,g->CASorbitals,g->ngQM); - snew_bc(cr,g->CASelectrons,g->ngQM); - snew_bc(cr,g->SAon,g->ngQM); - snew_bc(cr,g->SAoff,g->ngQM); - snew_bc(cr,g->SAsteps,g->ngQM); - + block_bc(cr, g->ngQM); + snew_bc(cr, g->QMmethod, g->ngQM); + snew_bc(cr, g->QMbasis, g->ngQM); + snew_bc(cr, g->QMcharge, g->ngQM); + snew_bc(cr, g->QMmult, g->ngQM); + snew_bc(cr, g->bSH, g->ngQM); + snew_bc(cr, g->CASorbitals, g->ngQM); + snew_bc(cr, g->CASelectrons, g->ngQM); + snew_bc(cr, g->SAon, g->ngQM); + snew_bc(cr, g->SAoff, g->ngQM); + snew_bc(cr, g->SAsteps, g->ngQM); + if (g->ngQM) { - nblock_bc(cr,g->ngQM,g->QMmethod); - nblock_bc(cr,g->ngQM,g->QMbasis); - nblock_bc(cr,g->ngQM,g->QMcharge); - nblock_bc(cr,g->ngQM,g->QMmult); - nblock_bc(cr,g->ngQM,g->bSH); - nblock_bc(cr,g->ngQM,g->CASorbitals); - nblock_bc(cr,g->ngQM,g->CASelectrons); - nblock_bc(cr,g->ngQM,g->SAon); - nblock_bc(cr,g->ngQM,g->SAoff); - nblock_bc(cr,g->ngQM,g->SAsteps); + nblock_bc(cr, g->ngQM, g->QMmethod); + nblock_bc(cr, g->ngQM, g->QMbasis); + nblock_bc(cr, g->ngQM, g->QMcharge); + nblock_bc(cr, g->ngQM, g->QMmult); + nblock_bc(cr, g->ngQM, g->bSH); + nblock_bc(cr, g->ngQM, g->CASorbitals); + nblock_bc(cr, g->ngQM, g->CASelectrons); + nblock_bc(cr, g->ngQM, g->SAon); + nblock_bc(cr, g->ngQM, g->SAoff); + nblock_bc(cr, g->ngQM, g->SAsteps); /* end of QMMM stuff */ } } -static void bc_cosines(const t_commrec *cr,t_cosines *cs) +static void bc_cosines(const t_commrec *cr, t_cosines *cs) { - block_bc(cr,cs->n); - snew_bc(cr,cs->a,cs->n); - snew_bc(cr,cs->phi,cs->n); - if (cs->n > 0) { - nblock_bc(cr,cs->n,cs->a); - nblock_bc(cr,cs->n,cs->phi); - } + block_bc(cr, cs->n); + snew_bc(cr, cs->a, cs->n); + snew_bc(cr, cs->phi, cs->n); + if (cs->n > 0) + { + nblock_bc(cr, cs->n, cs->a); + nblock_bc(cr, cs->n, cs->phi); + } } -static void bc_pullgrp(const t_commrec *cr,t_pullgrp *pgrp) +static void bc_pullgrp(const t_commrec *cr, t_pullgrp *pgrp) { - block_bc(cr,*pgrp); - if (pgrp->nat > 0) { - snew_bc(cr,pgrp->ind,pgrp->nat); - nblock_bc(cr,pgrp->nat,pgrp->ind); - } - if (pgrp->nweight > 0) { - snew_bc(cr,pgrp->weight,pgrp->nweight); - nblock_bc(cr,pgrp->nweight,pgrp->weight); - } + block_bc(cr, *pgrp); + if (pgrp->nat > 0) + { + snew_bc(cr, pgrp->ind, pgrp->nat); + nblock_bc(cr, pgrp->nat, pgrp->ind); + } + if (pgrp->nweight > 0) + { + snew_bc(cr, pgrp->weight, pgrp->nweight); + nblock_bc(cr, pgrp->nweight, pgrp->weight); + } } -static void bc_pull(const t_commrec *cr,t_pull *pull) +static void bc_pull(const t_commrec *cr, t_pull *pull) { - int g; - - block_bc(cr,*pull); - snew_bc(cr,pull->grp,pull->ngrp+1); - for(g=0; gngrp+1; g++) - { - bc_pullgrp(cr,&pull->grp[g]); - } + int g; + + block_bc(cr, *pull); + snew_bc(cr, pull->grp, pull->ngrp+1); + for (g = 0; g < pull->ngrp+1; g++) + { + bc_pullgrp(cr, &pull->grp[g]); + } } -static void bc_rotgrp(const t_commrec *cr,t_rotgrp *rotg) +static void bc_rotgrp(const t_commrec *cr, t_rotgrp *rotg) { - block_bc(cr,*rotg); - if (rotg->nat > 0) { - snew_bc(cr,rotg->ind,rotg->nat); - nblock_bc(cr,rotg->nat,rotg->ind); - snew_bc(cr,rotg->x_ref,rotg->nat); - nblock_bc(cr,rotg->nat,rotg->x_ref); - } + block_bc(cr, *rotg); + if (rotg->nat > 0) + { + snew_bc(cr, rotg->ind, rotg->nat); + nblock_bc(cr, rotg->nat, rotg->ind); + snew_bc(cr, rotg->x_ref, rotg->nat); + nblock_bc(cr, rotg->nat, rotg->x_ref); + } } -static void bc_rot(const t_commrec *cr,t_rot *rot) +static void bc_rot(const t_commrec *cr, t_rot *rot) { - int g; + int g; - block_bc(cr,*rot); - snew_bc(cr,rot->grp,rot->ngrp); - for(g=0; gngrp; g++) - bc_rotgrp(cr,&rot->grp[g]); + block_bc(cr, *rot); + snew_bc(cr, rot->grp, rot->ngrp); + for (g = 0; g < rot->ngrp; g++) + { + bc_rotgrp(cr, &rot->grp[g]); + } } -static void bc_adress(const t_commrec *cr,t_adress *adress) +static void bc_adress(const t_commrec *cr, t_adress *adress) { - block_bc(cr,*adress); - if (adress->n_tf_grps > 0) { - snew_bc(cr, adress->tf_table_index, adress->n_tf_grps); - nblock_bc(cr, adress->n_tf_grps, adress->tf_table_index); - } - if (adress->n_energy_grps > 0) { - snew_bc(cr, adress->group_explicit, adress->n_energy_grps); - nblock_bc(cr, adress->n_energy_grps, adress->group_explicit); - } + block_bc(cr, *adress); + if (adress->n_tf_grps > 0) + { + snew_bc(cr, adress->tf_table_index, adress->n_tf_grps); + nblock_bc(cr, adress->n_tf_grps, adress->tf_table_index); + } + if (adress->n_energy_grps > 0) + { + snew_bc(cr, adress->group_explicit, adress->n_energy_grps); + nblock_bc(cr, adress->n_energy_grps, adress->group_explicit); + } } -static void bc_fepvals(const t_commrec *cr,t_lambda *fep) +static void bc_fepvals(const t_commrec *cr, t_lambda *fep) { - gmx_bool bAlloc=TRUE; - int i; - - block_bc(cr,fep->nstdhdl); - block_bc(cr,fep->init_lambda); - block_bc(cr,fep->init_fep_state); - block_bc(cr,fep->delta_lambda); - block_bc(cr,fep->bPrintEnergy); - block_bc(cr,fep->n_lambda); - snew_bc(cr,fep->all_lambda,efptNR); - nblock_bc(cr,efptNR,fep->all_lambda); - for (i=0;iall_lambda[i],fep->n_lambda); - nblock_bc(cr,fep->n_lambda,fep->all_lambda[i]); - } - block_bc(cr,fep->sc_alpha); - block_bc(cr,fep->sc_power); - block_bc(cr,fep->sc_r_power); - block_bc(cr,fep->sc_sigma); - block_bc(cr,fep->sc_sigma_min); - block_bc(cr,fep->bScCoul); - nblock_bc(cr,efptNR,&(fep->separate_dvdl[0])); - block_bc(cr,fep->dhdl_derivatives); - block_bc(cr,fep->dh_hist_size); - block_bc(cr,fep->dh_hist_spacing); + gmx_bool bAlloc = TRUE; + int i; + + block_bc(cr, fep->nstdhdl); + block_bc(cr, fep->init_lambda); + block_bc(cr, fep->init_fep_state); + block_bc(cr, fep->delta_lambda); + block_bc(cr, fep->bPrintEnergy); + block_bc(cr, fep->n_lambda); + snew_bc(cr, fep->all_lambda, efptNR); + nblock_bc(cr, efptNR, fep->all_lambda); + for (i = 0; i < efptNR; i++) + { + snew_bc(cr, fep->all_lambda[i], fep->n_lambda); + nblock_bc(cr, fep->n_lambda, fep->all_lambda[i]); + } + block_bc(cr, fep->sc_alpha); + block_bc(cr, fep->sc_power); + block_bc(cr, fep->sc_r_power); + block_bc(cr, fep->sc_sigma); + block_bc(cr, fep->sc_sigma_min); + block_bc(cr, fep->bScCoul); + nblock_bc(cr, efptNR, &(fep->separate_dvdl[0])); + block_bc(cr, fep->dhdl_derivatives); + block_bc(cr, fep->dh_hist_size); + block_bc(cr, fep->dh_hist_spacing); if (debug) { - fprintf(debug,"after bc_fepvals\n"); + fprintf(debug, "after bc_fepvals\n"); } } -static void bc_expandedvals(const t_commrec *cr,t_expanded *expand, int n_lambda) +static void bc_expandedvals(const t_commrec *cr, t_expanded *expand, int n_lambda) { - gmx_bool bAlloc=TRUE; - int i; - - block_bc(cr,expand->nstexpanded); - block_bc(cr,expand->elamstats); - block_bc(cr,expand->elmcmove); - block_bc(cr,expand->elmceq); - block_bc(cr,expand->equil_n_at_lam); - block_bc(cr,expand->equil_wl_delta); - block_bc(cr,expand->equil_ratio); - block_bc(cr,expand->equil_steps); - block_bc(cr,expand->equil_samples); - block_bc(cr,expand->lmc_seed); - block_bc(cr,expand->minvar); - block_bc(cr,expand->minvar_const); - block_bc(cr,expand->c_range); - block_bc(cr,expand->bSymmetrizedTMatrix); - block_bc(cr,expand->nstTij); - block_bc(cr,expand->lmc_repeats); - block_bc(cr,expand->lmc_forced_nstart); - block_bc(cr,expand->gibbsdeltalam); - block_bc(cr,expand->wl_scale); - block_bc(cr,expand->wl_ratio); - block_bc(cr,expand->init_wl_delta); - block_bc(cr,expand->bInit_weights); - snew_bc(cr,expand->init_lambda_weights,n_lambda); - nblock_bc(cr,n_lambda,expand->init_lambda_weights); - block_bc(cr,expand->mc_temp); + gmx_bool bAlloc = TRUE; + int i; + + block_bc(cr, expand->nstexpanded); + block_bc(cr, expand->elamstats); + block_bc(cr, expand->elmcmove); + block_bc(cr, expand->elmceq); + block_bc(cr, expand->equil_n_at_lam); + block_bc(cr, expand->equil_wl_delta); + block_bc(cr, expand->equil_ratio); + block_bc(cr, expand->equil_steps); + block_bc(cr, expand->equil_samples); + block_bc(cr, expand->lmc_seed); + block_bc(cr, expand->minvar); + block_bc(cr, expand->minvar_const); + block_bc(cr, expand->c_range); + block_bc(cr, expand->bSymmetrizedTMatrix); + block_bc(cr, expand->nstTij); + block_bc(cr, expand->lmc_repeats); + block_bc(cr, expand->lmc_forced_nstart); + block_bc(cr, expand->gibbsdeltalam); + block_bc(cr, expand->wl_scale); + block_bc(cr, expand->wl_ratio); + block_bc(cr, expand->init_wl_delta); + block_bc(cr, expand->bInit_weights); + snew_bc(cr, expand->init_lambda_weights, n_lambda); + nblock_bc(cr, n_lambda, expand->init_lambda_weights); + block_bc(cr, expand->mc_temp); if (debug) { - fprintf(debug,"after bc_expandedvals\n"); + fprintf(debug, "after bc_expandedvals\n"); } } -static void bc_simtempvals(const t_commrec *cr,t_simtemp *simtemp, int n_lambda) +static void bc_simtempvals(const t_commrec *cr, t_simtemp *simtemp, int n_lambda) { - gmx_bool bAlloc=TRUE; - int i; - - block_bc(cr,simtemp->simtemp_low); - block_bc(cr,simtemp->simtemp_high); - block_bc(cr,simtemp->eSimTempScale); - snew_bc(cr,simtemp->temperatures,n_lambda); - nblock_bc(cr,n_lambda,simtemp->temperatures); + gmx_bool bAlloc = TRUE; + int i; + + block_bc(cr, simtemp->simtemp_low); + block_bc(cr, simtemp->simtemp_high); + block_bc(cr, simtemp->eSimTempScale); + snew_bc(cr, simtemp->temperatures, n_lambda); + nblock_bc(cr, n_lambda, simtemp->temperatures); if (debug) { - fprintf(debug,"after bc_simtempvals\n"); + fprintf(debug, "after bc_simtempvals\n"); } } -static void bc_inputrec(const t_commrec *cr,t_inputrec *inputrec) +static void bc_inputrec(const t_commrec *cr, t_inputrec *inputrec) { - gmx_bool bAlloc=TRUE; - int i; - - block_bc(cr,*inputrec); - - bc_grpopts(cr,&(inputrec->opts)); - - /* even if efep is efepNO, we need to initialize to make sure that - * n_lambda is set to zero */ - - snew_bc(cr,inputrec->fepvals,1); - if (inputrec->efep != efepNO || inputrec->bSimTemp) - { - bc_fepvals(cr,inputrec->fepvals); - } - /* need to initialize this as well because of data checked for in the logic */ - snew_bc(cr,inputrec->expandedvals,1); - if (inputrec->bExpanded) - { - bc_expandedvals(cr,inputrec->expandedvals,inputrec->fepvals->n_lambda); - } - snew_bc(cr,inputrec->simtempvals,1); - if (inputrec->bSimTemp) - { - bc_simtempvals(cr,inputrec->simtempvals,inputrec->fepvals->n_lambda); - } - if (inputrec->ePull != epullNO) { - snew_bc(cr,inputrec->pull,1); - bc_pull(cr,inputrec->pull); - } - if (inputrec->bRot) { - snew_bc(cr,inputrec->rot,1); - bc_rot(cr,inputrec->rot); - } - for(i=0; (iex[i])); - bc_cosines(cr,&(inputrec->et[i])); - } - if (inputrec->bAdress) { - snew_bc(cr,inputrec->adress,1); - bc_adress(cr,inputrec->adress); - } + gmx_bool bAlloc = TRUE; + int i; + + block_bc(cr, *inputrec); + + bc_grpopts(cr, &(inputrec->opts)); + + /* even if efep is efepNO, we need to initialize to make sure that + * n_lambda is set to zero */ + + snew_bc(cr, inputrec->fepvals, 1); + if (inputrec->efep != efepNO || inputrec->bSimTemp) + { + bc_fepvals(cr, inputrec->fepvals); + } + /* need to initialize this as well because of data checked for in the logic */ + snew_bc(cr, inputrec->expandedvals, 1); + if (inputrec->bExpanded) + { + bc_expandedvals(cr, inputrec->expandedvals, inputrec->fepvals->n_lambda); + } + snew_bc(cr, inputrec->simtempvals, 1); + if (inputrec->bSimTemp) + { + bc_simtempvals(cr, inputrec->simtempvals, inputrec->fepvals->n_lambda); + } + if (inputrec->ePull != epullNO) + { + snew_bc(cr, inputrec->pull, 1); + bc_pull(cr, inputrec->pull); + } + if (inputrec->bRot) + { + snew_bc(cr, inputrec->rot, 1); + bc_rot(cr, inputrec->rot); + } + for (i = 0; (i < DIM); i++) + { + bc_cosines(cr, &(inputrec->ex[i])); + bc_cosines(cr, &(inputrec->et[i])); + } + if (inputrec->bAdress) + { + snew_bc(cr, inputrec->adress, 1); + bc_adress(cr, inputrec->adress); + } } -static void bc_moltype(const t_commrec *cr,t_symtab *symtab, - gmx_moltype_t *moltype) +static void bc_moltype(const t_commrec *cr, t_symtab *symtab, + gmx_moltype_t *moltype) { - bc_string(cr,symtab,&moltype->name); - bc_atoms(cr,symtab,&moltype->atoms); - if (debug) fprintf(debug,"after bc_atoms\n"); + bc_string(cr, symtab, &moltype->name); + bc_atoms(cr, symtab, &moltype->atoms); + if (debug) + { + fprintf(debug, "after bc_atoms\n"); + } - bc_ilists(cr,moltype->ilist); - bc_block(cr,&moltype->cgs); - bc_blocka(cr,&moltype->excls); + bc_ilists(cr, moltype->ilist); + bc_block(cr, &moltype->cgs); + bc_blocka(cr, &moltype->excls); } -static void bc_molblock(const t_commrec *cr,gmx_molblock_t *molb) +static void bc_molblock(const t_commrec *cr, gmx_molblock_t *molb) { - gmx_bool bAlloc=TRUE; - - block_bc(cr,molb->type); - block_bc(cr,molb->nmol); - block_bc(cr,molb->natoms_mol); - block_bc(cr,molb->nposres_xA); - if (molb->nposres_xA > 0) { - snew_bc(cr,molb->posres_xA,molb->nposres_xA); - nblock_bc(cr,molb->nposres_xA*DIM,molb->posres_xA[0]); - } - block_bc(cr,molb->nposres_xB); - if (molb->nposres_xB > 0) { - snew_bc(cr,molb->posres_xB,molb->nposres_xB); - nblock_bc(cr,molb->nposres_xB*DIM,molb->posres_xB[0]); - } - if (debug) fprintf(debug,"after bc_molblock\n"); + gmx_bool bAlloc = TRUE; + + block_bc(cr, molb->type); + block_bc(cr, molb->nmol); + block_bc(cr, molb->natoms_mol); + block_bc(cr, molb->nposres_xA); + if (molb->nposres_xA > 0) + { + snew_bc(cr, molb->posres_xA, molb->nposres_xA); + nblock_bc(cr, molb->nposres_xA*DIM, molb->posres_xA[0]); + } + block_bc(cr, molb->nposres_xB); + if (molb->nposres_xB > 0) + { + snew_bc(cr, molb->posres_xB, molb->nposres_xB); + nblock_bc(cr, molb->nposres_xB*DIM, molb->posres_xB[0]); + } + if (debug) + { + fprintf(debug, "after bc_molblock\n"); + } } static void bc_atomtypes(const t_commrec *cr, t_atomtypes *atomtypes) { - int nr; + int nr; - block_bc(cr,atomtypes->nr); + block_bc(cr, atomtypes->nr); - nr = atomtypes->nr; + nr = atomtypes->nr; - snew_bc(cr,atomtypes->radius,nr); - snew_bc(cr,atomtypes->vol,nr); - snew_bc(cr,atomtypes->surftens,nr); - snew_bc(cr,atomtypes->gb_radius,nr); - snew_bc(cr,atomtypes->S_hct,nr); + snew_bc(cr, atomtypes->radius, nr); + snew_bc(cr, atomtypes->vol, nr); + snew_bc(cr, atomtypes->surftens, nr); + snew_bc(cr, atomtypes->gb_radius, nr); + snew_bc(cr, atomtypes->S_hct, nr); - nblock_bc(cr,nr,atomtypes->radius); - nblock_bc(cr,nr,atomtypes->vol); - nblock_bc(cr,nr,atomtypes->surftens); - nblock_bc(cr,nr,atomtypes->gb_radius); - nblock_bc(cr,nr,atomtypes->S_hct); + nblock_bc(cr, nr, atomtypes->radius); + nblock_bc(cr, nr, atomtypes->vol); + nblock_bc(cr, nr, atomtypes->surftens); + nblock_bc(cr, nr, atomtypes->gb_radius); + nblock_bc(cr, nr, atomtypes->S_hct); } -void bcast_ir_mtop(const t_commrec *cr,t_inputrec *inputrec,gmx_mtop_t *mtop) +void bcast_ir_mtop(const t_commrec *cr, t_inputrec *inputrec, gmx_mtop_t *mtop) { - int i; - if (debug) fprintf(debug,"in bc_data\n"); - bc_inputrec(cr,inputrec); - if (debug) fprintf(debug,"after bc_inputrec\n"); - bc_symtab(cr,&mtop->symtab); - if (debug) fprintf(debug,"after bc_symtab\n"); - bc_string(cr,&mtop->symtab,&mtop->name); - if (debug) fprintf(debug,"after bc_name\n"); - - bc_ffparams(cr,&mtop->ffparams); - - block_bc(cr,mtop->nmoltype); - snew_bc(cr,mtop->moltype,mtop->nmoltype); - for(i=0; inmoltype; i++) { - bc_moltype(cr,&mtop->symtab,&mtop->moltype[i]); - } - - block_bc(cr,mtop->nmolblock); - snew_bc(cr,mtop->molblock,mtop->nmolblock); - for(i=0; inmolblock; i++) { - bc_molblock(cr,&mtop->molblock[i]); - } - - block_bc(cr,mtop->natoms); - - bc_atomtypes(cr,&mtop->atomtypes); - - bc_block(cr,&mtop->mols); - bc_groups(cr,&mtop->symtab,mtop->natoms,&mtop->groups); + int i; + if (debug) + { + fprintf(debug, "in bc_data\n"); + } + bc_inputrec(cr, inputrec); + if (debug) + { + fprintf(debug, "after bc_inputrec\n"); + } + bc_symtab(cr, &mtop->symtab); + if (debug) + { + fprintf(debug, "after bc_symtab\n"); + } + bc_string(cr, &mtop->symtab, &mtop->name); + if (debug) + { + fprintf(debug, "after bc_name\n"); + } + + bc_ffparams(cr, &mtop->ffparams); + + block_bc(cr, mtop->nmoltype); + snew_bc(cr, mtop->moltype, mtop->nmoltype); + for (i = 0; i < mtop->nmoltype; i++) + { + bc_moltype(cr, &mtop->symtab, &mtop->moltype[i]); + } + + block_bc(cr, mtop->nmolblock); + snew_bc(cr, mtop->molblock, mtop->nmolblock); + for (i = 0; i < mtop->nmolblock; i++) + { + bc_molblock(cr, &mtop->molblock[i]); + } + + block_bc(cr, mtop->natoms); + + bc_atomtypes(cr, &mtop->atomtypes); + + bc_block(cr, &mtop->mols); + bc_groups(cr, &mtop->symtab, mtop->natoms, &mtop->groups); } diff --git a/src/gromacs/gmxlib/names.c b/src/gromacs/gmxlib/names.c index dcc9173291..b56b16b26c 100644 --- a/src/gromacs/gmxlib/names.c +++ b/src/gromacs/gmxlib/names.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -41,220 +41,220 @@ /* note: these arrays should correspond to enums in include/types/enums.h */ -const char *epbc_names[epbcNR+1]= +const char *epbc_names[epbcNR+1] = { - "xyz", "no", "xy", "screw", NULL + "xyz", "no", "xy", "screw", NULL }; -const char *ens_names[ensNR+1]= +const char *ens_names[ensNR+1] = { - "Grid","Simple", NULL + "Grid", "Simple", NULL }; -const char *ei_names[eiNR+1]= +const char *ei_names[eiNR+1] = { - "md", "steep", "cg", "bd", "sd", "nm", "l-bfgs", "tpi", "tpic", "sd1", "md-vv", "md-vv-avek",NULL + "md", "steep", "cg", "bd", "sd", "nm", "l-bfgs", "tpi", "tpic", "sd1", "md-vv", "md-vv-avek", NULL }; -const char *bool_names[BOOL_NR+1]= +const char *bool_names[BOOL_NR+1] = { - "FALSE","TRUE", NULL + "FALSE", "TRUE", NULL }; -const char *yesno_names[BOOL_NR+1]= +const char *yesno_names[BOOL_NR+1] = { - "no","yes", NULL + "no", "yes", NULL }; const char *ptype_str[eptNR+1] = { - "Atom", "Nucleus", "Shell", "Bond", "VSite", NULL + "Atom", "Nucleus", "Shell", "Bond", "VSite", NULL }; const char *ecutscheme_names[ecutsNR+1] = { - "Group", "Verlet", NULL + "Group", "Verlet", NULL }; const char *eel_names[eelNR+1] = { - "Cut-off", "Reaction-Field", "Generalized-Reaction-Field", - "PME", "Ewald", "P3M-AD", "Poisson", "Switch", "Shift", "User", - "Generalized-Born", "Reaction-Field-nec", "Encad-shift", - "PME-User", "PME-Switch", "PME-User-Switch", - "Reaction-Field-zero", NULL + "Cut-off", "Reaction-Field", "Generalized-Reaction-Field", + "PME", "Ewald", "P3M-AD", "Poisson", "Switch", "Shift", "User", + "Generalized-Born", "Reaction-Field-nec", "Encad-shift", + "PME-User", "PME-Switch", "PME-User-Switch", + "Reaction-Field-zero", NULL }; const char *eewg_names[eewgNR+1] = { - "3d", "3dc", NULL + "3d", "3dc", NULL }; const char *evdw_names[evdwNR+1] = { - "Cut-off", "Switch", "Shift", "User", "Encad-shift", NULL + "Cut-off", "Switch", "Shift", "User", "Encad-shift", NULL }; const char *econstr_names[econtNR+1] = { - "Lincs", "Shake", NULL + "Lincs", "Shake", NULL }; -const char *eintmod_names[eintmodNR+1] = { - "Potential-shift-Verlet","Potential-shift","None","Potential-switch","Exact-cutoff", NULL +const char *eintmod_names[eintmodNR+1] = { + "Potential-shift-Verlet", "Potential-shift", "None", "Potential-switch", "Exact-cutoff", NULL }; -const char *egrp_nm[egNR+1] = { - "Coul-SR","LJ-SR","Buck-SR", "Coul-LR", "LJ-LR", "Buck-LR", - "Coul-14", "LJ-14", NULL +const char *egrp_nm[egNR+1] = { + "Coul-SR", "LJ-SR", "Buck-SR", "Coul-LR", "LJ-LR", "Buck-LR", + "Coul-14", "LJ-14", NULL }; const char *etcoupl_names[etcNR+1] = { - "No", "Berendsen", "Nose-Hoover", "yes", "Andersen", "Andersen-massive", "V-rescale", NULL + "No", "Berendsen", "Nose-Hoover", "yes", "Andersen", "Andersen-massive", "V-rescale", NULL }; /* yes is alias for berendsen */ const char *epcoupl_names[epcNR+1] = { - "No", "Berendsen", "Parrinello-Rahman", "Isotropic", "MTTK", NULL + "No", "Berendsen", "Parrinello-Rahman", "Isotropic", "MTTK", NULL }; /* isotropic is alias for berendsen */ const char *epcoupltype_names[epctNR+1] = { - "Isotropic", "Semiisotropic", "Anisotropic", "Surface-Tension", NULL + "Isotropic", "Semiisotropic", "Anisotropic", "Surface-Tension", NULL }; const char *erefscaling_names[erscNR+1] = { - "No", "All", "COM", NULL + "No", "All", "COM", NULL }; const char *edisre_names[edrNR+1] = { - "No", "Simple", "Ensemble", NULL + "No", "Simple", "Ensemble", NULL }; const char *edisreweighting_names[edrwNR+1] = { - "Conservative", "Equal", NULL + "Conservative", "Equal", NULL }; const char *enbf_names[eNBF_NR+1] = { - "", "LJ", "Buckingham", NULL + "", "LJ", "Buckingham", NULL }; const char *ecomb_names[eCOMB_NR+1] = { - "", "Geometric", "Arithmetic", "GeomSigEps", NULL + "", "Geometric", "Arithmetic", "GeomSigEps", NULL }; const char *gtypes[egcNR+1] = { - "T-Coupling", "Energy Mon.", "Acceleration", "Freeze", - "User1", "User2", "VCM", "XTC", "Or. Res. Fit", "QMMM", NULL + "T-Coupling", "Energy Mon.", "Acceleration", "Freeze", + "User1", "User2", "VCM", "XTC", "Or. Res. Fit", "QMMM", NULL }; const char *esimtemp_names[esimtempNR+1] = { - "geometric", "exponential", "linear", NULL + "geometric", "exponential", "linear", NULL }; const char *efep_names[efepNR+1] = { - "no", "yes", "static", "slow-growth", "expanded", NULL + "no", "yes", "static", "slow-growth", "expanded", NULL }; const char *efpt_names[efptNR+1] = { - "fep-lambdas", "mass-lambdas", "coul-lambdas", "vdw-lambdas", "bonded-lambdas", "restraint-lambdas", "temperature-lambdas", NULL + "fep-lambdas", "mass-lambdas", "coul-lambdas", "vdw-lambdas", "bonded-lambdas", "restraint-lambdas", "temperature-lambdas", NULL }; const char *efpt_singular_names[efptNR+1] = { - "fep-lambda", "mass-lambda", "coul-lambda", "vdw-lambda", "bonded-lambda", "restraint-lambda", "temperature-lambda", NULL + "fep-lambda", "mass-lambda", "coul-lambda", "vdw-lambda", "bonded-lambda", "restraint-lambda", "temperature-lambda", NULL }; const char *elamstats_names[elamstatsNR+1] = { - "no", "metropolis-transition", "barker-transition", "minvar", "wang-landau", "weighted-wang-landau", NULL + "no", "metropolis-transition", "barker-transition", "minvar", "wang-landau", "weighted-wang-landau", NULL }; const char *elmcmove_names[elmcmoveNR+1] = { - "no", "metropolis", "barker", "gibbs", "metropolized-gibbs", NULL + "no", "metropolis", "barker", "gibbs", "metropolized-gibbs", NULL }; const char *elmceq_names[elmceqNR+1] = { - "no", "yes", "wl-delta", "number-all-lambda", "number-steps", "number-samples", "count-ratio", NULL + "no", "yes", "wl-delta", "number-all-lambda", "number-steps", "number-samples", "count-ratio", NULL }; const char *separate_dhdl_file_names[esepdhdlfileNR+1] = { - "yes", "no", NULL + "yes", "no", NULL }; const char *dhdl_derivatives_names[edhdlderivativesNR+1] = { - "yes", "no", NULL + "yes", "no", NULL }; const char *esol_names[esolNR+1] = { - "No", "SPC", "TIP4p", NULL + "No", "SPC", "TIP4p", NULL }; const char *edispc_names[edispcNR+1] = { - "No", "EnerPres", "Ener", "AllEnerPres", "AllEner", NULL + "No", "EnerPres", "Ener", "AllEnerPres", "AllEner", NULL }; -const char *ecm_names[ecmNR+1] = { - "Linear", "Angular", "None", NULL +const char *ecm_names[ecmNR+1] = { + "Linear", "Angular", "None", NULL }; const char *eann_names[eannNR+1] = { - "No", "Single", "Periodic", NULL + "No", "Single", "Periodic", NULL }; const char *eis_names[eisNR+1] = { - "No", "GBSA", NULL + "No", "GBSA", NULL }; const char *egb_names[egbNR+1] = { - "Still", "HCT", "OBC", NULL + "Still", "HCT", "OBC", NULL }; const char *esa_names[esaNR+1] = { - "Ace-approximation", "None", "Still", NULL + "Ace-approximation", "None", "Still", NULL }; const char *ewt_names[ewtNR+1] = { - "9-3", "10-4", "table", "12-6", NULL + "9-3", "10-4", "table", "12-6", NULL }; -const char *epull_names[epullNR+1] = { - "no", "umbrella", "constraint", "constant-force", NULL +const char *epull_names[epullNR+1] = { + "no", "umbrella", "constraint", "constant-force", NULL }; -const char *epullg_names[epullgNR+1] = { - "distance", "direction", "cylinder", "position", "direction-periodic", NULL +const char *epullg_names[epullgNR+1] = { + "distance", "direction", "cylinder", "position", "direction-periodic", NULL }; -const char *erotg_names[erotgNR+1] = { - "iso", "iso-pf", "pm", "pm-pf", "rm", "rm-pf", "rm2", "rm2-pf", "flex", "flex-t", "flex2", "flex2-t", NULL +const char *erotg_names[erotgNR+1] = { + "iso", "iso-pf", "pm", "pm-pf", "rm", "rm-pf", "rm2", "rm2-pf", "flex", "flex-t", "flex2", "flex2-t", NULL }; -const char *erotg_fitnames[erotgFitNR+1] = { - "rmsd", "norm", "potential", NULL +const char *erotg_fitnames[erotgFitNR+1] = { + "rmsd", "norm", "potential", NULL }; const char *eQMmethod_names[eQMmethodNR+1] = { - "AM1", "PM3", "RHF", - "UHF", "DFT", "B3LYP", "MP2", "CASSCF","B3LYPLAN", - "DIRECT", NULL + "AM1", "PM3", "RHF", + "UHF", "DFT", "B3LYP", "MP2", "CASSCF", "B3LYPLAN", + "DIRECT", NULL }; const char *eQMbasis_names[eQMbasisNR+1] = { - "STO3G", "STO-3G", "3-21G", - "3-21G*", "3-21+G*", "6-21G", - "6-31G", "6-31G*", "6-31+G*", - "6-311G", NULL + "STO3G", "STO-3G", "3-21G", + "3-21G*", "3-21+G*", "6-21G", + "6-31G", "6-31G*", "6-31+G*", + "6-311G", NULL }; const char *eQMMMscheme_names[eQMMMschemeNR+1] = { - "normal", "ONIOM", NULL + "normal", "ONIOM", NULL }; const char *eMultentOpt_names[eMultentOptNR+1] = { - "multiple_entries", "no", "use_last", NULL + "multiple_entries", "no", "use_last", NULL }; const char *eAdresstype_names[eAdressNR+1] = { - "off","constant", "xsplit", "sphere", NULL + "off", "constant", "xsplit", "sphere", NULL }; const char *eAdressICtype_names[eAdressICNR+1] = { - "off", "thermoforce", NULL + "off", "thermoforce", NULL }; const char *eAdressSITEtype_names[eAdressSITENR+1] = { - "com","cog", "atom", "atomperatom", NULL + "com", "cog", "atom", "atomperatom", NULL }; const char *gmx_nblist_geometry_names[GMX_NBLIST_GEOMETRY_NR+1] = { @@ -270,6 +270,3 @@ const char *gmx_nbkernel_vdw_names[GMX_NBKERNEL_VDW_NR+1] = { "None", "Lennard-Jones", "Buckingham", "Cubic-Spline-Table", NULL }; - - - diff --git a/src/gromacs/gmxlib/network.c b/src/gromacs/gmxlib/network.c index ec210de8f7..9e3f501f82 100644 --- a/src/gromacs/gmxlib/network.c +++ b/src/gromacs/gmxlib/network.c @@ -1,11 +1,11 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -55,79 +55,79 @@ #endif -/* The source code in this file should be thread-safe. +/* The source code in this file should be thread-safe. Please keep it that way. */ gmx_bool gmx_mpi_initialized(void) { - int n; + int n; #ifndef GMX_MPI - return 0; + return 0; #else - MPI_Initialized(&n); - - return n; + MPI_Initialized(&n); + + return n; #endif } -int gmx_setup(int *argc,char **argv,int *nnodes) +int gmx_setup(int *argc, char **argv, int *nnodes) { #ifndef GMX_MPI - gmx_call("gmx_setup"); - return 0; + gmx_call("gmx_setup"); + return 0; #else - char buf[256]; - int resultlen; /* actual length of node name */ - int i,flag; - int mpi_num_nodes; - int mpi_my_rank; - char mpi_hostname[MPI_MAX_PROCESSOR_NAME]; - - /* Call the MPI routines */ + char buf[256]; + int resultlen; /* actual length of node name */ + int i, flag; + int mpi_num_nodes; + int mpi_my_rank; + char mpi_hostname[MPI_MAX_PROCESSOR_NAME]; + + /* Call the MPI routines */ #ifdef GMX_LIB_MPI #ifdef GMX_FAHCORE - (void) fah_MPI_Init(argc,&argv); + (void) fah_MPI_Init(argc, &argv); #else - (void) MPI_Init(argc,&argv); + (void) MPI_Init(argc, &argv); #endif #endif - (void) MPI_Comm_size( MPI_COMM_WORLD, &mpi_num_nodes ); - (void) MPI_Comm_rank( MPI_COMM_WORLD, &mpi_my_rank ); - (void) MPI_Get_processor_name( mpi_hostname, &resultlen ); - -#ifdef GMX_LIB_MPI - if (debug) - { - fprintf(debug,"NNODES=%d, MYRANK=%d, HOSTNAME=%s\n", - mpi_num_nodes,mpi_my_rank,mpi_hostname); - } + (void) MPI_Comm_size( MPI_COMM_WORLD, &mpi_num_nodes ); + (void) MPI_Comm_rank( MPI_COMM_WORLD, &mpi_my_rank ); + (void) MPI_Get_processor_name( mpi_hostname, &resultlen ); + +#ifdef GMX_LIB_MPI + if (debug) + { + fprintf(debug, "NNODES=%d, MYRANK=%d, HOSTNAME=%s\n", + mpi_num_nodes, mpi_my_rank, mpi_hostname); + } #endif - - *nnodes=mpi_num_nodes; - - return mpi_my_rank; + + *nnodes = mpi_num_nodes; + + return mpi_my_rank; #endif } int gmx_node_num(void) { #ifndef GMX_MPI - return 1; + return 1; #else - int i; - (void) MPI_Comm_size(MPI_COMM_WORLD, &i); - return i; + int i; + (void) MPI_Comm_size(MPI_COMM_WORLD, &i); + return i; #endif } int gmx_node_rank(void) { #ifndef GMX_MPI - return 0; + return 0; #else - int i; - (void) MPI_Comm_rank(MPI_COMM_WORLD, &i); - return i; + int i; + (void) MPI_Comm_rank(MPI_COMM_WORLD, &i); + return i; #endif } @@ -135,52 +135,58 @@ int gmx_node_rank(void) int gmx_hostname_num() { #ifndef GMX_MPI - return 0; + return 0; #else #ifdef GMX_THREAD_MPI - /* thread-MPI currently puts the thread number in the process name, - * we might want to change this, as this is inconsistent with what - * most MPI implementations would do when running on a single node. - */ - return 0; + /* thread-MPI currently puts the thread number in the process name, + * we might want to change this, as this is inconsistent with what + * most MPI implementations would do when running on a single node. + */ + return 0; #else - int resultlen,hostnum,i,j; - char mpi_hostname[MPI_MAX_PROCESSOR_NAME],hostnum_str[MPI_MAX_PROCESSOR_NAME]; - - MPI_Get_processor_name(mpi_hostname,&resultlen); - /* This procedure can only differentiate nodes with host names - * that end on unique numbers. - */ - i = 0; - j = 0; - /* Only parse the host name up to the first dot */ - while(i < resultlen && mpi_hostname[i] != '.') { - if (isdigit(mpi_hostname[i])) { - hostnum_str[j++] = mpi_hostname[i]; - } - i++; - } - hostnum_str[j] = '\0'; - if (j == 0) { - hostnum = 0; - } else { - /* Use only the last 9 decimals, so we don't overflow an int */ - hostnum = strtol(hostnum_str + max(0,j-9), NULL, 10); - } - - if (debug) { - fprintf(debug,"In gmx_setup_nodecomm: hostname '%s', hostnum %d\n", - mpi_hostname,hostnum); - } - return hostnum; + int resultlen, hostnum, i, j; + char mpi_hostname[MPI_MAX_PROCESSOR_NAME], hostnum_str[MPI_MAX_PROCESSOR_NAME]; + + MPI_Get_processor_name(mpi_hostname, &resultlen); + /* This procedure can only differentiate nodes with host names + * that end on unique numbers. + */ + i = 0; + j = 0; + /* Only parse the host name up to the first dot */ + while (i < resultlen && mpi_hostname[i] != '.') + { + if (isdigit(mpi_hostname[i])) + { + hostnum_str[j++] = mpi_hostname[i]; + } + i++; + } + hostnum_str[j] = '\0'; + if (j == 0) + { + hostnum = 0; + } + else + { + /* Use only the last 9 decimals, so we don't overflow an int */ + hostnum = strtol(hostnum_str + max(0, j-9), NULL, 10); + } + + if (debug) + { + fprintf(debug, "In gmx_setup_nodecomm: hostname '%s', hostnum %d\n", + mpi_hostname, hostnum); + } + return hostnum; #endif #endif } -void gmx_setup_nodecomm(FILE *fplog,t_commrec *cr) +void gmx_setup_nodecomm(FILE *fplog, t_commrec *cr) { gmx_nodecomm_t *nc; - int n,rank,hostnum,ng,ni; + int n, rank, hostnum, ng, ni; /* Many MPI implementations do not optimize MPI_Allreduce * (and probably also other global communication calls) @@ -198,37 +204,37 @@ void gmx_setup_nodecomm(FILE *fplog,t_commrec *cr) nc->bUse = FALSE; #ifndef GMX_THREAD_MPI #ifdef GMX_MPI - MPI_Comm_size(cr->mpi_comm_mygroup,&n); - MPI_Comm_rank(cr->mpi_comm_mygroup,&rank); + MPI_Comm_size(cr->mpi_comm_mygroup, &n); + MPI_Comm_rank(cr->mpi_comm_mygroup, &rank); hostnum = gmx_hostname_num(); if (debug) { - fprintf(debug,"In gmx_setup_nodecomm: splitting communicator of size %d\n",n); + fprintf(debug, "In gmx_setup_nodecomm: splitting communicator of size %d\n", n); } /* The intra-node communicator, split on node number */ - MPI_Comm_split(cr->mpi_comm_mygroup,hostnum,rank,&nc->comm_intra); - MPI_Comm_rank(nc->comm_intra,&nc->rank_intra); + MPI_Comm_split(cr->mpi_comm_mygroup, hostnum, rank, &nc->comm_intra); + MPI_Comm_rank(nc->comm_intra, &nc->rank_intra); if (debug) { - fprintf(debug,"In gmx_setup_nodecomm: node rank %d rank_intra %d\n", - rank,nc->rank_intra); + fprintf(debug, "In gmx_setup_nodecomm: node rank %d rank_intra %d\n", + rank, nc->rank_intra); } /* The inter-node communicator, split on rank_intra. * We actually only need the one for rank=0, * but it is easier to create them all. */ - MPI_Comm_split(cr->mpi_comm_mygroup,nc->rank_intra,rank,&nc->comm_inter); + MPI_Comm_split(cr->mpi_comm_mygroup, nc->rank_intra, rank, &nc->comm_inter); /* Check if this really created two step communication */ - MPI_Comm_size(nc->comm_inter,&ng); - MPI_Comm_size(nc->comm_intra,&ni); + MPI_Comm_size(nc->comm_inter, &ng); + MPI_Comm_size(nc->comm_intra, &ni); if (debug) { - fprintf(debug,"In gmx_setup_nodecomm: groups %d, my group size %d\n", - ng,ni); + fprintf(debug, "In gmx_setup_nodecomm: groups %d, my group size %d\n", + ng, ni); } if (getenv("GMX_NO_NODECOMM") == NULL && @@ -237,8 +243,8 @@ void gmx_setup_nodecomm(FILE *fplog,t_commrec *cr) nc->bUse = TRUE; if (fplog) { - fprintf(fplog,"Using two step summing over %d groups of on average %.1f processes\n\n", - ng,(real)n/(real)ng); + fprintf(fplog, "Using two step summing over %d groups of on average %.1f processes\n\n", + ng, (real)n/(real)ng); } if (nc->rank_intra > 0) { @@ -252,7 +258,7 @@ void gmx_setup_nodecomm(FILE *fplog,t_commrec *cr) MPI_Comm_free(&nc->comm_intra); if (debug) { - fprintf(debug,"In gmx_setup_nodecomm: not unsing separate inter- and intra-node communicators.\n"); + fprintf(debug, "In gmx_setup_nodecomm: not unsing separate inter- and intra-node communicators.\n"); } } #endif @@ -272,8 +278,8 @@ void gmx_init_intranode_counters(t_commrec *cr) int nrank_world, rank_world; int i, mynum, *num, *num_s, *num_pp, *num_pp_s; - MPI_Comm_size(MPI_COMM_WORLD,&nrank_world); - MPI_Comm_rank(MPI_COMM_WORLD,&rank_world); + MPI_Comm_size(MPI_COMM_WORLD, &nrank_world); + MPI_Comm_rank(MPI_COMM_WORLD, &rank_world); /* Get the node number from the hostname to identify the nodes */ mynum = gmx_hostname_num(); @@ -294,7 +300,7 @@ void gmx_init_intranode_counters(t_commrec *cr) rank_intranode = 0; nrank_pp_intranode = 0; rank_pp_intranode = 0; - for(i=0; impi_comm_mygroup); + MPI_Barrier(cr->mpi_comm_mygroup); #endif } -void gmx_abort(int noderank,int nnodes,int errorno) +void gmx_abort(int noderank, int nnodes, int errorno) { #ifndef GMX_MPI - gmx_call("gmx_abort"); + gmx_call("gmx_abort"); #else #ifdef GMX_THREAD_MPI - fprintf(stderr,"Halting program %s\n",ShortProgram()); - thanx(stderr); - exit(1); + fprintf(stderr, "Halting program %s\n", ShortProgram()); + thanx(stderr); + exit(1); #else - if (nnodes > 1) - { - fprintf(stderr,"Halting parallel program %s on CPU %d out of %d\n", - ShortProgram(),noderank,nnodes); - } - else - { - fprintf(stderr,"Halting program %s\n",ShortProgram()); - } + if (nnodes > 1) + { + fprintf(stderr, "Halting parallel program %s on CPU %d out of %d\n", + ShortProgram(), noderank, nnodes); + } + else + { + fprintf(stderr, "Halting program %s\n", ShortProgram()); + } - thanx(stderr); - MPI_Abort(MPI_COMM_WORLD,errorno); - exit(1); + thanx(stderr); + MPI_Abort(MPI_COMM_WORLD, errorno); + exit(1); #endif #endif } -void gmx_bcast(int nbytes,void *b,const t_commrec *cr) +void gmx_bcast(int nbytes, void *b, const t_commrec *cr) { #ifndef GMX_MPI - gmx_call("gmx_bast"); + gmx_call("gmx_bast"); #else - MPI_Bcast(b,nbytes,MPI_BYTE,MASTERRANK(cr),cr->mpi_comm_mygroup); + MPI_Bcast(b, nbytes, MPI_BYTE, MASTERRANK(cr), cr->mpi_comm_mygroup); #endif } -void gmx_bcast_sim(int nbytes,void *b,const t_commrec *cr) +void gmx_bcast_sim(int nbytes, void *b, const t_commrec *cr) { #ifndef GMX_MPI - gmx_call("gmx_bast"); + gmx_call("gmx_bast"); #else - MPI_Bcast(b,nbytes,MPI_BYTE,MASTERRANK(cr),cr->mpi_comm_mysim); + MPI_Bcast(b, nbytes, MPI_BYTE, MASTERRANK(cr), cr->mpi_comm_mysim); #endif } -void gmx_sumd(int nr,double r[],const t_commrec *cr) +void gmx_sumd(int nr, double r[], const t_commrec *cr) { #ifndef GMX_MPI gmx_call("gmx_sumd"); #else #if defined(MPI_IN_PLACE_EXISTS) || defined(GMX_THREAD_MPI) - if (cr->nc.bUse) { + if (cr->nc.bUse) + { if (cr->nc.rank_intra == 0) { /* Use two step summing. */ - MPI_Reduce(MPI_IN_PLACE,r,nr,MPI_DOUBLE,MPI_SUM,0, + MPI_Reduce(MPI_IN_PLACE, r, nr, MPI_DOUBLE, MPI_SUM, 0, cr->nc.comm_intra); /* Sum the roots of the internal (intra) buffers. */ - MPI_Allreduce(MPI_IN_PLACE,r,nr,MPI_DOUBLE,MPI_SUM, + MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_DOUBLE, MPI_SUM, cr->nc.comm_inter); } else { /* This is here because of the silly MPI specification that MPI_IN_PLACE should be put in sendbuf instead of recvbuf */ - MPI_Reduce(r,NULL,nr,MPI_DOUBLE,MPI_SUM,0,cr->nc.comm_intra); + MPI_Reduce(r, NULL, nr, MPI_DOUBLE, MPI_SUM, 0, cr->nc.comm_intra); } - MPI_Bcast(r,nr,MPI_DOUBLE,0,cr->nc.comm_intra); - } - else + MPI_Bcast(r, nr, MPI_DOUBLE, 0, cr->nc.comm_intra); + } + else { - MPI_Allreduce(MPI_IN_PLACE,r,nr,MPI_DOUBLE,MPI_SUM, + MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_DOUBLE, MPI_SUM, cr->mpi_comm_mygroup); } #else int i; - if (nr > cr->mpb->dbuf_alloc) { + if (nr > cr->mpb->dbuf_alloc) + { cr->mpb->dbuf_alloc = nr; - srenew(cr->mpb->dbuf,cr->mpb->dbuf_alloc); + srenew(cr->mpb->dbuf, cr->mpb->dbuf_alloc); } - if (cr->nc.bUse) { + if (cr->nc.bUse) + { /* Use two step summing */ - MPI_Allreduce(r,cr->mpb->dbuf,nr,MPI_DOUBLE,MPI_SUM,cr->nc.comm_intra); - if (cr->nc.rank_intra == 0) { + MPI_Allreduce(r, cr->mpb->dbuf, nr, MPI_DOUBLE, MPI_SUM, cr->nc.comm_intra); + if (cr->nc.rank_intra == 0) + { /* Sum with the buffers reversed */ - MPI_Allreduce(cr->mpb->dbuf,r,nr,MPI_DOUBLE,MPI_SUM, + MPI_Allreduce(cr->mpb->dbuf, r, nr, MPI_DOUBLE, MPI_SUM, cr->nc.comm_inter); } - MPI_Bcast(r,nr,MPI_DOUBLE,0,cr->nc.comm_intra); - } else { - MPI_Allreduce(r,cr->mpb->dbuf,nr,MPI_DOUBLE,MPI_SUM, + MPI_Bcast(r, nr, MPI_DOUBLE, 0, cr->nc.comm_intra); + } + else + { + MPI_Allreduce(r, cr->mpb->dbuf, nr, MPI_DOUBLE, MPI_SUM, cr->mpi_comm_mygroup); - for(i=0; impb->dbuf[i]; + } } #endif #endif } -void gmx_sumf(int nr,float r[],const t_commrec *cr) +void gmx_sumf(int nr, float r[], const t_commrec *cr) { #ifndef GMX_MPI gmx_call("gmx_sumf"); #else #if defined(MPI_IN_PLACE_EXISTS) || defined(GMX_THREAD_MPI) - if (cr->nc.bUse) { + if (cr->nc.bUse) + { /* Use two step summing. */ if (cr->nc.rank_intra == 0) { - MPI_Reduce(MPI_IN_PLACE,r,nr,MPI_FLOAT,MPI_SUM,0, + MPI_Reduce(MPI_IN_PLACE, r, nr, MPI_FLOAT, MPI_SUM, 0, cr->nc.comm_intra); /* Sum the roots of the internal (intra) buffers */ - MPI_Allreduce(MPI_IN_PLACE,r,nr,MPI_FLOAT,MPI_SUM, + MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_FLOAT, MPI_SUM, cr->nc.comm_inter); } else { /* This is here because of the silly MPI specification that MPI_IN_PLACE should be put in sendbuf instead of recvbuf */ - MPI_Reduce(r,NULL,nr,MPI_FLOAT,MPI_SUM,0,cr->nc.comm_intra); + MPI_Reduce(r, NULL, nr, MPI_FLOAT, MPI_SUM, 0, cr->nc.comm_intra); } - MPI_Bcast(r,nr,MPI_FLOAT,0,cr->nc.comm_intra); - } - else + MPI_Bcast(r, nr, MPI_FLOAT, 0, cr->nc.comm_intra); + } + else { - MPI_Allreduce(MPI_IN_PLACE,r,nr,MPI_FLOAT,MPI_SUM,cr->mpi_comm_mygroup); + MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_FLOAT, MPI_SUM, cr->mpi_comm_mygroup); } #else int i; - if (nr > cr->mpb->fbuf_alloc) { + if (nr > cr->mpb->fbuf_alloc) + { cr->mpb->fbuf_alloc = nr; - srenew(cr->mpb->fbuf,cr->mpb->fbuf_alloc); + srenew(cr->mpb->fbuf, cr->mpb->fbuf_alloc); } - if (cr->nc.bUse) { + if (cr->nc.bUse) + { /* Use two step summing */ - MPI_Allreduce(r,cr->mpb->fbuf,nr,MPI_FLOAT,MPI_SUM,cr->nc.comm_intra); - if (cr->nc.rank_intra == 0) { + MPI_Allreduce(r, cr->mpb->fbuf, nr, MPI_FLOAT, MPI_SUM, cr->nc.comm_intra); + if (cr->nc.rank_intra == 0) + { /* Sum with the buffers reversed */ - MPI_Allreduce(cr->mpb->fbuf,r,nr,MPI_FLOAT,MPI_SUM, + MPI_Allreduce(cr->mpb->fbuf, r, nr, MPI_FLOAT, MPI_SUM, cr->nc.comm_inter); } - MPI_Bcast(r,nr,MPI_FLOAT,0,cr->nc.comm_intra); - } else { - MPI_Allreduce(r,cr->mpb->fbuf,nr,MPI_FLOAT,MPI_SUM, + MPI_Bcast(r, nr, MPI_FLOAT, 0, cr->nc.comm_intra); + } + else + { + MPI_Allreduce(r, cr->mpb->fbuf, nr, MPI_FLOAT, MPI_SUM, cr->mpi_comm_mygroup); - for(i=0; impb->fbuf[i]; + } } #endif #endif } -void gmx_sumi(int nr,int r[],const t_commrec *cr) +void gmx_sumi(int nr, int r[], const t_commrec *cr) { #ifndef GMX_MPI gmx_call("gmx_sumi"); #else #if defined(MPI_IN_PLACE_EXISTS) || defined(GMX_THREAD_MPI) - if (cr->nc.bUse) { + if (cr->nc.bUse) + { /* Use two step summing */ - if (cr->nc.rank_intra == 0) + if (cr->nc.rank_intra == 0) { - MPI_Reduce(MPI_IN_PLACE,r,nr,MPI_INT,MPI_SUM,0,cr->nc.comm_intra); + MPI_Reduce(MPI_IN_PLACE, r, nr, MPI_INT, MPI_SUM, 0, cr->nc.comm_intra); /* Sum with the buffers reversed */ - MPI_Allreduce(MPI_IN_PLACE,r,nr,MPI_INT,MPI_SUM,cr->nc.comm_inter); + MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_INT, MPI_SUM, cr->nc.comm_inter); } else { /* This is here because of the silly MPI specification that MPI_IN_PLACE should be put in sendbuf instead of recvbuf */ - MPI_Reduce(r,NULL,nr,MPI_INT,MPI_SUM,0,cr->nc.comm_intra); + MPI_Reduce(r, NULL, nr, MPI_INT, MPI_SUM, 0, cr->nc.comm_intra); } - MPI_Bcast(r,nr,MPI_INT,0,cr->nc.comm_intra); - } - else + MPI_Bcast(r, nr, MPI_INT, 0, cr->nc.comm_intra); + } + else { - MPI_Allreduce(MPI_IN_PLACE,r,nr,MPI_INT,MPI_SUM,cr->mpi_comm_mygroup); + MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_INT, MPI_SUM, cr->mpi_comm_mygroup); } #else int i; - if (nr > cr->mpb->ibuf_alloc) { + if (nr > cr->mpb->ibuf_alloc) + { cr->mpb->ibuf_alloc = nr; - srenew(cr->mpb->ibuf,cr->mpb->ibuf_alloc); + srenew(cr->mpb->ibuf, cr->mpb->ibuf_alloc); } - if (cr->nc.bUse) { + if (cr->nc.bUse) + { /* Use two step summing */ - MPI_Allreduce(r,cr->mpb->ibuf,nr,MPI_INT,MPI_SUM,cr->nc.comm_intra); - if (cr->nc.rank_intra == 0) { + MPI_Allreduce(r, cr->mpb->ibuf, nr, MPI_INT, MPI_SUM, cr->nc.comm_intra); + if (cr->nc.rank_intra == 0) + { /* Sum with the buffers reversed */ - MPI_Allreduce(cr->mpb->ibuf,r,nr,MPI_INT,MPI_SUM,cr->nc.comm_inter); + MPI_Allreduce(cr->mpb->ibuf, r, nr, MPI_INT, MPI_SUM, cr->nc.comm_inter); } - MPI_Bcast(r,nr,MPI_INT,0,cr->nc.comm_intra); - } else { - MPI_Allreduce(r,cr->mpb->ibuf,nr,MPI_INT,MPI_SUM,cr->mpi_comm_mygroup); - for(i=0; inc.comm_intra); + } + else + { + MPI_Allreduce(r, cr->mpb->ibuf, nr, MPI_INT, MPI_SUM, cr->mpi_comm_mygroup); + for (i = 0; i < nr; i++) + { r[i] = cr->mpb->ibuf[i]; + } } #endif #endif } -void gmx_sumli(int nr,gmx_large_int_t r[],const t_commrec *cr) +void gmx_sumli(int nr, gmx_large_int_t r[], const t_commrec *cr) { #ifndef GMX_MPI gmx_call("gmx_sumli"); #else #if defined(MPI_IN_PLACE_EXISTS) || defined(GMX_THREAD_MPI) - if (cr->nc.bUse) { + if (cr->nc.bUse) + { /* Use two step summing */ - if (cr->nc.rank_intra == 0) + if (cr->nc.rank_intra == 0) { - MPI_Reduce(MPI_IN_PLACE,r,nr,GMX_MPI_LARGE_INT,MPI_SUM,0, + MPI_Reduce(MPI_IN_PLACE, r, nr, GMX_MPI_LARGE_INT, MPI_SUM, 0, cr->nc.comm_intra); /* Sum with the buffers reversed */ - MPI_Allreduce(MPI_IN_PLACE,r,nr,GMX_MPI_LARGE_INT,MPI_SUM, + MPI_Allreduce(MPI_IN_PLACE, r, nr, GMX_MPI_LARGE_INT, MPI_SUM, cr->nc.comm_inter); } else { /* This is here because of the silly MPI specification that MPI_IN_PLACE should be put in sendbuf instead of recvbuf */ - MPI_Reduce(r,NULL,nr,GMX_MPI_LARGE_INT,MPI_SUM,0,cr->nc.comm_intra); + MPI_Reduce(r, NULL, nr, GMX_MPI_LARGE_INT, MPI_SUM, 0, cr->nc.comm_intra); } - MPI_Bcast(r,nr,GMX_MPI_LARGE_INT,0,cr->nc.comm_intra); - } - else + MPI_Bcast(r, nr, GMX_MPI_LARGE_INT, 0, cr->nc.comm_intra); + } + else { - MPI_Allreduce(MPI_IN_PLACE,r,nr,GMX_MPI_LARGE_INT,MPI_SUM,cr->mpi_comm_mygroup); + MPI_Allreduce(MPI_IN_PLACE, r, nr, GMX_MPI_LARGE_INT, MPI_SUM, cr->mpi_comm_mygroup); } #else int i; - if (nr > cr->mpb->libuf_alloc) { + if (nr > cr->mpb->libuf_alloc) + { cr->mpb->libuf_alloc = nr; - srenew(cr->mpb->libuf,cr->mpb->libuf_alloc); + srenew(cr->mpb->libuf, cr->mpb->libuf_alloc); } - if (cr->nc.bUse) { + if (cr->nc.bUse) + { /* Use two step summing */ - MPI_Allreduce(r,cr->mpb->libuf,nr,GMX_MPI_LARGE_INT,MPI_SUM, + MPI_Allreduce(r, cr->mpb->libuf, nr, GMX_MPI_LARGE_INT, MPI_SUM, cr->nc.comm_intra); - if (cr->nc.rank_intra == 0) { + if (cr->nc.rank_intra == 0) + { /* Sum with the buffers reversed */ - MPI_Allreduce(cr->mpb->libuf,r,nr,GMX_MPI_LARGE_INT,MPI_SUM, + MPI_Allreduce(cr->mpb->libuf, r, nr, GMX_MPI_LARGE_INT, MPI_SUM, cr->nc.comm_inter); } - MPI_Bcast(r,nr,GMX_MPI_LARGE_INT,0,cr->nc.comm_intra); - } else { - MPI_Allreduce(r,cr->mpb->libuf,nr,GMX_MPI_LARGE_INT,MPI_SUM, + MPI_Bcast(r, nr, GMX_MPI_LARGE_INT, 0, cr->nc.comm_intra); + } + else + { + MPI_Allreduce(r, cr->mpb->libuf, nr, GMX_MPI_LARGE_INT, MPI_SUM, cr->mpi_comm_mygroup); - for(i=0; impb->libuf[i]; + } } #endif #endif @@ -621,107 +659,117 @@ void gmx_sumli(int nr,gmx_large_int_t r[],const t_commrec *cr) #ifdef GMX_MPI -void gmx_sumd_comm(int nr,double r[],MPI_Comm mpi_comm) +void gmx_sumd_comm(int nr, double r[], MPI_Comm mpi_comm) { #if defined(MPI_IN_PLACE_EXISTS) || defined(GMX_THREAD_MPI) - MPI_Allreduce(MPI_IN_PLACE,r,nr,MPI_DOUBLE,MPI_SUM,mpi_comm); + MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_DOUBLE, MPI_SUM, mpi_comm); #else /* this function is only used in code that is not performance critical, - (during setup, when comm_rec is not the appropriate communication + (during setup, when comm_rec is not the appropriate communication structure), so this isn't as bad as it looks. */ double *buf; - int i; + int i; snew(buf, nr); - MPI_Allreduce(r,buf,nr,MPI_DOUBLE,MPI_SUM,mpi_comm); - for(i=0; impi_comm_masters); + gmx_sumd_comm(nr, r, ms->mpi_comm_masters); #endif } -void gmx_sumf_sim(int nr,float r[],const gmx_multisim_t *ms) +void gmx_sumf_sim(int nr, float r[], const gmx_multisim_t *ms) { #ifndef GMX_MPI - gmx_call("gmx_sumf_sim"); + gmx_call("gmx_sumf_sim"); #else - gmx_sumf_comm(nr,r,ms->mpi_comm_masters); + gmx_sumf_comm(nr, r, ms->mpi_comm_masters); #endif } -void gmx_sumi_sim(int nr,int r[], const gmx_multisim_t *ms) +void gmx_sumi_sim(int nr, int r[], const gmx_multisim_t *ms) { #ifndef GMX_MPI gmx_call("gmx_sumi_sim"); #else #if defined(MPI_IN_PLACE_EXISTS) || defined(GMX_THREAD_MPI) - MPI_Allreduce(MPI_IN_PLACE,r,nr,MPI_INT,MPI_SUM,ms->mpi_comm_masters); + MPI_Allreduce(MPI_IN_PLACE, r, nr, MPI_INT, MPI_SUM, ms->mpi_comm_masters); #else /* this is thread-unsafe, but it will do for now: */ int i; - if (nr > ms->mpb->ibuf_alloc) { + if (nr > ms->mpb->ibuf_alloc) + { ms->mpb->ibuf_alloc = nr; - srenew(ms->mpb->ibuf,ms->mpb->ibuf_alloc); + srenew(ms->mpb->ibuf, ms->mpb->ibuf_alloc); } - MPI_Allreduce(r,ms->mpb->ibuf,nr,MPI_INT,MPI_SUM,ms->mpi_comm_masters); - for(i=0; impb->ibuf, nr, MPI_INT, MPI_SUM, ms->mpi_comm_masters); + for (i = 0; i < nr; i++) + { r[i] = ms->mpb->ibuf[i]; + } #endif #endif } -void gmx_sumli_sim(int nr,gmx_large_int_t r[], const gmx_multisim_t *ms) +void gmx_sumli_sim(int nr, gmx_large_int_t r[], const gmx_multisim_t *ms) { #ifndef GMX_MPI gmx_call("gmx_sumli_sim"); #else #if defined(MPI_IN_PLACE_EXISTS) || defined(GMX_THREAD_MPI) - MPI_Allreduce(MPI_IN_PLACE,r,nr,GMX_MPI_LARGE_INT,MPI_SUM, + MPI_Allreduce(MPI_IN_PLACE, r, nr, GMX_MPI_LARGE_INT, MPI_SUM, ms->mpi_comm_masters); #else /* this is thread-unsafe, but it will do for now: */ int i; - if (nr > ms->mpb->libuf_alloc) { + if (nr > ms->mpb->libuf_alloc) + { ms->mpb->libuf_alloc = nr; - srenew(ms->mpb->libuf,ms->mpb->libuf_alloc); + srenew(ms->mpb->libuf, ms->mpb->libuf_alloc); } - MPI_Allreduce(r,ms->mpb->libuf,nr,GMX_MPI_LARGE_INT,MPI_SUM, + MPI_Allreduce(r, ms->mpb->libuf, nr, GMX_MPI_LARGE_INT, MPI_SUM, ms->mpi_comm_masters); - for(i=0; impb->libuf[i]; + } #endif #endif } @@ -733,7 +781,7 @@ void gmx_finalize_par(void) /* Compiled without MPI, no MPI finalizing needed */ return; #else - int initialized,finalized; + int initialized, finalized; int ret; MPI_Initialized(&initialized); @@ -745,33 +793,36 @@ void gmx_finalize_par(void) MPI_Finalized(&finalized); if (finalized) { - return; + return; } - /* We sync the processes here to try to avoid problems - * with buggy MPI implementations that could cause - * unfinished processes to terminate. - */ - MPI_Barrier(MPI_COMM_WORLD); - - /* - if (DOMAINDECOMP(cr)) { - if (cr->npmenodes > 0 || cr->dd->bCartesian) - MPI_Comm_free(&cr->mpi_comm_mygroup); - if (cr->dd->bCartesian) - MPI_Comm_free(&cr->mpi_comm_mysim); - } - */ + /* We sync the processes here to try to avoid problems + * with buggy MPI implementations that could cause + * unfinished processes to terminate. + */ + MPI_Barrier(MPI_COMM_WORLD); + + /* + if (DOMAINDECOMP(cr)) { + if (cr->npmenodes > 0 || cr->dd->bCartesian) + MPI_Comm_free(&cr->mpi_comm_mygroup); + if (cr->dd->bCartesian) + MPI_Comm_free(&cr->mpi_comm_mysim); + } + */ - /* Apparently certain mpich implementations cause problems - * with MPI_Finalize. In that case comment out MPI_Finalize. - */ - if (debug) - fprintf(debug,"Will call MPI_Finalize now\n"); + /* Apparently certain mpich implementations cause problems + * with MPI_Finalize. In that case comment out MPI_Finalize. + */ + if (debug) + { + fprintf(debug, "Will call MPI_Finalize now\n"); + } - ret = MPI_Finalize(); - if (debug) - fprintf(debug,"Return code from MPI_Finalize = %d\n",ret); + ret = MPI_Finalize(); + if (debug) + { + fprintf(debug, "Return code from MPI_Finalize = %d\n", ret); + } #endif } - diff --git a/src/gromacs/gmxlib/nonbonded/nb_free_energy.c b/src/gromacs/gmxlib/nonbonded/nb_free_energy.c index fb7bbefbd3..6941558aa1 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_free_energy.c +++ b/src/gromacs/gmxlib/nonbonded/nb_free_energy.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -58,28 +58,28 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, #define STATE_A 0 #define STATE_B 1 #define NSTATES 2 - int i,j,n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid; - real shX,shY,shZ; - real Fscal,FscalC[NSTATES],FscalV[NSTATES],tx,ty,tz; - real Vcoul[NSTATES],Vvdw[NSTATES]; - real rinv6,r,rt,rtC,rtV; - real iqA,iqB; - real qq[NSTATES],vctot,krsq; - int ntiA,ntiB,tj[NSTATES]; - real Vvdw6, Vvdw12,vvtot; - real ix,iy,iz,fix,fiy,fiz; - real dx,dy,dz,rsq,rinv; - real c6[NSTATES],c12[NSTATES]; - real LFC[NSTATES],LFV[NSTATES],DLF[NSTATES]; - double dvdl_coul,dvdl_vdw; - real lfac_coul[NSTATES],dlfac_coul[NSTATES],lfac_vdw[NSTATES],dlfac_vdw[NSTATES]; - real sigma6[NSTATES],alpha_vdw_eff,alpha_coul_eff,sigma2_def,sigma2_min; - real rp,rpm2,rC,rV,rinvC,rpinvC,rinvV,rpinvV; - real sigma2[NSTATES],sigma_pow[NSTATES],sigma_powm2[NSTATES],rs,rs2; - int do_coultab,do_vdwtab,do_tab,tab_elemsize; - int n0,n1C,n1V,nnn; - real Y,F,G,H,Fp,Geps,Heps2,epsC,eps2C,epsV,eps2V,VV,FF; - int icoul,ivdw; + int i, j, n, ii, is3, ii3, k, nj0, nj1, jnr, j3, ggid; + real shX, shY, shZ; + real Fscal, FscalC[NSTATES], FscalV[NSTATES], tx, ty, tz; + real Vcoul[NSTATES], Vvdw[NSTATES]; + real rinv6, r, rt, rtC, rtV; + real iqA, iqB; + real qq[NSTATES], vctot, krsq; + int ntiA, ntiB, tj[NSTATES]; + real Vvdw6, Vvdw12, vvtot; + real ix, iy, iz, fix, fiy, fiz; + real dx, dy, dz, rsq, rinv; + real c6[NSTATES], c12[NSTATES]; + real LFC[NSTATES], LFV[NSTATES], DLF[NSTATES]; + double dvdl_coul, dvdl_vdw; + real lfac_coul[NSTATES], dlfac_coul[NSTATES], lfac_vdw[NSTATES], dlfac_vdw[NSTATES]; + real sigma6[NSTATES], alpha_vdw_eff, alpha_coul_eff, sigma2_def, sigma2_min; + real rp, rpm2, rC, rV, rinvC, rpinvC, rinvV, rpinvV; + real sigma2[NSTATES], sigma_pow[NSTATES], sigma_powm2[NSTATES], rs, rs2; + int do_coultab, do_vdwtab, do_tab, tab_elemsize; + int n0, n1C, n1V, nnn; + real Y, F, G, H, Fp, Geps, Heps2, epsC, eps2C, epsV, eps2V, VV, FF; + int icoul, ivdw; int nri; int * iinr; int * jindex; @@ -96,19 +96,19 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, real * VFtab; real * x; real * f; - real facel,krf,crf; + real facel, krf, crf; real * chargeA; real * chargeB; - real sigma6_min,sigma6_def,lam_power,sc_power,sc_r_power; - real alpha_coul,alpha_vdw,lambda_coul,lambda_vdw,ewc; + real sigma6_min, sigma6_def, lam_power, sc_power, sc_r_power; + real alpha_coul, alpha_vdw, lambda_coul, lambda_vdw, ewc; real * nbfp; real * dvdl; real * Vv; real * Vc; gmx_bool bDoForces; - real rcoulomb,rvdw,factor_coul,factor_vdw,sh_invrc6; - gmx_bool bExactElecCutoff,bExactVdwCutoff; - real rcutoff,rcutoff2,rswitch,d,d2,swV3,swV4,swV5,swF2,swF3,swF4,sw,dsw,rinvcorr; + real rcoulomb, rvdw, factor_coul, factor_vdw, sh_invrc6; + gmx_bool bExactElecCutoff, bExactVdwCutoff; + real rcutoff, rcutoff2, rswitch, d, d2, swV3, swV4, swV5, swF2, swF3, swF4, sw, dsw, rinvcorr; x = xx[0]; f = ff[0]; @@ -158,11 +158,11 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, rvdw = fr->rvdw; sh_invrc6 = fr->ic->sh_invrc6; - if(fr->coulomb_modifier==eintmodPOTSWITCH || fr->vdw_modifier==eintmodPOTSWITCH) + if (fr->coulomb_modifier == eintmodPOTSWITCH || fr->vdw_modifier == eintmodPOTSWITCH) { - rcutoff = (fr->coulomb_modifier==eintmodPOTSWITCH) ? fr->rcoulomb : fr->rvdw; + rcutoff = (fr->coulomb_modifier == eintmodPOTSWITCH) ? fr->rcoulomb : fr->rvdw; rcutoff2 = rcutoff*rcutoff; - rswitch = (fr->coulomb_modifier==eintmodPOTSWITCH) ? fr->rcoulomb_switch : fr->rvdw_switch; + rswitch = (fr->coulomb_modifier == eintmodPOTSWITCH) ? fr->rcoulomb_switch : fr->rvdw_switch; d = rcutoff-rswitch; swV3 = -10.0/(d*d*d); swV4 = 15.0/(d*d*d*d); @@ -183,8 +183,8 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, swF4 = 0.0; } - bExactElecCutoff = (fr->coulomb_modifier!=eintmodNONE) || fr->eeltype == eelRF_ZERO; - bExactVdwCutoff = (fr->vdw_modifier!=eintmodNONE); + bExactElecCutoff = (fr->coulomb_modifier != eintmodNONE) || fr->eeltype == eelRF_ZERO; + bExactVdwCutoff = (fr->vdw_modifier != eintmodNONE); /* fix compiler warnings */ nj1 = 0; @@ -207,37 +207,37 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, DLF[STATE_A] = -1; DLF[STATE_B] = 1; - for (i=0;i 0) && (c12[i] > 0)) + if ((c6[i] > 0) && (c12[i] > 0)) { /* c12 is stored scaled with 12.0 and c6 is scaled with 6.0 - correct for this */ sigma6[i] = 0.5*c12[i]/c6[i]; - sigma2[i] = pow(sigma6[i],1.0/3.0); + sigma2[i] = pow(sigma6[i], 1.0/3.0); /* should be able to get rid of this ^^^ internal pow call eventually. Will require agreement on what data to store externally. Can't be fixed without larger scale changes, so not 4.6 */ - if (sigma6[i] < sigma6_min) { /* for disappearing coul and vdw with soft core at the same time */ + if (sigma6[i] < sigma6_min) /* for disappearing coul and vdw with soft core at the same time */ + { sigma6[i] = sigma6_min; sigma2[i] = sigma2_min; } @@ -312,30 +313,33 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, sigma_pow[i] = sigma6[i]; sigma_powm2[i] = sigma6[i]/sigma2[i]; } - else if (sc_r_power == 48.0) + else if (sc_r_power == 48.0) { - sigma_pow[i] = sigma6[i]*sigma6[i]; /* sigma^12 */ + sigma_pow[i] = sigma6[i]*sigma6[i]; /* sigma^12 */ sigma_pow[i] = sigma_pow[i]*sigma_pow[i]; /* sigma^24 */ sigma_pow[i] = sigma_pow[i]*sigma_pow[i]; /* sigma^48 */ - sigma_powm2[i] = sigma_pow[i]/sigma2[i]; + sigma_powm2[i] = sigma_pow[i]/sigma2[i]; } - else + else { /* not really supported as input, but in here for testing the general case*/ - sigma_pow[i] = pow(sigma2[i],sc_r_power/2); + sigma_pow[i] = pow(sigma2[i], sc_r_power/2); sigma_powm2[i] = sigma_pow[i]/(sigma2[i]); } } /* only use softcore if one of the states has a zero endstate - softcore is for avoiding infinities!*/ - if ((c12[STATE_A] > 0) && (c12[STATE_B] > 0)) { + if ((c12[STATE_A] > 0) && (c12[STATE_B] > 0)) + { alpha_vdw_eff = 0; alpha_coul_eff = 0; - } else { + } + else + { alpha_vdw_eff = alpha_vdw; alpha_coul_eff = alpha_coul; } - for (i=0;icoulomb_modifier==eintmodPOTSWITCH) + if (fr->coulomb_modifier == eintmodPOTSWITCH) { d = rC-rswitch; - d = (d>0.0) ? d : 0.0; + d = (d > 0.0) ? d : 0.0; d2 = d*d; sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); dsw = d2*(swF2+d*(swF3+d*swF4)); @@ -422,16 +426,16 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, FscalC[i] = FscalC[i]*sw + Vcoul[i]*dsw; } - if(bExactElecCutoff) + if (bExactElecCutoff) { - FscalC[i] = (rCvdw_modifier==eintmodPOTSHIFT) + if (fr->vdw_modifier == eintmodPOTSHIFT) { Vvdw[i] = ( (Vvdw12-c12[i]*sh_invrc6*sh_invrc6)*(1.0/12.0) - -(Vvdw6-c6[i]*sh_invrc6)*(1.0/6.0)); + -(Vvdw6-c6[i]*sh_invrc6)*(1.0/6.0)); } else { @@ -458,7 +462,7 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, break; case GMX_NBKERNEL_VDW_BUCKINGHAM: - gmx_fatal(FARGS,"Buckingham free energy not supported."); + gmx_fatal(FARGS, "Buckingham free energy not supported."); break; case GMX_NBKERNEL_VDW_CUBICSPLINETABLE: @@ -493,10 +497,10 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, break; } - if(fr->vdw_modifier==eintmodPOTSWITCH) + if (fr->vdw_modifier == eintmodPOTSWITCH) { d = rV-rswitch; - d = (d>0.0) ? d : 0.0; + d = (d > 0.0) ? d : 0.0; d2 = d*d; sw = 1.0+d2*d*(swV3+d*(swV4+d*swV5)); dsw = d2*(swF2+d*(swF3+d*swF4)); @@ -504,8 +508,8 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, Vvdw[i] *= sw; FscalV[i] = FscalV[i]*sw + Vvdw[i]*dsw; - FscalV[i] = (rVnri*12 + nlist->jindex[n]*150); + inc_nrnb(nrnb, eNR_NBKERNEL_FREE_ENERGY, nlist->nri*12 + nlist->jindex[n]*150); } real -nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul,real alpha_vdw, - real tabscale,real *vftab, +nb_free_energy_evaluate_single(real r2, real sc_r_power, real alpha_coul, real alpha_vdw, + real tabscale, real *vftab, real qqA, real c6A, real c12A, real qqB, real c6B, real c12B, - real LFC[2], real LFV[2],real DLF[2], - real lfac_coul[2], real lfac_vdw[2],real dlfac_coul[2], real dlfac_vdw[2], - real sigma6_def, real sigma6_min,real sigma2_def, real sigma2_min, + real LFC[2], real LFV[2], real DLF[2], + real lfac_coul[2], real lfac_vdw[2], real dlfac_coul[2], real dlfac_vdw[2], + real sigma6_def, real sigma6_min, real sigma2_def, real sigma2_min, real *velectot, real *vvdwtot, real *dvdl) { - real r,rp,rpm2,rtab,eps,eps2,Y,F,Geps,Heps2,Fp,VV,FF,fscal; - real qq[2],c6[2],c12[2],sigma6[2],sigma2[2],sigma_pow[2],sigma_powm2[2]; - real alpha_coul_eff,alpha_vdw_eff,dvdl_coul,dvdl_vdw; - real rpinv,r_coul,r_vdw,velecsum,vvdwsum; - real fscal_vdw[2],fscal_elec[2]; - real velec[2],vvdw[2]; - int i,ntab; + real r, rp, rpm2, rtab, eps, eps2, Y, F, Geps, Heps2, Fp, VV, FF, fscal; + real qq[2], c6[2], c12[2], sigma6[2], sigma2[2], sigma_pow[2], sigma_powm2[2]; + real alpha_coul_eff, alpha_vdw_eff, dvdl_coul, dvdl_vdw; + real rpinv, r_coul, r_vdw, velecsum, vvdwsum; + real fscal_vdw[2], fscal_elec[2]; + real velec[2], vvdw[2]; + int i, ntab; qq[0] = qqA; qq[1] = qqB; @@ -615,36 +619,37 @@ nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul,real alph if (sc_r_power == 6.0) { - rpm2 = r2*r2; /* r4 */ + rpm2 = r2*r2; /* r4 */ rp = rpm2*r2; /* r6 */ } else if (sc_r_power == 48.0) { - rp = r2*r2*r2; /* r6 */ - rp = rp*rp; /* r12 */ - rp = rp*rp; /* r24 */ - rp = rp*rp; /* r48 */ - rpm2 = rp/r2; /* r46 */ + rp = r2*r2*r2; /* r6 */ + rp = rp*rp; /* r12 */ + rp = rp*rp; /* r24 */ + rp = rp*rp; /* r48 */ + rpm2 = rp/r2; /* r46 */ } else { - rp = pow(r2,0.5*sc_r_power); /* not currently supported as input, but can handle it */ + rp = pow(r2, 0.5*sc_r_power); /* not currently supported as input, but can handle it */ rpm2 = rp/r2; } /* Loop over state A(0) and B(1) */ - for (i=0;i<2;i++) + for (i = 0; i < 2; i++) { - if((c6[i] > 0) && (c12[i] > 0)) + if ((c6[i] > 0) && (c12[i] > 0)) { /* The c6 & c12 coefficients now contain the constants 6.0 and 12.0, respectively. * Correct for this by multiplying with (1/12.0)/(1/6.0)=6.0/12.0=0.5. */ sigma6[i] = 0.5*c12[i]/c6[i]; - sigma2[i] = pow(0.5*c12[i]/c6[i],1.0/3.0); + sigma2[i] = pow(0.5*c12[i]/c6[i], 1.0/3.0); /* should be able to get rid of this ^^^ internal pow call eventually. Will require agreement on - what data to store externally. Can't be fixed without larger scale changes, so not 4.6 */ - if (sigma6[i] < sigma6_min) { /* for disappearing coul and vdw with soft core at the same time */ + what data to store externally. Can't be fixed without larger scale changes, so not 4.6 */ + if (sigma6[i] < sigma6_min) /* for disappearing coul and vdw with soft core at the same time */ + { sigma6[i] = sigma6_min; sigma2[i] = sigma2_min; } @@ -661,29 +666,32 @@ nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul,real alph } else if (sc_r_power == 48.0) { - sigma_pow[i] = sigma6[i]*sigma6[i]; /* sigma^12 */ + sigma_pow[i] = sigma6[i]*sigma6[i]; /* sigma^12 */ sigma_pow[i] = sigma_pow[i]*sigma_pow[i]; /* sigma^24 */ sigma_pow[i] = sigma_pow[i]*sigma_pow[i]; /* sigma^48 */ sigma_powm2[i] = sigma_pow[i]/sigma2[i]; } else { /* not really supported as input, but in here for testing the general case*/ - sigma_pow[i] = pow(sigma2[i],sc_r_power/2); + sigma_pow[i] = pow(sigma2[i], sc_r_power/2); sigma_powm2[i] = sigma_pow[i]/(sigma2[i]); } } /* only use softcore if one of the states has a zero endstate - softcore is for avoiding infinities!*/ - if ((c12[0] > 0) && (c12[1] > 0)) { + if ((c12[0] > 0) && (c12[1] > 0)) + { alpha_vdw_eff = 0; alpha_coul_eff = 0; - } else { + } + else + { alpha_vdw_eff = alpha_vdw; alpha_coul_eff = alpha_coul; } /* Loop over A and B states again */ - for (i=0;i<2;i++) + for (i = 0; i < 2; i++) { fscal_elec[i] = 0; fscal_vdw[i] = 0; @@ -691,11 +699,11 @@ nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul,real alph vvdw[i] = 0; /* Only spend time on A or B state if it is non-zero */ - if( (qq[i] != 0) || (c6[i] != 0) || (c12[i] != 0) ) + if ( (qq[i] != 0) || (c6[i] != 0) || (c12[i] != 0) ) { /* Coulomb */ rpinv = 1.0/(alpha_coul_eff*lfac_coul[i]*sigma_pow[i]+rp); - r_coul = pow(rpinv,-1.0/sc_r_power); + r_coul = pow(rpinv, -1.0/sc_r_power); /* Electrostatics table lookup data */ rtab = r_coul*tabscale; @@ -716,7 +724,7 @@ nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul,real alph /* Vdw */ rpinv = 1.0/(alpha_vdw_eff*lfac_vdw[i]*sigma_pow[i]+rp); - r_vdw = pow(rpinv,-1.0/sc_r_power); + r_vdw = pow(rpinv, -1.0/sc_r_power); /* Vdw table lookup data */ rtab = r_vdw*tabscale; ntab = rtab; @@ -754,7 +762,7 @@ nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul,real alph dvdl_coul = 0; dvdl_vdw = 0; fscal = 0; - for (i=0;i<2;i++) + for (i = 0; i < 2; i++) { velecsum += LFC[i]*velec[i]; vvdwsum += LFV[i]*vvdw[i]; @@ -773,4 +781,3 @@ nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul,real alph return fscal; } - diff --git a/src/gromacs/gmxlib/nonbonded/nb_free_energy.h b/src/gromacs/gmxlib/nonbonded/nb_free_energy.h index 4e7c63805a..f1b2217876 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_free_energy.h +++ b/src/gromacs/gmxlib/nonbonded/nb_free_energy.h @@ -1,33 +1,33 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2008, 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 - * + * * And Hey: * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon */ @@ -48,14 +48,13 @@ gmx_nb_free_energy_kernel(t_nblist * nlist, t_nrnb * nrnb); real -nb_free_energy_evaluate_single(real r2,real sc_r_power,real alpha_coul, - real alpha_vdw,real tabscale,real *vftab, - real qqA, real c6A, real c12A, real qqB, - real c6B, real c12B,real LFC[2], real LFV[2],real DLF[2], - real lfac_coul[2], real lfac_vdw[2],real dlfac_coul[2], - real dlfac_vdw[2],real sigma6_def, real sigma6_min, - real sigma2_def, real sigma2_min, - real *velectot, real *vvdwtot, real *dvdl); + nb_free_energy_evaluate_single(real r2, real sc_r_power, real alpha_coul, + real alpha_vdw, real tabscale, real *vftab, + real qqA, real c6A, real c12A, real qqB, + real c6B, real c12B, real LFC[2], real LFV[2], real DLF[2], + real lfac_coul[2], real lfac_vdw[2], real dlfac_coul[2], + real dlfac_vdw[2], real sigma6_def, real sigma6_min, + real sigma2_def, real sigma2_min, + real *velectot, real *vvdwtot, real *dvdl); #endif - diff --git a/src/gromacs/gmxlib/nonbonded/nb_generic.c b/src/gromacs/gmxlib/nonbonded/nb_generic.c index a9e39ca3b4..bb3ec449c4 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_generic.c +++ b/src/gromacs/gmxlib/nonbonded/nb_generic.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -57,24 +57,24 @@ gmx_nb_generic_kernel(t_nblist * nlist, nb_kernel_data_t * kernel_data, t_nrnb * nrnb) { - int nri,ntype,table_nelements,ielec,ivdw; - real facel,gbtabscale; - int n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid,nnn,n0; - real shX,shY,shZ; - real fscal,felec,fvdw,velec,vvdw,tx,ty,tz; + int nri, ntype, table_nelements, ielec, ivdw; + real facel, gbtabscale; + int n, ii, is3, ii3, k, nj0, nj1, jnr, j3, ggid, nnn, n0; + real shX, shY, shZ; + real fscal, felec, fvdw, velec, vvdw, tx, ty, tz; real rinvsq; real iq; - real qq,vctot; - int nti,nvdwparam; + real qq, vctot; + int nti, nvdwparam; int tj; - real rt,r,eps,eps2,Y,F,Geps,Heps2,VV,FF,Fp,fijD,fijR; + real rt, r, eps, eps2, Y, F, Geps, Heps2, VV, FF, Fp, fijD, fijR; real rinvsix; real vvdwtot; - real vvdw_rep,vvdw_disp; - real ix,iy,iz,fix,fiy,fiz; - real jx,jy,jz; - real dx,dy,dz,rsq,rinv; - real c6,c12,cexp1,cexp2,br; + real vvdw_rep, vvdw_disp; + real ix, iy, iz, fix, fiy, fiz; + real jx, jy, jz; + real dx, dy, dz, rsq, rinv; + real c6, c12, cexp1, cexp2, br; real * charge; real * shiftvec; real * vdwparam; @@ -88,14 +88,14 @@ gmx_nb_generic_kernel(t_nblist * nlist, real * x; real * f; int ewitab; - real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace; + real ewtabscale, eweps, sh_ewald, ewrt, ewtabhalfspace; real * ewtab; - real rcoulomb2,rvdw,rvdw2,sh_invrc6; - real rcutoff,rcutoff2; - real rswitch_elec,rswitch_vdw,d,d2,sw,dsw,rinvcorr; - real elec_swV3,elec_swV4,elec_swV5,elec_swF2,elec_swF3,elec_swF4; - real vdw_swV3,vdw_swV4,vdw_swV5,vdw_swF2,vdw_swF3,vdw_swF4; - gmx_bool bExactElecCutoff,bExactVdwCutoff,bExactCutoff; + real rcoulomb2, rvdw, rvdw2, sh_invrc6; + real rcutoff, rcutoff2; + real rswitch_elec, rswitch_vdw, d, d2, sw, dsw, rinvcorr; + real elec_swV3, elec_swV4, elec_swV5, elec_swF2, elec_swF3, elec_swF4; + real vdw_swV3, vdw_swV4, vdw_swV5, vdw_swF2, vdw_swF3, vdw_swF4; + gmx_bool bExactElecCutoff, bExactVdwCutoff, bExactCutoff; x = xx[0]; f = ff[0]; @@ -118,7 +118,7 @@ gmx_nb_generic_kernel(t_nblist * nlist, rvdw2 = rvdw*rvdw; sh_invrc6 = fr->ic->sh_invrc6; - if(fr->coulomb_modifier==eintmodPOTSWITCH) + if (fr->coulomb_modifier == eintmodPOTSWITCH) { d = fr->rcoulomb-fr->rcoulomb_switch; elec_swV3 = -10.0/(d*d*d); @@ -133,7 +133,7 @@ gmx_nb_generic_kernel(t_nblist * nlist, /* Avoid warnings from stupid compilers (looking at you, Clang!) */ elec_swV3 = elec_swV4 = elec_swV5 = elec_swF2 = elec_swF3 = elec_swF4 = 0.0; } - if(fr->vdw_modifier==eintmodPOTSWITCH) + if (fr->vdw_modifier == eintmodPOTSWITCH) { d = fr->rvdw-fr->rvdw_switch; vdw_swV3 = -10.0/(d*d*d); @@ -149,11 +149,11 @@ gmx_nb_generic_kernel(t_nblist * nlist, vdw_swV3 = vdw_swV4 = vdw_swV5 = vdw_swF2 = vdw_swF3 = vdw_swF4 = 0.0; } - bExactElecCutoff = (fr->coulomb_modifier!=eintmodNONE) || fr->eeltype == eelRF_ZERO; - bExactVdwCutoff = (fr->vdw_modifier!=eintmodNONE); + bExactElecCutoff = (fr->coulomb_modifier != eintmodNONE) || fr->eeltype == eelRF_ZERO; + bExactVdwCutoff = (fr->vdw_modifier != eintmodNONE); bExactCutoff = bExactElecCutoff || bExactVdwCutoff; - if(bExactCutoff) + if (bExactCutoff) { rcutoff = ( fr->rcoulomb > fr->rvdw ) ? fr->rcoulomb : fr->rvdw; rcutoff2 = rcutoff*rcutoff; @@ -170,7 +170,7 @@ gmx_nb_generic_kernel(t_nblist * nlist, eps2 = 0.0; /* 3 VdW parameters for buckingham, otherwise 2 */ - nvdwparam = (ivdw==GMX_NBKERNEL_VDW_BUCKINGHAM) ? 3 : 2; + nvdwparam = (ivdw == GMX_NBKERNEL_VDW_BUCKINGHAM) ? 3 : 2; table_nelements = 12; charge = mdatoms->chargeA; @@ -180,51 +180,51 @@ gmx_nb_generic_kernel(t_nblist * nlist, vdwparam = fr->nbfp; ntype = fr->ntype; - for(n=0; (nnri); n++) + for (n = 0; (n < nlist->nri); n++) { is3 = 3*nlist->shift[n]; - shX = shiftvec[is3]; + shX = shiftvec[is3]; shY = shiftvec[is3+1]; shZ = shiftvec[is3+2]; - nj0 = nlist->jindex[n]; - nj1 = nlist->jindex[n+1]; - ii = nlist->iinr[n]; - ii3 = 3*ii; + nj0 = nlist->jindex[n]; + nj1 = nlist->jindex[n+1]; + ii = nlist->iinr[n]; + ii3 = 3*ii; ix = shX + x[ii3+0]; iy = shY + x[ii3+1]; iz = shZ + x[ii3+2]; iq = facel*charge[ii]; nti = nvdwparam*ntype*type[ii]; - vctot = 0; + vctot = 0; vvdwtot = 0; fix = 0; fiy = 0; - fiz = 0; - - for(k=nj0; (kjjnr[k]; - j3 = 3*jnr; - jx = x[j3+0]; - jy = x[j3+1]; - jz = x[j3+2]; - dx = ix - jx; - dy = iy - jy; - dz = iz - jz; + jnr = nlist->jjnr[k]; + j3 = 3*jnr; + jx = x[j3+0]; + jy = x[j3+1]; + jz = x[j3+2]; + dx = ix - jx; + dy = iy - jy; + dz = iz - jz; rsq = dx*dx+dy*dy+dz*dz; rinv = gmx_invsqrt(rsq); - rinvsq = rinv*rinv; + rinvsq = rinv*rinv; felec = 0; fvdw = 0; velec = 0; vvdw = 0; - if(bExactCutoff && rsq>rcutoff2) + if (bExactCutoff && rsq > rcutoff2) { continue; } - if(ielec==GMX_NBKERNEL_ELEC_CUBICSPLINETABLE || ivdw==GMX_NBKERNEL_VDW_CUBICSPLINETABLE) + if (ielec == GMX_NBKERNEL_ELEC_CUBICSPLINETABLE || ivdw == GMX_NBKERNEL_VDW_CUBICSPLINETABLE) { r = rsq*rinv; rt = r*tabscale; @@ -235,11 +235,11 @@ gmx_nb_generic_kernel(t_nblist * nlist, } /* Coulomb interaction. ielec==0 means no interaction */ - if(ielec!=GMX_NBKERNEL_ELEC_NONE) + if (ielec != GMX_NBKERNEL_ELEC_NONE) { qq = iq*charge[jnr]; - switch(ielec) + switch (ielec) { case GMX_NBKERNEL_ELEC_NONE: break; @@ -271,7 +271,7 @@ gmx_nb_generic_kernel(t_nblist * nlist, case GMX_NBKERNEL_ELEC_GENERALIZEDBORN: /* GB */ - gmx_fatal(FARGS,"Death & horror! GB generic interaction not implemented.\n"); + gmx_fatal(FARGS, "Death & horror! GB generic interaction not implemented.\n"); break; case GMX_NBKERNEL_ELEC_EWALD: @@ -280,19 +280,19 @@ gmx_nb_generic_kernel(t_nblist * nlist, eweps = ewrt-ewitab; ewitab = 4*ewitab; felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; - rinvcorr = (fr->coulomb_modifier==eintmodPOTSHIFT) ? rinv-fr->ic->sh_ewald : rinv; + rinvcorr = (fr->coulomb_modifier == eintmodPOTSHIFT) ? rinv-fr->ic->sh_ewald : rinv; velec = qq*(rinvcorr-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); felec = qq*rinv*(rinvsq-felec); break; default: - gmx_fatal(FARGS,"Death & horror! No generic coulomb interaction for ielec=%d.\n",ielec); + gmx_fatal(FARGS, "Death & horror! No generic coulomb interaction for ielec=%d.\n", ielec); break; } - if(fr->coulomb_modifier==eintmodPOTSWITCH) + if (fr->coulomb_modifier == eintmodPOTSWITCH) { d = rsq*rinv-fr->rcoulomb_switch; - d = (d>0.0) ? d : 0.0; + d = (d > 0.0) ? d : 0.0; d2 = d*d; sw = 1.0+d2*d*(elec_swV3+d*(elec_swV4+d*elec_swV5)); dsw = d2*(elec_swF2+d*(elec_swF3+d*elec_swF4)); @@ -304,21 +304,21 @@ gmx_nb_generic_kernel(t_nblist * nlist, /* Once we have used velec to update felec we can modify velec too */ velec *= sw; } - if(bExactElecCutoff) + if (bExactElecCutoff) { - felec = (rsq<=rcoulomb2) ? felec : 0.0; - velec = (rsq<=rcoulomb2) ? velec : 0.0; + felec = (rsq <= rcoulomb2) ? felec : 0.0; + velec = (rsq <= rcoulomb2) ? velec : 0.0; } vctot += velec; } /* End of coulomb interactions */ /* VdW interaction. ivdw==0 means no interaction */ - if(ivdw!=GMX_NBKERNEL_VDW_NONE) + if (ivdw != GMX_NBKERNEL_VDW_NONE) { tj = nti+nvdwparam*type[jnr]; - switch(ivdw) + switch (ivdw) { case GMX_NBKERNEL_VDW_NONE: break; @@ -331,7 +331,7 @@ gmx_nb_generic_kernel(t_nblist * nlist, vvdw_disp = c6*rinvsix; vvdw_rep = c12*rinvsix*rinvsix; fvdw = (vvdw_rep-vvdw_disp)*rinvsq; - if(fr->vdw_modifier==eintmodPOTSHIFT) + if (fr->vdw_modifier == eintmodPOTSHIFT) { vvdw = (vvdw_rep-c12*sh_invrc6*sh_invrc6)*(1.0/12.0)-(vvdw_disp-c6*sh_invrc6)*(1.0/6.0); } @@ -352,7 +352,7 @@ gmx_nb_generic_kernel(t_nblist * nlist, br = cexp2*rsq*rinv; vvdw_rep = cexp1*exp(-br); fvdw = (br*vvdw_rep-vvdw_disp)*rinvsq; - if(fr->vdw_modifier==eintmodPOTSHIFT) + if (fr->vdw_modifier == eintmodPOTSHIFT) { vvdw = (vvdw_rep-cexp1*exp(-cexp2*rvdw))-(vvdw_disp-c6*sh_invrc6)/6.0; } @@ -389,13 +389,13 @@ gmx_nb_generic_kernel(t_nblist * nlist, break; default: - gmx_fatal(FARGS,"Death & horror! No generic VdW interaction for ivdw=%d.\n",ivdw); + gmx_fatal(FARGS, "Death & horror! No generic VdW interaction for ivdw=%d.\n", ivdw); break; } - if(fr->vdw_modifier==eintmodPOTSWITCH) + if (fr->vdw_modifier == eintmodPOTSWITCH) { d = rsq*rinv-fr->rvdw_switch; - d = (d>0.0) ? d : 0.0; + d = (d > 0.0) ? d : 0.0; d2 = d*d; sw = 1.0+d2*d*(vdw_swV3+d*(vdw_swV4+d*vdw_swV5)); dsw = d2*(vdw_swF2+d*(vdw_swF3+d*vdw_swF4)); @@ -403,10 +403,10 @@ gmx_nb_generic_kernel(t_nblist * nlist, fvdw = fvdw*sw - rinv*vvdw*dsw; vvdw *= sw; } - if(bExactVdwCutoff) + if (bExactVdwCutoff) { - fvdw = (rsq<=rvdw2) ? fvdw : 0.0; - vvdw = (rsq<=rvdw2) ? vvdw : 0.0; + fvdw = (rsq <= rvdw2) ? fvdw : 0.0; + vvdw = (rsq <= rvdw2) ? vvdw : 0.0; } vvdwtot += vvdw; } /* end VdW interactions */ @@ -438,5 +438,5 @@ gmx_nb_generic_kernel(t_nblist * nlist, * 12 flops per outer iteration * 50 flops per inner iteration */ - inc_nrnb(nrnb,eNR_NBKERNEL_GENERIC,nlist->nri*12 + nlist->jindex[n]*50); + inc_nrnb(nrnb, eNR_NBKERNEL_GENERIC, nlist->nri*12 + nlist->jindex[n]*50); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_generic.h b/src/gromacs/gmxlib/nonbonded/nb_generic.h index 845ca56997..c5933d146e 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_generic.h +++ b/src/gromacs/gmxlib/nonbonded/nb_generic.h @@ -1,33 +1,33 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2008, 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 - * + * * And Hey: * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon */ @@ -50,4 +50,3 @@ gmx_nb_generic_kernel(t_nblist * nlist, #endif - diff --git a/src/gromacs/gmxlib/nonbonded/nb_generic_adress.c b/src/gromacs/gmxlib/nonbonded/nb_generic_adress.c index fe3d8d83e9..7a96c75a31 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_generic_adress.c +++ b/src/gromacs/gmxlib/nonbonded/nb_generic_adress.c @@ -55,31 +55,31 @@ #define ALMOST_ONE 1-(1e-30) void gmx_nb_generic_adress_kernel(t_nblist * nlist, - rvec * xx, - rvec * ff, - t_forcerec * fr, - t_mdatoms * mdatoms, - nb_kernel_data_t * kernel_data, - t_nrnb * nrnb) + rvec * xx, + rvec * ff, + t_forcerec * fr, + t_mdatoms * mdatoms, + nb_kernel_data_t * kernel_data, + t_nrnb * nrnb) { - int nri,ntype,table_nelements,ielec,ivdw; - real facel,gbtabscale; - int n,ii,is3,ii3,k,nj0,nj1,jnr,j3,ggid,nnn,n0; - real shX,shY,shZ; - real fscal,felec,fvdw,velec,vvdw,tx,ty,tz; + int nri, ntype, table_nelements, ielec, ivdw; + real facel, gbtabscale; + int n, ii, is3, ii3, k, nj0, nj1, jnr, j3, ggid, nnn, n0; + real shX, shY, shZ; + real fscal, felec, fvdw, velec, vvdw, tx, ty, tz; real rinvsq; real iq; - real qq,vctot; - int nti,nvdwparam; + real qq, vctot; + int nti, nvdwparam; int tj; - real rt,r,eps,eps2,Y,F,Geps,Heps2,VV,FF,Fp,fijD,fijR; + real rt, r, eps, eps2, Y, F, Geps, Heps2, VV, FF, Fp, fijD, fijR; real rinvsix; real vvdwtot; - real vvdw_rep,vvdw_disp; - real ix,iy,iz,fix,fiy,fiz; - real jx,jy,jz; - real dx,dy,dz,rsq,rinv; - real c6,c12,cexp1,cexp2,br; + real vvdw_rep, vvdw_disp; + real ix, iy, iz, fix, fiy, fiz; + real jx, jy, jz; + real dx, dy, dz, rsq, rinv; + real c6, c12, cexp1, cexp2, br; real * charge; real * shiftvec; real * vdwparam; @@ -93,23 +93,23 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, real * x; real * f; int ewitab; - real ewtabscale,eweps,sh_ewald,ewrt,ewtabhalfspace; + real ewtabscale, eweps, sh_ewald, ewrt, ewtabhalfspace; real * ewtab; - real rcoulomb2,rvdw,rvdw2,sh_invrc6; - real rcutoff,rcutoff2; - real rswitch_elec,rswitch_vdw,d,d2,sw,dsw,rinvcorr; - real elec_swV3,elec_swV4,elec_swV5,elec_swF2,elec_swF3,elec_swF4; - real vdw_swV3,vdw_swV4,vdw_swV5,vdw_swF2,vdw_swF3,vdw_swF4; - gmx_bool bExactElecCutoff,bExactVdwCutoff,bExactCutoff; - - real * wf; - real weight_cg1; - real weight_cg2; - real weight_product; - real hybscal; /* the multiplicator to the force for hybrid interactions*/ - real force_cap; - gmx_bool bCG; - int egp_nr; + real rcoulomb2, rvdw, rvdw2, sh_invrc6; + real rcutoff, rcutoff2; + real rswitch_elec, rswitch_vdw, d, d2, sw, dsw, rinvcorr; + real elec_swV3, elec_swV4, elec_swV5, elec_swF2, elec_swF3, elec_swF4; + real vdw_swV3, vdw_swV4, vdw_swV5, vdw_swF2, vdw_swF3, vdw_swF4; + gmx_bool bExactElecCutoff, bExactVdwCutoff, bExactCutoff; + + real * wf; + real weight_cg1; + real weight_cg2; + real weight_product; + real hybscal; /* the multiplicator to the force for hybrid interactions*/ + real force_cap; + gmx_bool bCG; + int egp_nr; wf = mdatoms->wf; @@ -136,7 +136,7 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, rvdw2 = rvdw*rvdw; sh_invrc6 = fr->ic->sh_invrc6; - if(fr->coulomb_modifier==eintmodPOTSWITCH) + if (fr->coulomb_modifier == eintmodPOTSWITCH) { d = fr->rcoulomb-fr->rcoulomb_switch; elec_swV3 = -10.0/(d*d*d); @@ -151,7 +151,7 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, /* Avoid warnings from stupid compilers (looking at you, Clang!) */ elec_swV3 = elec_swV4 = elec_swV5 = elec_swF2 = elec_swF3 = elec_swF4 = 0.0; } - if(fr->vdw_modifier==eintmodPOTSWITCH) + if (fr->vdw_modifier == eintmodPOTSWITCH) { d = fr->rvdw-fr->rvdw_switch; vdw_swV3 = -10.0/(d*d*d); @@ -167,11 +167,11 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, vdw_swV3 = vdw_swV4 = vdw_swV5 = vdw_swF2 = vdw_swF3 = vdw_swF4 = 0.0; } - bExactElecCutoff = (fr->coulomb_modifier!=eintmodNONE) || fr->eeltype == eelRF_ZERO; - bExactVdwCutoff = (fr->vdw_modifier!=eintmodNONE); + bExactElecCutoff = (fr->coulomb_modifier != eintmodNONE) || fr->eeltype == eelRF_ZERO; + bExactVdwCutoff = (fr->vdw_modifier != eintmodNONE); bExactCutoff = bExactElecCutoff || bExactVdwCutoff; - if(bExactCutoff) + if (bExactCutoff) { rcutoff = ( fr->rcoulomb > fr->rvdw ) ? fr->rcoulomb : fr->rvdw; rcutoff2 = rcutoff*rcutoff; @@ -188,7 +188,7 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, eps2 = 0.0; /* 3 VdW parameters for buckingham, otherwise 2 */ - nvdwparam = (ivdw==GMX_NBKERNEL_VDW_BUCKINGHAM) ? 3 : 2; + nvdwparam = (ivdw == GMX_NBKERNEL_VDW_BUCKINGHAM) ? 3 : 2; table_nelements = 12; charge = mdatoms->chargeA; @@ -198,64 +198,65 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, vdwparam = fr->nbfp; ntype = fr->ntype; - for(n=0; (nnri); n++) + for (n = 0; (n < nlist->nri); n++) { is3 = 3*nlist->shift[n]; - shX = shiftvec[is3]; + shX = shiftvec[is3]; shY = shiftvec[is3+1]; shZ = shiftvec[is3+2]; - nj0 = nlist->jindex[n]; - nj1 = nlist->jindex[n+1]; - ii = nlist->iinr[n]; - ii3 = 3*ii; + nj0 = nlist->jindex[n]; + nj1 = nlist->jindex[n+1]; + ii = nlist->iinr[n]; + ii3 = 3*ii; ix = shX + x[ii3+0]; iy = shY + x[ii3+1]; iz = shZ + x[ii3+2]; iq = facel*charge[ii]; nti = nvdwparam*ntype*type[ii]; - vctot = 0; + vctot = 0; vvdwtot = 0; fix = 0; fiy = 0; - fiz = 0; + fiz = 0; /* We need to find out if this i atom is part of an all-atom or CG energy group */ - egp_nr=mdatoms->cENER[ii]; - bCG= !fr->adress_group_explicit[egp_nr]; - + egp_nr = mdatoms->cENER[ii]; + bCG = !fr->adress_group_explicit[egp_nr]; + weight_cg1 = wf[ii]; - if ((!bCG) && weight_cg1 < ALMOST_ZERO){ - continue; - } + if ((!bCG) && weight_cg1 < ALMOST_ZERO) + { + continue; + } - for(k=nj0; (kjjnr[k]; + jnr = nlist->jjnr[k]; weight_cg2 = wf[jnr]; weight_product = weight_cg1*weight_cg2; if (weight_product < ALMOST_ZERO) - { - /* if it's a explicit loop, skip this atom */ + { + /* if it's a explicit loop, skip this atom */ if (!bCG) { continue; } else /* if it's a coarse grained loop, include this atom */ { - hybscal = 1.0; + hybscal = 1.0; } } else if (weight_product >= ALMOST_ONE) { - - /* if it's a explicit loop, include this atom */ - if(!bCG) + + /* if it's a explicit loop, include this atom */ + if (!bCG) { - hybscal = 1.0; - } + hybscal = 1.0; + } else /* if it's a coarse grained loop, skip this atom */ { continue; @@ -266,33 +267,33 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, { hybscal = weight_product; - if(bCG) + if (bCG) { hybscal = 1.0 - hybscal; } } - j3 = 3*jnr; - jx = x[j3+0]; - jy = x[j3+1]; - jz = x[j3+2]; - dx = ix - jx; - dy = iy - jy; - dz = iz - jz; + j3 = 3*jnr; + jx = x[j3+0]; + jy = x[j3+1]; + jz = x[j3+2]; + dx = ix - jx; + dy = iy - jy; + dz = iz - jz; rsq = dx*dx+dy*dy+dz*dz; rinv = gmx_invsqrt(rsq); - rinvsq = rinv*rinv; + rinvsq = rinv*rinv; felec = 0; fvdw = 0; velec = 0; vvdw = 0; - if(bExactCutoff && rsq>rcutoff2) + if (bExactCutoff && rsq > rcutoff2) { continue; } - if(ielec==GMX_NBKERNEL_ELEC_CUBICSPLINETABLE || ivdw==GMX_NBKERNEL_VDW_CUBICSPLINETABLE) + if (ielec == GMX_NBKERNEL_ELEC_CUBICSPLINETABLE || ivdw == GMX_NBKERNEL_VDW_CUBICSPLINETABLE) { r = rsq*rinv; rt = r*tabscale; @@ -303,11 +304,11 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, } /* Coulomb interaction. ielec==0 means no interaction */ - if(ielec!=GMX_NBKERNEL_ELEC_NONE) + if (ielec != GMX_NBKERNEL_ELEC_NONE) { qq = iq*charge[jnr]; - switch(ielec) + switch (ielec) { case GMX_NBKERNEL_ELEC_NONE: break; @@ -339,7 +340,7 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, case GMX_NBKERNEL_ELEC_GENERALIZEDBORN: /* GB */ - gmx_fatal(FARGS,"Death & horror! GB generic interaction not implemented.\n"); + gmx_fatal(FARGS, "Death & horror! GB generic interaction not implemented.\n"); break; case GMX_NBKERNEL_ELEC_EWALD: @@ -348,19 +349,19 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, eweps = ewrt-ewitab; ewitab = 4*ewitab; felec = ewtab[ewitab]+eweps*ewtab[ewitab+1]; - rinvcorr = (fr->coulomb_modifier==eintmodPOTSHIFT) ? rinv-fr->ic->sh_ewald : rinv; + rinvcorr = (fr->coulomb_modifier == eintmodPOTSHIFT) ? rinv-fr->ic->sh_ewald : rinv; velec = qq*(rinvcorr-(ewtab[ewitab+2]-ewtabhalfspace*eweps*(ewtab[ewitab]+felec))); felec = qq*rinv*(rinvsq-felec); break; default: - gmx_fatal(FARGS,"Death & horror! No generic coulomb interaction for ielec=%d.\n",ielec); + gmx_fatal(FARGS, "Death & horror! No generic coulomb interaction for ielec=%d.\n", ielec); break; } - if(fr->coulomb_modifier==eintmodPOTSWITCH) + if (fr->coulomb_modifier == eintmodPOTSWITCH) { d = rsq*rinv-fr->rcoulomb_switch; - d = (d>0.0) ? d : 0.0; + d = (d > 0.0) ? d : 0.0; d2 = d*d; sw = 1.0+d2*d*(elec_swV3+d*(elec_swV4+d*elec_swV5)); dsw = d2*(elec_swF2+d*(elec_swF3+d*elec_swF4)); @@ -372,21 +373,21 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, /* Once we have used velec to update felec we can modify velec too */ velec *= sw; } - if(bExactElecCutoff) + if (bExactElecCutoff) { - felec = (rsq<=rcoulomb2) ? felec : 0.0; - velec = (rsq<=rcoulomb2) ? velec : 0.0; + felec = (rsq <= rcoulomb2) ? felec : 0.0; + velec = (rsq <= rcoulomb2) ? velec : 0.0; } vctot += velec; } /* End of coulomb interactions */ /* VdW interaction. ivdw==0 means no interaction */ - if(ivdw!=GMX_NBKERNEL_VDW_NONE) + if (ivdw != GMX_NBKERNEL_VDW_NONE) { tj = nti+nvdwparam*type[jnr]; - switch(ivdw) + switch (ivdw) { case GMX_NBKERNEL_VDW_NONE: break; @@ -399,7 +400,7 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, vvdw_disp = c6*rinvsix; vvdw_rep = c12*rinvsix*rinvsix; fvdw = (vvdw_rep-vvdw_disp)*rinvsq; - if(fr->vdw_modifier==eintmodPOTSHIFT) + if (fr->vdw_modifier == eintmodPOTSHIFT) { vvdw = (vvdw_rep-c12*sh_invrc6*sh_invrc6)*(1.0/12.0)-(vvdw_disp-c6*sh_invrc6)*(1.0/6.0); } @@ -420,7 +421,7 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, br = cexp2*rsq*rinv; vvdw_rep = cexp1*exp(-br); fvdw = (br*vvdw_rep-vvdw_disp)*rinvsq; - if(fr->vdw_modifier==eintmodPOTSHIFT) + if (fr->vdw_modifier == eintmodPOTSHIFT) { vvdw = (vvdw_rep-cexp1*exp(-cexp2*rvdw))-(vvdw_disp-c6*sh_invrc6)/6.0; } @@ -457,13 +458,13 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, break; default: - gmx_fatal(FARGS,"Death & horror! No generic VdW interaction for ivdw=%d.\n",ivdw); + gmx_fatal(FARGS, "Death & horror! No generic VdW interaction for ivdw=%d.\n", ivdw); break; } - if(fr->vdw_modifier==eintmodPOTSWITCH) + if (fr->vdw_modifier == eintmodPOTSWITCH) { d = rsq*rinv-fr->rvdw_switch; - d = (d>0.0) ? d : 0.0; + d = (d > 0.0) ? d : 0.0; d2 = d*d; sw = 1.0+d2*d*(vdw_swV3+d*(vdw_swV4+d*vdw_swV5)); dsw = d2*(vdw_swF2+d*(vdw_swF3+d*vdw_swF4)); @@ -471,19 +472,19 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, fvdw = fvdw*sw - rinv*vvdw*dsw; vvdw *= sw; } - if(bExactVdwCutoff) + if (bExactVdwCutoff) { - fvdw = (rsq<=rvdw2) ? fvdw : 0.0; - vvdw = (rsq<=rvdw2) ? vvdw : 0.0; + fvdw = (rsq <= rvdw2) ? fvdw : 0.0; + vvdw = (rsq <= rvdw2) ? vvdw : 0.0; } vvdwtot += vvdw; } /* end VdW interactions */ fscal = felec+fvdw; - if(!bCG && force_cap>0 && (fabs(fscal)> force_cap)) + if (!bCG && force_cap > 0 && (fabs(fscal) > force_cap)) { - fscal=force_cap*fscal/fabs(fscal); + fscal = force_cap*fscal/fabs(fscal); } fscal *= hybscal; @@ -513,5 +514,5 @@ gmx_nb_generic_adress_kernel(t_nblist * nlist, * 12 flops per outer iteration * 50 flops per inner iteration */ - inc_nrnb(nrnb,eNR_NBKERNEL_GENERIC,nlist->nri*12 + nlist->jindex[n]*50); + inc_nrnb(nrnb, eNR_NBKERNEL_GENERIC, nlist->nri*12 + nlist->jindex[n]*50); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_generic_adress.h b/src/gromacs/gmxlib/nonbonded/nb_generic_adress.h index ad43839a79..3ccf6c9441 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_generic_adress.h +++ b/src/gromacs/gmxlib/nonbonded/nb_generic_adress.h @@ -1,35 +1,35 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * * Copyright (c) 2011 Christoph Junghans, Sebastian Fritsch - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 4.0.5 * Written by Christoph Junghans, Brad Lambeth, and possibly others. * Copyright (c) 2009 Christoph Junghans, Brad Lambeth. * All rights reserved. - + * 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 - * + * * And Hey: * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon */ @@ -43,12 +43,11 @@ void gmx_nb_generic_adress_kernel(t_nblist * nlist, - rvec * xx, - rvec * ff, - t_forcerec * fr, - t_mdatoms * mdatoms, - nb_kernel_data_t * kernel_data, - t_nrnb * nrnb); + rvec * xx, + rvec * ff, + t_forcerec * fr, + t_mdatoms * mdatoms, + nb_kernel_data_t * kernel_data, + t_nrnb * nrnb); #endif - diff --git a/src/gromacs/gmxlib/nonbonded/nb_generic_cg.c b/src/gromacs/gmxlib/nonbonded/nb_generic_cg.c index 5349f26e7d..a7befbec06 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_generic_cg.c +++ b/src/gromacs/gmxlib/nonbonded/nb_generic_cg.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -47,7 +47,7 @@ #include "nb_kernel.h" #include "nrnb.h" - void +void gmx_nb_generic_cg_kernel(t_nblist * nlist, rvec * xx, rvec * ff, @@ -56,277 +56,276 @@ gmx_nb_generic_cg_kernel(t_nblist * nlist, nb_kernel_data_t * kernel_data, t_nrnb * nrnb) { - int nri,ntype,table_nelements,ielec,ivdw; - real facel,gbtabscale; - int n,is3,i3,k,nj0,nj1,j3,ggid,nnn,n0; - int ai0,ai1,ai,aj0,aj1,aj; - real shX,shY,shZ; - real fscal,tx,ty,tz; - real rinvsq; - real iq; - real qq,vcoul,krsq,vctot; - int nti,nvdwparam; - int tj; - real rt,r,eps,eps2,Y,F,Geps,Heps2,VV,FF,Fp,fijD,fijR; - real rinvsix; - real Vvdwtot; - real Vvdw_rep,Vvdw_disp; - real ix,iy,iz,fix,fiy,fiz; - real jx,jy,jz; - real dx,dy,dz,rsq,rinv; - real c6,c12,cexp1,cexp2,br; - real * charge; - real * shiftvec; - real * vdwparam; - int * shift; - int * type; - t_excl * excl; - real * fshift; - real * Vc; - real * Vvdw; - real tabscale; - real * VFtab; - real * x; - real * f; - - x = xx[0]; - f = ff[0]; - ielec = nlist->ielec; - ivdw = nlist->ivdw; - - fshift = fr->fshift[0]; - Vc = kernel_data->energygrp_elec; - Vvdw = kernel_data->energygrp_vdw; - tabscale = kernel_data->table_elec_vdw->scale; - VFtab = kernel_data->table_elec_vdw->data; - - /* avoid compiler warnings for cases that cannot happen */ - nnn = 0; - vcoul = 0.0; - eps = 0.0; - eps2 = 0.0; - - /* 3 VdW parameters for buckingham, otherwise 2 */ - nvdwparam = (nlist->ivdw==2) ? 3 : 2; - table_nelements = (ielec==3) ? 4 : 0; - table_nelements += (ivdw==3) ? 8 : 0; - - charge = mdatoms->chargeA; - type = mdatoms->typeA; - facel = fr->epsfac; - shiftvec = fr->shift_vec[0]; - vdwparam = fr->nbfp; - ntype = fr->ntype; - - for(n=0; (nnri); n++) - { - is3 = 3*nlist->shift[n]; - shX = shiftvec[is3]; - shY = shiftvec[is3+1]; - shZ = shiftvec[is3+2]; - nj0 = nlist->jindex[n]; - nj1 = nlist->jindex[n+1]; - ai0 = nlist->iinr[n]; - ai1 = nlist->iinr_end[n]; - vctot = 0; - Vvdwtot = 0; - fix = 0; - fiy = 0; - fiz = 0; - - for(k=nj0; (kjjnr[k]; - aj1 = nlist->jjnr_end[k]; - excl = &nlist->excl[k*MAX_CGCGSIZE]; - - for(ai=ai0; (ai 0) - { - qq = iq*charge[aj]; - - switch(ielec) - { - case 1: - /* Vanilla cutoff coulomb */ - vcoul = qq*rinv; - fscal = vcoul*rinvsq; - break; - - case 2: - /* Reaction-field */ - krsq = fr->k_rf*rsq; - vcoul = qq*(rinv+krsq-fr->c_rf); - fscal = qq*(rinv-2.0*krsq)*rinvsq; - break; - - case 3: - /* Tabulated coulomb */ - Y = VFtab[nnn]; - F = VFtab[nnn+1]; - Geps = eps*VFtab[nnn+2]; - Heps2 = eps2*VFtab[nnn+3]; - nnn += 4; - Fp = F+Geps+Heps2; - VV = Y+eps*Fp; - FF = Fp+Geps+2.0*Heps2; - vcoul = qq*VV; - fscal = -qq*FF*tabscale*rinv; - break; - - case 4: - /* GB */ - gmx_fatal(FARGS,"Death & horror! GB generic interaction not implemented.\n"); - break; - - default: - gmx_fatal(FARGS,"Death & horror! No generic coulomb interaction for ielec=%d.\n",ielec); - break; - } - vctot = vctot+vcoul; - } /* End of coulomb interactions */ - - - /* VdW interaction. ivdw==0 means no interaction */ - if (ivdw > 0) - { - tj = nti+nvdwparam*type[aj]; - - switch(ivdw) - { - case 1: - /* Vanilla Lennard-Jones cutoff */ - c6 = vdwparam[tj]; - c12 = vdwparam[tj+1]; - - rinvsix = rinvsq*rinvsq*rinvsq; - Vvdw_disp = c6*rinvsix; - Vvdw_rep = c12*rinvsix*rinvsix; - fscal += (12.0*Vvdw_rep-6.0*Vvdw_disp)*rinvsq; - Vvdwtot = Vvdwtot+Vvdw_rep-Vvdw_disp; - break; - - case 2: - /* Buckingham */ - c6 = vdwparam[tj]; - cexp1 = vdwparam[tj+1]; - cexp2 = vdwparam[tj+2]; - - rinvsix = rinvsq*rinvsq*rinvsq; - Vvdw_disp = c6*rinvsix; - br = cexp2*rsq*rinv; - Vvdw_rep = cexp1*exp(-br); - fscal += (br*Vvdw_rep-6.0*Vvdw_disp)*rinvsq; - Vvdwtot = Vvdwtot+Vvdw_rep-Vvdw_disp; - break; - - case 3: - /* Tabulated VdW */ - c6 = vdwparam[tj]; - c12 = vdwparam[tj+1]; - - Y = VFtab[nnn]; - F = VFtab[nnn+1]; - Geps = eps*VFtab[nnn+2]; - Heps2 = eps2*VFtab[nnn+3]; - Fp = F+Geps+Heps2; - VV = Y+eps*Fp; - FF = Fp+Geps+2.0*Heps2; - Vvdw_disp = c6*VV; - fijD = c6*FF; - nnn += 4; - Y = VFtab[nnn]; - F = VFtab[nnn+1]; - Geps = eps*VFtab[nnn+2]; - Heps2 = eps2*VFtab[nnn+3]; - Fp = F+Geps+Heps2; - VV = Y+eps*Fp; - FF = Fp+Geps+2.0*Heps2; - Vvdw_rep = c12*VV; - fijR = c12*FF; - fscal += -(fijD+fijR)*tabscale*rinv; - Vvdwtot = Vvdwtot + Vvdw_disp + Vvdw_rep; - break; - - default: - gmx_fatal(FARGS,"Death & horror! No generic VdW interaction for ivdw=%d.\n",ivdw); - break; - } - } /* end VdW interactions */ - - - tx = fscal*dx; - ty = fscal*dy; - tz = fscal*dz; - f[i3+0] += tx; - f[i3+1] += ty; - f[i3+2] += tz; - f[j3+0] -= tx; - f[j3+1] -= ty; - f[j3+2] -= tz; - fix += tx; - fiy += ty; - fiz += tz; - } - } - } - - fshift[is3] += fix; - fshift[is3+1] += fiy; - fshift[is3+2] += fiz; - ggid = nlist->gid[n]; - Vc[ggid] += vctot; - Vvdw[ggid] += Vvdwtot; - } + int nri, ntype, table_nelements, ielec, ivdw; + real facel, gbtabscale; + int n, is3, i3, k, nj0, nj1, j3, ggid, nnn, n0; + int ai0, ai1, ai, aj0, aj1, aj; + real shX, shY, shZ; + real fscal, tx, ty, tz; + real rinvsq; + real iq; + real qq, vcoul, krsq, vctot; + int nti, nvdwparam; + int tj; + real rt, r, eps, eps2, Y, F, Geps, Heps2, VV, FF, Fp, fijD, fijR; + real rinvsix; + real Vvdwtot; + real Vvdw_rep, Vvdw_disp; + real ix, iy, iz, fix, fiy, fiz; + real jx, jy, jz; + real dx, dy, dz, rsq, rinv; + real c6, c12, cexp1, cexp2, br; + real * charge; + real * shiftvec; + real * vdwparam; + int * shift; + int * type; + t_excl * excl; + real * fshift; + real * Vc; + real * Vvdw; + real tabscale; + real * VFtab; + real * x; + real * f; + + x = xx[0]; + f = ff[0]; + ielec = nlist->ielec; + ivdw = nlist->ivdw; + + fshift = fr->fshift[0]; + Vc = kernel_data->energygrp_elec; + Vvdw = kernel_data->energygrp_vdw; + tabscale = kernel_data->table_elec_vdw->scale; + VFtab = kernel_data->table_elec_vdw->data; + + /* avoid compiler warnings for cases that cannot happen */ + nnn = 0; + vcoul = 0.0; + eps = 0.0; + eps2 = 0.0; + + /* 3 VdW parameters for buckingham, otherwise 2 */ + nvdwparam = (nlist->ivdw == 2) ? 3 : 2; + table_nelements = (ielec == 3) ? 4 : 0; + table_nelements += (ivdw == 3) ? 8 : 0; + + charge = mdatoms->chargeA; + type = mdatoms->typeA; + facel = fr->epsfac; + shiftvec = fr->shift_vec[0]; + vdwparam = fr->nbfp; + ntype = fr->ntype; + + for (n = 0; (n < nlist->nri); n++) + { + is3 = 3*nlist->shift[n]; + shX = shiftvec[is3]; + shY = shiftvec[is3+1]; + shZ = shiftvec[is3+2]; + nj0 = nlist->jindex[n]; + nj1 = nlist->jindex[n+1]; + ai0 = nlist->iinr[n]; + ai1 = nlist->iinr_end[n]; + vctot = 0; + Vvdwtot = 0; + fix = 0; + fiy = 0; + fiz = 0; + + for (k = nj0; (k < nj1); k++) + { + aj0 = nlist->jjnr[k]; + aj1 = nlist->jjnr_end[k]; + excl = &nlist->excl[k*MAX_CGCGSIZE]; + + for (ai = ai0; (ai < ai1); ai++) + { + i3 = ai*3; + ix = shX + x[i3+0]; + iy = shY + x[i3+1]; + iz = shZ + x[i3+2]; + iq = facel*charge[ai]; + nti = nvdwparam*ntype*type[ai]; + + /* Note that this code currently calculates + * all LJ and Coulomb interactions, + * even if the LJ parameters or charges are zero. + * If required, this can be optimized. + */ + + for (aj = aj0; (aj < aj1); aj++) + { + /* Check if this interaction is excluded */ + if (excl[aj-aj0] & (1<<(ai-ai0))) + { + continue; + } + + j3 = aj*3; + jx = x[j3+0]; + jy = x[j3+1]; + jz = x[j3+2]; + dx = ix - jx; + dy = iy - jy; + dz = iz - jz; + rsq = dx*dx+dy*dy+dz*dz; + rinv = gmx_invsqrt(rsq); + rinvsq = rinv*rinv; + fscal = 0; + + if (ielec == 3 || ivdw == 3) + { + r = rsq*rinv; + rt = r*tabscale; + n0 = rt; + eps = rt-n0; + eps2 = eps*eps; + nnn = table_nelements*n0; + } + + /* Coulomb interaction. ielec==0 means no interaction */ + if (ielec > 0) + { + qq = iq*charge[aj]; + + switch (ielec) + { + case 1: + /* Vanilla cutoff coulomb */ + vcoul = qq*rinv; + fscal = vcoul*rinvsq; + break; + + case 2: + /* Reaction-field */ + krsq = fr->k_rf*rsq; + vcoul = qq*(rinv+krsq-fr->c_rf); + fscal = qq*(rinv-2.0*krsq)*rinvsq; + break; + + case 3: + /* Tabulated coulomb */ + Y = VFtab[nnn]; + F = VFtab[nnn+1]; + Geps = eps*VFtab[nnn+2]; + Heps2 = eps2*VFtab[nnn+3]; + nnn += 4; + Fp = F+Geps+Heps2; + VV = Y+eps*Fp; + FF = Fp+Geps+2.0*Heps2; + vcoul = qq*VV; + fscal = -qq*FF*tabscale*rinv; + break; + + case 4: + /* GB */ + gmx_fatal(FARGS, "Death & horror! GB generic interaction not implemented.\n"); + break; + + default: + gmx_fatal(FARGS, "Death & horror! No generic coulomb interaction for ielec=%d.\n", ielec); + break; + } + vctot = vctot+vcoul; + } /* End of coulomb interactions */ + + + /* VdW interaction. ivdw==0 means no interaction */ + if (ivdw > 0) + { + tj = nti+nvdwparam*type[aj]; + + switch (ivdw) + { + case 1: + /* Vanilla Lennard-Jones cutoff */ + c6 = vdwparam[tj]; + c12 = vdwparam[tj+1]; + + rinvsix = rinvsq*rinvsq*rinvsq; + Vvdw_disp = c6*rinvsix; + Vvdw_rep = c12*rinvsix*rinvsix; + fscal += (12.0*Vvdw_rep-6.0*Vvdw_disp)*rinvsq; + Vvdwtot = Vvdwtot+Vvdw_rep-Vvdw_disp; + break; + + case 2: + /* Buckingham */ + c6 = vdwparam[tj]; + cexp1 = vdwparam[tj+1]; + cexp2 = vdwparam[tj+2]; + + rinvsix = rinvsq*rinvsq*rinvsq; + Vvdw_disp = c6*rinvsix; + br = cexp2*rsq*rinv; + Vvdw_rep = cexp1*exp(-br); + fscal += (br*Vvdw_rep-6.0*Vvdw_disp)*rinvsq; + Vvdwtot = Vvdwtot+Vvdw_rep-Vvdw_disp; + break; + + case 3: + /* Tabulated VdW */ + c6 = vdwparam[tj]; + c12 = vdwparam[tj+1]; + + Y = VFtab[nnn]; + F = VFtab[nnn+1]; + Geps = eps*VFtab[nnn+2]; + Heps2 = eps2*VFtab[nnn+3]; + Fp = F+Geps+Heps2; + VV = Y+eps*Fp; + FF = Fp+Geps+2.0*Heps2; + Vvdw_disp = c6*VV; + fijD = c6*FF; + nnn += 4; + Y = VFtab[nnn]; + F = VFtab[nnn+1]; + Geps = eps*VFtab[nnn+2]; + Heps2 = eps2*VFtab[nnn+3]; + Fp = F+Geps+Heps2; + VV = Y+eps*Fp; + FF = Fp+Geps+2.0*Heps2; + Vvdw_rep = c12*VV; + fijR = c12*FF; + fscal += -(fijD+fijR)*tabscale*rinv; + Vvdwtot = Vvdwtot + Vvdw_disp + Vvdw_rep; + break; + + default: + gmx_fatal(FARGS, "Death & horror! No generic VdW interaction for ivdw=%d.\n", ivdw); + break; + } + } /* end VdW interactions */ + + + tx = fscal*dx; + ty = fscal*dy; + tz = fscal*dz; + f[i3+0] += tx; + f[i3+1] += ty; + f[i3+2] += tz; + f[j3+0] -= tx; + f[j3+1] -= ty; + f[j3+2] -= tz; + fix += tx; + fiy += ty; + fiz += tz; + } + } + } + + fshift[is3] += fix; + fshift[is3+1] += fiy; + fshift[is3+2] += fiz; + ggid = nlist->gid[n]; + Vc[ggid] += vctot; + Vvdw[ggid] += Vvdwtot; + } /* Estimate flops, average for generic cg kernel: * 12 flops per outer iteration * 100 flops per inner iteration */ - inc_nrnb(nrnb,eNR_NBKERNEL_FREE_ENERGY,nlist->nri*12 + nlist->jindex[n]*100); + inc_nrnb(nrnb, eNR_NBKERNEL_FREE_ENERGY, nlist->nri*12 + nlist->jindex[n]*100); } - diff --git a/src/gromacs/gmxlib/nonbonded/nb_generic_cg.h b/src/gromacs/gmxlib/nonbonded/nb_generic_cg.h index 5e760522d5..65f5acce27 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_generic_cg.h +++ b/src/gromacs/gmxlib/nonbonded/nb_generic_cg.h @@ -1,34 +1,34 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2008, 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 - * + * * And Hey: * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon */ @@ -51,4 +51,3 @@ gmx_nb_generic_cg_kernel(t_nblist * nlist, t_nrnb * nrnb); #endif - diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel.c b/src/gromacs/gmxlib/nonbonded/nb_kernel.c index 350f6834c0..e8701f6046 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel.c @@ -49,14 +49,14 @@ nb_kernel_hash_func(const char * arch, { unsigned int hash; - hash = gmx_string_hash_func(arch,gmx_string_hash_init); - hash = gmx_string_hash_func(elec,hash); - hash = gmx_string_hash_func(elec_mod,hash); - hash = gmx_string_hash_func(vdw,hash); - hash = gmx_string_hash_func(vdw_mod,hash); - hash = gmx_string_hash_func(geom,hash); - hash = gmx_string_hash_func(other,hash); - hash = gmx_string_hash_func(vf,hash); + hash = gmx_string_hash_func(arch, gmx_string_hash_init); + hash = gmx_string_hash_func(elec, hash); + hash = gmx_string_hash_func(elec_mod, hash); + hash = gmx_string_hash_func(vdw, hash); + hash = gmx_string_hash_func(vdw_mod, hash); + hash = gmx_string_hash_func(geom, hash); + hash = gmx_string_hash_func(other, hash); + hash = gmx_string_hash_func(vf, hash); return hash; } @@ -65,8 +65,8 @@ void nb_kernel_list_add_kernels(nb_kernel_info_t * new_kernel_list, int new_kernel_list_size) { - srenew(kernel_list,kernel_list_size+new_kernel_list_size); - memcpy(kernel_list+kernel_list_size,new_kernel_list,new_kernel_list_size*sizeof(nb_kernel_info_t)); + srenew(kernel_list, kernel_list_size+new_kernel_list_size); + memcpy(kernel_list+kernel_list_size, new_kernel_list, new_kernel_list_size*sizeof(nb_kernel_info_t)); kernel_list_size += new_kernel_list_size; } @@ -78,25 +78,25 @@ nb_kernel_list_hash_init(void) unsigned int index; kernel_list_hash_size = kernel_list_size*5; - snew(kernel_list_hash,kernel_list_hash_size); + snew(kernel_list_hash, kernel_list_hash_size); - for(i=0;ikernelname,arch,electrostatics,electrostatics_modifier, - vdw,vdw_modifier,geometry,other,vf); + kernelinfo_ptr->kernelname, arch, electrostatics, electrostatics_modifier, + vdw, vdw_modifier, geometry, other, vf); } /* If we did not find any kernel the pointer will still be NULL */ - return (kernelinfo_ptr !=NULL) ? kernelinfo_ptr->kernelptr : NULL; + return (kernelinfo_ptr != NULL) ? kernelinfo_ptr->kernelptr : NULL; } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel.h b/src/gromacs/gmxlib/nonbonded/nb_kernel.h index 2830ec6017..8619b3999f 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel.h @@ -60,13 +60,13 @@ nb_kernel_data_t; typedef void -nb_kernel_t(t_nblist * nlist, - rvec * x, - rvec * f, - t_forcerec * fr, - t_mdatoms * mdatoms, - nb_kernel_data_t * kernel_data, - t_nrnb * nrnb); + nb_kernel_t (t_nblist * nlist, + rvec * x, + rvec * f, + t_forcerec * fr, + t_mdatoms * mdatoms, + nb_kernel_data_t * kernel_data, + t_nrnb * nrnb); /* Structure with a kernel pointer and settings. This cannot be abstract @@ -90,11 +90,11 @@ nb_kernel_t(t_nblist * nlist, * The interaction modifiers are described by the eintmod enum type, while * the kernel geometry is decided from the neighborlist geometry, which is * described by the enum gmx_nblist_kernel_geometry (again, see types/enums.h). - * The + * The * - * Note that any particular implementation of kernels might not support all of + * Note that any particular implementation of kernels might not support all of * these strings. In fact, some might not be supported by any architecture yet. - * The whole point of using strings and hashes is that we do not have to define a + * The whole point of using strings and hashes is that we do not have to define a * unique set of strings in a single place. Thus, as long as you implement a * corresponding kernel, you could in theory provide any string you want. */ diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/kernelutil_x86_avx_128_fma_double.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/kernelutil_x86_avx_128_fma_double.h index 0f07685000..c38c9a7e0b 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/kernelutil_x86_avx_128_fma_double.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/kernelutil_x86_avx_128_fma_double.h @@ -35,18 +35,18 @@ static int gmx_mm_any_lt(__m128d a, __m128d b) { - return _mm_movemask_pd(_mm_cmplt_pd(a,b)); + return _mm_movemask_pd(_mm_cmplt_pd(a, b)); } static gmx_inline __m128d gmx_mm_calc_rsq_pd(__m128d dx, __m128d dy, __m128d dz) { - return _mm_macc_pd(dx,dx,_mm_macc_pd(dy,dy,_mm_mul_pd(dz,dz))); + return _mm_macc_pd(dx, dx, _mm_macc_pd(dy, dy, _mm_mul_pd(dz, dz))); } /* Normal sum of four ymm registers */ -#define gmx_mm_sum4_pd(t0,t1,t2,t3) _mm_add_pd(_mm_add_pd(t0,t1),_mm_add_pd(t2,t3)) +#define gmx_mm_sum4_pd(t0, t1, t2, t3) _mm_add_pd(_mm_add_pd(t0, t1), _mm_add_pd(t2, t3)) @@ -57,7 +57,7 @@ static __m128d gmx_mm_load_2real_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB) { - return _mm_unpacklo_pd(_mm_load_sd(ptrA),_mm_load_sd(ptrB)); + return _mm_unpacklo_pd(_mm_load_sd(ptrA), _mm_load_sd(ptrB)); } static __m128d @@ -70,19 +70,19 @@ gmx_mm_load_1real_pd(const double * gmx_restrict ptrA) static void gmx_mm_store_2real_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, - __m128d xmm1) + __m128d xmm1) { __m128d t2; - t2 = _mm_unpackhi_pd(xmm1,xmm1); - _mm_store_sd(ptrA,xmm1); - _mm_store_sd(ptrB,t2); + t2 = _mm_unpackhi_pd(xmm1, xmm1); + _mm_store_sd(ptrA, xmm1); + _mm_store_sd(ptrB, t2); } static void gmx_mm_store_1real_pd(double * gmx_restrict ptrA, __m128d xmm1) { - _mm_store_sd(ptrA,xmm1); + _mm_store_sd(ptrA, xmm1); } @@ -93,11 +93,11 @@ gmx_mm_increment_2real_swizzle_pd(double * gmx_restrict ptrA, { __m128d t1; - t1 = _mm_unpackhi_pd(xmm1,xmm1); - xmm1 = _mm_add_sd(xmm1,_mm_load_sd(ptrA)); - t1 = _mm_add_sd(t1,_mm_load_sd(ptrB)); - _mm_store_sd(ptrA,xmm1); - _mm_store_sd(ptrB,t1); + t1 = _mm_unpackhi_pd(xmm1, xmm1); + xmm1 = _mm_add_sd(xmm1, _mm_load_sd(ptrA)); + t1 = _mm_add_sd(t1, _mm_load_sd(ptrB)); + _mm_store_sd(ptrA, xmm1); + _mm_store_sd(ptrB, t1); } static void @@ -106,8 +106,8 @@ gmx_mm_increment_1real_pd(double * gmx_restrict ptrA, __m128d xmm1) __m128d tmp; tmp = gmx_mm_load_1real_pd(ptrA); - tmp = _mm_add_sd(tmp,xmm1); - gmx_mm_store_1real_pd(ptrA,tmp); + tmp = _mm_add_sd(tmp, xmm1); + gmx_mm_store_1real_pd(ptrA, tmp); } @@ -115,22 +115,22 @@ gmx_mm_increment_1real_pd(double * gmx_restrict ptrA, __m128d xmm1) static gmx_inline void gmx_mm_load_2pair_swizzle_pd(const double * gmx_restrict p1, const double * gmx_restrict p2, - __m128d * gmx_restrict c6, - __m128d * gmx_restrict c12) + __m128d * gmx_restrict c6, + __m128d * gmx_restrict c12) { - __m128d t1,t2,t3; + __m128d t1, t2, t3; /* The c6/c12 array should be aligned */ t1 = _mm_loadu_pd(p1); t2 = _mm_loadu_pd(p2); - *c6 = _mm_unpacklo_pd(t1,t2); - *c12 = _mm_unpackhi_pd(t1,t2); + *c6 = _mm_unpacklo_pd(t1, t2); + *c12 = _mm_unpackhi_pd(t1, t2); } static gmx_inline void gmx_mm_load_1pair_swizzle_pd(const double * gmx_restrict p1, - __m128d * gmx_restrict c6, - __m128d * gmx_restrict c12) + __m128d * gmx_restrict c6, + __m128d * gmx_restrict c12) { *c6 = _mm_load_sd(p1); *c12 = _mm_load_sd(p1+1); @@ -139,35 +139,35 @@ gmx_mm_load_1pair_swizzle_pd(const double * gmx_restrict p1, static gmx_inline void gmx_mm_load_shift_and_1rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m128d * gmx_restrict x1, - __m128d * gmx_restrict y1, - __m128d * gmx_restrict z1) + const double * gmx_restrict xyz, + __m128d * gmx_restrict x1, + __m128d * gmx_restrict y1, + __m128d * gmx_restrict z1) { - __m128d mem_xy,mem_z,mem_sxy,mem_sz; + __m128d mem_xy, mem_z, mem_sxy, mem_sz; mem_xy = _mm_loadu_pd(xyz); mem_z = _mm_load_sd(xyz+2); mem_sxy = _mm_loadu_pd(xyz_shift); mem_sz = _mm_load_sd(xyz_shift+2); - mem_xy = _mm_add_pd(mem_xy,mem_sxy); - mem_z = _mm_add_pd(mem_z,mem_sz); + mem_xy = _mm_add_pd(mem_xy, mem_sxy); + mem_z = _mm_add_pd(mem_z, mem_sz); - *x1 = _mm_shuffle_pd(mem_xy,mem_xy,_MM_SHUFFLE2(0,0)); - *y1 = _mm_shuffle_pd(mem_xy,mem_xy,_MM_SHUFFLE2(1,1)); - *z1 = _mm_shuffle_pd(mem_z,mem_z,_MM_SHUFFLE2(0,0)); + *x1 = _mm_shuffle_pd(mem_xy, mem_xy, _MM_SHUFFLE2(0, 0)); + *y1 = _mm_shuffle_pd(mem_xy, mem_xy, _MM_SHUFFLE2(1, 1)); + *z1 = _mm_shuffle_pd(mem_z, mem_z, _MM_SHUFFLE2(0, 0)); } static gmx_inline void gmx_mm_load_shift_and_3rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1, - __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, - __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3) + const double * gmx_restrict xyz, + __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1, + __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, + __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3) { - __m128d t1,t2,t3,t4,t5,sxy,sz,szx,syz; + __m128d t1, t2, t3, t4, t5, sxy, sz, szx, syz; t1 = _mm_loadu_pd(xyz); t2 = _mm_loadu_pd(xyz+2); @@ -177,36 +177,36 @@ gmx_mm_load_shift_and_3rvec_broadcast_pd(const double * gmx_restrict xyz_shift, sxy = _mm_loadu_pd(xyz_shift); sz = _mm_load_sd(xyz_shift+2); - szx = _mm_shuffle_pd(sz,sxy,_MM_SHUFFLE2(0,0)); - syz = _mm_shuffle_pd(sxy,sz,_MM_SHUFFLE2(0,1)); - - t1 = _mm_add_pd(t1,sxy); - t2 = _mm_add_pd(t2,szx); - t3 = _mm_add_pd(t3,syz); - t4 = _mm_add_pd(t4,sxy); - t5 = _mm_add_sd(t5,sz); - - *x1 = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(0,0)); - *y1 = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(1,1)); - *z1 = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(0,0)); - *x2 = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(1,1)); - *y2 = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(0,0)); - *z2 = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(1,1)); - *x3 = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(0,0)); - *y3 = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(1,1)); - *z3 = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(0,0)); + szx = _mm_shuffle_pd(sz, sxy, _MM_SHUFFLE2(0, 0)); + syz = _mm_shuffle_pd(sxy, sz, _MM_SHUFFLE2(0, 1)); + + t1 = _mm_add_pd(t1, sxy); + t2 = _mm_add_pd(t2, szx); + t3 = _mm_add_pd(t3, syz); + t4 = _mm_add_pd(t4, sxy); + t5 = _mm_add_sd(t5, sz); + + *x1 = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(0, 0)); + *y1 = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(1, 1)); + *z1 = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(0, 0)); + *x2 = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(1, 1)); + *y2 = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(0, 0)); + *z2 = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(1, 1)); + *x3 = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(0, 0)); + *y3 = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(1, 1)); + *z3 = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(0, 0)); } static gmx_inline void gmx_mm_load_shift_and_4rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1, - __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, - __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3, - __m128d * gmx_restrict x4, __m128d * gmx_restrict y4, __m128d * gmx_restrict z4) + const double * gmx_restrict xyz, + __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1, + __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, + __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3, + __m128d * gmx_restrict x4, __m128d * gmx_restrict y4, __m128d * gmx_restrict z4) { - __m128d t1,t2,t3,t4,t5,t6,sxy,sz,szx,syz; + __m128d t1, t2, t3, t4, t5, t6, sxy, sz, szx, syz; t1 = _mm_loadu_pd(xyz); t2 = _mm_loadu_pd(xyz+2); @@ -217,28 +217,28 @@ gmx_mm_load_shift_and_4rvec_broadcast_pd(const double * gmx_restrict xyz_shift, sxy = _mm_loadu_pd(xyz_shift); sz = _mm_load_sd(xyz_shift+2); - szx = _mm_shuffle_pd(sz,sxy,_MM_SHUFFLE2(0,0)); - syz = _mm_shuffle_pd(sxy,sz,_MM_SHUFFLE2(0,1)); - - t1 = _mm_add_pd(t1,sxy); - t2 = _mm_add_pd(t2,szx); - t3 = _mm_add_pd(t3,syz); - t4 = _mm_add_pd(t4,sxy); - t5 = _mm_add_pd(t5,szx); - t6 = _mm_add_pd(t6,syz); - - *x1 = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(0,0)); - *y1 = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(1,1)); - *z1 = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(0,0)); - *x2 = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(1,1)); - *y2 = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(0,0)); - *z2 = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(1,1)); - *x3 = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(0,0)); - *y3 = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(1,1)); - *z3 = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(0,0)); - *x4 = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(1,1)); - *y4 = _mm_shuffle_pd(t6,t6,_MM_SHUFFLE2(0,0)); - *z4 = _mm_shuffle_pd(t6,t6,_MM_SHUFFLE2(1,1)); + szx = _mm_shuffle_pd(sz, sxy, _MM_SHUFFLE2(0, 0)); + syz = _mm_shuffle_pd(sxy, sz, _MM_SHUFFLE2(0, 1)); + + t1 = _mm_add_pd(t1, sxy); + t2 = _mm_add_pd(t2, szx); + t3 = _mm_add_pd(t3, syz); + t4 = _mm_add_pd(t4, sxy); + t5 = _mm_add_pd(t5, szx); + t6 = _mm_add_pd(t6, syz); + + *x1 = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(0, 0)); + *y1 = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(1, 1)); + *z1 = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(0, 0)); + *x2 = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(1, 1)); + *y2 = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(0, 0)); + *z2 = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(1, 1)); + *x3 = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(0, 0)); + *y3 = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(1, 1)); + *z3 = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(0, 0)); + *x4 = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(1, 1)); + *y4 = _mm_shuffle_pd(t6, t6, _MM_SHUFFLE2(0, 0)); + *z4 = _mm_shuffle_pd(t6, t6, _MM_SHUFFLE2(1, 1)); } @@ -296,15 +296,15 @@ gmx_mm_load_1rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB, __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1) { - __m128d t1,t2,t3,t4; + __m128d t1, t2, t3, t4; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrB); t3 = _mm_load_sd(ptrA+2); t4 = _mm_load_sd(ptrB+2); - GMX_MM_TRANSPOSE2_PD(t1,t2); + GMX_MM_TRANSPOSE2_PD(t1, t2); *x1 = t1; *y1 = t2; - *z1 = _mm_unpacklo_pd(t3,t4); + *z1 = _mm_unpacklo_pd(t3, t4); } static gmx_inline void @@ -313,7 +313,7 @@ gmx_mm_load_3rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3) { - __m128d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; + __m128d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrB); t3 = _mm_loadu_pd(ptrA+2); @@ -324,10 +324,10 @@ gmx_mm_load_3rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double t8 = _mm_loadu_pd(ptrB+6); t9 = _mm_load_sd(ptrA+8); t10 = _mm_load_sd(ptrB+8); - GMX_MM_TRANSPOSE2_PD(t1,t2); - GMX_MM_TRANSPOSE2_PD(t3,t4); - GMX_MM_TRANSPOSE2_PD(t5,t6); - GMX_MM_TRANSPOSE2_PD(t7,t8); + GMX_MM_TRANSPOSE2_PD(t1, t2); + GMX_MM_TRANSPOSE2_PD(t3, t4); + GMX_MM_TRANSPOSE2_PD(t5, t6); + GMX_MM_TRANSPOSE2_PD(t7, t8); *x1 = t1; *y1 = t2; *z1 = t3; @@ -336,7 +336,7 @@ gmx_mm_load_3rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double *z2 = t6; *x3 = t7; *y3 = t8; - *z3 = _mm_unpacklo_pd(t9,t10); + *z3 = _mm_unpacklo_pd(t9, t10); } @@ -347,16 +347,16 @@ gmx_mm_load_4rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3, __m128d * gmx_restrict x4, __m128d * gmx_restrict y4, __m128d * gmx_restrict z4) { - __m128d t1,t2,t3,t4,t5,t6; + __m128d t1, t2, t3, t4, t5, t6; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrB); t3 = _mm_loadu_pd(ptrA+2); t4 = _mm_loadu_pd(ptrB+2); t5 = _mm_loadu_pd(ptrA+4); t6 = _mm_loadu_pd(ptrB+4); - GMX_MM_TRANSPOSE2_PD(t1,t2); - GMX_MM_TRANSPOSE2_PD(t3,t4); - GMX_MM_TRANSPOSE2_PD(t5,t6); + GMX_MM_TRANSPOSE2_PD(t1, t2); + GMX_MM_TRANSPOSE2_PD(t3, t4); + GMX_MM_TRANSPOSE2_PD(t5, t6); *x1 = t1; *y1 = t2; *z1 = t3; @@ -369,9 +369,9 @@ gmx_mm_load_4rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double t4 = _mm_loadu_pd(ptrB+8); t5 = _mm_loadu_pd(ptrA+10); t6 = _mm_loadu_pd(ptrB+10); - GMX_MM_TRANSPOSE2_PD(t1,t2); - GMX_MM_TRANSPOSE2_PD(t3,t4); - GMX_MM_TRANSPOSE2_PD(t5,t6); + GMX_MM_TRANSPOSE2_PD(t1, t2); + GMX_MM_TRANSPOSE2_PD(t3, t4); + GMX_MM_TRANSPOSE2_PD(t5, t6); *x3 = t1; *y3 = t2; *z3 = t3; @@ -386,46 +386,46 @@ static void gmx_mm_decrement_1rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, __m128d x1, __m128d y1, __m128d z1) { - __m128d t1,t2,t3; + __m128d t1, t2, t3; t1 = _mm_load_sd(ptrA); t2 = _mm_load_sd(ptrA+1); t3 = _mm_load_sd(ptrA+2); - t1 = _mm_sub_sd(t1,x1); - t2 = _mm_sub_sd(t2,y1); - t3 = _mm_sub_sd(t3,z1); - _mm_store_sd(ptrA,t1); - _mm_store_sd(ptrA+1,t2); - _mm_store_sd(ptrA+2,t3); + t1 = _mm_sub_sd(t1, x1); + t2 = _mm_sub_sd(t2, y1); + t3 = _mm_sub_sd(t3, z1); + _mm_store_sd(ptrA, t1); + _mm_store_sd(ptrA+1, t2); + _mm_store_sd(ptrA+2, t3); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_1ptr_swizzle_pd(ptrA,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ -__m128d _t1,_t2,_t3,_t4,_t5;\ -_t1 = _mm_loadu_pd(ptrA);\ -_t2 = _mm_loadu_pd(ptrA+2);\ -_t3 = _mm_loadu_pd(ptrA+4);\ -_t4 = _mm_loadu_pd(ptrA+6);\ -_t5 = _mm_load_sd(ptrA+8);\ -_x1 = _mm_unpacklo_pd(_x1,_y1);\ -_z1 = _mm_unpacklo_pd(_z1,_x2);\ -_y2 = _mm_unpacklo_pd(_y2,_z2);\ -_x3 = _mm_unpacklo_pd(_x3,_y3);\ -_t1 = _mm_sub_pd(_t1,_x1);\ -_t2 = _mm_sub_pd(_t2,_z1);\ -_t3 = _mm_sub_pd(_t3,_y2);\ -_t4 = _mm_sub_pd(_t4,_x3);\ -_t5 = _mm_sub_sd(_t5,_z3);\ -_mm_storeu_pd(ptrA,_t1);\ -_mm_storeu_pd(ptrA+2,_t2);\ -_mm_storeu_pd(ptrA+4,_t3);\ -_mm_storeu_pd(ptrA+6,_t4);\ -_mm_store_sd(ptrA+8,_t5);\ -} +#define gmx_mm_decrement_3rvec_1ptr_swizzle_pd(ptrA, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_load_sd(ptrA+8); \ + _x1 = _mm_unpacklo_pd(_x1, _y1); \ + _z1 = _mm_unpacklo_pd(_z1, _x2); \ + _y2 = _mm_unpacklo_pd(_y2, _z2); \ + _x3 = _mm_unpacklo_pd(_x3, _y3); \ + _t1 = _mm_sub_pd(_t1, _x1); \ + _t2 = _mm_sub_pd(_t2, _z1); \ + _t3 = _mm_sub_pd(_t3, _y2); \ + _t4 = _mm_sub_pd(_t4, _x3); \ + _t5 = _mm_sub_sd(_t5, _z3); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_store_sd(ptrA+8, _t5); \ + } #else /* Real function for sane compilers */ static void @@ -434,7 +434,7 @@ gmx_mm_decrement_3rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, __m128d x2, __m128d y2, __m128d z2, __m128d x3, __m128d y3, __m128d z3) { - __m128d t1,t2,t3,t4,t5; + __m128d t1, t2, t3, t4, t5; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -442,50 +442,50 @@ gmx_mm_decrement_3rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, t4 = _mm_loadu_pd(ptrA+6); t5 = _mm_load_sd(ptrA+8); - x1 = _mm_unpacklo_pd(x1,y1); - z1 = _mm_unpacklo_pd(z1,x2); - y2 = _mm_unpacklo_pd(y2,z2); - x3 = _mm_unpacklo_pd(x3,y3); + x1 = _mm_unpacklo_pd(x1, y1); + z1 = _mm_unpacklo_pd(z1, x2); + y2 = _mm_unpacklo_pd(y2, z2); + x3 = _mm_unpacklo_pd(x3, y3); /* nothing to be done for z3 */ - t1 = _mm_sub_pd(t1,x1); - t2 = _mm_sub_pd(t2,z1); - t3 = _mm_sub_pd(t3,y2); - t4 = _mm_sub_pd(t4,x3); - t5 = _mm_sub_sd(t5,z3); - _mm_storeu_pd(ptrA,t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_store_sd(ptrA+8,t5); + t1 = _mm_sub_pd(t1, x1); + t2 = _mm_sub_pd(t2, z1); + t3 = _mm_sub_pd(t3, y2); + t4 = _mm_sub_pd(t4, x3); + t5 = _mm_sub_sd(t5, z3); + _mm_storeu_pd(ptrA, t1); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_store_sd(ptrA+8, t5); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_1ptr_swizzle_pd(ptrA,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ -__m128d _t1,_t2,_t3,_t4,_t5,_t6;\ -_t1 = _mm_loadu_pd(ptrA);\ -_t2 = _mm_loadu_pd(ptrA+2);\ -_t3 = _mm_loadu_pd(ptrA+4);\ -_t4 = _mm_loadu_pd(ptrA+6);\ -_t5 = _mm_loadu_pd(ptrA+8);\ -_t6 = _mm_loadu_pd(ptrA+10);\ -_x1 = _mm_unpacklo_pd(_x1,_y1);\ -_z1 = _mm_unpacklo_pd(_z1,_x2);\ -_y2 = _mm_unpacklo_pd(_y2,_z2);\ -_x3 = _mm_unpacklo_pd(_x3,_y3);\ -_z3 = _mm_unpacklo_pd(_z3,_x4);\ -_y4 = _mm_unpacklo_pd(_y4,_z4);\ -_mm_storeu_pd(ptrA, _mm_sub_pd( _t1,_x1 ));\ -_mm_storeu_pd(ptrA+2, _mm_sub_pd( _t2,_z1 ));\ -_mm_storeu_pd(ptrA+4, _mm_sub_pd( _t3,_y2 ));\ -_mm_storeu_pd(ptrA+6, _mm_sub_pd( _t4,_x3 ));\ -_mm_storeu_pd(ptrA+8, _mm_sub_pd( _t5,_z3 ));\ -_mm_storeu_pd(ptrA+10, _mm_sub_pd( _t6,_y4 ));\ -} +#define gmx_mm_decrement_4rvec_1ptr_swizzle_pd(ptrA, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_loadu_pd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrA+10); \ + _x1 = _mm_unpacklo_pd(_x1, _y1); \ + _z1 = _mm_unpacklo_pd(_z1, _x2); \ + _y2 = _mm_unpacklo_pd(_y2, _z2); \ + _x3 = _mm_unpacklo_pd(_x3, _y3); \ + _z3 = _mm_unpacklo_pd(_z3, _x4); \ + _y4 = _mm_unpacklo_pd(_y4, _z4); \ + _mm_storeu_pd(ptrA, _mm_sub_pd( _t1, _x1 )); \ + _mm_storeu_pd(ptrA+2, _mm_sub_pd( _t2, _z1 )); \ + _mm_storeu_pd(ptrA+4, _mm_sub_pd( _t3, _y2 )); \ + _mm_storeu_pd(ptrA+6, _mm_sub_pd( _t4, _x3 )); \ + _mm_storeu_pd(ptrA+8, _mm_sub_pd( _t5, _z3 )); \ + _mm_storeu_pd(ptrA+10, _mm_sub_pd( _t6, _y4 )); \ + } #else /* Real function for sane compilers */ static void @@ -495,7 +495,7 @@ gmx_mm_decrement_4rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, __m128d x3, __m128d y3, __m128d z3, __m128d x4, __m128d y4, __m128d z4) { - __m128d t1,t2,t3,t4,t5,t6; + __m128d t1, t2, t3, t4, t5, t6; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -504,19 +504,19 @@ gmx_mm_decrement_4rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, t5 = _mm_loadu_pd(ptrA+8); t6 = _mm_loadu_pd(ptrA+10); - x1 = _mm_unpacklo_pd(x1,y1); - z1 = _mm_unpacklo_pd(z1,x2); - y2 = _mm_unpacklo_pd(y2,z2); - x3 = _mm_unpacklo_pd(x3,y3); - z3 = _mm_unpacklo_pd(z3,x4); - y4 = _mm_unpacklo_pd(y4,z4); - - _mm_storeu_pd(ptrA, _mm_sub_pd( t1,x1 )); - _mm_storeu_pd(ptrA+2, _mm_sub_pd( t2,z1 )); - _mm_storeu_pd(ptrA+4, _mm_sub_pd( t3,y2 )); - _mm_storeu_pd(ptrA+6, _mm_sub_pd( t4,x3 )); - _mm_storeu_pd(ptrA+8, _mm_sub_pd( t5,z3 )); - _mm_storeu_pd(ptrA+10, _mm_sub_pd( t6,y4 )); + x1 = _mm_unpacklo_pd(x1, y1); + z1 = _mm_unpacklo_pd(z1, x2); + y2 = _mm_unpacklo_pd(y2, z2); + x3 = _mm_unpacklo_pd(x3, y3); + z3 = _mm_unpacklo_pd(z3, x4); + y4 = _mm_unpacklo_pd(y4, z4); + + _mm_storeu_pd(ptrA, _mm_sub_pd( t1, x1 )); + _mm_storeu_pd(ptrA+2, _mm_sub_pd( t2, z1 )); + _mm_storeu_pd(ptrA+4, _mm_sub_pd( t3, y2 )); + _mm_storeu_pd(ptrA+6, _mm_sub_pd( t4, x3 )); + _mm_storeu_pd(ptrA+8, _mm_sub_pd( t5, z3 )); + _mm_storeu_pd(ptrA+10, _mm_sub_pd( t6, y4 )); } #endif @@ -525,76 +525,76 @@ static void gmx_mm_decrement_1rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, __m128d x1, __m128d y1, __m128d z1) { - __m128d t1,t2,t3,t4,t5,t6,t7; + __m128d t1, t2, t3, t4, t5, t6, t7; t1 = _mm_loadu_pd(ptrA); t2 = _mm_load_sd(ptrA+2); t3 = _mm_loadu_pd(ptrB); t4 = _mm_load_sd(ptrB+2); - t5 = _mm_unpacklo_pd(x1,y1); - t6 = _mm_unpackhi_pd(x1,y1); - t7 = _mm_unpackhi_pd(z1,z1); + t5 = _mm_unpacklo_pd(x1, y1); + t6 = _mm_unpackhi_pd(x1, y1); + t7 = _mm_unpackhi_pd(z1, z1); - t1 = _mm_sub_pd(t1,t5); - t2 = _mm_sub_sd(t2,z1); + t1 = _mm_sub_pd(t1, t5); + t2 = _mm_sub_sd(t2, z1); - t3 = _mm_sub_pd(t3,t6); - t4 = _mm_sub_sd(t4,t7); + t3 = _mm_sub_pd(t3, t6); + t4 = _mm_sub_sd(t4, t7); - _mm_storeu_pd(ptrA,t1); - _mm_store_sd(ptrA+2,t2); - _mm_storeu_pd(ptrB,t3); - _mm_store_sd(ptrB+2,t4); + _mm_storeu_pd(ptrA, t1); + _mm_store_sd(ptrA+2, t2); + _mm_storeu_pd(ptrB, t3); + _mm_store_sd(ptrB+2, t4); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_2ptr_swizzle_pd(ptrA,ptrB,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ -__m128d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10;\ -__m128d _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH,_tI;\ -_t1 = _mm_loadu_pd(ptrA);\ -_t2 = _mm_loadu_pd(ptrA+2);\ -_t3 = _mm_loadu_pd(ptrA+4);\ -_t4 = _mm_loadu_pd(ptrA+6);\ -_t5 = _mm_load_sd(ptrA+8);\ -_t6 = _mm_loadu_pd(ptrB);\ -_t7 = _mm_loadu_pd(ptrB+2);\ -_t8 = _mm_loadu_pd(ptrB+4);\ -_t9 = _mm_loadu_pd(ptrB+6);\ -_t10 = _mm_load_sd(ptrB+8);\ -_tA = _mm_unpacklo_pd(_x1,_y1);\ -_tB = _mm_unpackhi_pd(_x1,_y1);\ -_tC = _mm_unpacklo_pd(_z1,_x2);\ -_tD = _mm_unpackhi_pd(_z1,_x2);\ -_tE = _mm_unpacklo_pd(_y2,_z2);\ -_tF = _mm_unpackhi_pd(_y2,_z2);\ -_tG = _mm_unpacklo_pd(_x3,_y3);\ -_tH = _mm_unpackhi_pd(_x3,_y3);\ -_tI = _mm_unpackhi_pd(_z3,_z3);\ -_t1 = _mm_sub_pd(_t1,_tA);\ -_t2 = _mm_sub_pd(_t2,_tC);\ -_t3 = _mm_sub_pd(_t3,_tE);\ -_t4 = _mm_sub_pd(_t4,_tG);\ -_t5 = _mm_sub_sd(_t5,_z3);\ -_t6 = _mm_sub_pd(_t6,_tB);\ -_t7 = _mm_sub_pd(_t7,_tD);\ -_t8 = _mm_sub_pd(_t8,_tF);\ -_t9 = _mm_sub_pd(_t9,_tH);\ -_t10 = _mm_sub_sd(_t10,_tI);\ -_mm_storeu_pd(ptrA,_t1);\ -_mm_storeu_pd(ptrA+2,_t2);\ -_mm_storeu_pd(ptrA+4,_t3);\ -_mm_storeu_pd(ptrA+6,_t4);\ -_mm_store_sd(ptrA+8,_t5);\ -_mm_storeu_pd(ptrB,_t6);\ -_mm_storeu_pd(ptrB+2,_t7);\ -_mm_storeu_pd(ptrB+4,_t8);\ -_mm_storeu_pd(ptrB+6,_t9);\ -_mm_store_sd(ptrB+8,_t10);\ -} +#define gmx_mm_decrement_3rvec_2ptr_swizzle_pd(ptrA, ptrB, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \ + __m128d _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH, _tI; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_load_sd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrB); \ + _t7 = _mm_loadu_pd(ptrB+2); \ + _t8 = _mm_loadu_pd(ptrB+4); \ + _t9 = _mm_loadu_pd(ptrB+6); \ + _t10 = _mm_load_sd(ptrB+8); \ + _tA = _mm_unpacklo_pd(_x1, _y1); \ + _tB = _mm_unpackhi_pd(_x1, _y1); \ + _tC = _mm_unpacklo_pd(_z1, _x2); \ + _tD = _mm_unpackhi_pd(_z1, _x2); \ + _tE = _mm_unpacklo_pd(_y2, _z2); \ + _tF = _mm_unpackhi_pd(_y2, _z2); \ + _tG = _mm_unpacklo_pd(_x3, _y3); \ + _tH = _mm_unpackhi_pd(_x3, _y3); \ + _tI = _mm_unpackhi_pd(_z3, _z3); \ + _t1 = _mm_sub_pd(_t1, _tA); \ + _t2 = _mm_sub_pd(_t2, _tC); \ + _t3 = _mm_sub_pd(_t3, _tE); \ + _t4 = _mm_sub_pd(_t4, _tG); \ + _t5 = _mm_sub_sd(_t5, _z3); \ + _t6 = _mm_sub_pd(_t6, _tB); \ + _t7 = _mm_sub_pd(_t7, _tD); \ + _t8 = _mm_sub_pd(_t8, _tF); \ + _t9 = _mm_sub_pd(_t9, _tH); \ + _t10 = _mm_sub_sd(_t10, _tI); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_store_sd(ptrA+8, _t5); \ + _mm_storeu_pd(ptrB, _t6); \ + _mm_storeu_pd(ptrB+2, _t7); \ + _mm_storeu_pd(ptrB+4, _t8); \ + _mm_storeu_pd(ptrB+6, _t9); \ + _mm_store_sd(ptrB+8, _t10); \ + } #else /* Real function for sane compilers */ static void @@ -603,8 +603,8 @@ gmx_mm_decrement_3rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ __m128d x2, __m128d y2, __m128d z2, __m128d x3, __m128d y3, __m128d z3) { - __m128d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; - __m128d tA,tB,tC,tD,tE,tF,tG,tH,tI; + __m128d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; + __m128d tA, tB, tC, tD, tE, tF, tG, tH, tI; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -617,97 +617,97 @@ gmx_mm_decrement_3rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ t9 = _mm_loadu_pd(ptrB+6); t10 = _mm_load_sd(ptrB+8); - tA = _mm_unpacklo_pd(x1,y1); - tB = _mm_unpackhi_pd(x1,y1); - tC = _mm_unpacklo_pd(z1,x2); - tD = _mm_unpackhi_pd(z1,x2); - tE = _mm_unpacklo_pd(y2,z2); - tF = _mm_unpackhi_pd(y2,z2); - tG = _mm_unpacklo_pd(x3,y3); - tH = _mm_unpackhi_pd(x3,y3); - tI = _mm_unpackhi_pd(z3,z3); - - t1 = _mm_sub_pd(t1,tA); - t2 = _mm_sub_pd(t2,tC); - t3 = _mm_sub_pd(t3,tE); - t4 = _mm_sub_pd(t4,tG); - t5 = _mm_sub_sd(t5,z3); - - t6 = _mm_sub_pd(t6,tB); - t7 = _mm_sub_pd(t7,tD); - t8 = _mm_sub_pd(t8,tF); - t9 = _mm_sub_pd(t9,tH); - t10 = _mm_sub_sd(t10,tI); - - _mm_storeu_pd(ptrA,t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_store_sd(ptrA+8,t5); - _mm_storeu_pd(ptrB,t6); - _mm_storeu_pd(ptrB+2,t7); - _mm_storeu_pd(ptrB+4,t8); - _mm_storeu_pd(ptrB+6,t9); - _mm_store_sd(ptrB+8,t10); + tA = _mm_unpacklo_pd(x1, y1); + tB = _mm_unpackhi_pd(x1, y1); + tC = _mm_unpacklo_pd(z1, x2); + tD = _mm_unpackhi_pd(z1, x2); + tE = _mm_unpacklo_pd(y2, z2); + tF = _mm_unpackhi_pd(y2, z2); + tG = _mm_unpacklo_pd(x3, y3); + tH = _mm_unpackhi_pd(x3, y3); + tI = _mm_unpackhi_pd(z3, z3); + + t1 = _mm_sub_pd(t1, tA); + t2 = _mm_sub_pd(t2, tC); + t3 = _mm_sub_pd(t3, tE); + t4 = _mm_sub_pd(t4, tG); + t5 = _mm_sub_sd(t5, z3); + + t6 = _mm_sub_pd(t6, tB); + t7 = _mm_sub_pd(t7, tD); + t8 = _mm_sub_pd(t8, tF); + t9 = _mm_sub_pd(t9, tH); + t10 = _mm_sub_sd(t10, tI); + + _mm_storeu_pd(ptrA, t1); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_store_sd(ptrA+8, t5); + _mm_storeu_pd(ptrB, t6); + _mm_storeu_pd(ptrB+2, t7); + _mm_storeu_pd(ptrB+4, t8); + _mm_storeu_pd(ptrB+6, t9); + _mm_store_sd(ptrB+8, t10); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_2ptr_swizzle_pd(ptrA,ptrB,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ -__m128d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11,_t12;\ -__m128d _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH,_tI,_tJ,_tK,_tL;\ -_t1 = _mm_loadu_pd(ptrA);\ -_t2 = _mm_loadu_pd(ptrA+2);\ -_t3 = _mm_loadu_pd(ptrA+4);\ -_t4 = _mm_loadu_pd(ptrA+6);\ -_t5 = _mm_loadu_pd(ptrA+8);\ -_t6 = _mm_loadu_pd(ptrA+10);\ -_t7 = _mm_loadu_pd(ptrB);\ -_t8 = _mm_loadu_pd(ptrB+2);\ -_t9 = _mm_loadu_pd(ptrB+4);\ -_t10 = _mm_loadu_pd(ptrB+6);\ -_t11 = _mm_loadu_pd(ptrB+8);\ -_t12 = _mm_loadu_pd(ptrB+10);\ -_tA = _mm_unpacklo_pd(_x1,_y1);\ -_tB = _mm_unpackhi_pd(_x1,_y1);\ -_tC = _mm_unpacklo_pd(_z1,_x2);\ -_tD = _mm_unpackhi_pd(_z1,_x2);\ -_tE = _mm_unpacklo_pd(_y2,_z2);\ -_tF = _mm_unpackhi_pd(_y2,_z2);\ -_tG = _mm_unpacklo_pd(_x3,_y3);\ -_tH = _mm_unpackhi_pd(_x3,_y3);\ -_tI = _mm_unpacklo_pd(_z3,_x4);\ -_tJ = _mm_unpackhi_pd(_z3,_x4);\ -_tK = _mm_unpacklo_pd(_y4,_z4);\ -_tL = _mm_unpackhi_pd(_y4,_z4);\ -_t1 = _mm_sub_pd(_t1,_tA);\ -_t2 = _mm_sub_pd(_t2,_tC);\ -_t3 = _mm_sub_pd(_t3,_tE);\ -_t4 = _mm_sub_pd(_t4,_tG);\ -_t5 = _mm_sub_pd(_t5,_tI);\ -_t6 = _mm_sub_pd(_t6,_tK);\ -_t7 = _mm_sub_pd(_t7,_tB);\ -_t8 = _mm_sub_pd(_t8,_tD);\ -_t9 = _mm_sub_pd(_t9,_tF);\ -_t10 = _mm_sub_pd(_t10,_tH);\ -_t11 = _mm_sub_pd(_t11,_tJ);\ -_t12 = _mm_sub_pd(_t12,_tL);\ -_mm_storeu_pd(ptrA, _t1);\ -_mm_storeu_pd(ptrA+2,_t2);\ -_mm_storeu_pd(ptrA+4,_t3);\ -_mm_storeu_pd(ptrA+6,_t4);\ -_mm_storeu_pd(ptrA+8,_t5);\ -_mm_storeu_pd(ptrA+10,_t6);\ -_mm_storeu_pd(ptrB, _t7);\ -_mm_storeu_pd(ptrB+2,_t8);\ -_mm_storeu_pd(ptrB+4,_t9);\ -_mm_storeu_pd(ptrB+6,_t10);\ -_mm_storeu_pd(ptrB+8,_t11);\ -_mm_storeu_pd(ptrB+10,_t12);\ -} +#define gmx_mm_decrement_4rvec_2ptr_swizzle_pd(ptrA, ptrB, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11, _t12; \ + __m128d _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH, _tI, _tJ, _tK, _tL; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_loadu_pd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrA+10); \ + _t7 = _mm_loadu_pd(ptrB); \ + _t8 = _mm_loadu_pd(ptrB+2); \ + _t9 = _mm_loadu_pd(ptrB+4); \ + _t10 = _mm_loadu_pd(ptrB+6); \ + _t11 = _mm_loadu_pd(ptrB+8); \ + _t12 = _mm_loadu_pd(ptrB+10); \ + _tA = _mm_unpacklo_pd(_x1, _y1); \ + _tB = _mm_unpackhi_pd(_x1, _y1); \ + _tC = _mm_unpacklo_pd(_z1, _x2); \ + _tD = _mm_unpackhi_pd(_z1, _x2); \ + _tE = _mm_unpacklo_pd(_y2, _z2); \ + _tF = _mm_unpackhi_pd(_y2, _z2); \ + _tG = _mm_unpacklo_pd(_x3, _y3); \ + _tH = _mm_unpackhi_pd(_x3, _y3); \ + _tI = _mm_unpacklo_pd(_z3, _x4); \ + _tJ = _mm_unpackhi_pd(_z3, _x4); \ + _tK = _mm_unpacklo_pd(_y4, _z4); \ + _tL = _mm_unpackhi_pd(_y4, _z4); \ + _t1 = _mm_sub_pd(_t1, _tA); \ + _t2 = _mm_sub_pd(_t2, _tC); \ + _t3 = _mm_sub_pd(_t3, _tE); \ + _t4 = _mm_sub_pd(_t4, _tG); \ + _t5 = _mm_sub_pd(_t5, _tI); \ + _t6 = _mm_sub_pd(_t6, _tK); \ + _t7 = _mm_sub_pd(_t7, _tB); \ + _t8 = _mm_sub_pd(_t8, _tD); \ + _t9 = _mm_sub_pd(_t9, _tF); \ + _t10 = _mm_sub_pd(_t10, _tH); \ + _t11 = _mm_sub_pd(_t11, _tJ); \ + _t12 = _mm_sub_pd(_t12, _tL); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_storeu_pd(ptrA+8, _t5); \ + _mm_storeu_pd(ptrA+10, _t6); \ + _mm_storeu_pd(ptrB, _t7); \ + _mm_storeu_pd(ptrB+2, _t8); \ + _mm_storeu_pd(ptrB+4, _t9); \ + _mm_storeu_pd(ptrB+6, _t10); \ + _mm_storeu_pd(ptrB+8, _t11); \ + _mm_storeu_pd(ptrB+10, _t12); \ + } #else /* Real function for sane compilers */ static void @@ -717,8 +717,8 @@ gmx_mm_decrement_4rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ __m128d x3, __m128d y3, __m128d z3, __m128d x4, __m128d y4, __m128d z4) { - __m128d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - __m128d tA,tB,tC,tD,tE,tF,tG,tH,tI,tJ,tK,tL; + __m128d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + __m128d tA, tB, tC, tD, tE, tF, tG, tH, tI, tJ, tK, tL; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -733,45 +733,45 @@ gmx_mm_decrement_4rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ t11 = _mm_loadu_pd(ptrB+8); t12 = _mm_loadu_pd(ptrB+10); - tA = _mm_unpacklo_pd(x1,y1); - tB = _mm_unpackhi_pd(x1,y1); - tC = _mm_unpacklo_pd(z1,x2); - tD = _mm_unpackhi_pd(z1,x2); - tE = _mm_unpacklo_pd(y2,z2); - tF = _mm_unpackhi_pd(y2,z2); - tG = _mm_unpacklo_pd(x3,y3); - tH = _mm_unpackhi_pd(x3,y3); - tI = _mm_unpacklo_pd(z3,x4); - tJ = _mm_unpackhi_pd(z3,x4); - tK = _mm_unpacklo_pd(y4,z4); - tL = _mm_unpackhi_pd(y4,z4); - - t1 = _mm_sub_pd(t1,tA); - t2 = _mm_sub_pd(t2,tC); - t3 = _mm_sub_pd(t3,tE); - t4 = _mm_sub_pd(t4,tG); - t5 = _mm_sub_pd(t5,tI); - t6 = _mm_sub_pd(t6,tK); - - t7 = _mm_sub_pd(t7,tB); - t8 = _mm_sub_pd(t8,tD); - t9 = _mm_sub_pd(t9,tF); - t10 = _mm_sub_pd(t10,tH); - t11 = _mm_sub_pd(t11,tJ); - t12 = _mm_sub_pd(t12,tL); + tA = _mm_unpacklo_pd(x1, y1); + tB = _mm_unpackhi_pd(x1, y1); + tC = _mm_unpacklo_pd(z1, x2); + tD = _mm_unpackhi_pd(z1, x2); + tE = _mm_unpacklo_pd(y2, z2); + tF = _mm_unpackhi_pd(y2, z2); + tG = _mm_unpacklo_pd(x3, y3); + tH = _mm_unpackhi_pd(x3, y3); + tI = _mm_unpacklo_pd(z3, x4); + tJ = _mm_unpackhi_pd(z3, x4); + tK = _mm_unpacklo_pd(y4, z4); + tL = _mm_unpackhi_pd(y4, z4); + + t1 = _mm_sub_pd(t1, tA); + t2 = _mm_sub_pd(t2, tC); + t3 = _mm_sub_pd(t3, tE); + t4 = _mm_sub_pd(t4, tG); + t5 = _mm_sub_pd(t5, tI); + t6 = _mm_sub_pd(t6, tK); + + t7 = _mm_sub_pd(t7, tB); + t8 = _mm_sub_pd(t8, tD); + t9 = _mm_sub_pd(t9, tF); + t10 = _mm_sub_pd(t10, tH); + t11 = _mm_sub_pd(t11, tJ); + t12 = _mm_sub_pd(t12, tL); _mm_storeu_pd(ptrA, t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_storeu_pd(ptrA+8,t5); - _mm_storeu_pd(ptrA+10,t6); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_storeu_pd(ptrA+8, t5); + _mm_storeu_pd(ptrA+10, t6); _mm_storeu_pd(ptrB, t7); - _mm_storeu_pd(ptrB+2,t8); - _mm_storeu_pd(ptrB+4,t9); - _mm_storeu_pd(ptrB+6,t10); - _mm_storeu_pd(ptrB+8,t11); - _mm_storeu_pd(ptrB+10,t12); + _mm_storeu_pd(ptrB+2, t8); + _mm_storeu_pd(ptrB+4, t9); + _mm_storeu_pd(ptrB+6, t10); + _mm_storeu_pd(ptrB+8, t11); + _mm_storeu_pd(ptrB+10, t12); } #endif @@ -781,8 +781,8 @@ gmx_mm_update_iforce_1atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - fix1 = _mm_hadd_pd(fix1,fiy1); - fiz1 = _mm_hadd_pd(fiz1,fiz1); + fix1 = _mm_hadd_pd(fix1, fiy1); + fiz1 = _mm_hadd_pd(fiz1, fiz1); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_store_sd( fptr+2, _mm_add_sd( _mm_load_sd(fptr+2), fiz1 )); @@ -793,29 +793,29 @@ gmx_mm_update_iforce_1atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \ -fptr,fshiftptr) \ -{\ -__m128d _t1,_t2;\ -fix1 = _mm_hadd_pd(fix1,fiy1);\ -fiz1 = _mm_hadd_pd(fiz1,fix2);\ -fiy2 = _mm_hadd_pd(fiy2,fiz2);\ -fix3 = _mm_hadd_pd(fix3,fiy3);\ -fiz3 = _mm_hadd_pd(fiz3,fiz3);\ -_mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 ));\ -_mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 ));\ -_mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 ));\ -_mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 ));\ -_mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 ));\ -fix1 = _mm_add_pd(fix1,fix3);\ -_t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1));\ -fix1 = _mm_add_pd(fix1,_t1);\ -_t2 = _mm_shuffle_pd(fiy2,fiy2,_MM_SHUFFLE2(1,1));\ -fiz1 = _mm_add_sd(fiz1,fiz3);\ -fiz1 = _mm_add_sd(fiz1,_t2);\ -_mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 ));\ -_mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 ));\ -} +#define gmx_mm_update_iforce_3atom_swizzle_pd(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \ + fptr, fshiftptr) \ + { \ + __m128d _t1, _t2; \ + fix1 = _mm_hadd_pd(fix1, fiy1); \ + fiz1 = _mm_hadd_pd(fiz1, fix2); \ + fiy2 = _mm_hadd_pd(fiy2, fiz2); \ + fix3 = _mm_hadd_pd(fix3, fiy3); \ + fiz3 = _mm_hadd_pd(fiz3, fiz3); \ + _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); \ + _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); \ + _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 )); \ + _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); \ + _mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 )); \ + fix1 = _mm_add_pd(fix1, fix3); \ + _t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); \ + fix1 = _mm_add_pd(fix1, _t1); \ + _t2 = _mm_shuffle_pd(fiy2, fiy2, _MM_SHUFFLE2(1, 1)); \ + fiz1 = _mm_add_sd(fiz1, fiz3); \ + fiz1 = _mm_add_sd(fiz1, _t2); \ + _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); \ + _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -825,13 +825,13 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - __m128d t1,t2; + __m128d t1, t2; - fix1 = _mm_hadd_pd(fix1,fiy1); - fiz1 = _mm_hadd_pd(fiz1,fix2); - fiy2 = _mm_hadd_pd(fiy2,fiz2); - fix3 = _mm_hadd_pd(fix3,fiy3); - fiz3 = _mm_hadd_pd(fiz3,fiz3); + fix1 = _mm_hadd_pd(fix1, fiy1); + fiz1 = _mm_hadd_pd(fiz1, fix2); + fiy2 = _mm_hadd_pd(fiy2, fiz2); + fix3 = _mm_hadd_pd(fix3, fiy3); + fiz3 = _mm_hadd_pd(fiz3, fiz3); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); @@ -839,13 +839,13 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); _mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 )); - fix1 = _mm_add_pd(fix1,fix3); - t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1)); - fix1 = _mm_add_pd(fix1,t1); /* x and y sums */ + fix1 = _mm_add_pd(fix1, fix3); + t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); + fix1 = _mm_add_pd(fix1, t1); /* x and y sums */ - t2 = _mm_shuffle_pd(fiy2,fiy2,_MM_SHUFFLE2(1,1)); - fiz1 = _mm_add_sd(fiz1,fiz3); - fiz1 = _mm_add_sd(fiz1,t2); /* z sum */ + t2 = _mm_shuffle_pd(fiy2, fiy2, _MM_SHUFFLE2(1, 1)); + fiz1 = _mm_add_sd(fiz1, fiz3); + fiz1 = _mm_add_sd(fiz1, t2); /* z sum */ _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); @@ -854,33 +854,33 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_4atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \ -fptr,fshiftptr) \ -{\ -__m128d _t1,_t2;\ -fix1 = _mm_hadd_pd(fix1,fiy1);\ -fiz1 = _mm_hadd_pd(fiz1,fix2);\ -fiy2 = _mm_hadd_pd(fiy2,fiz2);\ -fix3 = _mm_hadd_pd(fix3,fiy3);\ -fiz3 = _mm_hadd_pd(fiz3,fix4);\ -fiy4 = _mm_hadd_pd(fiy4,fiz4);\ -_mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 ));\ -_mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 ));\ -_mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 ));\ -_mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 ));\ -_mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 ));\ -_mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 ));\ -_t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1));\ -fix1 = _mm_add_pd(fix1,_t1);\ -_t2 = _mm_shuffle_pd(fiz3,fiy4,_MM_SHUFFLE2(0,1));\ -fix3 = _mm_add_pd(fix3,_t2);\ -fix1 = _mm_add_pd(fix1,fix3);\ -fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2,fiy2));\ -fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4,fiy4));\ -fiz1 = _mm_add_sd(fiz1,fiz3);\ -_mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 ));\ -_mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 ));\ -} +#define gmx_mm_update_iforce_4atom_swizzle_pd(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \ + fptr, fshiftptr) \ + { \ + __m128d _t1, _t2; \ + fix1 = _mm_hadd_pd(fix1, fiy1); \ + fiz1 = _mm_hadd_pd(fiz1, fix2); \ + fiy2 = _mm_hadd_pd(fiy2, fiz2); \ + fix3 = _mm_hadd_pd(fix3, fiy3); \ + fiz3 = _mm_hadd_pd(fiz3, fix4); \ + fiy4 = _mm_hadd_pd(fiy4, fiz4); \ + _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); \ + _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); \ + _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 )); \ + _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); \ + _mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 )); \ + _mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 )); \ + _t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); \ + fix1 = _mm_add_pd(fix1, _t1); \ + _t2 = _mm_shuffle_pd(fiz3, fiy4, _MM_SHUFFLE2(0, 1)); \ + fix3 = _mm_add_pd(fix3, _t2); \ + fix1 = _mm_add_pd(fix1, fix3); \ + fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2, fiy2)); \ + fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4, fiy4)); \ + fiz1 = _mm_add_sd(fiz1, fiz3); \ + _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); \ + _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -891,14 +891,14 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - __m128d t1,t2; + __m128d t1, t2; - fix1 = _mm_hadd_pd(fix1,fiy1); - fiz1 = _mm_hadd_pd(fiz1,fix2); - fiy2 = _mm_hadd_pd(fiy2,fiz2); - fix3 = _mm_hadd_pd(fix3,fiy3); - fiz3 = _mm_hadd_pd(fiz3,fix4); - fiy4 = _mm_hadd_pd(fiy4,fiz4); + fix1 = _mm_hadd_pd(fix1, fiy1); + fiz1 = _mm_hadd_pd(fiz1, fix2); + fiy2 = _mm_hadd_pd(fiy2, fiz2); + fix3 = _mm_hadd_pd(fix3, fiy3); + fiz3 = _mm_hadd_pd(fiz3, fix4); + fiy4 = _mm_hadd_pd(fiy4, fiz4); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); @@ -907,15 +907,15 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, _mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 )); _mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 )); - t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1)); - fix1 = _mm_add_pd(fix1,t1); - t2 = _mm_shuffle_pd(fiz3,fiy4,_MM_SHUFFLE2(0,1)); - fix3 = _mm_add_pd(fix3,t2); - fix1 = _mm_add_pd(fix1,fix3); /* x and y sums */ + t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); + fix1 = _mm_add_pd(fix1, t1); + t2 = _mm_shuffle_pd(fiz3, fiy4, _MM_SHUFFLE2(0, 1)); + fix3 = _mm_add_pd(fix3, t2); + fix1 = _mm_add_pd(fix1, fix3); /* x and y sums */ - fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2,fiy2)); - fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4,fiy4)); - fiz1 = _mm_add_sd(fiz1,fiz3); /* z sum */ + fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2, fiy2)); + fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4, fiy4)); + fiz1 = _mm_add_sd(fiz1, fiz3); /* z sum */ _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); @@ -926,19 +926,19 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, static gmx_inline void gmx_mm_update_1pot_pd(__m128d pot1, double * gmx_restrict ptrA) { - pot1 = _mm_hadd_pd(pot1,pot1); - _mm_store_sd(ptrA,_mm_add_sd(pot1,_mm_load_sd(ptrA))); + pot1 = _mm_hadd_pd(pot1, pot1); + _mm_store_sd(ptrA, _mm_add_sd(pot1, _mm_load_sd(ptrA))); } static gmx_inline void gmx_mm_update_2pot_pd(__m128d pot1, double * gmx_restrict ptrA, __m128d pot2, double * gmx_restrict ptrB) { - pot1 = _mm_hadd_pd(pot1,pot2); - pot2 = _mm_unpackhi_pd(pot1,pot1); + pot1 = _mm_hadd_pd(pot1, pot2); + pot2 = _mm_unpackhi_pd(pot1, pot1); - _mm_store_sd(ptrA,_mm_add_sd(pot1,_mm_load_sd(ptrA))); - _mm_store_sd(ptrB,_mm_add_sd(pot2,_mm_load_sd(ptrB))); + _mm_store_sd(ptrA, _mm_add_sd(pot1, _mm_load_sd(ptrA))); + _mm_store_sd(ptrB, _mm_add_sd(pot2, _mm_load_sd(ptrB))); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.c index ceb52b591e..a58de0c174 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.c @@ -241,7 +241,7 @@ nb_kernel_t nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_avx_128_fma_double; nb_kernel_info_t -kernellist_avx_128_fma_double[] = + kernellist_avx_128_fma_double[] = { { nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_128_fma_double, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_128_fma_double", "avx_128_fma_double", "None", "None", "LennardJones", "None", "ParticleParticle", "", "PotentialAndForce" }, { nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_128_fma_double, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_128_fma_double", "avx_128_fma_double", "None", "None", "LennardJones", "None", "ParticleParticle", "", "Force" }, @@ -460,6 +460,6 @@ kernellist_avx_128_fma_double[] = }; int -kernellist_avx_128_fma_double_size = sizeof(kernellist_avx_128_fma_double)/sizeof(kernellist_avx_128_fma_double[0]); + kernellist_avx_128_fma_double_size = sizeof(kernellist_avx_128_fma_double)/sizeof(kernellist_avx_128_fma_double[0]); #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.h index 2f7e8d9ed5..8f9f8a966d 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_double/nb_kernel_avx_128_fma_double.h @@ -27,10 +27,10 @@ /* List of kernels for this architecture with metadata about them */ extern nb_kernel_info_t -kernellist_avx_128_fma_double[]; + kernellist_avx_128_fma_double[]; /* Length of kernellist_c */ extern int -kernellist_avx_128_fma_double_size; + kernellist_avx_128_fma_double_size; #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/kernelutil_x86_avx_128_fma_single.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/kernelutil_x86_avx_128_fma_single.h index 7b663ed733..77f2002a5e 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/kernelutil_x86_avx_128_fma_single.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/kernelutil_x86_avx_128_fma_single.h @@ -35,18 +35,18 @@ #include "gmx_x86_avx_128_fma.h" /* Normal sum of four xmm registers */ -#define gmx_mm_sum4_ps(t0,t1,t2,t3) _mm_add_ps(_mm_add_ps(t0,t1),_mm_add_ps(t2,t3)) +#define gmx_mm_sum4_ps(t0, t1, t2, t3) _mm_add_ps(_mm_add_ps(t0, t1), _mm_add_ps(t2, t3)) static gmx_inline int gmx_mm_any_lt(__m128 a, __m128 b) { - return _mm_movemask_ps(_mm_cmplt_ps(a,b)); + return _mm_movemask_ps(_mm_cmplt_ps(a, b)); } static gmx_inline __m128 gmx_mm_calc_rsq_ps(__m128 dx, __m128 dy, __m128 dz) { - return _mm_macc_ps(dx,dx,_mm_macc_ps(dy,dy,_mm_mul_ps(dz,dz))); + return _mm_macc_ps(dx, dx, _mm_macc_ps(dy, dy, _mm_mul_ps(dz, dz))); } /* Load a single value from 1-4 places, merge into xmm register */ @@ -57,11 +57,11 @@ gmx_mm_load_4real_swizzle_ps(const float * gmx_restrict ptrA, const float * gmx_restrict ptrC, const float * gmx_restrict ptrD) { - __m128 t1,t2; + __m128 t1, t2; - t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA),_mm_load_ss(ptrC)); - t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB),_mm_load_ss(ptrD)); - return _mm_unpacklo_ps(t1,t2); + t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA), _mm_load_ss(ptrC)); + t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB), _mm_load_ss(ptrD)); + return _mm_unpacklo_ps(t1, t2); } @@ -71,15 +71,15 @@ gmx_mm_store_4real_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrC, float * gmx_restrict ptrD, __m128 xmm1) { - __m128 t2,t3,t4; - - t2 = _mm_permute_ps(xmm1,_MM_SHUFFLE(1,1,1,1)); - t3 = _mm_permute_ps(xmm1,_MM_SHUFFLE(2,2,2,2)); - t4 = _mm_permute_ps(xmm1,_MM_SHUFFLE(3,3,3,3)); - _mm_store_ss(ptrA,xmm1); - _mm_store_ss(ptrB,t2); - _mm_store_ss(ptrC,t3); - _mm_store_ss(ptrD,t4); + __m128 t2, t3, t4; + + t2 = _mm_permute_ps(xmm1, _MM_SHUFFLE(1, 1, 1, 1)); + t3 = _mm_permute_ps(xmm1, _MM_SHUFFLE(2, 2, 2, 2)); + t4 = _mm_permute_ps(xmm1, _MM_SHUFFLE(3, 3, 3, 3)); + _mm_store_ss(ptrA, xmm1); + _mm_store_ss(ptrB, t2); + _mm_store_ss(ptrC, t3); + _mm_store_ss(ptrD, t4); } @@ -91,9 +91,9 @@ gmx_mm_increment_4real_swizzle_ps(float * gmx_restrict ptrA, { __m128 tmp; - tmp = gmx_mm_load_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD); - tmp = _mm_add_ps(tmp,xmm1); - gmx_mm_store_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD,tmp); + tmp = gmx_mm_load_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD); + tmp = _mm_add_ps(tmp, xmm1); + gmx_mm_store_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD, tmp); } @@ -104,15 +104,15 @@ gmx_mm_load_4pair_swizzle_ps(const float * gmx_restrict p1, const float * gmx_restrict p4, __m128 * gmx_restrict c6, __m128 * gmx_restrict c12) { - __m128 t1,t2,t3,t4; - t1 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p1); - t2 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p2); - t3 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p3); - t4 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p4); - t1 = _mm_unpacklo_ps(t1,t3); - t2 = _mm_unpacklo_ps(t2,t4); - *c6 = _mm_unpacklo_ps(t1,t2); - *c12 = _mm_unpackhi_ps(t1,t2); + __m128 t1, t2, t3, t4; + t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p1); + t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p2); + t3 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p3); + t4 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p4); + t1 = _mm_unpacklo_ps(t1, t3); + t2 = _mm_unpacklo_ps(t2, t4); + *c6 = _mm_unpacklo_ps(t1, t2); + *c12 = _mm_unpackhi_ps(t1, t2); } @@ -120,103 +120,103 @@ gmx_mm_load_4pair_swizzle_ps(const float * gmx_restrict p1, static gmx_inline void gmx_mm_load_shift_and_1rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, - __m128 * gmx_restrict y1, - __m128 * gmx_restrict z1) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, + __m128 * gmx_restrict y1, + __m128 * gmx_restrict z1) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; - t1 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); - t2 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz); + t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); + t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz); t3 = _mm_load_ss(xyz_shift+2); t4 = _mm_load_ss(xyz+2); - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ss(t3,t4); + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ss(t3, t4); - *x1 = _mm_permute_ps(t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_permute_ps(t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_permute_ps(t3,_MM_SHUFFLE(0,0,0,0)); + *x1 = _mm_permute_ps(t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_permute_ps(t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_permute_ps(t3, _MM_SHUFFLE(0, 0, 0, 0)); } static gmx_inline void gmx_mm_load_shift_and_3rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, - __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, - __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, + __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, + __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) { - __m128 tA,tB; - __m128 t1,t2,t3,t4,t5,t6; + __m128 tA, tB; + __m128 t1, t2, t3, t4, t5, t6; - tA = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); + tA = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); tB = _mm_load_ss(xyz_shift+2); t1 = _mm_loadu_ps(xyz); t2 = _mm_loadu_ps(xyz+4); t3 = _mm_load_ss(xyz+8); - tA = _mm_movelh_ps(tA,tB); - t4 = _mm_permute_ps(tA,_MM_SHUFFLE(0,2,1,0)); - t5 = _mm_permute_ps(tA,_MM_SHUFFLE(1,0,2,1)); - t6 = _mm_permute_ps(tA,_MM_SHUFFLE(2,1,0,2)); - - t1 = _mm_add_ps(t1,t4); - t2 = _mm_add_ps(t2,t5); - t3 = _mm_add_ss(t3,t6); - - *x1 = _mm_permute_ps(t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_permute_ps(t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_permute_ps(t1,_MM_SHUFFLE(2,2,2,2)); - *x2 = _mm_permute_ps(t1,_MM_SHUFFLE(3,3,3,3)); - *y2 = _mm_permute_ps(t2,_MM_SHUFFLE(0,0,0,0)); - *z2 = _mm_permute_ps(t2,_MM_SHUFFLE(1,1,1,1)); - *x3 = _mm_permute_ps(t2,_MM_SHUFFLE(2,2,2,2)); - *y3 = _mm_permute_ps(t2,_MM_SHUFFLE(3,3,3,3)); - *z3 = _mm_permute_ps(t3,_MM_SHUFFLE(0,0,0,0)); + tA = _mm_movelh_ps(tA, tB); + t4 = _mm_permute_ps(tA, _MM_SHUFFLE(0, 2, 1, 0)); + t5 = _mm_permute_ps(tA, _MM_SHUFFLE(1, 0, 2, 1)); + t6 = _mm_permute_ps(tA, _MM_SHUFFLE(2, 1, 0, 2)); + + t1 = _mm_add_ps(t1, t4); + t2 = _mm_add_ps(t2, t5); + t3 = _mm_add_ss(t3, t6); + + *x1 = _mm_permute_ps(t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_permute_ps(t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_permute_ps(t1, _MM_SHUFFLE(2, 2, 2, 2)); + *x2 = _mm_permute_ps(t1, _MM_SHUFFLE(3, 3, 3, 3)); + *y2 = _mm_permute_ps(t2, _MM_SHUFFLE(0, 0, 0, 0)); + *z2 = _mm_permute_ps(t2, _MM_SHUFFLE(1, 1, 1, 1)); + *x3 = _mm_permute_ps(t2, _MM_SHUFFLE(2, 2, 2, 2)); + *y3 = _mm_permute_ps(t2, _MM_SHUFFLE(3, 3, 3, 3)); + *z3 = _mm_permute_ps(t3, _MM_SHUFFLE(0, 0, 0, 0)); } static gmx_inline void gmx_mm_load_shift_and_4rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, - __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, - __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, - __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, + __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, + __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, + __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) { - __m128 tA,tB; - __m128 t1,t2,t3,t4,t5,t6; + __m128 tA, tB; + __m128 t1, t2, t3, t4, t5, t6; - tA = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); + tA = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); tB = _mm_load_ss(xyz_shift+2); t1 = _mm_loadu_ps(xyz); t2 = _mm_loadu_ps(xyz+4); t3 = _mm_loadu_ps(xyz+8); - tA = _mm_movelh_ps(tA,tB); - t4 = _mm_permute_ps(tA,_MM_SHUFFLE(0,2,1,0)); - t5 = _mm_permute_ps(tA,_MM_SHUFFLE(1,0,2,1)); - t6 = _mm_permute_ps(tA,_MM_SHUFFLE(2,1,0,2)); - - t1 = _mm_add_ps(t1,t4); - t2 = _mm_add_ps(t2,t5); - t3 = _mm_add_ps(t3,t6); - - *x1 = _mm_permute_ps(t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_permute_ps(t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_permute_ps(t1,_MM_SHUFFLE(2,2,2,2)); - *x2 = _mm_permute_ps(t1,_MM_SHUFFLE(3,3,3,3)); - *y2 = _mm_permute_ps(t2,_MM_SHUFFLE(0,0,0,0)); - *z2 = _mm_permute_ps(t2,_MM_SHUFFLE(1,1,1,1)); - *x3 = _mm_permute_ps(t2,_MM_SHUFFLE(2,2,2,2)); - *y3 = _mm_permute_ps(t2,_MM_SHUFFLE(3,3,3,3)); - *z3 = _mm_permute_ps(t3,_MM_SHUFFLE(0,0,0,0)); - *x4 = _mm_permute_ps(t3,_MM_SHUFFLE(1,1,1,1)); - *y4 = _mm_permute_ps(t3,_MM_SHUFFLE(2,2,2,2)); - *z4 = _mm_permute_ps(t3,_MM_SHUFFLE(3,3,3,3)); + tA = _mm_movelh_ps(tA, tB); + t4 = _mm_permute_ps(tA, _MM_SHUFFLE(0, 2, 1, 0)); + t5 = _mm_permute_ps(tA, _MM_SHUFFLE(1, 0, 2, 1)); + t6 = _mm_permute_ps(tA, _MM_SHUFFLE(2, 1, 0, 2)); + + t1 = _mm_add_ps(t1, t4); + t2 = _mm_add_ps(t2, t5); + t3 = _mm_add_ps(t3, t6); + + *x1 = _mm_permute_ps(t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_permute_ps(t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_permute_ps(t1, _MM_SHUFFLE(2, 2, 2, 2)); + *x2 = _mm_permute_ps(t1, _MM_SHUFFLE(3, 3, 3, 3)); + *y2 = _mm_permute_ps(t2, _MM_SHUFFLE(0, 0, 0, 0)); + *z2 = _mm_permute_ps(t2, _MM_SHUFFLE(1, 1, 1, 1)); + *x3 = _mm_permute_ps(t2, _MM_SHUFFLE(2, 2, 2, 2)); + *y3 = _mm_permute_ps(t2, _MM_SHUFFLE(3, 3, 3, 3)); + *z3 = _mm_permute_ps(t3, _MM_SHUFFLE(0, 0, 0, 0)); + *x4 = _mm_permute_ps(t3, _MM_SHUFFLE(1, 1, 1, 1)); + *y4 = _mm_permute_ps(t3, _MM_SHUFFLE(2, 2, 2, 2)); + *z4 = _mm_permute_ps(t3, _MM_SHUFFLE(3, 3, 3, 3)); } @@ -225,13 +225,13 @@ gmx_mm_load_1rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const float * const float * gmx_restrict ptrC, const float * gmx_restrict ptrD, __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1) { - __m128 t1,t2,t3,t4; - __m128i mask = _mm_set_epi32(0,-1,-1,-1); - t1 = gmx_mm_maskload_ps(ptrA,mask); - t2 = gmx_mm_maskload_ps(ptrB,mask); - t3 = gmx_mm_maskload_ps(ptrC,mask); - t4 = gmx_mm_maskload_ps(ptrD,mask); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + __m128 t1, t2, t3, t4; + __m128i mask = _mm_set_epi32(0, -1, -1, -1); + t1 = gmx_mm_maskload_ps(ptrA, mask); + t2 = gmx_mm_maskload_ps(ptrB, mask); + t3 = gmx_mm_maskload_ps(ptrC, mask); + t4 = gmx_mm_maskload_ps(ptrD, mask); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = t1; *y1 = t2; *z1 = t3; @@ -245,12 +245,12 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const float * __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrB); t3 = _mm_loadu_ps(ptrC); t4 = _mm_loadu_ps(ptrD); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = t1; *y1 = t2; *z1 = t3; @@ -259,7 +259,7 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const float * t2 = _mm_loadu_ps(ptrB+4); t3 = _mm_loadu_ps(ptrC+4); t4 = _mm_loadu_ps(ptrD+4); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *y2 = t1; *z2 = t2; *x3 = t3; @@ -268,9 +268,9 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const float * t2 = _mm_load_ss(ptrB+8); t3 = _mm_load_ss(ptrC+8); t4 = _mm_load_ss(ptrD+8); - t1 = _mm_unpacklo_ps(t1,t3); - t3 = _mm_unpacklo_ps(t2,t4); - *z3 = _mm_unpacklo_ps(t1,t3); + t1 = _mm_unpacklo_ps(t1, t3); + t3 = _mm_unpacklo_ps(t2, t4); + *z3 = _mm_unpacklo_ps(t1, t3); } @@ -282,12 +282,12 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const float * __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrB); t3 = _mm_loadu_ps(ptrC); t4 = _mm_loadu_ps(ptrD); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = t1; *y1 = t2; *z1 = t3; @@ -296,7 +296,7 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const float * t2 = _mm_loadu_ps(ptrB+4); t3 = _mm_loadu_ps(ptrC+4); t4 = _mm_loadu_ps(ptrD+4); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *y2 = t1; *z2 = t2; *x3 = t3; @@ -305,7 +305,7 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const float * t2 = _mm_loadu_ps(ptrB+8); t3 = _mm_loadu_ps(ptrC+8); t4 = _mm_loadu_ps(ptrD+8); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *z3 = t1; *x4 = t2; *y4 = t3; @@ -318,100 +318,100 @@ gmx_mm_decrement_1rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_re float * gmx_restrict ptrC, float * gmx_restrict ptrD, __m128 x1, __m128 y1, __m128 z1) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - t5 = _mm_unpacklo_ps(y1,z1); - t6 = _mm_unpackhi_ps(y1,z1); - t7 = _mm_shuffle_ps(x1,t5,_MM_SHUFFLE(1,0,0,0)); - t8 = _mm_shuffle_ps(x1,t5,_MM_SHUFFLE(3,2,0,1)); - t9 = _mm_shuffle_ps(x1,t6,_MM_SHUFFLE(1,0,0,2)); - t10 = _mm_shuffle_ps(x1,t6,_MM_SHUFFLE(3,2,0,3)); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + t5 = _mm_unpacklo_ps(y1, z1); + t6 = _mm_unpackhi_ps(y1, z1); + t7 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(1, 0, 0, 0)); + t8 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(3, 2, 0, 1)); + t9 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(1, 0, 0, 2)); + t10 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(3, 2, 0, 3)); t1 = _mm_load_ss(ptrA); - t1 = _mm_loadh_pi(t1,(__m64 *)(ptrA+1)); - t1 = _mm_sub_ps(t1,t7); - _mm_store_ss(ptrA,t1); - _mm_storeh_pi((__m64 *)(ptrA+1),t1); + t1 = _mm_loadh_pi(t1, (__m64 *)(ptrA+1)); + t1 = _mm_sub_ps(t1, t7); + _mm_store_ss(ptrA, t1); + _mm_storeh_pi((__m64 *)(ptrA+1), t1); t2 = _mm_load_ss(ptrB); - t2 = _mm_loadh_pi(t2,(__m64 *)(ptrB+1)); - t2 = _mm_sub_ps(t2,t8); - _mm_store_ss(ptrB,t2); - _mm_storeh_pi((__m64 *)(ptrB+1),t2); + t2 = _mm_loadh_pi(t2, (__m64 *)(ptrB+1)); + t2 = _mm_sub_ps(t2, t8); + _mm_store_ss(ptrB, t2); + _mm_storeh_pi((__m64 *)(ptrB+1), t2); t3 = _mm_load_ss(ptrC); - t3 = _mm_loadh_pi(t3,(__m64 *)(ptrC+1)); - t3 = _mm_sub_ps(t3,t9); - _mm_store_ss(ptrC,t3); - _mm_storeh_pi((__m64 *)(ptrC+1),t3); + t3 = _mm_loadh_pi(t3, (__m64 *)(ptrC+1)); + t3 = _mm_sub_ps(t3, t9); + _mm_store_ss(ptrC, t3); + _mm_storeh_pi((__m64 *)(ptrC+1), t3); t4 = _mm_load_ss(ptrD); - t4 = _mm_loadh_pi(t4,(__m64 *)(ptrD+1)); - t4 = _mm_sub_ps(t4,t10); - _mm_store_ss(ptrD,t4); - _mm_storeh_pi((__m64 *)(ptrD+1),t4); + t4 = _mm_loadh_pi(t4, (__m64 *)(ptrD+1)); + t4 = _mm_sub_ps(t4, t10); + _mm_store_ss(ptrD, t4); + _mm_storeh_pi((__m64 *)(ptrD+1), t4); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_4ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD, \ - _x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ - __m128 _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10;\ - __m128 _t11,_t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19;\ - __m128 _t20,_t21,_t22,_t23,_t24,_t25;\ - _t13 = _mm_unpackhi_ps(_x1,_y1);\ - _x1 = _mm_unpacklo_ps(_x1,_y1);\ - _t14 = _mm_unpackhi_ps(_z1,_x2);\ - _z1 = _mm_unpacklo_ps(_z1,_x2);\ - _t15 = _mm_unpackhi_ps(_y2,_z2);\ - _y2 = _mm_unpacklo_ps(_y2,_z2);\ - _t16 = _mm_unpackhi_ps(_x3,_y3);\ - _x3 = _mm_unpacklo_ps(_x3,_y3);\ - _t17 = _mm_permute_ps(_z3,_MM_SHUFFLE(0,0,0,1));\ - _t18 = _mm_movehl_ps(_z3,_z3);\ - _t19 = _mm_permute_ps(_t18,_MM_SHUFFLE(0,0,0,1));\ - _t20 = _mm_movelh_ps(_x1,_z1);\ - _t21 = _mm_movehl_ps(_z1,_x1);\ - _t22 = _mm_movelh_ps(_t13,_t14);\ - _t14 = _mm_movehl_ps(_t14,_t13);\ - _t23 = _mm_movelh_ps(_y2,_x3);\ - _t24 = _mm_movehl_ps(_x3,_y2);\ - _t25 = _mm_movelh_ps(_t15,_t16);\ - _t16 = _mm_movehl_ps(_t16,_t15);\ - _t1 = _mm_loadu_ps(ptrA);\ - _t2 = _mm_loadu_ps(ptrA+4);\ - _t3 = _mm_load_ss(ptrA+8);\ - _t1 = _mm_sub_ps(_t1,_t20);\ - _t2 = _mm_sub_ps(_t2,_t23);\ - _t3 = _mm_sub_ss(_t3,_z3);\ - _mm_storeu_ps(ptrA,_t1);\ - _mm_storeu_ps(ptrA+4,_t2);\ - _mm_store_ss(ptrA+8,_t3);\ - _t4 = _mm_loadu_ps(ptrB);\ - _t5 = _mm_loadu_ps(ptrB+4);\ - _t6 = _mm_load_ss(ptrB+8);\ - _t4 = _mm_sub_ps(_t4,_t21);\ - _t5 = _mm_sub_ps(_t5,_t24);\ - _t6 = _mm_sub_ss(_t6,_t17);\ - _mm_storeu_ps(ptrB,_t4);\ - _mm_storeu_ps(ptrB+4,_t5);\ - _mm_store_ss(ptrB+8,_t6);\ - _t7 = _mm_loadu_ps(ptrC);\ - _t8 = _mm_loadu_ps(ptrC+4);\ - _t9 = _mm_load_ss(ptrC+8);\ - _t7 = _mm_sub_ps(_t7,_t22);\ - _t8 = _mm_sub_ps(_t8,_t25);\ - _t9 = _mm_sub_ss(_t9,_t18);\ - _mm_storeu_ps(ptrC,_t7);\ - _mm_storeu_ps(ptrC+4,_t8);\ - _mm_store_ss(ptrC+8,_t9);\ - _t10 = _mm_loadu_ps(ptrD);\ - _t11 = _mm_loadu_ps(ptrD+4);\ - _t12 = _mm_load_ss(ptrD+8);\ - _t10 = _mm_sub_ps(_t10,_t14);\ - _t11 = _mm_sub_ps(_t11,_t16);\ - _t12 = _mm_sub_ss(_t12,_t19);\ - _mm_storeu_ps(ptrD,_t10);\ - _mm_storeu_ps(ptrD+4,_t11);\ - _mm_store_ss(ptrD+8,_t12);\ -} +#define gmx_mm_decrement_3rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \ + __m128 _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19; \ + __m128 _t20, _t21, _t22, _t23, _t24, _t25; \ + _t13 = _mm_unpackhi_ps(_x1, _y1); \ + _x1 = _mm_unpacklo_ps(_x1, _y1); \ + _t14 = _mm_unpackhi_ps(_z1, _x2); \ + _z1 = _mm_unpacklo_ps(_z1, _x2); \ + _t15 = _mm_unpackhi_ps(_y2, _z2); \ + _y2 = _mm_unpacklo_ps(_y2, _z2); \ + _t16 = _mm_unpackhi_ps(_x3, _y3); \ + _x3 = _mm_unpacklo_ps(_x3, _y3); \ + _t17 = _mm_permute_ps(_z3, _MM_SHUFFLE(0, 0, 0, 1)); \ + _t18 = _mm_movehl_ps(_z3, _z3); \ + _t19 = _mm_permute_ps(_t18, _MM_SHUFFLE(0, 0, 0, 1)); \ + _t20 = _mm_movelh_ps(_x1, _z1); \ + _t21 = _mm_movehl_ps(_z1, _x1); \ + _t22 = _mm_movelh_ps(_t13, _t14); \ + _t14 = _mm_movehl_ps(_t14, _t13); \ + _t23 = _mm_movelh_ps(_y2, _x3); \ + _t24 = _mm_movehl_ps(_x3, _y2); \ + _t25 = _mm_movelh_ps(_t15, _t16); \ + _t16 = _mm_movehl_ps(_t16, _t15); \ + _t1 = _mm_loadu_ps(ptrA); \ + _t2 = _mm_loadu_ps(ptrA+4); \ + _t3 = _mm_load_ss(ptrA+8); \ + _t1 = _mm_sub_ps(_t1, _t20); \ + _t2 = _mm_sub_ps(_t2, _t23); \ + _t3 = _mm_sub_ss(_t3, _z3); \ + _mm_storeu_ps(ptrA, _t1); \ + _mm_storeu_ps(ptrA+4, _t2); \ + _mm_store_ss(ptrA+8, _t3); \ + _t4 = _mm_loadu_ps(ptrB); \ + _t5 = _mm_loadu_ps(ptrB+4); \ + _t6 = _mm_load_ss(ptrB+8); \ + _t4 = _mm_sub_ps(_t4, _t21); \ + _t5 = _mm_sub_ps(_t5, _t24); \ + _t6 = _mm_sub_ss(_t6, _t17); \ + _mm_storeu_ps(ptrB, _t4); \ + _mm_storeu_ps(ptrB+4, _t5); \ + _mm_store_ss(ptrB+8, _t6); \ + _t7 = _mm_loadu_ps(ptrC); \ + _t8 = _mm_loadu_ps(ptrC+4); \ + _t9 = _mm_load_ss(ptrC+8); \ + _t7 = _mm_sub_ps(_t7, _t22); \ + _t8 = _mm_sub_ps(_t8, _t25); \ + _t9 = _mm_sub_ss(_t9, _t18); \ + _mm_storeu_ps(ptrC, _t7); \ + _mm_storeu_ps(ptrC+4, _t8); \ + _mm_store_ss(ptrC+8, _t9); \ + _t10 = _mm_loadu_ps(ptrD); \ + _t11 = _mm_loadu_ps(ptrD+4); \ + _t12 = _mm_load_ss(ptrD+8); \ + _t10 = _mm_sub_ps(_t10, _t14); \ + _t11 = _mm_sub_ps(_t11, _t16); \ + _t12 = _mm_sub_ss(_t12, _t19); \ + _mm_storeu_ps(ptrD, _t10); \ + _mm_storeu_ps(ptrD+4, _t11); \ + _mm_store_ss(ptrD+8, _t12); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -421,136 +421,136 @@ gmx_mm_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_re __m128 x2, __m128 y2, __m128 z2, __m128 x3, __m128 y3, __m128 z3) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; - __m128 t11,t12,t13,t14,t15,t16,t17,t18,t19; - __m128 t20,t21,t22,t23,t24,t25; - t13 = _mm_unpackhi_ps(x1,y1); - x1 = _mm_unpacklo_ps(x1,y1); - t14 = _mm_unpackhi_ps(z1,x2); - z1 = _mm_unpacklo_ps(z1,x2); - t15 = _mm_unpackhi_ps(y2,z2); - y2 = _mm_unpacklo_ps(y2,z2); - t16 = _mm_unpackhi_ps(x3,y3); - x3 = _mm_unpacklo_ps(x3,y3); - t17 = _mm_permute_ps(z3,_MM_SHUFFLE(0,0,0,1)); - t18 = _mm_movehl_ps(z3,z3); - t19 = _mm_permute_ps(t18,_MM_SHUFFLE(0,0,0,1)); - t20 = _mm_movelh_ps(x1,z1); - t21 = _mm_movehl_ps(z1,x1); - t22 = _mm_movelh_ps(t13,t14); - t14 = _mm_movehl_ps(t14,t13); - t23 = _mm_movelh_ps(y2,x3); - t24 = _mm_movehl_ps(x3,y2); - t25 = _mm_movelh_ps(t15,t16); - t16 = _mm_movehl_ps(t16,t15); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; + __m128 t11, t12, t13, t14, t15, t16, t17, t18, t19; + __m128 t20, t21, t22, t23, t24, t25; + t13 = _mm_unpackhi_ps(x1, y1); + x1 = _mm_unpacklo_ps(x1, y1); + t14 = _mm_unpackhi_ps(z1, x2); + z1 = _mm_unpacklo_ps(z1, x2); + t15 = _mm_unpackhi_ps(y2, z2); + y2 = _mm_unpacklo_ps(y2, z2); + t16 = _mm_unpackhi_ps(x3, y3); + x3 = _mm_unpacklo_ps(x3, y3); + t17 = _mm_permute_ps(z3, _MM_SHUFFLE(0, 0, 0, 1)); + t18 = _mm_movehl_ps(z3, z3); + t19 = _mm_permute_ps(t18, _MM_SHUFFLE(0, 0, 0, 1)); + t20 = _mm_movelh_ps(x1, z1); + t21 = _mm_movehl_ps(z1, x1); + t22 = _mm_movelh_ps(t13, t14); + t14 = _mm_movehl_ps(t14, t13); + t23 = _mm_movelh_ps(y2, x3); + t24 = _mm_movehl_ps(x3, y2); + t25 = _mm_movelh_ps(t15, t16); + t16 = _mm_movehl_ps(t16, t15); t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrA+4); t3 = _mm_load_ss(ptrA+8); - t1 = _mm_sub_ps(t1,t20); - t2 = _mm_sub_ps(t2,t23); - t3 = _mm_sub_ss(t3,z3); - _mm_storeu_ps(ptrA,t1); - _mm_storeu_ps(ptrA+4,t2); - _mm_store_ss(ptrA+8,t3); + t1 = _mm_sub_ps(t1, t20); + t2 = _mm_sub_ps(t2, t23); + t3 = _mm_sub_ss(t3, z3); + _mm_storeu_ps(ptrA, t1); + _mm_storeu_ps(ptrA+4, t2); + _mm_store_ss(ptrA+8, t3); t4 = _mm_loadu_ps(ptrB); t5 = _mm_loadu_ps(ptrB+4); t6 = _mm_load_ss(ptrB+8); - t4 = _mm_sub_ps(t4,t21); - t5 = _mm_sub_ps(t5,t24); - t6 = _mm_sub_ss(t6,t17); - _mm_storeu_ps(ptrB,t4); - _mm_storeu_ps(ptrB+4,t5); - _mm_store_ss(ptrB+8,t6); + t4 = _mm_sub_ps(t4, t21); + t5 = _mm_sub_ps(t5, t24); + t6 = _mm_sub_ss(t6, t17); + _mm_storeu_ps(ptrB, t4); + _mm_storeu_ps(ptrB+4, t5); + _mm_store_ss(ptrB+8, t6); t7 = _mm_loadu_ps(ptrC); t8 = _mm_loadu_ps(ptrC+4); t9 = _mm_load_ss(ptrC+8); - t7 = _mm_sub_ps(t7,t22); - t8 = _mm_sub_ps(t8,t25); - t9 = _mm_sub_ss(t9,t18); - _mm_storeu_ps(ptrC,t7); - _mm_storeu_ps(ptrC+4,t8); - _mm_store_ss(ptrC+8,t9); + t7 = _mm_sub_ps(t7, t22); + t8 = _mm_sub_ps(t8, t25); + t9 = _mm_sub_ss(t9, t18); + _mm_storeu_ps(ptrC, t7); + _mm_storeu_ps(ptrC+4, t8); + _mm_store_ss(ptrC+8, t9); t10 = _mm_loadu_ps(ptrD); t11 = _mm_loadu_ps(ptrD+4); t12 = _mm_load_ss(ptrD+8); - t10 = _mm_sub_ps(t10,t14); - t11 = _mm_sub_ps(t11,t16); - t12 = _mm_sub_ss(t12,t19); - _mm_storeu_ps(ptrD,t10); - _mm_storeu_ps(ptrD+4,t11); - _mm_store_ss(ptrD+8,t12); + t10 = _mm_sub_ps(t10, t14); + t11 = _mm_sub_ps(t11, t16); + t12 = _mm_sub_ss(t12, t19); + _mm_storeu_ps(ptrD, t10); + _mm_storeu_ps(ptrD+4, t11); + _mm_store_ss(ptrD+8, t12); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_4ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD, \ - _x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ - __m128 _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11;\ - __m128 _t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19,_t20,_t21,_t22;\ - __m128 _t23,_t24;\ - _t13 = _mm_unpackhi_ps(_x1,_y1);\ - _x1 = _mm_unpacklo_ps(_x1,_y1);\ - _t14 = _mm_unpackhi_ps(_z1,_x2);\ - _z1 = _mm_unpacklo_ps(_z1,_x2);\ - _t15 = _mm_unpackhi_ps(_y2,_z2);\ - _y2 = _mm_unpacklo_ps(_y2,_z2);\ - _t16 = _mm_unpackhi_ps(_x3,_y3);\ - _x3 = _mm_unpacklo_ps(_x3,_y3);\ - _t17 = _mm_unpackhi_ps(_z3,_x4);\ - _z3 = _mm_unpacklo_ps(_z3,_x4);\ - _t18 = _mm_unpackhi_ps(_y4,_z4);\ - _y4 = _mm_unpacklo_ps(_y4,_z4);\ - _t19 = _mm_movelh_ps(_x1,_z1);\ - _z1 = _mm_movehl_ps(_z1,_x1);\ - _t20 = _mm_movelh_ps(_t13,_t14);\ - _t14 = _mm_movehl_ps(_t14,_t13);\ - _t21 = _mm_movelh_ps(_y2,_x3);\ - _x3 = _mm_movehl_ps(_x3,_y2);\ - _t22 = _mm_movelh_ps(_t15,_t16);\ - _t16 = _mm_movehl_ps(_t16,_t15);\ - _t23 = _mm_movelh_ps(_z3,_y4);\ - _y4 = _mm_movehl_ps(_y4,_z3);\ - _t24 = _mm_movelh_ps(_t17,_t18);\ - _t18 = _mm_movehl_ps(_t18,_t17);\ - _t1 = _mm_loadu_ps(ptrA);\ - _t2 = _mm_loadu_ps(ptrA+4);\ - _t3 = _mm_loadu_ps(ptrA+8);\ - _t1 = _mm_sub_ps(_t1,_t19);\ - _t2 = _mm_sub_ps(_t2,_t21);\ - _t3 = _mm_sub_ps(_t3,_t23);\ - _mm_storeu_ps(ptrA,_t1);\ - _mm_storeu_ps(ptrA+4,_t2);\ - _mm_storeu_ps(ptrA+8,_t3);\ - _t4 = _mm_loadu_ps(ptrB);\ - _t5 = _mm_loadu_ps(ptrB+4);\ - _t6 = _mm_loadu_ps(ptrB+8);\ - _t4 = _mm_sub_ps(_t4,_z1);\ - _t5 = _mm_sub_ps(_t5,_x3);\ - _t6 = _mm_sub_ps(_t6,_y4);\ - _mm_storeu_ps(ptrB,_t4);\ - _mm_storeu_ps(ptrB+4,_t5);\ - _mm_storeu_ps(ptrB+8,_t6);\ - _t7 = _mm_loadu_ps(ptrC);\ - _t8 = _mm_loadu_ps(ptrC+4);\ - _t9 = _mm_loadu_ps(ptrC+8);\ - _t7 = _mm_sub_ps(_t7,_t20);\ - _t8 = _mm_sub_ps(_t8,_t22);\ - _t9 = _mm_sub_ps(_t9,_t24);\ - _mm_storeu_ps(ptrC,_t7);\ - _mm_storeu_ps(ptrC+4,_t8);\ - _mm_storeu_ps(ptrC+8,_t9);\ - _t10 = _mm_loadu_ps(ptrD);\ - _t11 = _mm_loadu_ps(ptrD+4);\ - _t12 = _mm_loadu_ps(ptrD+8);\ - _t10 = _mm_sub_ps(_t10,_t14);\ - _t11 = _mm_sub_ps(_t11,_t16);\ - _t12 = _mm_sub_ps(_t12,_t18);\ - _mm_storeu_ps(ptrD,_t10);\ - _mm_storeu_ps(ptrD+4,_t11);\ - _mm_storeu_ps(ptrD+8,_t12);\ -} +#define gmx_mm_decrement_4rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11; \ + __m128 _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20, _t21, _t22; \ + __m128 _t23, _t24; \ + _t13 = _mm_unpackhi_ps(_x1, _y1); \ + _x1 = _mm_unpacklo_ps(_x1, _y1); \ + _t14 = _mm_unpackhi_ps(_z1, _x2); \ + _z1 = _mm_unpacklo_ps(_z1, _x2); \ + _t15 = _mm_unpackhi_ps(_y2, _z2); \ + _y2 = _mm_unpacklo_ps(_y2, _z2); \ + _t16 = _mm_unpackhi_ps(_x3, _y3); \ + _x3 = _mm_unpacklo_ps(_x3, _y3); \ + _t17 = _mm_unpackhi_ps(_z3, _x4); \ + _z3 = _mm_unpacklo_ps(_z3, _x4); \ + _t18 = _mm_unpackhi_ps(_y4, _z4); \ + _y4 = _mm_unpacklo_ps(_y4, _z4); \ + _t19 = _mm_movelh_ps(_x1, _z1); \ + _z1 = _mm_movehl_ps(_z1, _x1); \ + _t20 = _mm_movelh_ps(_t13, _t14); \ + _t14 = _mm_movehl_ps(_t14, _t13); \ + _t21 = _mm_movelh_ps(_y2, _x3); \ + _x3 = _mm_movehl_ps(_x3, _y2); \ + _t22 = _mm_movelh_ps(_t15, _t16); \ + _t16 = _mm_movehl_ps(_t16, _t15); \ + _t23 = _mm_movelh_ps(_z3, _y4); \ + _y4 = _mm_movehl_ps(_y4, _z3); \ + _t24 = _mm_movelh_ps(_t17, _t18); \ + _t18 = _mm_movehl_ps(_t18, _t17); \ + _t1 = _mm_loadu_ps(ptrA); \ + _t2 = _mm_loadu_ps(ptrA+4); \ + _t3 = _mm_loadu_ps(ptrA+8); \ + _t1 = _mm_sub_ps(_t1, _t19); \ + _t2 = _mm_sub_ps(_t2, _t21); \ + _t3 = _mm_sub_ps(_t3, _t23); \ + _mm_storeu_ps(ptrA, _t1); \ + _mm_storeu_ps(ptrA+4, _t2); \ + _mm_storeu_ps(ptrA+8, _t3); \ + _t4 = _mm_loadu_ps(ptrB); \ + _t5 = _mm_loadu_ps(ptrB+4); \ + _t6 = _mm_loadu_ps(ptrB+8); \ + _t4 = _mm_sub_ps(_t4, _z1); \ + _t5 = _mm_sub_ps(_t5, _x3); \ + _t6 = _mm_sub_ps(_t6, _y4); \ + _mm_storeu_ps(ptrB, _t4); \ + _mm_storeu_ps(ptrB+4, _t5); \ + _mm_storeu_ps(ptrB+8, _t6); \ + _t7 = _mm_loadu_ps(ptrC); \ + _t8 = _mm_loadu_ps(ptrC+4); \ + _t9 = _mm_loadu_ps(ptrC+8); \ + _t7 = _mm_sub_ps(_t7, _t20); \ + _t8 = _mm_sub_ps(_t8, _t22); \ + _t9 = _mm_sub_ps(_t9, _t24); \ + _mm_storeu_ps(ptrC, _t7); \ + _mm_storeu_ps(ptrC+4, _t8); \ + _mm_storeu_ps(ptrC+8, _t9); \ + _t10 = _mm_loadu_ps(ptrD); \ + _t11 = _mm_loadu_ps(ptrD+4); \ + _t12 = _mm_loadu_ps(ptrD+8); \ + _t10 = _mm_sub_ps(_t10, _t14); \ + _t11 = _mm_sub_ps(_t11, _t16); \ + _t12 = _mm_sub_ps(_t12, _t18); \ + _mm_storeu_ps(ptrD, _t10); \ + _mm_storeu_ps(ptrD+4, _t11); \ + _mm_storeu_ps(ptrD+8, _t12); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -561,69 +561,69 @@ gmx_mm_decrement_4rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_re __m128 x3, __m128 y3, __m128 z3, __m128 x4, __m128 y4, __m128 z4) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; - __m128 t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22; - __m128 t23,t24; - t13 = _mm_unpackhi_ps(x1,y1); - x1 = _mm_unpacklo_ps(x1,y1); - t14 = _mm_unpackhi_ps(z1,x2); - z1 = _mm_unpacklo_ps(z1,x2); - t15 = _mm_unpackhi_ps(y2,z2); - y2 = _mm_unpacklo_ps(y2,z2); - t16 = _mm_unpackhi_ps(x3,y3); - x3 = _mm_unpacklo_ps(x3,y3); - t17 = _mm_unpackhi_ps(z3,x4); - z3 = _mm_unpacklo_ps(z3,x4); - t18 = _mm_unpackhi_ps(y4,z4); - y4 = _mm_unpacklo_ps(y4,z4); - t19 = _mm_movelh_ps(x1,z1); - z1 = _mm_movehl_ps(z1,x1); - t20 = _mm_movelh_ps(t13,t14); - t14 = _mm_movehl_ps(t14,t13); - t21 = _mm_movelh_ps(y2,x3); - x3 = _mm_movehl_ps(x3,y2); - t22 = _mm_movelh_ps(t15,t16); - t16 = _mm_movehl_ps(t16,t15); - t23 = _mm_movelh_ps(z3,y4); - y4 = _mm_movehl_ps(y4,z3); - t24 = _mm_movelh_ps(t17,t18); - t18 = _mm_movehl_ps(t18,t17); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; + __m128 t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22; + __m128 t23, t24; + t13 = _mm_unpackhi_ps(x1, y1); + x1 = _mm_unpacklo_ps(x1, y1); + t14 = _mm_unpackhi_ps(z1, x2); + z1 = _mm_unpacklo_ps(z1, x2); + t15 = _mm_unpackhi_ps(y2, z2); + y2 = _mm_unpacklo_ps(y2, z2); + t16 = _mm_unpackhi_ps(x3, y3); + x3 = _mm_unpacklo_ps(x3, y3); + t17 = _mm_unpackhi_ps(z3, x4); + z3 = _mm_unpacklo_ps(z3, x4); + t18 = _mm_unpackhi_ps(y4, z4); + y4 = _mm_unpacklo_ps(y4, z4); + t19 = _mm_movelh_ps(x1, z1); + z1 = _mm_movehl_ps(z1, x1); + t20 = _mm_movelh_ps(t13, t14); + t14 = _mm_movehl_ps(t14, t13); + t21 = _mm_movelh_ps(y2, x3); + x3 = _mm_movehl_ps(x3, y2); + t22 = _mm_movelh_ps(t15, t16); + t16 = _mm_movehl_ps(t16, t15); + t23 = _mm_movelh_ps(z3, y4); + y4 = _mm_movehl_ps(y4, z3); + t24 = _mm_movelh_ps(t17, t18); + t18 = _mm_movehl_ps(t18, t17); t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrA+4); t3 = _mm_loadu_ps(ptrA+8); - t1 = _mm_sub_ps(t1,t19); - t2 = _mm_sub_ps(t2,t21); - t3 = _mm_sub_ps(t3,t23); - _mm_storeu_ps(ptrA,t1); - _mm_storeu_ps(ptrA+4,t2); - _mm_storeu_ps(ptrA+8,t3); + t1 = _mm_sub_ps(t1, t19); + t2 = _mm_sub_ps(t2, t21); + t3 = _mm_sub_ps(t3, t23); + _mm_storeu_ps(ptrA, t1); + _mm_storeu_ps(ptrA+4, t2); + _mm_storeu_ps(ptrA+8, t3); t4 = _mm_loadu_ps(ptrB); t5 = _mm_loadu_ps(ptrB+4); t6 = _mm_loadu_ps(ptrB+8); - t4 = _mm_sub_ps(t4,z1); - t5 = _mm_sub_ps(t5,x3); - t6 = _mm_sub_ps(t6,y4); - _mm_storeu_ps(ptrB,t4); - _mm_storeu_ps(ptrB+4,t5); - _mm_storeu_ps(ptrB+8,t6); + t4 = _mm_sub_ps(t4, z1); + t5 = _mm_sub_ps(t5, x3); + t6 = _mm_sub_ps(t6, y4); + _mm_storeu_ps(ptrB, t4); + _mm_storeu_ps(ptrB+4, t5); + _mm_storeu_ps(ptrB+8, t6); t7 = _mm_loadu_ps(ptrC); t8 = _mm_loadu_ps(ptrC+4); t9 = _mm_loadu_ps(ptrC+8); - t7 = _mm_sub_ps(t7,t20); - t8 = _mm_sub_ps(t8,t22); - t9 = _mm_sub_ps(t9,t24); - _mm_storeu_ps(ptrC,t7); - _mm_storeu_ps(ptrC+4,t8); - _mm_storeu_ps(ptrC+8,t9); + t7 = _mm_sub_ps(t7, t20); + t8 = _mm_sub_ps(t8, t22); + t9 = _mm_sub_ps(t9, t24); + _mm_storeu_ps(ptrC, t7); + _mm_storeu_ps(ptrC+4, t8); + _mm_storeu_ps(ptrC+8, t9); t10 = _mm_loadu_ps(ptrD); t11 = _mm_loadu_ps(ptrD+4); t12 = _mm_loadu_ps(ptrD+8); - t10 = _mm_sub_ps(t10,t14); - t11 = _mm_sub_ps(t11,t16); - t12 = _mm_sub_ps(t12,t18); - _mm_storeu_ps(ptrD,t10); - _mm_storeu_ps(ptrD+4,t11); - _mm_storeu_ps(ptrD+8,t12); + t10 = _mm_sub_ps(t10, t14); + t11 = _mm_sub_ps(t11, t16); + t12 = _mm_sub_ps(t12, t18); + _mm_storeu_ps(ptrD, t10); + _mm_storeu_ps(ptrD+4, t11); + _mm_storeu_ps(ptrD+8, t12); } #endif @@ -632,57 +632,57 @@ gmx_mm_update_iforce_1atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t2,t3; + __m128 t2, t3; - fix1 = _mm_hadd_ps(fix1,fix1); - fiy1 = _mm_hadd_ps(fiy1,fiz1); + fix1 = _mm_hadd_ps(fix1, fix1); + fiy1 = _mm_hadd_ps(fiy1, fiz1); - fix1 = _mm_hadd_ps(fix1,fiy1); /* fiz1 fiy1 fix1 fix1 */ + fix1 = _mm_hadd_ps(fix1, fiy1); /* fiz1 fiy1 fix1 fix1 */ t2 = _mm_load_ss(fptr); - t2 = _mm_loadh_pi(t2,(__m64 *)(fptr+1)); + t2 = _mm_loadh_pi(t2, (__m64 *)(fptr+1)); t3 = _mm_load_ss(fshiftptr); - t3 = _mm_loadh_pi(t3,(__m64 *)(fshiftptr+1)); + t3 = _mm_loadh_pi(t3, (__m64 *)(fshiftptr+1)); - t2 = _mm_add_ps(t2,fix1); - t3 = _mm_add_ps(t3,fix1); + t2 = _mm_add_ps(t2, fix1); + t3 = _mm_add_ps(t3, fix1); - _mm_store_ss(fptr,t2); - _mm_storeh_pi((__m64 *)(fptr+1),t2); - _mm_store_ss(fshiftptr,t3); - _mm_storeh_pi((__m64 *)(fshiftptr+1),t3); + _mm_store_ss(fptr, t2); + _mm_storeh_pi((__m64 *)(fptr+1), t2); + _mm_store_ss(fshiftptr, t3); + _mm_storeh_pi((__m64 *)(fshiftptr+1), t3); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \ - fptr,fshiftptr) \ -{\ - __m128 _t1,_t2,_t3,_t4;\ +#define gmx_mm_update_iforce_3atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \ + fptr, fshiftptr) \ + { \ + __m128 _t1, _t2, _t3, _t4; \ \ - fix1 = _mm_hadd_ps(fix1,fiy1);\ - fiz1 = _mm_hadd_ps(fiz1,fix2);\ - fiy2 = _mm_hadd_ps(fiy2,fiz2);\ - fix3 = _mm_hadd_ps(fix3,fiy3);\ - fiz3 = _mm_hadd_ps(fiz3,fiz3);\ - fix1 = _mm_hadd_ps(fix1,fiz1);\ - fiy2 = _mm_hadd_ps(fiy2,fix3);\ - fiz3 = _mm_hadd_ps(fiz3,fiz3);\ - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) ));\ - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4)));\ - _mm_store_ss (fptr+8,_mm_add_ss(fiz3,_mm_load_ss(fptr+8) ));\ - _t4 = _mm_load_ss(fshiftptr+2);\ - _t4 = _mm_loadh_pi(_t4,(__m64 *)(fshiftptr));\ - _t1 = _mm_shuffle_ps(fiz3,fix1,_MM_SHUFFLE(1,0,0,0));\ - _t2 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(3,2,2,2));\ - _t3 = _mm_shuffle_ps(fiy2,fix1,_MM_SHUFFLE(3,3,0,1));\ - _t3 = _mm_permute_ps(_t3 ,_MM_SHUFFLE(1,2,0,0));\ - _t1 = _mm_add_ps(_t1,_t2);\ - _t3 = _mm_add_ps(_t3,_t4);\ - _t1 = _mm_add_ps(_t1,_t3);\ - _mm_store_ss(fshiftptr+2,_t1);\ - _mm_storeh_pi((__m64 *)(fshiftptr),_t1);\ -} + fix1 = _mm_hadd_ps(fix1, fiy1); \ + fiz1 = _mm_hadd_ps(fiz1, fix2); \ + fiy2 = _mm_hadd_ps(fiy2, fiz2); \ + fix3 = _mm_hadd_ps(fix3, fiy3); \ + fiz3 = _mm_hadd_ps(fiz3, fiz3); \ + fix1 = _mm_hadd_ps(fix1, fiz1); \ + fiy2 = _mm_hadd_ps(fiy2, fix3); \ + fiz3 = _mm_hadd_ps(fiz3, fiz3); \ + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \ + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \ + _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) )); \ + _t4 = _mm_load_ss(fshiftptr+2); \ + _t4 = _mm_loadh_pi(_t4, (__m64 *)(fshiftptr)); \ + _t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); \ + _t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); \ + _t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); \ + _t3 = _mm_permute_ps(_t3, _MM_SHUFFLE(1, 2, 0, 0)); \ + _t1 = _mm_add_ps(_t1, _t2); \ + _t3 = _mm_add_ps(_t3, _t4); \ + _t1 = _mm_add_ps(_t1, _t3); \ + _mm_store_ss(fshiftptr+2, _t1); \ + _mm_storeh_pi((__m64 *)(fshiftptr), _t1); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -692,72 +692,72 @@ gmx_mm_update_iforce_3atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; - fix1 = _mm_hadd_ps(fix1,fiy1); - fiz1 = _mm_hadd_ps(fiz1,fix2); - fiy2 = _mm_hadd_ps(fiy2,fiz2); - fix3 = _mm_hadd_ps(fix3,fiy3); - fiz3 = _mm_hadd_ps(fiz3,fiz3); + fix1 = _mm_hadd_ps(fix1, fiy1); + fiz1 = _mm_hadd_ps(fiz1, fix2); + fiy2 = _mm_hadd_ps(fiy2, fiz2); + fix3 = _mm_hadd_ps(fix3, fiy3); + fiz3 = _mm_hadd_ps(fiz3, fiz3); - fix1 = _mm_hadd_ps(fix1,fiz1); /* fix2 fiz1 fiy1 fix1 */ - fiy2 = _mm_hadd_ps(fiy2,fix3); /* fiy3 fix3 fiz2 fiy2 */ - fiz3 = _mm_hadd_ps(fiz3,fiz3); /* - - - fiz3 */ + fix1 = _mm_hadd_ps(fix1, fiz1); /* fix2 fiz1 fiy1 fix1 */ + fiy2 = _mm_hadd_ps(fiy2, fix3); /* fiy3 fix3 fiz2 fiy2 */ + fiz3 = _mm_hadd_ps(fiz3, fiz3); /* - - - fiz3 */ - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) )); - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4))); - _mm_store_ss (fptr+8,_mm_add_ss(fiz3,_mm_load_ss(fptr+8) )); + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); + _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) )); t4 = _mm_load_ss(fshiftptr+2); - t4 = _mm_loadh_pi(t4,(__m64 *)(fshiftptr)); + t4 = _mm_loadh_pi(t4, (__m64 *)(fshiftptr)); - t1 = _mm_shuffle_ps(fiz3,fix1,_MM_SHUFFLE(1,0,0,0)); /* fiy1 fix1 - fiz3 */ - t2 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(3,2,2,2)); /* fiy3 fix3 - fiz1 */ - t3 = _mm_shuffle_ps(fiy2,fix1,_MM_SHUFFLE(3,3,0,1)); /* fix2 fix2 fiy2 fiz2 */ - t3 = _mm_permute_ps(t3 ,_MM_SHUFFLE(1,2,0,0)); /* fiy2 fix2 - fiz2 */ + t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); /* fiy1 fix1 - fiz3 */ + t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); /* fiy3 fix3 - fiz1 */ + t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); /* fix2 fix2 fiy2 fiz2 */ + t3 = _mm_permute_ps(t3, _MM_SHUFFLE(1, 2, 0, 0)); /* fiy2 fix2 - fiz2 */ - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ps(t3,t4); - t1 = _mm_add_ps(t1,t3); /* y x - z */ + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ps(t3, t4); + t1 = _mm_add_ps(t1, t3); /* y x - z */ - _mm_store_ss(fshiftptr+2,t1); - _mm_storeh_pi((__m64 *)(fshiftptr),t1); + _mm_store_ss(fshiftptr+2, t1); + _mm_storeh_pi((__m64 *)(fshiftptr), t1); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_4atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \ - fptr,fshiftptr) \ -{\ - __m128 _t1,_t2,_t3,_t4,_t5;\ +#define gmx_mm_update_iforce_4atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \ + fptr, fshiftptr) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5; \ \ - fix1 = _mm_hadd_ps(fix1,fiy1);\ - fiz1 = _mm_hadd_ps(fiz1,fix2);\ - fiy2 = _mm_hadd_ps(fiy2,fiz2);\ - fix3 = _mm_hadd_ps(fix3,fiy3);\ - fiz3 = _mm_hadd_ps(fiz3,fix4);\ - fiy4 = _mm_hadd_ps(fiy4,fiz4);\ - fix1 = _mm_hadd_ps(fix1,fiz1);\ - fiy2 = _mm_hadd_ps(fiy2,fix3);\ - fiz3 = _mm_hadd_ps(fiz3,fiy4);\ - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) ));\ - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4)));\ - _mm_storeu_ps(fptr+8,_mm_add_ps(fiz3,_mm_loadu_ps(fptr+8)));\ - _t5 = _mm_load_ss(fshiftptr+2);\ - _t5 = _mm_loadh_pi(_t5,(__m64 *)(fshiftptr));\ - _t1 = _mm_permute_ps(fix1,_MM_SHUFFLE(1,0,2,2));\ - _t2 = _mm_permute_ps(fiy2,_MM_SHUFFLE(3,2,1,1));\ - _t3 = _mm_permute_ps(fiz3,_MM_SHUFFLE(2,1,0,0));\ - _t4 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(0,0,3,3));\ - _t4 = _mm_shuffle_ps(fiz3,_t4 ,_MM_SHUFFLE(2,0,3,3));\ - _t1 = _mm_add_ps(_t1,_t2);\ - _t3 = _mm_add_ps(_t3,_t4);\ - _t1 = _mm_add_ps(_t1,_t3);\ - _t5 = _mm_add_ps(_t5,_t1);\ - _mm_store_ss(fshiftptr+2,_t5);\ - _mm_storeh_pi((__m64 *)(fshiftptr),_t5);\ -} + fix1 = _mm_hadd_ps(fix1, fiy1); \ + fiz1 = _mm_hadd_ps(fiz1, fix2); \ + fiy2 = _mm_hadd_ps(fiy2, fiz2); \ + fix3 = _mm_hadd_ps(fix3, fiy3); \ + fiz3 = _mm_hadd_ps(fiz3, fix4); \ + fiy4 = _mm_hadd_ps(fiy4, fiz4); \ + fix1 = _mm_hadd_ps(fix1, fiz1); \ + fiy2 = _mm_hadd_ps(fiy2, fix3); \ + fiz3 = _mm_hadd_ps(fiz3, fiy4); \ + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \ + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \ + _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8))); \ + _t5 = _mm_load_ss(fshiftptr+2); \ + _t5 = _mm_loadh_pi(_t5, (__m64 *)(fshiftptr)); \ + _t1 = _mm_permute_ps(fix1, _MM_SHUFFLE(1, 0, 2, 2)); \ + _t2 = _mm_permute_ps(fiy2, _MM_SHUFFLE(3, 2, 1, 1)); \ + _t3 = _mm_permute_ps(fiz3, _MM_SHUFFLE(2, 1, 0, 0)); \ + _t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3)); \ + _t4 = _mm_shuffle_ps(fiz3, _t4, _MM_SHUFFLE(2, 0, 3, 3)); \ + _t1 = _mm_add_ps(_t1, _t2); \ + _t3 = _mm_add_ps(_t3, _t4); \ + _t1 = _mm_add_ps(_t1, _t3); \ + _t5 = _mm_add_ps(_t5, _t1); \ + _mm_store_ss(fshiftptr+2, _t5); \ + _mm_storeh_pi((__m64 *)(fshiftptr), _t5); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -768,39 +768,39 @@ gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t1,t2,t3,t4,t5; + __m128 t1, t2, t3, t4, t5; - fix1 = _mm_hadd_ps(fix1,fiy1); - fiz1 = _mm_hadd_ps(fiz1,fix2); - fiy2 = _mm_hadd_ps(fiy2,fiz2); - fix3 = _mm_hadd_ps(fix3,fiy3); - fiz3 = _mm_hadd_ps(fiz3,fix4); - fiy4 = _mm_hadd_ps(fiy4,fiz4); + fix1 = _mm_hadd_ps(fix1, fiy1); + fiz1 = _mm_hadd_ps(fiz1, fix2); + fiy2 = _mm_hadd_ps(fiy2, fiz2); + fix3 = _mm_hadd_ps(fix3, fiy3); + fiz3 = _mm_hadd_ps(fiz3, fix4); + fiy4 = _mm_hadd_ps(fiy4, fiz4); - fix1 = _mm_hadd_ps(fix1,fiz1); /* fix2 fiz1 fiy1 fix1 */ - fiy2 = _mm_hadd_ps(fiy2,fix3); /* fiy3 fix3 fiz2 fiy2 */ - fiz3 = _mm_hadd_ps(fiz3,fiy4); /* fiz4 fiy4 fix4 fiz3 */ + fix1 = _mm_hadd_ps(fix1, fiz1); /* fix2 fiz1 fiy1 fix1 */ + fiy2 = _mm_hadd_ps(fiy2, fix3); /* fiy3 fix3 fiz2 fiy2 */ + fiz3 = _mm_hadd_ps(fiz3, fiy4); /* fiz4 fiy4 fix4 fiz3 */ - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) )); - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4))); - _mm_storeu_ps(fptr+8,_mm_add_ps(fiz3,_mm_loadu_ps(fptr+8))); + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); + _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8))); t5 = _mm_load_ss(fshiftptr+2); - t5 = _mm_loadh_pi(t5,(__m64 *)(fshiftptr)); + t5 = _mm_loadh_pi(t5, (__m64 *)(fshiftptr)); - t1 = _mm_permute_ps(fix1,_MM_SHUFFLE(1,0,2,2)); - t2 = _mm_permute_ps(fiy2,_MM_SHUFFLE(3,2,1,1)); - t3 = _mm_permute_ps(fiz3,_MM_SHUFFLE(2,1,0,0)); - t4 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(0,0,3,3)); - t4 = _mm_shuffle_ps(fiz3,t4 ,_MM_SHUFFLE(2,0,3,3)); + t1 = _mm_permute_ps(fix1, _MM_SHUFFLE(1, 0, 2, 2)); + t2 = _mm_permute_ps(fiy2, _MM_SHUFFLE(3, 2, 1, 1)); + t3 = _mm_permute_ps(fiz3, _MM_SHUFFLE(2, 1, 0, 0)); + t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3)); + t4 = _mm_shuffle_ps(fiz3, t4, _MM_SHUFFLE(2, 0, 3, 3)); - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ps(t3,t4); - t1 = _mm_add_ps(t1,t3); - t5 = _mm_add_ps(t5,t1); + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ps(t3, t4); + t1 = _mm_add_ps(t1, t3); + t5 = _mm_add_ps(t5, t1); - _mm_store_ss(fshiftptr+2,t5); - _mm_storeh_pi((__m64 *)(fshiftptr),t5); + _mm_store_ss(fshiftptr+2, t5); + _mm_storeh_pi((__m64 *)(fshiftptr), t5); } #endif @@ -808,20 +808,20 @@ gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, static gmx_inline void gmx_mm_update_1pot_ps(__m128 pot1, float * gmx_restrict ptrA) { - pot1 = _mm_hadd_ps(pot1,pot1); - pot1 = _mm_hadd_ps(pot1,pot1); - _mm_store_ss(ptrA,_mm_add_ss(pot1,_mm_load_ss(ptrA))); + pot1 = _mm_hadd_ps(pot1, pot1); + pot1 = _mm_hadd_ps(pot1, pot1); + _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA))); } static gmx_inline void gmx_mm_update_2pot_ps(__m128 pot1, float * gmx_restrict ptrA, __m128 pot2, float * gmx_restrict ptrB) { - pot1 = _mm_hadd_ps(pot1,pot2); - pot1 = _mm_hadd_ps(pot1,pot1); - pot2 = _mm_permute_ps(pot1,_MM_SHUFFLE(0,0,0,1)); - _mm_store_ss(ptrA,_mm_add_ss(pot1,_mm_load_ss(ptrA))); - _mm_store_ss(ptrB,_mm_add_ss(pot2,_mm_load_ss(ptrB))); + pot1 = _mm_hadd_ps(pot1, pot2); + pot1 = _mm_hadd_ps(pot1, pot1); + pot2 = _mm_permute_ps(pot1, _MM_SHUFFLE(0, 0, 0, 1)); + _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA))); + _mm_store_ss(ptrB, _mm_add_ss(pot2, _mm_load_ss(ptrB))); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.c index 20add7f0a6..dfc40d9261 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.c @@ -241,7 +241,7 @@ nb_kernel_t nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_avx_128_fma_single; nb_kernel_info_t -kernellist_avx_128_fma_single[] = + kernellist_avx_128_fma_single[] = { { nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_128_fma_single, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_128_fma_single", "avx_128_fma_single", "None", "None", "LennardJones", "None", "ParticleParticle", "", "PotentialAndForce" }, { nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_128_fma_single, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_128_fma_single", "avx_128_fma_single", "None", "None", "LennardJones", "None", "ParticleParticle", "", "Force" }, @@ -460,6 +460,6 @@ kernellist_avx_128_fma_single[] = }; int -kernellist_avx_128_fma_single_size = sizeof(kernellist_avx_128_fma_single)/sizeof(kernellist_avx_128_fma_single[0]); + kernellist_avx_128_fma_single_size = sizeof(kernellist_avx_128_fma_single)/sizeof(kernellist_avx_128_fma_single[0]); #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.h index c40e6d4604..0c4a49d629 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_128_fma_single/nb_kernel_avx_128_fma_single.h @@ -27,10 +27,10 @@ /* List of kernels for this architecture with metadata about them */ extern nb_kernel_info_t -kernellist_avx_128_fma_single[]; + kernellist_avx_128_fma_single[]; /* Length of kernellist_c */ extern int -kernellist_avx_128_fma_single_size; + kernellist_avx_128_fma_single_size; #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/kernelutil_x86_avx_256_double.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/kernelutil_x86_avx_256_double.h index c00b6dad84..e16b3c68d5 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/kernelutil_x86_avx_256_double.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/kernelutil_x86_avx_256_double.h @@ -36,17 +36,17 @@ static int gmx_mm256_any_lt(__m256d a, __m256d b) { - return _mm256_movemask_pd(_mm256_cmp_pd(a,b,_CMP_LT_OQ)); + return _mm256_movemask_pd(_mm256_cmp_pd(a, b, _CMP_LT_OQ)); } static gmx_inline __m256d gmx_mm256_calc_rsq_pd(__m256d dx, __m256d dy, __m256d dz) { - return _mm256_add_pd( _mm256_add_pd( _mm256_mul_pd(dx,dx), _mm256_mul_pd(dy,dy) ), _mm256_mul_pd(dz,dz) ); + return _mm256_add_pd( _mm256_add_pd( _mm256_mul_pd(dx, dx), _mm256_mul_pd(dy, dy) ), _mm256_mul_pd(dz, dz) ); } /* Normal sum of four ymm registers */ -#define gmx_mm256_sum4_pd(t0,t1,t2,t3) _mm256_add_pd(_mm256_add_pd(t0,t1),_mm256_add_pd(t2,t3)) +#define gmx_mm256_sum4_pd(t0, t1, t2, t3) _mm256_add_pd(_mm256_add_pd(t0, t1), _mm256_add_pd(t2, t3)) /* Load a single value from 1-4 places, merge into xmm register */ @@ -60,12 +60,12 @@ static __m256d gmx_mm256_load_2real_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB) { - __m128d tA,tB; + __m128d tA, tB; tA = _mm_load_sd(ptrA); tB = _mm_load_sd(ptrB); - return _mm256_castpd128_pd256(_mm_unpacklo_pd(tA,tB)); + return _mm256_castpd128_pd256(_mm_unpacklo_pd(tA, tB)); } @@ -73,11 +73,11 @@ static __m256d gmx_mm256_load_4real_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB, const double * gmx_restrict ptrC, const double * gmx_restrict ptrD) { - __m128d t1,t2; + __m128d t1, t2; - t1 = _mm_unpacklo_pd(_mm_load_sd(ptrA),_mm_load_sd(ptrB)); - t2 = _mm_unpacklo_pd(_mm_load_sd(ptrC),_mm_load_sd(ptrD)); - return gmx_mm256_set_m128d(t2,t1); + t1 = _mm_unpacklo_pd(_mm_load_sd(ptrA), _mm_load_sd(ptrB)); + t2 = _mm_unpacklo_pd(_mm_load_sd(ptrC), _mm_load_sd(ptrD)); + return gmx_mm256_set_m128d(t2, t1); } @@ -85,7 +85,7 @@ gmx_mm256_load_4real_swizzle_pd(const double * gmx_restrict ptrA, const double * static void gmx_mm256_store_1real_pd(double * gmx_restrict ptrA, __m256d xmm1) { - _mm_store_sd(ptrA,_mm256_castpd256_pd128(xmm1)); + _mm_store_sd(ptrA, _mm256_castpd256_pd128(xmm1)); } @@ -94,9 +94,9 @@ gmx_mm256_store_2real_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restri { __m256d t2; - t2 = _mm256_permute_pd(xmm1,_GMX_MM_PERMUTE256D(1,1,1,1)); - _mm_store_sd(ptrA,_mm256_castpd256_pd128(xmm1)); - _mm_store_sd(ptrB,_mm256_castpd256_pd128(t2)); + t2 = _mm256_permute_pd(xmm1, _GMX_MM_PERMUTE256D(1, 1, 1, 1)); + _mm_store_sd(ptrA, _mm256_castpd256_pd128(xmm1)); + _mm_store_sd(ptrB, _mm256_castpd256_pd128(t2)); } @@ -107,15 +107,15 @@ gmx_mm256_store_4real_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restri double * gmx_restrict ptrC, double * gmx_restrict ptrD, __m256d xmm1) { __m256d t2; - __m128d t3,t4; - - t2 = _mm256_permute_pd(xmm1,_GMX_MM_PERMUTE256D(1,1,1,1)); - t3 = _mm256_extractf128_pd(xmm1,0x1); - t4 = _mm_permute_pd(t3,_GMX_MM_PERMUTE128D(1,1)); - _mm_store_sd(ptrA,_mm256_castpd256_pd128(xmm1)); - _mm_store_sd(ptrB,_mm256_castpd256_pd128(t2)); - _mm_store_sd(ptrC,t3); - _mm_store_sd(ptrD,t4); + __m128d t3, t4; + + t2 = _mm256_permute_pd(xmm1, _GMX_MM_PERMUTE256D(1, 1, 1, 1)); + t3 = _mm256_extractf128_pd(xmm1, 0x1); + t4 = _mm_permute_pd(t3, _GMX_MM_PERMUTE128D(1, 1)); + _mm_store_sd(ptrA, _mm256_castpd256_pd128(xmm1)); + _mm_store_sd(ptrB, _mm256_castpd256_pd128(t2)); + _mm_store_sd(ptrC, t3); + _mm_store_sd(ptrD, t4); } @@ -127,25 +127,25 @@ gmx_mm256_increment_1real_pd(double * gmx_restrict ptrA, __m256d xmm1) __m128d t1; t1 = _mm256_castpd256_pd128(xmm1); - t1 = _mm_add_sd(t1,_mm_load_sd(ptrA)); + t1 = _mm_add_sd(t1, _mm_load_sd(ptrA)); - _mm_store_sd(ptrA,t1); + _mm_store_sd(ptrA, t1); } static void gmx_mm256_increment_2real_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, __m256d xmm1) { - __m128d t1,t2; + __m128d t1, t2; t1 = _mm256_castpd256_pd128(xmm1); - t2 = _mm_permute_pd(t1,_GMX_MM_PERMUTE128D(1,1)); + t2 = _mm_permute_pd(t1, _GMX_MM_PERMUTE128D(1, 1)); - t1 = _mm_add_sd(t1,_mm_load_sd(ptrA)); - t2 = _mm_add_sd(t2,_mm_load_sd(ptrB)); + t1 = _mm_add_sd(t1, _mm_load_sd(ptrA)); + t2 = _mm_add_sd(t2, _mm_load_sd(ptrB)); - _mm_store_sd(ptrA,t1); - _mm_store_sd(ptrB,t2); + _mm_store_sd(ptrA, t1); + _mm_store_sd(ptrB, t2); } @@ -153,22 +153,22 @@ static void gmx_mm256_increment_4real_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, double * gmx_restrict ptrC, double * gmx_restrict ptrD, __m256d xmm1) { - __m128d t1,t2,t3,t4; + __m128d t1, t2, t3, t4; t1 = _mm256_castpd256_pd128(xmm1); - t2 = _mm_permute_pd(t1,_GMX_MM_PERMUTE128D(1,1)); - t3 = _mm256_extractf128_pd(xmm1,0x1); - t4 = _mm_permute_pd(t3,_GMX_MM_PERMUTE128D(1,1)); - - t1 = _mm_add_sd(t1,_mm_load_sd(ptrA)); - t2 = _mm_add_sd(t2,_mm_load_sd(ptrB)); - t3 = _mm_add_sd(t3,_mm_load_sd(ptrC)); - t4 = _mm_add_sd(t4,_mm_load_sd(ptrD)); - - _mm_store_sd(ptrA,t1); - _mm_store_sd(ptrB,t2); - _mm_store_sd(ptrC,t3); - _mm_store_sd(ptrD,t4); + t2 = _mm_permute_pd(t1, _GMX_MM_PERMUTE128D(1, 1)); + t3 = _mm256_extractf128_pd(xmm1, 0x1); + t4 = _mm_permute_pd(t3, _GMX_MM_PERMUTE128D(1, 1)); + + t1 = _mm_add_sd(t1, _mm_load_sd(ptrA)); + t2 = _mm_add_sd(t2, _mm_load_sd(ptrB)); + t3 = _mm_add_sd(t3, _mm_load_sd(ptrC)); + t4 = _mm_add_sd(t4, _mm_load_sd(ptrD)); + + _mm_store_sd(ptrA, t1); + _mm_store_sd(ptrB, t2); + _mm_store_sd(ptrC, t3); + _mm_store_sd(ptrD, t4); } @@ -184,12 +184,12 @@ gmx_mm256_load_1pair_swizzle_pd(const double * gmx_restrict p1, __m256d *c6, __m static void gmx_mm256_load_2pair_swizzle_pd(const double * gmx_restrict p1, const double * gmx_restrict p2, __m256d *c6, __m256d *c12) { - __m128d t1,t2,t3; + __m128d t1, t2, t3; t1 = _mm_loadu_pd(p1); t2 = _mm_loadu_pd(p2); - *c6 = _mm256_castpd128_pd256(_mm_unpacklo_pd(t1,t2)); - *c12 = _mm256_castpd128_pd256(_mm_unpackhi_pd(t1,t2)); + *c6 = _mm256_castpd128_pd256(_mm_unpacklo_pd(t1, t2)); + *c12 = _mm256_castpd128_pd256(_mm_unpackhi_pd(t1, t2)); } @@ -199,51 +199,51 @@ gmx_mm256_load_4pair_swizzle_pd(const double * gmx_restrict p1, const double * g const double * gmx_restrict p3, const double * gmx_restrict p4, __m256d * gmx_restrict c6, __m256d * gmx_restrict c12) { - __m256d t1,t2; + __m256d t1, t2; - t1 = gmx_mm256_set_m128d(_mm_loadu_pd(p3),_mm_loadu_pd(p1)); /* c12c c6c | c12a c6a */ - t2 = gmx_mm256_set_m128d(_mm_loadu_pd(p4),_mm_loadu_pd(p2)); /* c12d c6d | c12b c6b */ + t1 = gmx_mm256_set_m128d(_mm_loadu_pd(p3), _mm_loadu_pd(p1)); /* c12c c6c | c12a c6a */ + t2 = gmx_mm256_set_m128d(_mm_loadu_pd(p4), _mm_loadu_pd(p2)); /* c12d c6d | c12b c6b */ - *c6 = _mm256_unpacklo_pd(t1,t2); /* c6d c6c | c6b c6a */ - *c12 = _mm256_unpackhi_pd(t1,t2); /* c12d c12c | c12b c12a */ + *c6 = _mm256_unpacklo_pd(t1, t2); /* c6d c6c | c6b c6a */ + *c12 = _mm256_unpackhi_pd(t1, t2); /* c12d c12c | c12b c12a */ } static gmx_inline void gmx_mm256_load_shift_and_1rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m256d * gmx_restrict x1, - __m256d * gmx_restrict y1, - __m256d * gmx_restrict z1) + const double * gmx_restrict xyz, + __m256d * gmx_restrict x1, + __m256d * gmx_restrict y1, + __m256d * gmx_restrict z1) { - __m128d mem_xy,mem_z,mem_sxy,mem_sz,tx,ty,tz; + __m128d mem_xy, mem_z, mem_sxy, mem_sz, tx, ty, tz; mem_xy = _mm_loadu_pd(xyz); mem_z = _mm_load_sd(xyz+2); mem_sxy = _mm_loadu_pd(xyz_shift); mem_sz = _mm_load_sd(xyz_shift+2); - mem_xy = _mm_add_pd(mem_xy,mem_sxy); - mem_z = _mm_add_pd(mem_z,mem_sz); + mem_xy = _mm_add_pd(mem_xy, mem_sxy); + mem_z = _mm_add_pd(mem_z, mem_sz); - tx = _mm_shuffle_pd(mem_xy,mem_xy,_MM_SHUFFLE2(0,0)); - ty = _mm_shuffle_pd(mem_xy,mem_xy,_MM_SHUFFLE2(1,1)); - tz = _mm_shuffle_pd(mem_z,mem_z,_MM_SHUFFLE2(0,0)); + tx = _mm_shuffle_pd(mem_xy, mem_xy, _MM_SHUFFLE2(0, 0)); + ty = _mm_shuffle_pd(mem_xy, mem_xy, _MM_SHUFFLE2(1, 1)); + tz = _mm_shuffle_pd(mem_z, mem_z, _MM_SHUFFLE2(0, 0)); - *x1 = gmx_mm256_set_m128d(tx,tx); - *y1 = gmx_mm256_set_m128d(ty,ty); - *z1 = gmx_mm256_set_m128d(tz,tz); + *x1 = gmx_mm256_set_m128d(tx, tx); + *y1 = gmx_mm256_set_m128d(ty, ty); + *z1 = gmx_mm256_set_m128d(tz, tz); } static gmx_inline void gmx_mm256_load_shift_and_3rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1, - __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2, - __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3) + const double * gmx_restrict xyz, + __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1, + __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2, + __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3) { - __m128d t1,t2,t3,t4,t5,sxy,sz,szx,syz,tx,ty,tz; + __m128d t1, t2, t3, t4, t5, sxy, sz, szx, syz, tx, ty, tz; t1 = _mm_loadu_pd(xyz); t2 = _mm_loadu_pd(xyz+2); @@ -253,45 +253,45 @@ gmx_mm256_load_shift_and_3rvec_broadcast_pd(const double * gmx_restrict xyz_shif sxy = _mm_loadu_pd(xyz_shift); sz = _mm_load_sd(xyz_shift+2); - szx = _mm_shuffle_pd(sz,sxy,_MM_SHUFFLE2(0,0)); - syz = _mm_shuffle_pd(sxy,sz,_MM_SHUFFLE2(0,1)); - - t1 = _mm_add_pd(t1,sxy); - t2 = _mm_add_pd(t2,szx); - t3 = _mm_add_pd(t3,syz); - t4 = _mm_add_pd(t4,sxy); - t5 = _mm_add_sd(t5,sz); - - tx = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(0,0)); - ty = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(1,1)); - tz = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(0,0)); - *x1 = gmx_mm256_set_m128d(tx,tx); - *y1 = gmx_mm256_set_m128d(ty,ty); - *z1 = gmx_mm256_set_m128d(tz,tz); - tx = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(1,1)); - ty = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(0,0)); - tz = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(1,1)); - *x2 = gmx_mm256_set_m128d(tx,tx); - *y2 = gmx_mm256_set_m128d(ty,ty); - *z2 = gmx_mm256_set_m128d(tz,tz); - tx = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(0,0)); - ty = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(1,1)); - tz = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(0,0)); - *x3 = gmx_mm256_set_m128d(tx,tx); - *y3 = gmx_mm256_set_m128d(ty,ty); - *z3 = gmx_mm256_set_m128d(tz,tz); + szx = _mm_shuffle_pd(sz, sxy, _MM_SHUFFLE2(0, 0)); + syz = _mm_shuffle_pd(sxy, sz, _MM_SHUFFLE2(0, 1)); + + t1 = _mm_add_pd(t1, sxy); + t2 = _mm_add_pd(t2, szx); + t3 = _mm_add_pd(t3, syz); + t4 = _mm_add_pd(t4, sxy); + t5 = _mm_add_sd(t5, sz); + + tx = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(0, 0)); + ty = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(1, 1)); + tz = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(0, 0)); + *x1 = gmx_mm256_set_m128d(tx, tx); + *y1 = gmx_mm256_set_m128d(ty, ty); + *z1 = gmx_mm256_set_m128d(tz, tz); + tx = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(1, 1)); + ty = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(0, 0)); + tz = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(1, 1)); + *x2 = gmx_mm256_set_m128d(tx, tx); + *y2 = gmx_mm256_set_m128d(ty, ty); + *z2 = gmx_mm256_set_m128d(tz, tz); + tx = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(0, 0)); + ty = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(1, 1)); + tz = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(0, 0)); + *x3 = gmx_mm256_set_m128d(tx, tx); + *y3 = gmx_mm256_set_m128d(ty, ty); + *z3 = gmx_mm256_set_m128d(tz, tz); } static gmx_inline void gmx_mm256_load_shift_and_4rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1, - __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2, - __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3, - __m256d * gmx_restrict x4, __m256d * gmx_restrict y4, __m256d * gmx_restrict z4) + const double * gmx_restrict xyz, + __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1, + __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2, + __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3, + __m256d * gmx_restrict x4, __m256d * gmx_restrict y4, __m256d * gmx_restrict z4) { - __m128d t1,t2,t3,t4,t5,t6,sxy,sz,szx,syz,tx,ty,tz; + __m128d t1, t2, t3, t4, t5, t6, sxy, sz, szx, syz, tx, ty, tz; t1 = _mm_loadu_pd(xyz); t2 = _mm_loadu_pd(xyz+2); @@ -302,40 +302,40 @@ gmx_mm256_load_shift_and_4rvec_broadcast_pd(const double * gmx_restrict xyz_shif sxy = _mm_loadu_pd(xyz_shift); sz = _mm_load_sd(xyz_shift+2); - szx = _mm_shuffle_pd(sz,sxy,_MM_SHUFFLE2(0,0)); - syz = _mm_shuffle_pd(sxy,sz,_MM_SHUFFLE2(0,1)); - - t1 = _mm_add_pd(t1,sxy); - t2 = _mm_add_pd(t2,szx); - t3 = _mm_add_pd(t3,syz); - t4 = _mm_add_pd(t4,sxy); - t5 = _mm_add_pd(t5,szx); - t6 = _mm_add_pd(t6,syz); - - tx = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(0,0)); - ty = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(1,1)); - tz = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(0,0)); - *x1 = gmx_mm256_set_m128d(tx,tx); - *y1 = gmx_mm256_set_m128d(ty,ty); - *z1 = gmx_mm256_set_m128d(tz,tz); - tx = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(1,1)); - ty = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(0,0)); - tz = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(1,1)); - *x2 = gmx_mm256_set_m128d(tx,tx); - *y2 = gmx_mm256_set_m128d(ty,ty); - *z2 = gmx_mm256_set_m128d(tz,tz); - tx = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(0,0)); - ty = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(1,1)); - tz = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(0,0)); - *x3 = gmx_mm256_set_m128d(tx,tx); - *y3 = gmx_mm256_set_m128d(ty,ty); - *z3 = gmx_mm256_set_m128d(tz,tz); - tx = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(1,1)); - ty = _mm_shuffle_pd(t6,t6,_MM_SHUFFLE2(0,0)); - tz = _mm_shuffle_pd(t6,t6,_MM_SHUFFLE2(1,1)); - *x4 = gmx_mm256_set_m128d(tx,tx); - *y4 = gmx_mm256_set_m128d(ty,ty); - *z4 = gmx_mm256_set_m128d(tz,tz); + szx = _mm_shuffle_pd(sz, sxy, _MM_SHUFFLE2(0, 0)); + syz = _mm_shuffle_pd(sxy, sz, _MM_SHUFFLE2(0, 1)); + + t1 = _mm_add_pd(t1, sxy); + t2 = _mm_add_pd(t2, szx); + t3 = _mm_add_pd(t3, syz); + t4 = _mm_add_pd(t4, sxy); + t5 = _mm_add_pd(t5, szx); + t6 = _mm_add_pd(t6, syz); + + tx = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(0, 0)); + ty = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(1, 1)); + tz = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(0, 0)); + *x1 = gmx_mm256_set_m128d(tx, tx); + *y1 = gmx_mm256_set_m128d(ty, ty); + *z1 = gmx_mm256_set_m128d(tz, tz); + tx = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(1, 1)); + ty = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(0, 0)); + tz = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(1, 1)); + *x2 = gmx_mm256_set_m128d(tx, tx); + *y2 = gmx_mm256_set_m128d(ty, ty); + *z2 = gmx_mm256_set_m128d(tz, tz); + tx = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(0, 0)); + ty = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(1, 1)); + tz = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(0, 0)); + *x3 = gmx_mm256_set_m128d(tx, tx); + *y3 = gmx_mm256_set_m128d(ty, ty); + *z3 = gmx_mm256_set_m128d(tz, tz); + tx = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(1, 1)); + ty = _mm_shuffle_pd(t6, t6, _MM_SHUFFLE2(0, 0)); + tz = _mm_shuffle_pd(t6, t6, _MM_SHUFFLE2(1, 1)); + *x4 = gmx_mm256_set_m128d(tx, tx); + *y4 = gmx_mm256_set_m128d(ty, ty); + *z4 = gmx_mm256_set_m128d(tz, tz); } @@ -347,8 +347,8 @@ gmx_mm256_load_1rvec_1ptr_swizzle_pd(const double * gmx_restrict p1, t1 = _mm256_loadu_pd(p1); *x = t1; - *y = _mm256_permute_pd(t1,_GMX_MM_PERMUTE256D(0,1,0,1)); - *z = _mm256_castpd128_pd256(_mm256_extractf128_pd(t1,0x1)); + *y = _mm256_permute_pd(t1, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *z = _mm256_castpd128_pd256(_mm256_extractf128_pd(t1, 0x1)); } @@ -358,20 +358,20 @@ gmx_mm256_load_3rvec_1ptr_swizzle_pd(const double * gmx_restrict p1, __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2, __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3) { - __m256d t1,t2,t3,t4; + __m256d t1, t2, t3, t4; t1 = _mm256_loadu_pd(p1); t3 = _mm256_loadu_pd(p1+4); *x1 = t1; *y2 = t3; - t2 = gmx_mm256_unpack128hi_pd(t1,t1); - t4 = gmx_mm256_unpack128hi_pd(t3,t3); + t2 = gmx_mm256_unpack128hi_pd(t1, t1); + t4 = gmx_mm256_unpack128hi_pd(t3, t3); *z1 = t2; *x3 = t4; - *y1 = _mm256_permute_pd(t1,_GMX_MM_PERMUTE256D(0,1,0,1)); - *z2 = _mm256_permute_pd(t3,_GMX_MM_PERMUTE256D(0,1,0,1)); - *x2 = _mm256_permute_pd(t2,_GMX_MM_PERMUTE256D(0,1,0,1)); - *y3 = _mm256_permute_pd(t4,_GMX_MM_PERMUTE256D(0,1,0,1)); + *y1 = _mm256_permute_pd(t1, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *z2 = _mm256_permute_pd(t3, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *x2 = _mm256_permute_pd(t2, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *y3 = _mm256_permute_pd(t4, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); *z3 = _mm256_castpd128_pd256(_mm_load_sd(p1+8)); } @@ -382,15 +382,15 @@ gmx_mm256_load_4rvec_1ptr_swizzle_pd(const double * gmx_restrict p1, __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3, __m256d * gmx_restrict x4, __m256d * gmx_restrict y4, __m256d * gmx_restrict z4) { - __m256d t1,t2,t3,t4,t5,t6; + __m256d t1, t2, t3, t4, t5, t6; t1 = _mm256_loadu_pd(p1); t2 = _mm256_loadu_pd(p1+4); t3 = _mm256_loadu_pd(p1+8); - t4 = _mm256_castpd128_pd256(_mm256_extractf128_pd(t1,0x1)); - t5 = _mm256_castpd128_pd256(_mm256_extractf128_pd(t2,0x1)); - t6 = _mm256_castpd128_pd256(_mm256_extractf128_pd(t3,0x1)); + t4 = _mm256_castpd128_pd256(_mm256_extractf128_pd(t1, 0x1)); + t5 = _mm256_castpd128_pd256(_mm256_extractf128_pd(t2, 0x1)); + t6 = _mm256_castpd128_pd256(_mm256_extractf128_pd(t3, 0x1)); *x1 = t1; *y2 = t2; @@ -399,12 +399,12 @@ gmx_mm256_load_4rvec_1ptr_swizzle_pd(const double * gmx_restrict p1, *x3 = t5; *y4 = t6; - *y1 = _mm256_permute_pd(t1,_GMX_MM_PERMUTE256D(0,1,0,1)); - *z2 = _mm256_permute_pd(t2,_GMX_MM_PERMUTE256D(0,1,0,1)); - *x4 = _mm256_permute_pd(t3,_GMX_MM_PERMUTE256D(0,1,0,1)); - *x2 = _mm256_permute_pd(t4,_GMX_MM_PERMUTE256D(0,1,0,1)); - *y3 = _mm256_permute_pd(t5,_GMX_MM_PERMUTE256D(0,1,0,1)); - *z4 = _mm256_permute_pd(t6,_GMX_MM_PERMUTE256D(0,1,0,1)); + *y1 = _mm256_permute_pd(t1, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *z2 = _mm256_permute_pd(t2, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *x4 = _mm256_permute_pd(t3, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *x2 = _mm256_permute_pd(t4, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *y3 = _mm256_permute_pd(t5, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + *z4 = _mm256_permute_pd(t6, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); } @@ -413,21 +413,21 @@ gmx_mm256_load_1rvec_4ptr_swizzle_pd(const double * gmx_restrict ptrA, const dou const double * gmx_restrict ptrC, const double * gmx_restrict ptrD, __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1) { - __m256d t1,t2,t3,t4,t5,t6; + __m256d t1, t2, t3, t4, t5, t6; t1 = _mm256_loadu_pd(ptrA); /* - z1a | y1a x1a */ t2 = _mm256_loadu_pd(ptrB); /* - z1b | y1b x1b */ t3 = _mm256_loadu_pd(ptrC); /* - z1c | y1c x1c */ t4 = _mm256_loadu_pd(ptrD); /* - z1d | y1d x1d */ - t5 = _mm256_unpacklo_pd(t1,t2); /* z1b z1a | x1b x1a */ - t6 = _mm256_unpackhi_pd(t1,t2); /* - - | y1b y1a */ - t1 = _mm256_unpacklo_pd(t3,t4); /* z1c z1c | x1d x1c */ - t2 = _mm256_unpackhi_pd(t3,t4); /* - - | y1d y1c */ + t5 = _mm256_unpacklo_pd(t1, t2); /* z1b z1a | x1b x1a */ + t6 = _mm256_unpackhi_pd(t1, t2); /* - - | y1b y1a */ + t1 = _mm256_unpacklo_pd(t3, t4); /* z1c z1c | x1d x1c */ + t2 = _mm256_unpackhi_pd(t3, t4); /* - - | y1d y1c */ - *x1 = gmx_mm256_unpack128lo_pd(t5,t1); - *y1 = gmx_mm256_unpack128lo_pd(t6,t2); - *z1 = gmx_mm256_unpack128hi_pd(t5,t1); + *x1 = gmx_mm256_unpack128lo_pd(t5, t1); + *y1 = gmx_mm256_unpack128lo_pd(t6, t2); + *z1 = gmx_mm256_unpack128hi_pd(t5, t1); } @@ -439,43 +439,43 @@ gmx_mm256_load_3rvec_4ptr_swizzle_pd(const double * gmx_restrict ptrA, const dou __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2, __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3) { - __m256d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14; - - t1 = _mm256_loadu_pd(ptrA); /* x2a z1a | y1a x1a */ - t2 = _mm256_loadu_pd(ptrB); /* x2b z1b | y1b x1b */ - t3 = _mm256_loadu_pd(ptrC); /* x2c z1c | y1c x1c */ - t4 = _mm256_loadu_pd(ptrD); /* x2d z1d | y1d x1d */ - t5 = _mm256_loadu_pd(ptrA+4); /* y3a x3a | z2a y2a */ - t6 = _mm256_loadu_pd(ptrB+4); /* y3b x3b | z2b y2b */ - t7 = _mm256_loadu_pd(ptrC+4); /* y3c x3c | z2c y2c */ - t8 = _mm256_loadu_pd(ptrD+4); /* y3d x3d | z2d y2d */ - t9 = _mm256_castpd128_pd256(_mm_load_sd(ptrA+8)); /* - - | - z3a */ - t10 = _mm256_castpd128_pd256(_mm_load_sd(ptrB+8)); /* - - | - z3b */ - t11 = _mm256_castpd128_pd256(_mm_load_sd(ptrC+8)); /* - - | - z3c */ - t12 = _mm256_castpd128_pd256(_mm_load_sd(ptrD+8)); /* - - | - z3d */ - - t13 = _mm256_unpacklo_pd(t1,t2); /* z1b z1a | x1b x1a */ - t14 = _mm256_unpackhi_pd(t1,t2); /* x2b x2a | y1b y1a */ - t1 = _mm256_unpacklo_pd(t3,t4); /* z1d z1c | x1d x1c */ - t2 = _mm256_unpackhi_pd(t3,t4); /* x2d x2c | y1d y1c */ - - t3 = _mm256_unpacklo_pd(t5,t6); /* x3b x3a | y2b y2a */ - t4 = _mm256_unpackhi_pd(t5,t6); /* y3b y3a | z2b z2a */ - t5 = _mm256_unpacklo_pd(t7,t8); /* x3d x3c | y2d y2c */ - t6 = _mm256_unpackhi_pd(t7,t8); /* y3d y3c | z2d z2c */ - - t9 = _mm256_unpacklo_pd(t9,t10); /* - - | z3b z3a */ - t11 = _mm256_unpacklo_pd(t11,t12); /* - - | z3d z3c */ - - *x1 = gmx_mm256_unpack128lo_pd(t13,t1); - *y1 = gmx_mm256_unpack128lo_pd(t14,t2); - *z1 = gmx_mm256_unpack128hi_pd(t13,t1); - *x2 = gmx_mm256_unpack128hi_pd(t14,t2); - *y2 = gmx_mm256_unpack128lo_pd(t3,t5); - *z2 = gmx_mm256_unpack128lo_pd(t4,t6); - *x3 = gmx_mm256_unpack128hi_pd(t3,t5); - *y3 = gmx_mm256_unpack128hi_pd(t4,t6); - *z3 = gmx_mm256_unpack128lo_pd(t9,t11); + __m256d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14; + + t1 = _mm256_loadu_pd(ptrA); /* x2a z1a | y1a x1a */ + t2 = _mm256_loadu_pd(ptrB); /* x2b z1b | y1b x1b */ + t3 = _mm256_loadu_pd(ptrC); /* x2c z1c | y1c x1c */ + t4 = _mm256_loadu_pd(ptrD); /* x2d z1d | y1d x1d */ + t5 = _mm256_loadu_pd(ptrA+4); /* y3a x3a | z2a y2a */ + t6 = _mm256_loadu_pd(ptrB+4); /* y3b x3b | z2b y2b */ + t7 = _mm256_loadu_pd(ptrC+4); /* y3c x3c | z2c y2c */ + t8 = _mm256_loadu_pd(ptrD+4); /* y3d x3d | z2d y2d */ + t9 = _mm256_castpd128_pd256(_mm_load_sd(ptrA+8)); /* - - | - z3a */ + t10 = _mm256_castpd128_pd256(_mm_load_sd(ptrB+8)); /* - - | - z3b */ + t11 = _mm256_castpd128_pd256(_mm_load_sd(ptrC+8)); /* - - | - z3c */ + t12 = _mm256_castpd128_pd256(_mm_load_sd(ptrD+8)); /* - - | - z3d */ + + t13 = _mm256_unpacklo_pd(t1, t2); /* z1b z1a | x1b x1a */ + t14 = _mm256_unpackhi_pd(t1, t2); /* x2b x2a | y1b y1a */ + t1 = _mm256_unpacklo_pd(t3, t4); /* z1d z1c | x1d x1c */ + t2 = _mm256_unpackhi_pd(t3, t4); /* x2d x2c | y1d y1c */ + + t3 = _mm256_unpacklo_pd(t5, t6); /* x3b x3a | y2b y2a */ + t4 = _mm256_unpackhi_pd(t5, t6); /* y3b y3a | z2b z2a */ + t5 = _mm256_unpacklo_pd(t7, t8); /* x3d x3c | y2d y2c */ + t6 = _mm256_unpackhi_pd(t7, t8); /* y3d y3c | z2d z2c */ + + t9 = _mm256_unpacklo_pd(t9, t10); /* - - | z3b z3a */ + t11 = _mm256_unpacklo_pd(t11, t12); /* - - | z3d z3c */ + + *x1 = gmx_mm256_unpack128lo_pd(t13, t1); + *y1 = gmx_mm256_unpack128lo_pd(t14, t2); + *z1 = gmx_mm256_unpack128hi_pd(t13, t1); + *x2 = gmx_mm256_unpack128hi_pd(t14, t2); + *y2 = gmx_mm256_unpack128lo_pd(t3, t5); + *z2 = gmx_mm256_unpack128lo_pd(t4, t6); + *x3 = gmx_mm256_unpack128hi_pd(t3, t5); + *y3 = gmx_mm256_unpack128hi_pd(t4, t6); + *z3 = gmx_mm256_unpack128lo_pd(t9, t11); } @@ -488,162 +488,162 @@ gmx_mm256_load_4rvec_4ptr_swizzle_pd(const double * gmx_restrict ptrA, const dou __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3, __m256d * gmx_restrict x4, __m256d * gmx_restrict y4, __m256d * gmx_restrict z4) { - __m256d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14; + __m256d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14; t1 = _mm256_loadu_pd(ptrA); /* x2a z1a | y1a x1a */ t2 = _mm256_loadu_pd(ptrB); /* x2b z1b | y1b x1b */ t3 = _mm256_loadu_pd(ptrC); /* x2c z1c | y1c x1c */ t4 = _mm256_loadu_pd(ptrD); /* x2d z1d | y1d x1d */ - t5 = _mm256_loadu_pd(ptrA+4); /* y3a x3a | z2a y2a */ - t6 = _mm256_loadu_pd(ptrB+4); /* y3b x3b | z2b y2b */ - t7 = _mm256_loadu_pd(ptrC+4); /* y3c x3c | z2c y2c */ - t8 = _mm256_loadu_pd(ptrD+4); /* y3d x3d | z2d y2d */ - t9 = _mm256_loadu_pd(ptrA+8); /* z4a y4a | x4a z3a */ - t10 = _mm256_loadu_pd(ptrB+8); /* z4b y4b | x4b z3b */ - t11 = _mm256_loadu_pd(ptrC+8); /* z4c y4c | x4c z3c */ - t12 = _mm256_loadu_pd(ptrD+8); /* z4d y4d | x4d z3d */ - - t13 = _mm256_unpacklo_pd(t1,t2); /* z1b z1a | x1b x1a */ - t14 = _mm256_unpackhi_pd(t1,t2); /* x2b x2a | y1b y1a */ - t1 = _mm256_unpacklo_pd(t3,t4); /* z1d z1c | x1d x1c */ - t2 = _mm256_unpackhi_pd(t3,t4); /* x2d x2c | y1d y1c */ - - t3 = _mm256_unpacklo_pd(t5,t6); /* x3b x3a | y2b y2a */ - t4 = _mm256_unpackhi_pd(t5,t6); /* y3b y3a | z2b z2a */ - t5 = _mm256_unpacklo_pd(t7,t8); /* x3d x3c | y2d y2c */ - t6 = _mm256_unpackhi_pd(t7,t8); /* y3d y3c | z2d z2c */ - - t7 = _mm256_unpacklo_pd(t9,t10); /* y4b y4a | z3b z3a */ - t8 = _mm256_unpackhi_pd(t9,t10); /* z4b z4a | x4b x4a */ - t9 = _mm256_unpacklo_pd(t11,t12); /* y4d y4c | z3d z3c */ - t10 = _mm256_unpackhi_pd(t11,t12); /* z4d z4c | x4d x4c */ - - *x1 = gmx_mm256_unpack128lo_pd(t13,t1); - *y1 = gmx_mm256_unpack128lo_pd(t14,t2); - *z1 = gmx_mm256_unpack128hi_pd(t13,t1); - *x2 = gmx_mm256_unpack128hi_pd(t14,t2); - *y2 = gmx_mm256_unpack128lo_pd(t3,t5); - *z2 = gmx_mm256_unpack128lo_pd(t4,t6); - *x3 = gmx_mm256_unpack128hi_pd(t3,t5); - *y3 = gmx_mm256_unpack128hi_pd(t4,t6); - *z3 = gmx_mm256_unpack128lo_pd(t7,t9); - *x4 = gmx_mm256_unpack128lo_pd(t8,t10); - *y4 = gmx_mm256_unpack128hi_pd(t7,t9); - *z4 = gmx_mm256_unpack128hi_pd(t8,t10); + t5 = _mm256_loadu_pd(ptrA+4); /* y3a x3a | z2a y2a */ + t6 = _mm256_loadu_pd(ptrB+4); /* y3b x3b | z2b y2b */ + t7 = _mm256_loadu_pd(ptrC+4); /* y3c x3c | z2c y2c */ + t8 = _mm256_loadu_pd(ptrD+4); /* y3d x3d | z2d y2d */ + t9 = _mm256_loadu_pd(ptrA+8); /* z4a y4a | x4a z3a */ + t10 = _mm256_loadu_pd(ptrB+8); /* z4b y4b | x4b z3b */ + t11 = _mm256_loadu_pd(ptrC+8); /* z4c y4c | x4c z3c */ + t12 = _mm256_loadu_pd(ptrD+8); /* z4d y4d | x4d z3d */ + + t13 = _mm256_unpacklo_pd(t1, t2); /* z1b z1a | x1b x1a */ + t14 = _mm256_unpackhi_pd(t1, t2); /* x2b x2a | y1b y1a */ + t1 = _mm256_unpacklo_pd(t3, t4); /* z1d z1c | x1d x1c */ + t2 = _mm256_unpackhi_pd(t3, t4); /* x2d x2c | y1d y1c */ + + t3 = _mm256_unpacklo_pd(t5, t6); /* x3b x3a | y2b y2a */ + t4 = _mm256_unpackhi_pd(t5, t6); /* y3b y3a | z2b z2a */ + t5 = _mm256_unpacklo_pd(t7, t8); /* x3d x3c | y2d y2c */ + t6 = _mm256_unpackhi_pd(t7, t8); /* y3d y3c | z2d z2c */ + + t7 = _mm256_unpacklo_pd(t9, t10); /* y4b y4a | z3b z3a */ + t8 = _mm256_unpackhi_pd(t9, t10); /* z4b z4a | x4b x4a */ + t9 = _mm256_unpacklo_pd(t11, t12); /* y4d y4c | z3d z3c */ + t10 = _mm256_unpackhi_pd(t11, t12); /* z4d z4c | x4d x4c */ + + *x1 = gmx_mm256_unpack128lo_pd(t13, t1); + *y1 = gmx_mm256_unpack128lo_pd(t14, t2); + *z1 = gmx_mm256_unpack128hi_pd(t13, t1); + *x2 = gmx_mm256_unpack128hi_pd(t14, t2); + *y2 = gmx_mm256_unpack128lo_pd(t3, t5); + *z2 = gmx_mm256_unpack128lo_pd(t4, t6); + *x3 = gmx_mm256_unpack128hi_pd(t3, t5); + *y3 = gmx_mm256_unpack128hi_pd(t4, t6); + *z3 = gmx_mm256_unpack128lo_pd(t7, t9); + *x4 = gmx_mm256_unpack128lo_pd(t8, t10); + *y4 = gmx_mm256_unpack128hi_pd(t7, t9); + *z4 = gmx_mm256_unpack128hi_pd(t8, t10); } static void gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, - double * gmx_restrict ptrC, double * gmx_restrict ptrD, - __m256d x1, __m256d y1, __m256d z1) + double * gmx_restrict ptrC, double * gmx_restrict ptrD, + __m256d x1, __m256d y1, __m256d z1) { - __m256d t1,t2,tA,tB,tC,tD; + __m256d t1, t2, tA, tB, tC, tD; __m256i mask; - t1 = _mm256_unpacklo_pd(x1,y1); /* y1c x1c | y1a x1a */ - t2 = _mm256_unpackhi_pd(x1,y1); /* y1d x1d | y1b x1b */ - x1 = gmx_mm256_unpack128lo_pd(t1,z1); /* - z1a | y1a x1a */ - y1 = gmx_mm256_unpack128hi_pd(t1,z1); /* - z1c | y1c x1c */ - z1 = _mm256_permute_pd(z1,_GMX_MM_PERMUTE256D(0,1,0,1)); - t1 = gmx_mm256_unpack128lo_pd(t2,z1); /* - z1b | y1b x1b */ - z1 = gmx_mm256_unpack128hi_pd(t2,z1); /* - z1d | y1d x1d */ + t1 = _mm256_unpacklo_pd(x1, y1); /* y1c x1c | y1a x1a */ + t2 = _mm256_unpackhi_pd(x1, y1); /* y1d x1d | y1b x1b */ + x1 = gmx_mm256_unpack128lo_pd(t1, z1); /* - z1a | y1a x1a */ + y1 = gmx_mm256_unpack128hi_pd(t1, z1); /* - z1c | y1c x1c */ + z1 = _mm256_permute_pd(z1, _GMX_MM_PERMUTE256D(0, 1, 0, 1)); + t1 = gmx_mm256_unpack128lo_pd(t2, z1); /* - z1b | y1b x1b */ + z1 = gmx_mm256_unpack128hi_pd(t2, z1); /* - z1d | y1d x1d */ /* Construct a mask without executing any data loads */ mask = _mm256_castpd_si256(_mm256_blend_pd(_mm256_setzero_pd(), - _mm256_cmp_pd(_mm256_setzero_pd(),_mm256_setzero_pd(),_CMP_EQ_OQ),0x7)); + _mm256_cmp_pd(_mm256_setzero_pd(), _mm256_setzero_pd(), _CMP_EQ_OQ), 0x7)); tA = _mm256_loadu_pd(ptrA); tB = _mm256_loadu_pd(ptrB); tC = _mm256_loadu_pd(ptrC); tD = _mm256_loadu_pd(ptrD); - tA = _mm256_sub_pd(tA,x1); - tB = _mm256_sub_pd(tB,t1); - tC = _mm256_sub_pd(tC,y1); - tD = _mm256_sub_pd(tD,z1); + tA = _mm256_sub_pd(tA, x1); + tB = _mm256_sub_pd(tB, t1); + tC = _mm256_sub_pd(tC, y1); + tD = _mm256_sub_pd(tD, z1); - _mm256_maskstore_pd(ptrA,mask,tA); - _mm256_maskstore_pd(ptrB,mask,tB); - _mm256_maskstore_pd(ptrC,mask,tC); - _mm256_maskstore_pd(ptrD,mask,tD); + _mm256_maskstore_pd(ptrA, mask, tA); + _mm256_maskstore_pd(ptrB, mask, tB); + _mm256_maskstore_pd(ptrC, mask, tC); + _mm256_maskstore_pd(ptrD, mask, tD); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_decrement_3rvec_4ptr_swizzle_pd(ptrA,ptrB,ptrC,ptrD, \ - _x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{ \ - __m256d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10;\ - __m128d _tA,_tB,_tC,_tD,_tE;\ - _t1 = _mm256_loadu_pd(ptrA);\ - _t2 = _mm256_loadu_pd(ptrB);\ - _t3 = _mm256_loadu_pd(ptrC);\ - _t4 = _mm256_loadu_pd(ptrD);\ - _t5 = _mm256_loadu_pd(ptrA+4);\ - _t6 = _mm256_loadu_pd(ptrB+4);\ - _t7 = _mm256_loadu_pd(ptrC+4);\ - _t8 = _mm256_loadu_pd(ptrD+4);\ - _tA = _mm_load_sd(ptrA+8);\ - _tB = _mm_load_sd(ptrB+8);\ - _tC = _mm_load_sd(ptrC+8);\ - _tD = _mm_load_sd(ptrD+8);\ - _t9 = _mm256_unpacklo_pd(_x1,_y1);\ - _x1 = _mm256_unpackhi_pd(_x1,_y1);\ - _y1 = _mm256_unpacklo_pd(_z1,_x2);\ - _z1 = _mm256_unpackhi_pd(_z1,_x2);\ - _x2 = _mm256_unpacklo_pd(_y2,_z2);\ - _y2 = _mm256_unpackhi_pd(_y2,_z2);\ - _z2 = _mm256_unpacklo_pd(_x3,_y3);\ - _x3 = _mm256_unpackhi_pd(_x3,_y3);\ - _t10 = gmx_mm256_unpack128lo_pd(_t9,_y1);\ - _y3 = gmx_mm256_unpack128hi_pd(_t9,_y1);\ - _t9 = gmx_mm256_unpack128lo_pd(_x1,_z1);\ - _y1 = gmx_mm256_unpack128hi_pd(_x1,_z1);\ - _x1 = gmx_mm256_unpack128lo_pd(_x2,_z2);\ - _z1 = gmx_mm256_unpack128hi_pd(_x2,_z2);\ - _x2 = gmx_mm256_unpack128lo_pd(_y2,_x3);\ - _z2 = gmx_mm256_unpack128hi_pd(_y2,_x3);\ - _t1 = _mm256_sub_pd(_t1,_t10);\ - _t2 = _mm256_sub_pd(_t2,_t9);\ - _t3 = _mm256_sub_pd(_t3,_y3);\ - _t4 = _mm256_sub_pd(_t4,_y1);\ - _t5 = _mm256_sub_pd(_t5,_x1);\ - _t6 = _mm256_sub_pd(_t6,_x2);\ - _t7 = _mm256_sub_pd(_t7,_z1);\ - _t8 = _mm256_sub_pd(_t8,_z2);\ - _tA = _mm_sub_sd(_tA, _mm256_castpd256_pd128(_z3));\ - _tB = _mm_sub_sd(_tB, _mm_permute_pd(_mm256_castpd256_pd128(_z3),_GMX_MM_PERMUTE128D(1,1)));\ - _tE = _mm256_extractf128_pd(_z3,0x1);\ - _tC = _mm_sub_sd(_tC, _tE);\ - _tD = _mm_sub_sd(_tD, _mm_permute_pd(_tE,_GMX_MM_PERMUTE128D(1,1)));\ - _mm256_storeu_pd(ptrA,_t1);\ - _mm256_storeu_pd(ptrB,_t2);\ - _mm256_storeu_pd(ptrC,_t3);\ - _mm256_storeu_pd(ptrD,_t4);\ - _mm256_storeu_pd(ptrA+4,_t5);\ - _mm256_storeu_pd(ptrB+4,_t6);\ - _mm256_storeu_pd(ptrC+4,_t7);\ - _mm256_storeu_pd(ptrD+4,_t8);\ - _mm_store_sd(ptrA+8,_tA);\ - _mm_store_sd(ptrB+8,_tB);\ - _mm_store_sd(ptrC+8,_tC);\ - _mm_store_sd(ptrD+8,_tD);\ -} +#define gmx_mm256_decrement_3rvec_4ptr_swizzle_pd(ptrA, ptrB, ptrC, ptrD, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m256d _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \ + __m128d _tA, _tB, _tC, _tD, _tE; \ + _t1 = _mm256_loadu_pd(ptrA); \ + _t2 = _mm256_loadu_pd(ptrB); \ + _t3 = _mm256_loadu_pd(ptrC); \ + _t4 = _mm256_loadu_pd(ptrD); \ + _t5 = _mm256_loadu_pd(ptrA+4); \ + _t6 = _mm256_loadu_pd(ptrB+4); \ + _t7 = _mm256_loadu_pd(ptrC+4); \ + _t8 = _mm256_loadu_pd(ptrD+4); \ + _tA = _mm_load_sd(ptrA+8); \ + _tB = _mm_load_sd(ptrB+8); \ + _tC = _mm_load_sd(ptrC+8); \ + _tD = _mm_load_sd(ptrD+8); \ + _t9 = _mm256_unpacklo_pd(_x1, _y1); \ + _x1 = _mm256_unpackhi_pd(_x1, _y1); \ + _y1 = _mm256_unpacklo_pd(_z1, _x2); \ + _z1 = _mm256_unpackhi_pd(_z1, _x2); \ + _x2 = _mm256_unpacklo_pd(_y2, _z2); \ + _y2 = _mm256_unpackhi_pd(_y2, _z2); \ + _z2 = _mm256_unpacklo_pd(_x3, _y3); \ + _x3 = _mm256_unpackhi_pd(_x3, _y3); \ + _t10 = gmx_mm256_unpack128lo_pd(_t9, _y1); \ + _y3 = gmx_mm256_unpack128hi_pd(_t9, _y1); \ + _t9 = gmx_mm256_unpack128lo_pd(_x1, _z1); \ + _y1 = gmx_mm256_unpack128hi_pd(_x1, _z1); \ + _x1 = gmx_mm256_unpack128lo_pd(_x2, _z2); \ + _z1 = gmx_mm256_unpack128hi_pd(_x2, _z2); \ + _x2 = gmx_mm256_unpack128lo_pd(_y2, _x3); \ + _z2 = gmx_mm256_unpack128hi_pd(_y2, _x3); \ + _t1 = _mm256_sub_pd(_t1, _t10); \ + _t2 = _mm256_sub_pd(_t2, _t9); \ + _t3 = _mm256_sub_pd(_t3, _y3); \ + _t4 = _mm256_sub_pd(_t4, _y1); \ + _t5 = _mm256_sub_pd(_t5, _x1); \ + _t6 = _mm256_sub_pd(_t6, _x2); \ + _t7 = _mm256_sub_pd(_t7, _z1); \ + _t8 = _mm256_sub_pd(_t8, _z2); \ + _tA = _mm_sub_sd(_tA, _mm256_castpd256_pd128(_z3)); \ + _tB = _mm_sub_sd(_tB, _mm_permute_pd(_mm256_castpd256_pd128(_z3), _GMX_MM_PERMUTE128D(1, 1))); \ + _tE = _mm256_extractf128_pd(_z3, 0x1); \ + _tC = _mm_sub_sd(_tC, _tE); \ + _tD = _mm_sub_sd(_tD, _mm_permute_pd(_tE, _GMX_MM_PERMUTE128D(1, 1))); \ + _mm256_storeu_pd(ptrA, _t1); \ + _mm256_storeu_pd(ptrB, _t2); \ + _mm256_storeu_pd(ptrC, _t3); \ + _mm256_storeu_pd(ptrD, _t4); \ + _mm256_storeu_pd(ptrA+4, _t5); \ + _mm256_storeu_pd(ptrB+4, _t6); \ + _mm256_storeu_pd(ptrC+4, _t7); \ + _mm256_storeu_pd(ptrD+4, _t8); \ + _mm_store_sd(ptrA+8, _tA); \ + _mm_store_sd(ptrB+8, _tB); \ + _mm_store_sd(ptrC+8, _tC); \ + _mm_store_sd(ptrD+8, _tD); \ + } #else /* Real function for sane compilers */ static void gmx_mm256_decrement_3rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, - double * gmx_restrict ptrC, double * gmx_restrict ptrD, - __m256d x1, __m256d y1, __m256d z1, - __m256d x2, __m256d y2, __m256d z2, - __m256d x3, __m256d y3, __m256d z3) + double * gmx_restrict ptrC, double * gmx_restrict ptrD, + __m256d x1, __m256d y1, __m256d z1, + __m256d x2, __m256d y2, __m256d z2, + __m256d x3, __m256d y3, __m256d z3) { - __m256d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; - __m128d tA,tB,tC,tD,tE; + __m256d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; + __m128d tA, tB, tC, tD, tE; t1 = _mm256_loadu_pd(ptrA); t2 = _mm256_loadu_pd(ptrB); @@ -658,141 +658,141 @@ gmx_mm256_decrement_3rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * g tC = _mm_load_sd(ptrC+8); tD = _mm_load_sd(ptrD+8); - t9 = _mm256_unpacklo_pd(x1,y1); /* y1c x1c | y1a x1a */ - x1 = _mm256_unpackhi_pd(x1,y1); /* y1d x1d | y1b x1b */ + t9 = _mm256_unpacklo_pd(x1, y1); /* y1c x1c | y1a x1a */ + x1 = _mm256_unpackhi_pd(x1, y1); /* y1d x1d | y1b x1b */ - y1 = _mm256_unpacklo_pd(z1,x2); /* x2c z1c | x2a z1a */ - z1 = _mm256_unpackhi_pd(z1,x2); /* x2d z1d | x2b z1b */ + y1 = _mm256_unpacklo_pd(z1, x2); /* x2c z1c | x2a z1a */ + z1 = _mm256_unpackhi_pd(z1, x2); /* x2d z1d | x2b z1b */ - x2 = _mm256_unpacklo_pd(y2,z2); /* z2c y2c | z2a y2a */ - y2 = _mm256_unpackhi_pd(y2,z2); /* z2d y2d | z2b y2b */ + x2 = _mm256_unpacklo_pd(y2, z2); /* z2c y2c | z2a y2a */ + y2 = _mm256_unpackhi_pd(y2, z2); /* z2d y2d | z2b y2b */ - z2 = _mm256_unpacklo_pd(x3,y3); /* y3c x3c | y3a x3a */ - x3 = _mm256_unpackhi_pd(x3,y3); /* y3d x3d | y3b x3b */ + z2 = _mm256_unpacklo_pd(x3, y3); /* y3c x3c | y3a x3a */ + x3 = _mm256_unpackhi_pd(x3, y3); /* y3d x3d | y3b x3b */ - t10 = gmx_mm256_unpack128lo_pd(t9,y1); /* x2a z1a | y1a x1a */ - y3 = gmx_mm256_unpack128hi_pd(t9,y1); /* x2c z1c | y1c x1c */ + t10 = gmx_mm256_unpack128lo_pd(t9, y1); /* x2a z1a | y1a x1a */ + y3 = gmx_mm256_unpack128hi_pd(t9, y1); /* x2c z1c | y1c x1c */ - t9 = gmx_mm256_unpack128lo_pd(x1,z1); /* x2b z1b | y1b x1b */ - y1 = gmx_mm256_unpack128hi_pd(x1,z1); /* x2d z1d | y1d x1d */ + t9 = gmx_mm256_unpack128lo_pd(x1, z1); /* x2b z1b | y1b x1b */ + y1 = gmx_mm256_unpack128hi_pd(x1, z1); /* x2d z1d | y1d x1d */ - x1 = gmx_mm256_unpack128lo_pd(x2,z2); /* y3a x3a | z2a y2a */ - z1 = gmx_mm256_unpack128hi_pd(x2,z2); /* y3c x3c | z2c y2c */ + x1 = gmx_mm256_unpack128lo_pd(x2, z2); /* y3a x3a | z2a y2a */ + z1 = gmx_mm256_unpack128hi_pd(x2, z2); /* y3c x3c | z2c y2c */ - x2 = gmx_mm256_unpack128lo_pd(y2,x3); /* y3b x3b | z2b y2b */ - z2 = gmx_mm256_unpack128hi_pd(y2,x3); /* y3d x3d | z2d y2d */ + x2 = gmx_mm256_unpack128lo_pd(y2, x3); /* y3b x3b | z2b y2b */ + z2 = gmx_mm256_unpack128hi_pd(y2, x3); /* y3d x3d | z2d y2d */ - t1 = _mm256_sub_pd(t1,t10); - t2 = _mm256_sub_pd(t2,t9); - t3 = _mm256_sub_pd(t3,y3); - t4 = _mm256_sub_pd(t4,y1); - t5 = _mm256_sub_pd(t5,x1); - t6 = _mm256_sub_pd(t6,x2); - t7 = _mm256_sub_pd(t7,z1); - t8 = _mm256_sub_pd(t8,z2); + t1 = _mm256_sub_pd(t1, t10); + t2 = _mm256_sub_pd(t2, t9); + t3 = _mm256_sub_pd(t3, y3); + t4 = _mm256_sub_pd(t4, y1); + t5 = _mm256_sub_pd(t5, x1); + t6 = _mm256_sub_pd(t6, x2); + t7 = _mm256_sub_pd(t7, z1); + t8 = _mm256_sub_pd(t8, z2); tA = _mm_sub_sd(tA, _mm256_castpd256_pd128(z3)); - tB = _mm_sub_sd(tB, _mm_permute_pd(_mm256_castpd256_pd128(z3),_GMX_MM_PERMUTE128D(1,1))); - tE = _mm256_extractf128_pd(z3,0x1); + tB = _mm_sub_sd(tB, _mm_permute_pd(_mm256_castpd256_pd128(z3), _GMX_MM_PERMUTE128D(1, 1))); + tE = _mm256_extractf128_pd(z3, 0x1); tC = _mm_sub_sd(tC, tE); - tD = _mm_sub_sd(tD, _mm_permute_pd(tE,_GMX_MM_PERMUTE128D(1,1))); + tD = _mm_sub_sd(tD, _mm_permute_pd(tE, _GMX_MM_PERMUTE128D(1, 1))); /* Here we store a full 256-bit value and a separate 64-bit one; no overlap can happen */ - _mm256_storeu_pd(ptrA,t1); - _mm256_storeu_pd(ptrB,t2); - _mm256_storeu_pd(ptrC,t3); - _mm256_storeu_pd(ptrD,t4); - _mm256_storeu_pd(ptrA+4,t5); - _mm256_storeu_pd(ptrB+4,t6); - _mm256_storeu_pd(ptrC+4,t7); - _mm256_storeu_pd(ptrD+4,t8); - _mm_store_sd(ptrA+8,tA); - _mm_store_sd(ptrB+8,tB); - _mm_store_sd(ptrC+8,tC); - _mm_store_sd(ptrD+8,tD); + _mm256_storeu_pd(ptrA, t1); + _mm256_storeu_pd(ptrB, t2); + _mm256_storeu_pd(ptrC, t3); + _mm256_storeu_pd(ptrD, t4); + _mm256_storeu_pd(ptrA+4, t5); + _mm256_storeu_pd(ptrB+4, t6); + _mm256_storeu_pd(ptrC+4, t7); + _mm256_storeu_pd(ptrD+4, t8); + _mm_store_sd(ptrA+8, tA); + _mm_store_sd(ptrB+8, tB); + _mm_store_sd(ptrC+8, tC); + _mm_store_sd(ptrD+8, tD); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(ptrA,ptrB,ptrC,ptrD, \ - _x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{ \ - __m256d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11,_t12,_t13,_t14;\ - __m128d _tA,_tB,_tC,_tD,_tE;\ - _t1 = _mm256_loadu_pd(ptrA);\ - _t2 = _mm256_loadu_pd(ptrB);\ - _t3 = _mm256_loadu_pd(ptrC);\ - _t4 = _mm256_loadu_pd(ptrD);\ - _t5 = _mm256_loadu_pd(ptrA+4);\ - _t6 = _mm256_loadu_pd(ptrB+4);\ - _t7 = _mm256_loadu_pd(ptrC+4);\ - _t8 = _mm256_loadu_pd(ptrD+4);\ - _t9 = _mm256_loadu_pd(ptrA+8);\ - _t10 = _mm256_loadu_pd(ptrB+8);\ - _t11 = _mm256_loadu_pd(ptrC+8);\ - _t12 = _mm256_loadu_pd(ptrD+8);\ - _t13 = _mm256_unpacklo_pd(_x1,_y1);\ - _x1 = _mm256_unpackhi_pd(_x1,_y1);\ - _y1 = _mm256_unpacklo_pd(_z1,_x2);\ - _z1 = _mm256_unpackhi_pd(_z1,_x2);\ - _x2 = _mm256_unpacklo_pd(_y2,_z2);\ - _y2 = _mm256_unpackhi_pd(_y2,_z2);\ - _z2 = _mm256_unpacklo_pd(_x3,_y3);\ - _x3 = _mm256_unpackhi_pd(_x3,_y3);\ - _y3 = _mm256_unpacklo_pd(_z3,_x4);\ - _z3 = _mm256_unpackhi_pd(_z3,_x4);\ - _x4 = _mm256_unpacklo_pd(_y4,_z4);\ - _y4 = _mm256_unpackhi_pd(_y4,_z4);\ - _z4 = gmx_mm256_unpack128lo_pd(_t13,_y1);\ - _t13 = gmx_mm256_unpack128hi_pd(_t13,_y1);\ - _y1 = gmx_mm256_unpack128lo_pd(_x1,_z1);\ - _x1 = gmx_mm256_unpack128hi_pd(_x1,_z1);\ - _z1 = gmx_mm256_unpack128lo_pd(_x2,_z2);\ - _x2 = gmx_mm256_unpack128hi_pd(_x2,_z2);\ - _z2 = gmx_mm256_unpack128lo_pd(_y2,_x3);\ - _y2 = gmx_mm256_unpack128hi_pd(_y2,_x3);\ - _x3 = gmx_mm256_unpack128lo_pd(_y3,_x4);\ - _y3 = gmx_mm256_unpack128hi_pd(_y3,_x4);\ - _x4 = gmx_mm256_unpack128lo_pd(_z3,_y4);\ - _z3 = gmx_mm256_unpack128hi_pd(_z3,_y4);\ - _t1 = _mm256_sub_pd(_t1,_z4);\ - _t2 = _mm256_sub_pd(_t2,_y1);\ - _t3 = _mm256_sub_pd(_t3,_t13);\ - _t4 = _mm256_sub_pd(_t4,_x1);\ - _t5 = _mm256_sub_pd(_t5,_z1);\ - _t6 = _mm256_sub_pd(_t6,_z2);\ - _t7 = _mm256_sub_pd(_t7,_x2);\ - _t8 = _mm256_sub_pd(_t8,_y2);\ - _t9 = _mm256_sub_pd(_t9,_x3);\ - _t10 = _mm256_sub_pd(_t10,_x4);\ - _t11 = _mm256_sub_pd(_t11,_y3);\ - _t12 = _mm256_sub_pd(_t12,_z3);\ - _mm256_storeu_pd(ptrA,_t1);\ - _mm256_storeu_pd(ptrB,_t2);\ - _mm256_storeu_pd(ptrC,_t3);\ - _mm256_storeu_pd(ptrD,_t4);\ - _mm256_storeu_pd(ptrA+4,_t5);\ - _mm256_storeu_pd(ptrB+4,_t6);\ - _mm256_storeu_pd(ptrC+4,_t7);\ - _mm256_storeu_pd(ptrD+4,_t8);\ - _mm256_storeu_pd(ptrA+8,_t9);\ - _mm256_storeu_pd(ptrB+8,_t10);\ - _mm256_storeu_pd(ptrC+8,_t11);\ - _mm256_storeu_pd(ptrD+8,_t12);\ -} +#define gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(ptrA, ptrB, ptrC, ptrD, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m256d _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11, _t12, _t13, _t14; \ + __m128d _tA, _tB, _tC, _tD, _tE; \ + _t1 = _mm256_loadu_pd(ptrA); \ + _t2 = _mm256_loadu_pd(ptrB); \ + _t3 = _mm256_loadu_pd(ptrC); \ + _t4 = _mm256_loadu_pd(ptrD); \ + _t5 = _mm256_loadu_pd(ptrA+4); \ + _t6 = _mm256_loadu_pd(ptrB+4); \ + _t7 = _mm256_loadu_pd(ptrC+4); \ + _t8 = _mm256_loadu_pd(ptrD+4); \ + _t9 = _mm256_loadu_pd(ptrA+8); \ + _t10 = _mm256_loadu_pd(ptrB+8); \ + _t11 = _mm256_loadu_pd(ptrC+8); \ + _t12 = _mm256_loadu_pd(ptrD+8); \ + _t13 = _mm256_unpacklo_pd(_x1, _y1); \ + _x1 = _mm256_unpackhi_pd(_x1, _y1); \ + _y1 = _mm256_unpacklo_pd(_z1, _x2); \ + _z1 = _mm256_unpackhi_pd(_z1, _x2); \ + _x2 = _mm256_unpacklo_pd(_y2, _z2); \ + _y2 = _mm256_unpackhi_pd(_y2, _z2); \ + _z2 = _mm256_unpacklo_pd(_x3, _y3); \ + _x3 = _mm256_unpackhi_pd(_x3, _y3); \ + _y3 = _mm256_unpacklo_pd(_z3, _x4); \ + _z3 = _mm256_unpackhi_pd(_z3, _x4); \ + _x4 = _mm256_unpacklo_pd(_y4, _z4); \ + _y4 = _mm256_unpackhi_pd(_y4, _z4); \ + _z4 = gmx_mm256_unpack128lo_pd(_t13, _y1); \ + _t13 = gmx_mm256_unpack128hi_pd(_t13, _y1); \ + _y1 = gmx_mm256_unpack128lo_pd(_x1, _z1); \ + _x1 = gmx_mm256_unpack128hi_pd(_x1, _z1); \ + _z1 = gmx_mm256_unpack128lo_pd(_x2, _z2); \ + _x2 = gmx_mm256_unpack128hi_pd(_x2, _z2); \ + _z2 = gmx_mm256_unpack128lo_pd(_y2, _x3); \ + _y2 = gmx_mm256_unpack128hi_pd(_y2, _x3); \ + _x3 = gmx_mm256_unpack128lo_pd(_y3, _x4); \ + _y3 = gmx_mm256_unpack128hi_pd(_y3, _x4); \ + _x4 = gmx_mm256_unpack128lo_pd(_z3, _y4); \ + _z3 = gmx_mm256_unpack128hi_pd(_z3, _y4); \ + _t1 = _mm256_sub_pd(_t1, _z4); \ + _t2 = _mm256_sub_pd(_t2, _y1); \ + _t3 = _mm256_sub_pd(_t3, _t13); \ + _t4 = _mm256_sub_pd(_t4, _x1); \ + _t5 = _mm256_sub_pd(_t5, _z1); \ + _t6 = _mm256_sub_pd(_t6, _z2); \ + _t7 = _mm256_sub_pd(_t7, _x2); \ + _t8 = _mm256_sub_pd(_t8, _y2); \ + _t9 = _mm256_sub_pd(_t9, _x3); \ + _t10 = _mm256_sub_pd(_t10, _x4); \ + _t11 = _mm256_sub_pd(_t11, _y3); \ + _t12 = _mm256_sub_pd(_t12, _z3); \ + _mm256_storeu_pd(ptrA, _t1); \ + _mm256_storeu_pd(ptrB, _t2); \ + _mm256_storeu_pd(ptrC, _t3); \ + _mm256_storeu_pd(ptrD, _t4); \ + _mm256_storeu_pd(ptrA+4, _t5); \ + _mm256_storeu_pd(ptrB+4, _t6); \ + _mm256_storeu_pd(ptrC+4, _t7); \ + _mm256_storeu_pd(ptrD+4, _t8); \ + _mm256_storeu_pd(ptrA+8, _t9); \ + _mm256_storeu_pd(ptrB+8, _t10); \ + _mm256_storeu_pd(ptrC+8, _t11); \ + _mm256_storeu_pd(ptrD+8, _t12); \ + } #else /* Real function for sane compilers */ static void gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, - double * gmx_restrict ptrC, double * gmx_restrict ptrD, - __m256d x1, __m256d y1, __m256d z1, - __m256d x2, __m256d y2, __m256d z2, - __m256d x3, __m256d y3, __m256d z3, - __m256d x4, __m256d y4, __m256d z4) + double * gmx_restrict ptrC, double * gmx_restrict ptrD, + __m256d x1, __m256d y1, __m256d z1, + __m256d x2, __m256d y2, __m256d z2, + __m256d x3, __m256d y3, __m256d z3, + __m256d x4, __m256d y4, __m256d z4) { - __m256d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14; - __m128d tA,tB,tC,tD,tE; + __m256d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14; + __m128d tA, tB, tC, tD, tE; t1 = _mm256_loadu_pd(ptrA); t2 = _mm256_loadu_pd(ptrB); @@ -807,58 +807,58 @@ gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * g t11 = _mm256_loadu_pd(ptrC+8); t12 = _mm256_loadu_pd(ptrD+8); - t13 = _mm256_unpacklo_pd(x1,y1); /* y1c x1c | y1a x1a */ - x1 = _mm256_unpackhi_pd(x1,y1); /* y1d x1d | y1b x1b */ - y1 = _mm256_unpacklo_pd(z1,x2); /* x2c z1c | x2a z1a */ - z1 = _mm256_unpackhi_pd(z1,x2); /* x2d z1d | x2b z1b */ - x2 = _mm256_unpacklo_pd(y2,z2); /* z2c y2c | z2a y2a */ - y2 = _mm256_unpackhi_pd(y2,z2); /* z2d y2d | z2b y2b */ - z2 = _mm256_unpacklo_pd(x3,y3); /* y3c x3c | y3a x3a */ - x3 = _mm256_unpackhi_pd(x3,y3); /* y3d x3d | y3b x3b */ - y3 = _mm256_unpacklo_pd(z3,x4); /* x4c z3c | x4a z3a */ - z3 = _mm256_unpackhi_pd(z3,x4); /* x4d z3d | x4b z3b */ - x4 = _mm256_unpacklo_pd(y4,z4); /* z4c y4c | z4a y4a */ - y4 = _mm256_unpackhi_pd(y4,z4); /* z4d y4d | z4b y4b */ - - z4 = gmx_mm256_unpack128lo_pd(t13,y1); /* x2a z1a | y1a x1a */ - t13 = gmx_mm256_unpack128hi_pd(t13,y1); /* x2c z1c | y1c x1c */ - y1 = gmx_mm256_unpack128lo_pd(x1,z1); /* x2b z1b | y1b x1b */ - x1 = gmx_mm256_unpack128hi_pd(x1,z1); /* x2d z1d | y1d x1d */ - z1 = gmx_mm256_unpack128lo_pd(x2,z2); /* y3a x3a | z2a y2a */ - x2 = gmx_mm256_unpack128hi_pd(x2,z2); /* y3c x3c | z2c y2c */ - z2 = gmx_mm256_unpack128lo_pd(y2,x3); /* y3b x3b | z2b y2b */ - y2 = gmx_mm256_unpack128hi_pd(y2,x3); /* y3d x3d | z2d y2d */ - x3 = gmx_mm256_unpack128lo_pd(y3,x4); /* z4a y4a | x4a z3a */ - y3 = gmx_mm256_unpack128hi_pd(y3,x4); /* z4c y4c | x4c z3c */ - x4 = gmx_mm256_unpack128lo_pd(z3,y4); /* z4b y4b | x4b z3b */ - z3 = gmx_mm256_unpack128hi_pd(z3,y4); /* z4d y4d | x4d z3d */ - - t1 = _mm256_sub_pd(t1,z4); - t2 = _mm256_sub_pd(t2,y1); - t3 = _mm256_sub_pd(t3,t13); - t4 = _mm256_sub_pd(t4,x1); - t5 = _mm256_sub_pd(t5,z1); - t6 = _mm256_sub_pd(t6,z2); - t7 = _mm256_sub_pd(t7,x2); - t8 = _mm256_sub_pd(t8,y2); - t9 = _mm256_sub_pd(t9,x3); - t10 = _mm256_sub_pd(t10,x4); - t11 = _mm256_sub_pd(t11,y3); - t12 = _mm256_sub_pd(t12,z3); + t13 = _mm256_unpacklo_pd(x1, y1); /* y1c x1c | y1a x1a */ + x1 = _mm256_unpackhi_pd(x1, y1); /* y1d x1d | y1b x1b */ + y1 = _mm256_unpacklo_pd(z1, x2); /* x2c z1c | x2a z1a */ + z1 = _mm256_unpackhi_pd(z1, x2); /* x2d z1d | x2b z1b */ + x2 = _mm256_unpacklo_pd(y2, z2); /* z2c y2c | z2a y2a */ + y2 = _mm256_unpackhi_pd(y2, z2); /* z2d y2d | z2b y2b */ + z2 = _mm256_unpacklo_pd(x3, y3); /* y3c x3c | y3a x3a */ + x3 = _mm256_unpackhi_pd(x3, y3); /* y3d x3d | y3b x3b */ + y3 = _mm256_unpacklo_pd(z3, x4); /* x4c z3c | x4a z3a */ + z3 = _mm256_unpackhi_pd(z3, x4); /* x4d z3d | x4b z3b */ + x4 = _mm256_unpacklo_pd(y4, z4); /* z4c y4c | z4a y4a */ + y4 = _mm256_unpackhi_pd(y4, z4); /* z4d y4d | z4b y4b */ + + z4 = gmx_mm256_unpack128lo_pd(t13, y1); /* x2a z1a | y1a x1a */ + t13 = gmx_mm256_unpack128hi_pd(t13, y1); /* x2c z1c | y1c x1c */ + y1 = gmx_mm256_unpack128lo_pd(x1, z1); /* x2b z1b | y1b x1b */ + x1 = gmx_mm256_unpack128hi_pd(x1, z1); /* x2d z1d | y1d x1d */ + z1 = gmx_mm256_unpack128lo_pd(x2, z2); /* y3a x3a | z2a y2a */ + x2 = gmx_mm256_unpack128hi_pd(x2, z2); /* y3c x3c | z2c y2c */ + z2 = gmx_mm256_unpack128lo_pd(y2, x3); /* y3b x3b | z2b y2b */ + y2 = gmx_mm256_unpack128hi_pd(y2, x3); /* y3d x3d | z2d y2d */ + x3 = gmx_mm256_unpack128lo_pd(y3, x4); /* z4a y4a | x4a z3a */ + y3 = gmx_mm256_unpack128hi_pd(y3, x4); /* z4c y4c | x4c z3c */ + x4 = gmx_mm256_unpack128lo_pd(z3, y4); /* z4b y4b | x4b z3b */ + z3 = gmx_mm256_unpack128hi_pd(z3, y4); /* z4d y4d | x4d z3d */ + + t1 = _mm256_sub_pd(t1, z4); + t2 = _mm256_sub_pd(t2, y1); + t3 = _mm256_sub_pd(t3, t13); + t4 = _mm256_sub_pd(t4, x1); + t5 = _mm256_sub_pd(t5, z1); + t6 = _mm256_sub_pd(t6, z2); + t7 = _mm256_sub_pd(t7, x2); + t8 = _mm256_sub_pd(t8, y2); + t9 = _mm256_sub_pd(t9, x3); + t10 = _mm256_sub_pd(t10, x4); + t11 = _mm256_sub_pd(t11, y3); + t12 = _mm256_sub_pd(t12, z3); /* Here we store a full 256-bit value and a separate 128-bit one; no overlap can happen */ - _mm256_storeu_pd(ptrA,t1); - _mm256_storeu_pd(ptrB,t2); - _mm256_storeu_pd(ptrC,t3); - _mm256_storeu_pd(ptrD,t4); - _mm256_storeu_pd(ptrA+4,t5); - _mm256_storeu_pd(ptrB+4,t6); - _mm256_storeu_pd(ptrC+4,t7); - _mm256_storeu_pd(ptrD+4,t8); - _mm256_storeu_pd(ptrA+8,t9); - _mm256_storeu_pd(ptrB+8,t10); - _mm256_storeu_pd(ptrC+8,t11); - _mm256_storeu_pd(ptrD+8,t12); + _mm256_storeu_pd(ptrA, t1); + _mm256_storeu_pd(ptrB, t2); + _mm256_storeu_pd(ptrC, t3); + _mm256_storeu_pd(ptrD, t4); + _mm256_storeu_pd(ptrA+4, t5); + _mm256_storeu_pd(ptrB+4, t6); + _mm256_storeu_pd(ptrC+4, t7); + _mm256_storeu_pd(ptrD+4, t8); + _mm256_storeu_pd(ptrA+8, t9); + _mm256_storeu_pd(ptrB+8, t10); + _mm256_storeu_pd(ptrC+8, t11); + _mm256_storeu_pd(ptrD+8, t12); } #endif @@ -868,115 +868,115 @@ gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * g static gmx_inline void gmx_mm256_update_iforce_1atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz1, - double * gmx_restrict fptr, - double * gmx_restrict fshiftptr) + double * gmx_restrict fptr, + double * gmx_restrict fshiftptr) { - __m256d t1,t2; - __m128d tA,tB; - fix1 = _mm256_hadd_pd(fix1,fiy1); - fiz1 = _mm256_hadd_pd(fiz1,_mm256_setzero_pd()); + __m256d t1, t2; + __m128d tA, tB; + fix1 = _mm256_hadd_pd(fix1, fiy1); + fiz1 = _mm256_hadd_pd(fiz1, _mm256_setzero_pd()); /* Add across the two lanes */ - tA = _mm_add_pd(_mm256_castpd256_pd128(fix1),_mm256_extractf128_pd(fix1,0x1)); - tB = _mm_add_pd(_mm256_castpd256_pd128(fiz1),_mm256_extractf128_pd(fiz1,0x1)); + tA = _mm_add_pd(_mm256_castpd256_pd128(fix1), _mm256_extractf128_pd(fix1, 0x1)); + tB = _mm_add_pd(_mm256_castpd256_pd128(fiz1), _mm256_extractf128_pd(fiz1, 0x1)); - fix1 = gmx_mm256_set_m128d(tB,tA); /* 0 fiz fiy fix */ + fix1 = gmx_mm256_set_m128d(tB, tA); /* 0 fiz fiy fix */ t1 = _mm256_loadu_pd(fptr); t2 = _mm256_loadu_pd(fshiftptr); - t1 = _mm256_add_pd(t1,fix1); - t2 = _mm256_add_pd(t2,fix1); + t1 = _mm256_add_pd(t1, fix1); + t2 = _mm256_add_pd(t2, fix1); - _mm256_storeu_pd(fptr,t1); - _mm256_storeu_pd(fshiftptr,t2); + _mm256_storeu_pd(fptr, t1); + _mm256_storeu_pd(fshiftptr, t2); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \ - fptr,fshiftptr) \ -{ \ - __m256d _t1,_t2,_t3,_t4;\ - __m128d _tz3,_tA,_tB,_tC,_tD;\ - fix1 = _mm256_hadd_pd(fix1,fiy1);\ - fiz1 = _mm256_hadd_pd(fiz1,fix2);\ - fiy2 = _mm256_hadd_pd(fiy2,fiz2);\ - fix3 = _mm256_hadd_pd(fix3,fiy3);\ - fiz3 = _mm256_hadd_pd(fiz3,_mm256_setzero_pd());\ - _t1 = gmx_mm256_unpack128lo_pd(fix1,fiz1);\ - _t2 = gmx_mm256_unpack128hi_pd(fix1,fiz1);\ - _t1 = _mm256_add_pd(_t1,_t2);\ - _t3 = gmx_mm256_unpack128lo_pd(fiy2,fix3);\ - _t4 = gmx_mm256_unpack128hi_pd(fiy2,fix3);\ - _t3 = _mm256_add_pd(_t3,_t4);\ - _tz3 = _mm_add_pd(_mm256_castpd256_pd128(fiz3),_mm256_extractf128_pd(fiz3,0x1));\ - _t2 = _mm256_loadu_pd(fptr);\ - _t4 = _mm256_loadu_pd(fptr+4);\ - _tA = _mm_load_sd(fptr+8);\ - _t2 = _mm256_add_pd(_t2,_t1);\ - _t4 = _mm256_add_pd(_t4,_t3);\ - _tA = _mm_add_sd(_tA,_tz3);\ - _mm256_storeu_pd(fptr,_t2);\ - _mm256_storeu_pd(fptr+4,_t4);\ - _mm_store_sd(fptr+8,_tA);\ - _tB = _mm256_extractf128_pd(_t1,0x1);\ - _tC = _mm256_extractf128_pd(_t3,0x1);\ - _tz3 = _mm_add_sd(_tz3,_tB);\ - _tD = _mm_permute_pd(_mm256_castpd256_pd128(_t3),_GMX_MM_PERMUTE128D(1,1));\ - _tz3 = _mm_add_sd(_tz3,_tD);\ - _tC = _mm_add_pd(_tC,_mm256_castpd256_pd128(_t1));\ - _tD = _mm_shuffle_pd(_tB,_mm256_castpd256_pd128(_t3),_MM_SHUFFLE2(0,1));\ - _tC = _mm_add_pd(_tC,_tD);\ - _tA = _mm_loadu_pd(fshiftptr);\ - _tB = _mm_load_sd(fshiftptr+2);\ - _tA = _mm_add_pd(_tA,_tC);\ - _tB = _mm_add_sd(_tB,_tz3);\ - _mm_storeu_pd(fshiftptr,_tA);\ - _mm_store_sd(fshiftptr+2,_tB);\ -} +#define gmx_mm256_update_iforce_3atom_swizzle_pd(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \ + fptr, fshiftptr) \ + { \ + __m256d _t1, _t2, _t3, _t4; \ + __m128d _tz3, _tA, _tB, _tC, _tD; \ + fix1 = _mm256_hadd_pd(fix1, fiy1); \ + fiz1 = _mm256_hadd_pd(fiz1, fix2); \ + fiy2 = _mm256_hadd_pd(fiy2, fiz2); \ + fix3 = _mm256_hadd_pd(fix3, fiy3); \ + fiz3 = _mm256_hadd_pd(fiz3, _mm256_setzero_pd()); \ + _t1 = gmx_mm256_unpack128lo_pd(fix1, fiz1); \ + _t2 = gmx_mm256_unpack128hi_pd(fix1, fiz1); \ + _t1 = _mm256_add_pd(_t1, _t2); \ + _t3 = gmx_mm256_unpack128lo_pd(fiy2, fix3); \ + _t4 = gmx_mm256_unpack128hi_pd(fiy2, fix3); \ + _t3 = _mm256_add_pd(_t3, _t4); \ + _tz3 = _mm_add_pd(_mm256_castpd256_pd128(fiz3), _mm256_extractf128_pd(fiz3, 0x1)); \ + _t2 = _mm256_loadu_pd(fptr); \ + _t4 = _mm256_loadu_pd(fptr+4); \ + _tA = _mm_load_sd(fptr+8); \ + _t2 = _mm256_add_pd(_t2, _t1); \ + _t4 = _mm256_add_pd(_t4, _t3); \ + _tA = _mm_add_sd(_tA, _tz3); \ + _mm256_storeu_pd(fptr, _t2); \ + _mm256_storeu_pd(fptr+4, _t4); \ + _mm_store_sd(fptr+8, _tA); \ + _tB = _mm256_extractf128_pd(_t1, 0x1); \ + _tC = _mm256_extractf128_pd(_t3, 0x1); \ + _tz3 = _mm_add_sd(_tz3, _tB); \ + _tD = _mm_permute_pd(_mm256_castpd256_pd128(_t3), _GMX_MM_PERMUTE128D(1, 1)); \ + _tz3 = _mm_add_sd(_tz3, _tD); \ + _tC = _mm_add_pd(_tC, _mm256_castpd256_pd128(_t1)); \ + _tD = _mm_shuffle_pd(_tB, _mm256_castpd256_pd128(_t3), _MM_SHUFFLE2(0, 1)); \ + _tC = _mm_add_pd(_tC, _tD); \ + _tA = _mm_loadu_pd(fshiftptr); \ + _tB = _mm_load_sd(fshiftptr+2); \ + _tA = _mm_add_pd(_tA, _tC); \ + _tB = _mm_add_sd(_tB, _tz3); \ + _mm_storeu_pd(fshiftptr, _tA); \ + _mm_store_sd(fshiftptr+2, _tB); \ + } #else /* Real function for sane compilers */ static gmx_inline void gmx_mm256_update_iforce_3atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz1, - __m256d fix2, __m256d fiy2, __m256d fiz2, - __m256d fix3, __m256d fiy3, __m256d fiz3, - double * gmx_restrict fptr, - double * gmx_restrict fshiftptr) + __m256d fix2, __m256d fiy2, __m256d fiz2, + __m256d fix3, __m256d fiy3, __m256d fiz3, + double * gmx_restrict fptr, + double * gmx_restrict fshiftptr) { - __m256d t1,t2,t3,t4; - __m128d tz3,tA,tB,tC,tD; + __m256d t1, t2, t3, t4; + __m128d tz3, tA, tB, tC, tD; - fix1 = _mm256_hadd_pd(fix1,fiy1); /* Y1c-d X1c-d | Y1a-b X1a-b */ - fiz1 = _mm256_hadd_pd(fiz1,fix2); /* X2c-d Z1c-d | X2a-b Z1a-b */ - fiy2 = _mm256_hadd_pd(fiy2,fiz2); /* Z2c-d Y2c-d | Z2a-b Y2a-b */ - fix3 = _mm256_hadd_pd(fix3,fiy3); /* Y3c-d X3c-d | Y3a-b X3a-b */ - fiz3 = _mm256_hadd_pd(fiz3,_mm256_setzero_pd()); /* 0 Z3c-d | 0 Z3a-b */ + fix1 = _mm256_hadd_pd(fix1, fiy1); /* Y1c-d X1c-d | Y1a-b X1a-b */ + fiz1 = _mm256_hadd_pd(fiz1, fix2); /* X2c-d Z1c-d | X2a-b Z1a-b */ + fiy2 = _mm256_hadd_pd(fiy2, fiz2); /* Z2c-d Y2c-d | Z2a-b Y2a-b */ + fix3 = _mm256_hadd_pd(fix3, fiy3); /* Y3c-d X3c-d | Y3a-b X3a-b */ + fiz3 = _mm256_hadd_pd(fiz3, _mm256_setzero_pd()); /* 0 Z3c-d | 0 Z3a-b */ /* Add across the two lanes by swapping and adding back */ - t1 = gmx_mm256_unpack128lo_pd(fix1,fiz1); /* X2a-b Z1a-b | Y1a-b X1a-b */ - t2 = gmx_mm256_unpack128hi_pd(fix1,fiz1); /* X2c-d Z1c-d | Y1c-d X1c-d */ - t1 = _mm256_add_pd(t1,t2); /* x2 z1 | y1 x1 */ + t1 = gmx_mm256_unpack128lo_pd(fix1, fiz1); /* X2a-b Z1a-b | Y1a-b X1a-b */ + t2 = gmx_mm256_unpack128hi_pd(fix1, fiz1); /* X2c-d Z1c-d | Y1c-d X1c-d */ + t1 = _mm256_add_pd(t1, t2); /* x2 z1 | y1 x1 */ - t3 = gmx_mm256_unpack128lo_pd(fiy2,fix3); /* Y3a-b X3a-b | Z2a-b Y2a-b */ - t4 = gmx_mm256_unpack128hi_pd(fiy2,fix3); /* Y3c-d X3c-d | Z2c-d Y2c-d */ - t3 = _mm256_add_pd(t3,t4); /* y3 x3 | z2 y2 */ + t3 = gmx_mm256_unpack128lo_pd(fiy2, fix3); /* Y3a-b X3a-b | Z2a-b Y2a-b */ + t4 = gmx_mm256_unpack128hi_pd(fiy2, fix3); /* Y3c-d X3c-d | Z2c-d Y2c-d */ + t3 = _mm256_add_pd(t3, t4); /* y3 x3 | z2 y2 */ - tz3 = _mm_add_pd(_mm256_castpd256_pd128(fiz3),_mm256_extractf128_pd(fiz3,0x1)); /* 0 z3 */ + tz3 = _mm_add_pd(_mm256_castpd256_pd128(fiz3), _mm256_extractf128_pd(fiz3, 0x1)); /* 0 z3 */ t2 = _mm256_loadu_pd(fptr); t4 = _mm256_loadu_pd(fptr+4); tA = _mm_load_sd(fptr+8); - t2 = _mm256_add_pd(t2,t1); - t4 = _mm256_add_pd(t4,t3); - tA = _mm_add_sd(tA,tz3); + t2 = _mm256_add_pd(t2, t1); + t4 = _mm256_add_pd(t4, t3); + tA = _mm_add_sd(tA, tz3); - _mm256_storeu_pd(fptr,t2); - _mm256_storeu_pd(fptr+4,t4); - _mm_store_sd(fptr+8,tA); + _mm256_storeu_pd(fptr, t2); + _mm256_storeu_pd(fptr+4, t4); + _mm_store_sd(fptr+8, tA); /* Add up shift force */ /* t1: x2 z1 | y1 x1 */ @@ -984,119 +984,119 @@ gmx_mm256_update_iforce_3atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz /* tz3: 0 z3 */ /* z component */ - tB = _mm256_extractf128_pd(t1,0x1); /* x2 z1 */ - tC = _mm256_extractf128_pd(t3,0x1); /* y3 x3 */ - tz3 = _mm_add_sd(tz3,tB); /* 0 z1+z3 */ - tD = _mm_permute_pd(_mm256_castpd256_pd128(t3),_GMX_MM_PERMUTE128D(1,1)); - tz3 = _mm_add_sd(tz3,tD); /* - z */ + tB = _mm256_extractf128_pd(t1, 0x1); /* x2 z1 */ + tC = _mm256_extractf128_pd(t3, 0x1); /* y3 x3 */ + tz3 = _mm_add_sd(tz3, tB); /* 0 z1+z3 */ + tD = _mm_permute_pd(_mm256_castpd256_pd128(t3), _GMX_MM_PERMUTE128D(1, 1)); + tz3 = _mm_add_sd(tz3, tD); /* - z */ - tC = _mm_add_pd(tC,_mm256_castpd256_pd128(t1)); /* y1+y3 x1+x3 */ + tC = _mm_add_pd(tC, _mm256_castpd256_pd128(t1)); /* y1+y3 x1+x3 */ - tD = _mm_shuffle_pd(tB,_mm256_castpd256_pd128(t3),_MM_SHUFFLE2(0,1)); /* y2 x2 */ - tC = _mm_add_pd(tC,tD); /* y x */ + tD = _mm_shuffle_pd(tB, _mm256_castpd256_pd128(t3), _MM_SHUFFLE2(0, 1)); /* y2 x2 */ + tC = _mm_add_pd(tC, tD); /* y x */ tA = _mm_loadu_pd(fshiftptr); tB = _mm_load_sd(fshiftptr+2); - tA = _mm_add_pd(tA,tC); - tB = _mm_add_sd(tB,tz3); - _mm_storeu_pd(fshiftptr,tA); - _mm_store_sd(fshiftptr+2,tB); + tA = _mm_add_pd(tA, tC); + tB = _mm_add_sd(tB, tz3); + _mm_storeu_pd(fshiftptr, tA); + _mm_store_sd(fshiftptr+2, tB); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_update_iforce_4atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \ - fptr,fshiftptr) \ -{\ - __m256d _t1,_t2,_t3,_t4,_t5,_t6;\ - __m128d _tA,_tB,_tC,_tD;\ - fix1 = _mm256_hadd_pd(fix1,fiy1);\ - fiz1 = _mm256_hadd_pd(fiz1,fix2);\ - fiy2 = _mm256_hadd_pd(fiy2,fiz2);\ - fix3 = _mm256_hadd_pd(fix3,fiy3);\ - fiz3 = _mm256_hadd_pd(fiz3,fix4);\ - fiy4 = _mm256_hadd_pd(fiy4,fiz4);\ - _t1 = gmx_mm256_unpack128lo_pd(fix1,fiz1);\ - _t2 = gmx_mm256_unpack128hi_pd(fix1,fiz1);\ - _t1 = _mm256_add_pd(_t1,_t2);\ - _t3 = gmx_mm256_unpack128lo_pd(fiy2,fix3);\ - _t4 = gmx_mm256_unpack128hi_pd(fiy2,fix3);\ - _t3 = _mm256_add_pd(_t3,_t4);\ - _t5 = gmx_mm256_unpack128lo_pd(fiz3,fiy4);\ - _t6 = gmx_mm256_unpack128hi_pd(fiz3,fiy4);\ - _t5 = _mm256_add_pd(_t5,_t6);\ - _t2 = _mm256_loadu_pd(fptr);\ - _t4 = _mm256_loadu_pd(fptr+4);\ - _t6 = _mm256_loadu_pd(fptr+8);\ - _t2 = _mm256_add_pd(_t2,_t1);\ - _t4 = _mm256_add_pd(_t4,_t3);\ - _t6 = _mm256_add_pd(_t6,_t5);\ - _mm256_storeu_pd(fptr,_t2);\ - _mm256_storeu_pd(fptr+4,_t4);\ - _mm256_storeu_pd(fptr+8,_t6);\ - _tA = _mm256_extractf128_pd(_t1,0x1);\ - _tB = _mm256_extractf128_pd(_t3,0x1);\ - _tC = _mm256_extractf128_pd(_t5,0x1);\ - _tB = _mm_add_pd(_tB,_mm256_castpd256_pd128(_t1));\ - _tA = _mm_add_pd(_tA,_mm256_castpd256_pd128(_t5));\ - _tC = _mm_add_pd(_tC,_mm256_castpd256_pd128(_t3));\ - _tD = _mm_shuffle_pd(_tA,_tC,_MM_SHUFFLE2(0,1));\ - _tB = _mm_add_pd(_tB,_tD);\ - _tC = _mm_permute_pd(_tC,_GMX_MM_PERMUTE128D(1,1));\ - _tC = _mm_add_sd(_tC,_tA);\ - _tA = _mm_loadu_pd(fshiftptr);\ - _tD = _mm_load_sd(fshiftptr+2);\ - _tA = _mm_add_pd(_tA,_tB);\ - _tD = _mm_add_sd(_tD,_tC);\ - _mm_storeu_pd(fshiftptr,_tA);\ - _mm_store_sd(fshiftptr+2,_tD);\ -} +#define gmx_mm256_update_iforce_4atom_swizzle_pd(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \ + fptr, fshiftptr) \ + { \ + __m256d _t1, _t2, _t3, _t4, _t5, _t6; \ + __m128d _tA, _tB, _tC, _tD; \ + fix1 = _mm256_hadd_pd(fix1, fiy1); \ + fiz1 = _mm256_hadd_pd(fiz1, fix2); \ + fiy2 = _mm256_hadd_pd(fiy2, fiz2); \ + fix3 = _mm256_hadd_pd(fix3, fiy3); \ + fiz3 = _mm256_hadd_pd(fiz3, fix4); \ + fiy4 = _mm256_hadd_pd(fiy4, fiz4); \ + _t1 = gmx_mm256_unpack128lo_pd(fix1, fiz1); \ + _t2 = gmx_mm256_unpack128hi_pd(fix1, fiz1); \ + _t1 = _mm256_add_pd(_t1, _t2); \ + _t3 = gmx_mm256_unpack128lo_pd(fiy2, fix3); \ + _t4 = gmx_mm256_unpack128hi_pd(fiy2, fix3); \ + _t3 = _mm256_add_pd(_t3, _t4); \ + _t5 = gmx_mm256_unpack128lo_pd(fiz3, fiy4); \ + _t6 = gmx_mm256_unpack128hi_pd(fiz3, fiy4); \ + _t5 = _mm256_add_pd(_t5, _t6); \ + _t2 = _mm256_loadu_pd(fptr); \ + _t4 = _mm256_loadu_pd(fptr+4); \ + _t6 = _mm256_loadu_pd(fptr+8); \ + _t2 = _mm256_add_pd(_t2, _t1); \ + _t4 = _mm256_add_pd(_t4, _t3); \ + _t6 = _mm256_add_pd(_t6, _t5); \ + _mm256_storeu_pd(fptr, _t2); \ + _mm256_storeu_pd(fptr+4, _t4); \ + _mm256_storeu_pd(fptr+8, _t6); \ + _tA = _mm256_extractf128_pd(_t1, 0x1); \ + _tB = _mm256_extractf128_pd(_t3, 0x1); \ + _tC = _mm256_extractf128_pd(_t5, 0x1); \ + _tB = _mm_add_pd(_tB, _mm256_castpd256_pd128(_t1)); \ + _tA = _mm_add_pd(_tA, _mm256_castpd256_pd128(_t5)); \ + _tC = _mm_add_pd(_tC, _mm256_castpd256_pd128(_t3)); \ + _tD = _mm_shuffle_pd(_tA, _tC, _MM_SHUFFLE2(0, 1)); \ + _tB = _mm_add_pd(_tB, _tD); \ + _tC = _mm_permute_pd(_tC, _GMX_MM_PERMUTE128D(1, 1)); \ + _tC = _mm_add_sd(_tC, _tA); \ + _tA = _mm_loadu_pd(fshiftptr); \ + _tD = _mm_load_sd(fshiftptr+2); \ + _tA = _mm_add_pd(_tA, _tB); \ + _tD = _mm_add_sd(_tD, _tC); \ + _mm_storeu_pd(fshiftptr, _tA); \ + _mm_store_sd(fshiftptr+2, _tD); \ + } #else /* Real function for sane compilers */ static gmx_inline void gmx_mm256_update_iforce_4atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz1, - __m256d fix2, __m256d fiy2, __m256d fiz2, - __m256d fix3, __m256d fiy3, __m256d fiz3, - __m256d fix4, __m256d fiy4, __m256d fiz4, - double * gmx_restrict fptr, - double * gmx_restrict fshiftptr) + __m256d fix2, __m256d fiy2, __m256d fiz2, + __m256d fix3, __m256d fiy3, __m256d fiz3, + __m256d fix4, __m256d fiy4, __m256d fiz4, + double * gmx_restrict fptr, + double * gmx_restrict fshiftptr) { - __m256d t1,t2,t3,t4,t5,t6; - __m128d tA,tB,tC,tD; + __m256d t1, t2, t3, t4, t5, t6; + __m128d tA, tB, tC, tD; - fix1 = _mm256_hadd_pd(fix1,fiy1); /* Y1c-d X1c-d | Y1a-b X1a-b */ - fiz1 = _mm256_hadd_pd(fiz1,fix2); /* X2c-d Z1c-d | X2a-b Z1a-b */ - fiy2 = _mm256_hadd_pd(fiy2,fiz2); /* Z2c-d Y2c-d | Z2a-b Y2a-b */ - fix3 = _mm256_hadd_pd(fix3,fiy3); /* Y3c-d X3c-d | Y3a-b X3a-b */ - fiz3 = _mm256_hadd_pd(fiz3,fix4); /* X4c-d Z3c-d | X4a-b Z3a-b */ - fiy4 = _mm256_hadd_pd(fiy4,fiz4); /* Z4c-d Y4c-d | Z4a-b Y4a-b */ + fix1 = _mm256_hadd_pd(fix1, fiy1); /* Y1c-d X1c-d | Y1a-b X1a-b */ + fiz1 = _mm256_hadd_pd(fiz1, fix2); /* X2c-d Z1c-d | X2a-b Z1a-b */ + fiy2 = _mm256_hadd_pd(fiy2, fiz2); /* Z2c-d Y2c-d | Z2a-b Y2a-b */ + fix3 = _mm256_hadd_pd(fix3, fiy3); /* Y3c-d X3c-d | Y3a-b X3a-b */ + fiz3 = _mm256_hadd_pd(fiz3, fix4); /* X4c-d Z3c-d | X4a-b Z3a-b */ + fiy4 = _mm256_hadd_pd(fiy4, fiz4); /* Z4c-d Y4c-d | Z4a-b Y4a-b */ /* Add across the two lanes by swapping and adding back */ - t1 = gmx_mm256_unpack128lo_pd(fix1,fiz1); /* X2a-b Z1a-b | Y1a-b X1a-b */ - t2 = gmx_mm256_unpack128hi_pd(fix1,fiz1); /* X2c-d Z1c-d | Y1c-d X1c-d */ - t1 = _mm256_add_pd(t1,t2); /* x2 z1 | y1 x1 */ + t1 = gmx_mm256_unpack128lo_pd(fix1, fiz1); /* X2a-b Z1a-b | Y1a-b X1a-b */ + t2 = gmx_mm256_unpack128hi_pd(fix1, fiz1); /* X2c-d Z1c-d | Y1c-d X1c-d */ + t1 = _mm256_add_pd(t1, t2); /* x2 z1 | y1 x1 */ - t3 = gmx_mm256_unpack128lo_pd(fiy2,fix3); /* Y3a-b X3a-b | Z2a-b Y2a-b */ - t4 = gmx_mm256_unpack128hi_pd(fiy2,fix3); /* Y3c-d X3c-d | Z2c-d Y2c-d */ - t3 = _mm256_add_pd(t3,t4); /* y3 x3 | z2 y2 */ + t3 = gmx_mm256_unpack128lo_pd(fiy2, fix3); /* Y3a-b X3a-b | Z2a-b Y2a-b */ + t4 = gmx_mm256_unpack128hi_pd(fiy2, fix3); /* Y3c-d X3c-d | Z2c-d Y2c-d */ + t3 = _mm256_add_pd(t3, t4); /* y3 x3 | z2 y2 */ - t5 = gmx_mm256_unpack128lo_pd(fiz3,fiy4); /* Z4a-b Y4a-b | X4a-b Z3a-b */ - t6 = gmx_mm256_unpack128hi_pd(fiz3,fiy4); /* Z4c-d Y4c-d | X4c-d Z3c-d */ - t5 = _mm256_add_pd(t5,t6); /* z4 y4 | x4 z3 */ + t5 = gmx_mm256_unpack128lo_pd(fiz3, fiy4); /* Z4a-b Y4a-b | X4a-b Z3a-b */ + t6 = gmx_mm256_unpack128hi_pd(fiz3, fiy4); /* Z4c-d Y4c-d | X4c-d Z3c-d */ + t5 = _mm256_add_pd(t5, t6); /* z4 y4 | x4 z3 */ t2 = _mm256_loadu_pd(fptr); t4 = _mm256_loadu_pd(fptr+4); t6 = _mm256_loadu_pd(fptr+8); - t2 = _mm256_add_pd(t2,t1); - t4 = _mm256_add_pd(t4,t3); - t6 = _mm256_add_pd(t6,t5); + t2 = _mm256_add_pd(t2, t1); + t4 = _mm256_add_pd(t4, t3); + t6 = _mm256_add_pd(t6, t5); - _mm256_storeu_pd(fptr,t2); - _mm256_storeu_pd(fptr+4,t4); - _mm256_storeu_pd(fptr+8,t6); + _mm256_storeu_pd(fptr, t2); + _mm256_storeu_pd(fptr+4, t4); + _mm256_storeu_pd(fptr+8, t6); /* Add up shift force */ /* t1: x2. z1. | y1. x1. */ @@ -1104,25 +1104,25 @@ gmx_mm256_update_iforce_4atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz /* t5: z4 y4 | x4. z3. */ /* z component */ - tA = _mm256_extractf128_pd(t1,0x1); /* x2 z1 */ - tB = _mm256_extractf128_pd(t3,0x1); /* y3 x3 */ - tC = _mm256_extractf128_pd(t5,0x1); /* z4 y4 */ + tA = _mm256_extractf128_pd(t1, 0x1); /* x2 z1 */ + tB = _mm256_extractf128_pd(t3, 0x1); /* y3 x3 */ + tC = _mm256_extractf128_pd(t5, 0x1); /* z4 y4 */ - tB = _mm_add_pd(tB,_mm256_castpd256_pd128(t1)); /* y1+y3 x1+x3 */ - tA = _mm_add_pd(tA,_mm256_castpd256_pd128(t5)); /* x2+x4 z1+z3 */ - tC = _mm_add_pd(tC,_mm256_castpd256_pd128(t3)); /* z4+z2 y4+y2 */ + tB = _mm_add_pd(tB, _mm256_castpd256_pd128(t1)); /* y1+y3 x1+x3 */ + tA = _mm_add_pd(tA, _mm256_castpd256_pd128(t5)); /* x2+x4 z1+z3 */ + tC = _mm_add_pd(tC, _mm256_castpd256_pd128(t3)); /* z4+z2 y4+y2 */ - tD = _mm_shuffle_pd(tA,tC,_MM_SHUFFLE2(0,1)); /* y4+y2 x2+x4 */ - tB = _mm_add_pd(tB,tD); /* y x */ - tC = _mm_permute_pd(tC,_GMX_MM_PERMUTE128D(1,1)); /* - z4+z2 */ - tC = _mm_add_sd(tC,tA); /* - z */ + tD = _mm_shuffle_pd(tA, tC, _MM_SHUFFLE2(0, 1)); /* y4+y2 x2+x4 */ + tB = _mm_add_pd(tB, tD); /* y x */ + tC = _mm_permute_pd(tC, _GMX_MM_PERMUTE128D(1, 1)); /* - z4+z2 */ + tC = _mm_add_sd(tC, tA); /* - z */ tA = _mm_loadu_pd(fshiftptr); tD = _mm_load_sd(fshiftptr+2); - tA = _mm_add_pd(tA,tB); - tD = _mm_add_sd(tD,tC); - _mm_storeu_pd(fshiftptr,tA); - _mm_store_sd(fshiftptr+2,tD); + tA = _mm_add_pd(tA, tB); + tD = _mm_add_sd(tD, tC); + _mm_storeu_pd(fshiftptr, tA); + _mm_store_sd(fshiftptr+2, tD); } #endif @@ -1133,26 +1133,26 @@ gmx_mm256_update_1pot_pd(__m256d pot1, double * gmx_restrict ptrA) { __m128d t1; - pot1 = _mm256_hadd_pd(pot1,pot1); + pot1 = _mm256_hadd_pd(pot1, pot1); - t1 = _mm_add_pd(_mm256_castpd256_pd128(pot1),_mm256_extractf128_pd(pot1,0x1)); + t1 = _mm_add_pd(_mm256_castpd256_pd128(pot1), _mm256_extractf128_pd(pot1, 0x1)); - _mm_store_sd(ptrA,_mm_add_sd(_mm_load_sd(ptrA),t1)); + _mm_store_sd(ptrA, _mm_add_sd(_mm_load_sd(ptrA), t1)); } static void gmx_mm256_update_2pot_pd(__m256d pot1, double * gmx_restrict ptrA, __m256d pot2, double * gmx_restrict ptrB) { - __m128d t1,t2; + __m128d t1, t2; - pot1 = _mm256_hadd_pd(pot1,pot2); + pot1 = _mm256_hadd_pd(pot1, pot2); - t1 = _mm_add_pd(_mm256_castpd256_pd128(pot1),_mm256_extractf128_pd(pot1,0x1)); + t1 = _mm_add_pd(_mm256_castpd256_pd128(pot1), _mm256_extractf128_pd(pot1, 0x1)); - t2 = _mm_permute_pd(t1,_GMX_MM_PERMUTE128D(1,1)); - _mm_store_sd(ptrA,_mm_add_sd(_mm_load_sd(ptrA),t1)); - _mm_store_sd(ptrB,_mm_add_sd(_mm_load_sd(ptrB),t2)); + t2 = _mm_permute_pd(t1, _GMX_MM_PERMUTE128D(1, 1)); + _mm_store_sd(ptrA, _mm_add_sd(_mm_load_sd(ptrA), t1)); + _mm_store_sd(ptrB, _mm_add_sd(_mm_load_sd(ptrB), t2)); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.c index a887b3b9e4..9fef448af5 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.c @@ -241,7 +241,7 @@ nb_kernel_t nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_avx_256_double; nb_kernel_info_t -kernellist_avx_256_double[] = + kernellist_avx_256_double[] = { { nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_256_double, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_256_double", "avx_256_double", "None", "None", "LennardJones", "None", "ParticleParticle", "", "PotentialAndForce" }, { nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_256_double, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_256_double", "avx_256_double", "None", "None", "LennardJones", "None", "ParticleParticle", "", "Force" }, @@ -460,6 +460,6 @@ kernellist_avx_256_double[] = }; int -kernellist_avx_256_double_size = sizeof(kernellist_avx_256_double)/sizeof(kernellist_avx_256_double[0]); + kernellist_avx_256_double_size = sizeof(kernellist_avx_256_double)/sizeof(kernellist_avx_256_double[0]); #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.h index 4a7ac0245e..f0543b7c68 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_double/nb_kernel_avx_256_double.h @@ -27,10 +27,10 @@ /* List of kernels for this architecture with metadata about them */ extern nb_kernel_info_t -kernellist_avx_256_double[]; + kernellist_avx_256_double[]; /* Length of kernellist_c */ extern int -kernellist_avx_256_double_size; + kernellist_avx_256_double_size; #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/kernelutil_x86_avx_256_single.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/kernelutil_x86_avx_256_single.h index f3a1f6740a..bb52ea1c97 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/kernelutil_x86_avx_256_single.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/kernelutil_x86_avx_256_single.h @@ -32,34 +32,34 @@ #include "gmx_x86_avx_256.h" /* Transpose lower/upper half of 256-bit registers separately */ -#define GMX_MM256_HALFTRANSPOSE4_PS(ymm0,ymm1,ymm2,ymm3) { \ - __m256 __tmp0,__tmp1,__tmp2,__tmp3; \ +#define GMX_MM256_HALFTRANSPOSE4_PS(ymm0, ymm1, ymm2, ymm3) { \ + __m256 __tmp0, __tmp1, __tmp2, __tmp3; \ \ - __tmp0 = _mm256_unpacklo_ps((ymm0),(ymm1)); \ - __tmp1 = _mm256_unpacklo_ps((ymm2),(ymm3)); \ - __tmp2 = _mm256_unpackhi_ps((ymm0),(ymm1)); \ - __tmp3 = _mm256_unpackhi_ps((ymm2),(ymm3)); \ - ymm0 = _mm256_shuffle_ps(__tmp0,__tmp1,_MM_SHUFFLE(1,0,1,0)); \ - ymm1 = _mm256_shuffle_ps(__tmp0,__tmp1,_MM_SHUFFLE(3,2,3,2)); \ - ymm2 = _mm256_shuffle_ps(__tmp2,__tmp3,_MM_SHUFFLE(1,0,1,0)); \ - ymm3 = _mm256_shuffle_ps(__tmp2,__tmp3,_MM_SHUFFLE(3,2,3,2)); \ + __tmp0 = _mm256_unpacklo_ps((ymm0), (ymm1)); \ + __tmp1 = _mm256_unpacklo_ps((ymm2), (ymm3)); \ + __tmp2 = _mm256_unpackhi_ps((ymm0), (ymm1)); \ + __tmp3 = _mm256_unpackhi_ps((ymm2), (ymm3)); \ + ymm0 = _mm256_shuffle_ps(__tmp0, __tmp1, _MM_SHUFFLE(1, 0, 1, 0)); \ + ymm1 = _mm256_shuffle_ps(__tmp0, __tmp1, _MM_SHUFFLE(3, 2, 3, 2)); \ + ymm2 = _mm256_shuffle_ps(__tmp2, __tmp3, _MM_SHUFFLE(1, 0, 1, 0)); \ + ymm3 = _mm256_shuffle_ps(__tmp2, __tmp3, _MM_SHUFFLE(3, 2, 3, 2)); \ } static gmx_inline __m256 gmx_mm256_calc_rsq_ps(__m256 dx, __m256 dy, __m256 dz) { - return _mm256_add_ps( _mm256_add_ps( _mm256_mul_ps(dx,dx), _mm256_mul_ps(dy,dy) ), _mm256_mul_ps(dz,dz) ); + return _mm256_add_ps( _mm256_add_ps( _mm256_mul_ps(dx, dx), _mm256_mul_ps(dy, dy) ), _mm256_mul_ps(dz, dz) ); } /* Normal sum of four ymm registers */ -#define gmx_mm256_sum4_ps(t0,t1,t2,t3) _mm256_add_ps(_mm256_add_ps(t0,t1),_mm256_add_ps(t2,t3)) +#define gmx_mm256_sum4_ps(t0, t1, t2, t3) _mm256_add_ps(_mm256_add_ps(t0, t1), _mm256_add_ps(t2, t3)) static gmx_inline int gmx_mm256_any_lt(__m256 a, __m256 b) { - return _mm256_movemask_ps(_mm256_cmp_ps(a,b,_CMP_LT_OQ)); + return _mm256_movemask_ps(_mm256_cmp_ps(a, b, _CMP_LT_OQ)); } @@ -67,11 +67,11 @@ static gmx_inline __m256 gmx_mm256_load_4real_swizzle_ps(const float * gmx_restrict ptrA, const float * gmx_restrict ptrB, const float * gmx_restrict ptrC, const float * gmx_restrict ptrD) { - __m128 t1,t2; + __m128 t1, t2; - t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA),_mm_load_ss(ptrC)); - t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB),_mm_load_ss(ptrD)); - return _mm256_castps128_ps256(_mm_unpacklo_ps(t1,t2)); + t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA), _mm_load_ss(ptrC)); + t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB), _mm_load_ss(ptrD)); + return _mm256_castps128_ps256(_mm_unpacklo_ps(t1, t2)); } @@ -81,12 +81,12 @@ gmx_mm256_load_8real_swizzle_ps(const float * gmx_restrict ptrA, const float * g const float * gmx_restrict ptrE, const float * gmx_restrict ptrF, const float * gmx_restrict ptrG, const float * gmx_restrict ptrH) { - __m256 t1,t2; + __m256 t1, t2; - t1 = gmx_mm256_load_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD); - t2 = gmx_mm256_load_4real_swizzle_ps(ptrE,ptrF,ptrG,ptrH); + t1 = gmx_mm256_load_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD); + t2 = gmx_mm256_load_4real_swizzle_ps(ptrE, ptrF, ptrG, ptrH); - return _mm256_permute2f128_ps(t1,t2,0x20); + return _mm256_permute2f128_ps(t1, t2, 0x20); } @@ -95,15 +95,15 @@ static gmx_inline void gmx_mm256_store_4real_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, float * gmx_restrict ptrC, float * gmx_restrict ptrD, __m256 xmm1) { - __m256 t2,t3,t4; - - t2 = _mm256_permute_ps(xmm1,_MM_SHUFFLE(1,1,1,1)); - t3 = _mm256_permute_ps(xmm1,_MM_SHUFFLE(2,2,2,2)); - t4 = _mm256_permute_ps(xmm1,_MM_SHUFFLE(3,3,3,3)); - _mm_store_ss(ptrA,_mm256_castps256_ps128(xmm1)); - _mm_store_ss(ptrB,_mm256_castps256_ps128(t2)); - _mm_store_ss(ptrC,_mm256_castps256_ps128(t3)); - _mm_store_ss(ptrD,_mm256_castps256_ps128(t4)); + __m256 t2, t3, t4; + + t2 = _mm256_permute_ps(xmm1, _MM_SHUFFLE(1, 1, 1, 1)); + t3 = _mm256_permute_ps(xmm1, _MM_SHUFFLE(2, 2, 2, 2)); + t4 = _mm256_permute_ps(xmm1, _MM_SHUFFLE(3, 3, 3, 3)); + _mm_store_ss(ptrA, _mm256_castps256_ps128(xmm1)); + _mm_store_ss(ptrB, _mm256_castps256_ps128(t2)); + _mm_store_ss(ptrC, _mm256_castps256_ps128(t3)); + _mm_store_ss(ptrD, _mm256_castps256_ps128(t4)); } @@ -115,10 +115,10 @@ gmx_mm256_store_8real_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict { __m256 t1; - t1 = _mm256_permute2f128_ps(xmm1,xmm1,0x11); + t1 = _mm256_permute2f128_ps(xmm1, xmm1, 0x11); - gmx_mm256_store_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD,xmm1); - gmx_mm256_store_4real_swizzle_ps(ptrE,ptrF,ptrG,ptrH,t1); + gmx_mm256_store_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD, xmm1); + gmx_mm256_store_4real_swizzle_ps(ptrE, ptrF, ptrG, ptrH, t1); } @@ -127,22 +127,22 @@ gmx_mm256_increment_4real_swizzle_ps(float * gmx_restrict ptrA, float * gmx_rest float * gmx_restrict ptrC, float * gmx_restrict ptrD, __m256 xmm1) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = _mm256_castps256_ps128(xmm1); - t2 = _mm_permute_ps(t1,_MM_SHUFFLE(1,1,1,1)); - t3 = _mm_permute_ps(t1,_MM_SHUFFLE(2,2,2,2)); - t4 = _mm_permute_ps(t1,_MM_SHUFFLE(3,3,3,3)); - - t1 = _mm_add_ss(t1,_mm_load_ss(ptrA)); - t2 = _mm_add_ss(t2,_mm_load_ss(ptrB)); - t3 = _mm_add_ss(t3,_mm_load_ss(ptrC)); - t4 = _mm_add_ss(t4,_mm_load_ss(ptrD)); - - _mm_store_ss(ptrA,t1); - _mm_store_ss(ptrB,t2); - _mm_store_ss(ptrC,t3); - _mm_store_ss(ptrD,t4); + t2 = _mm_permute_ps(t1, _MM_SHUFFLE(1, 1, 1, 1)); + t3 = _mm_permute_ps(t1, _MM_SHUFFLE(2, 2, 2, 2)); + t4 = _mm_permute_ps(t1, _MM_SHUFFLE(3, 3, 3, 3)); + + t1 = _mm_add_ss(t1, _mm_load_ss(ptrA)); + t2 = _mm_add_ss(t2, _mm_load_ss(ptrB)); + t3 = _mm_add_ss(t3, _mm_load_ss(ptrC)); + t4 = _mm_add_ss(t4, _mm_load_ss(ptrD)); + + _mm_store_ss(ptrA, t1); + _mm_store_ss(ptrB, t2); + _mm_store_ss(ptrC, t3); + _mm_store_ss(ptrD, t4); } static gmx_inline void @@ -154,10 +154,10 @@ gmx_mm256_increment_8real_swizzle_ps(float * gmx_restrict ptrA, float * gmx_rest { __m256 t1; - t1 = _mm256_permute2f128_ps(xmm1,xmm1,0x11); + t1 = _mm256_permute2f128_ps(xmm1, xmm1, 0x11); - gmx_mm256_increment_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD,xmm1); - gmx_mm256_increment_4real_swizzle_ps(ptrE,ptrF,ptrG,ptrH,t1); + gmx_mm256_increment_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD, xmm1); + gmx_mm256_increment_4real_swizzle_ps(ptrE, ptrF, ptrG, ptrH, t1); } @@ -166,18 +166,18 @@ gmx_mm256_load_4pair_swizzle_ps(const float * gmx_restrict p1, const float * gmx const float * gmx_restrict p3, const float * gmx_restrict p4, __m256 * gmx_restrict c6, __m256 * gmx_restrict c12) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; - t1 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p1); /* - - c12a c6a */ - t2 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p2); /* - - c12b c6b */ - t3 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p3); /* - - c12c c6c */ - t4 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p4); /* - - c12d c6d */ + t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p1); /* - - c12a c6a */ + t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p2); /* - - c12b c6b */ + t3 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p3); /* - - c12c c6c */ + t4 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p4); /* - - c12d c6d */ - t1 = _mm_unpacklo_ps(t1,t2); /* c12b c12a c6b c6a */ - t3 = _mm_unpacklo_ps(t3,t4); /* c12d c12c c6d c6c */ + t1 = _mm_unpacklo_ps(t1, t2); /* c12b c12a c6b c6a */ + t3 = _mm_unpacklo_ps(t3, t4); /* c12d c12c c6d c6c */ - *c6 = _mm256_castps128_ps256(_mm_shuffle_ps(t1,t3,_MM_SHUFFLE(1,0,1,0))); - *c12 = _mm256_castps128_ps256(_mm_shuffle_ps(t1,t3,_MM_SHUFFLE(3,2,3,2))); + *c6 = _mm256_castps128_ps256(_mm_shuffle_ps(t1, t3, _MM_SHUFFLE(1, 0, 1, 0))); + *c12 = _mm256_castps128_ps256(_mm_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 2, 3, 2))); } static gmx_inline void @@ -187,142 +187,142 @@ gmx_mm256_load_8pair_swizzle_ps(const float * gmx_restrict p1, const float * gmx const float * gmx_restrict p7, const float * gmx_restrict p8, __m256 * gmx_restrict c6, __m256 * gmx_restrict c12) { - __m256 c6l,c6h,c12l,c12h; + __m256 c6l, c6h, c12l, c12h; - gmx_mm256_load_4pair_swizzle_ps(p1,p2,p3,p4,&c6l,&c12l); - gmx_mm256_load_4pair_swizzle_ps(p5,p6,p7,p8,&c6h,&c12h); + gmx_mm256_load_4pair_swizzle_ps(p1, p2, p3, p4, &c6l, &c12l); + gmx_mm256_load_4pair_swizzle_ps(p5, p6, p7, p8, &c6h, &c12h); - *c6 = _mm256_permute2f128_ps(c6l,c6h,0x20); - *c12 = _mm256_permute2f128_ps(c12l,c12h,0x20); + *c6 = _mm256_permute2f128_ps(c6l, c6h, 0x20); + *c12 = _mm256_permute2f128_ps(c12l, c12h, 0x20); } static gmx_inline void gmx_mm256_load_shift_and_1rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m256 * gmx_restrict x1, - __m256 * gmx_restrict y1, - __m256 * gmx_restrict z1) + const float * gmx_restrict xyz, + __m256 * gmx_restrict x1, + __m256 * gmx_restrict y1, + __m256 * gmx_restrict z1) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; - t1 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); - t2 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz); + t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); + t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz); t3 = _mm_load_ss(xyz_shift+2); t4 = _mm_load_ss(xyz+2); - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ss(t3,t4); + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ss(t3, t4); - t2 = _mm_permute_ps(t1,_MM_SHUFFLE(1,1,1,1)); - t1 = _mm_permute_ps(t1,_MM_SHUFFLE(0,0,0,0)); - t3 = _mm_permute_ps(t3,_MM_SHUFFLE(0,0,0,0)); + t2 = _mm_permute_ps(t1, _MM_SHUFFLE(1, 1, 1, 1)); + t1 = _mm_permute_ps(t1, _MM_SHUFFLE(0, 0, 0, 0)); + t3 = _mm_permute_ps(t3, _MM_SHUFFLE(0, 0, 0, 0)); - *x1 = gmx_mm256_set_m128(t1,t1); - *y1 = gmx_mm256_set_m128(t2,t2); - *z1 = gmx_mm256_set_m128(t3,t3); + *x1 = gmx_mm256_set_m128(t1, t1); + *y1 = gmx_mm256_set_m128(t2, t2); + *z1 = gmx_mm256_set_m128(t3, t3); } static gmx_inline void gmx_mm256_load_shift_and_3rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m256 * gmx_restrict x1, __m256 * gmx_restrict y1, __m256 * gmx_restrict z1, - __m256 * gmx_restrict x2, __m256 * gmx_restrict y2, __m256 * gmx_restrict z2, - __m256 * gmx_restrict x3, __m256 * gmx_restrict y3, __m256 * gmx_restrict z3) + const float * gmx_restrict xyz, + __m256 * gmx_restrict x1, __m256 * gmx_restrict y1, __m256 * gmx_restrict z1, + __m256 * gmx_restrict x2, __m256 * gmx_restrict y2, __m256 * gmx_restrict z2, + __m256 * gmx_restrict x3, __m256 * gmx_restrict y3, __m256 * gmx_restrict z3) { - __m128 tA,tB; - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9; + __m128 tA, tB; + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9; - tA = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); + tA = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); tB = _mm_load_ss(xyz_shift+2); t1 = _mm_loadu_ps(xyz); t2 = _mm_loadu_ps(xyz+4); t3 = _mm_load_ss(xyz+8); - tA = _mm_movelh_ps(tA,tB); - t4 = _mm_permute_ps(tA,_MM_SHUFFLE(0,2,1,0)); - t5 = _mm_permute_ps(tA,_MM_SHUFFLE(1,0,2,1)); - t6 = _mm_permute_ps(tA,_MM_SHUFFLE(2,1,0,2)); - - t1 = _mm_add_ps(t1,t4); - t2 = _mm_add_ps(t2,t5); - t3 = _mm_add_ss(t3,t6); - - t9 = _mm_permute_ps(t3,_MM_SHUFFLE(0,0,0,0)); - t8 = _mm_permute_ps(t2,_MM_SHUFFLE(3,3,3,3)); - t7 = _mm_permute_ps(t2,_MM_SHUFFLE(2,2,2,2)); - t6 = _mm_permute_ps(t2,_MM_SHUFFLE(1,1,1,1)); - t5 = _mm_permute_ps(t2,_MM_SHUFFLE(0,0,0,0)); - t4 = _mm_permute_ps(t1,_MM_SHUFFLE(3,3,3,3)); - t3 = _mm_permute_ps(t1,_MM_SHUFFLE(2,2,2,2)); - t2 = _mm_permute_ps(t1,_MM_SHUFFLE(1,1,1,1)); - t1 = _mm_permute_ps(t1,_MM_SHUFFLE(0,0,0,0)); - - *x1 = gmx_mm256_set_m128(t1,t1); - *y1 = gmx_mm256_set_m128(t2,t2); - *z1 = gmx_mm256_set_m128(t3,t3); - *x2 = gmx_mm256_set_m128(t4,t4); - *y2 = gmx_mm256_set_m128(t5,t5); - *z2 = gmx_mm256_set_m128(t6,t6); - *x3 = gmx_mm256_set_m128(t7,t7); - *y3 = gmx_mm256_set_m128(t8,t8); - *z3 = gmx_mm256_set_m128(t9,t9); + tA = _mm_movelh_ps(tA, tB); + t4 = _mm_permute_ps(tA, _MM_SHUFFLE(0, 2, 1, 0)); + t5 = _mm_permute_ps(tA, _MM_SHUFFLE(1, 0, 2, 1)); + t6 = _mm_permute_ps(tA, _MM_SHUFFLE(2, 1, 0, 2)); + + t1 = _mm_add_ps(t1, t4); + t2 = _mm_add_ps(t2, t5); + t3 = _mm_add_ss(t3, t6); + + t9 = _mm_permute_ps(t3, _MM_SHUFFLE(0, 0, 0, 0)); + t8 = _mm_permute_ps(t2, _MM_SHUFFLE(3, 3, 3, 3)); + t7 = _mm_permute_ps(t2, _MM_SHUFFLE(2, 2, 2, 2)); + t6 = _mm_permute_ps(t2, _MM_SHUFFLE(1, 1, 1, 1)); + t5 = _mm_permute_ps(t2, _MM_SHUFFLE(0, 0, 0, 0)); + t4 = _mm_permute_ps(t1, _MM_SHUFFLE(3, 3, 3, 3)); + t3 = _mm_permute_ps(t1, _MM_SHUFFLE(2, 2, 2, 2)); + t2 = _mm_permute_ps(t1, _MM_SHUFFLE(1, 1, 1, 1)); + t1 = _mm_permute_ps(t1, _MM_SHUFFLE(0, 0, 0, 0)); + + *x1 = gmx_mm256_set_m128(t1, t1); + *y1 = gmx_mm256_set_m128(t2, t2); + *z1 = gmx_mm256_set_m128(t3, t3); + *x2 = gmx_mm256_set_m128(t4, t4); + *y2 = gmx_mm256_set_m128(t5, t5); + *z2 = gmx_mm256_set_m128(t6, t6); + *x3 = gmx_mm256_set_m128(t7, t7); + *y3 = gmx_mm256_set_m128(t8, t8); + *z3 = gmx_mm256_set_m128(t9, t9); } static gmx_inline void gmx_mm256_load_shift_and_4rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m256 * gmx_restrict x1, __m256 * gmx_restrict y1, __m256 * gmx_restrict z1, - __m256 * gmx_restrict x2, __m256 * gmx_restrict y2, __m256 * gmx_restrict z2, - __m256 * gmx_restrict x3, __m256 * gmx_restrict y3, __m256 * gmx_restrict z3, - __m256 * gmx_restrict x4, __m256 * gmx_restrict y4, __m256 * gmx_restrict z4) + const float * gmx_restrict xyz, + __m256 * gmx_restrict x1, __m256 * gmx_restrict y1, __m256 * gmx_restrict z1, + __m256 * gmx_restrict x2, __m256 * gmx_restrict y2, __m256 * gmx_restrict z2, + __m256 * gmx_restrict x3, __m256 * gmx_restrict y3, __m256 * gmx_restrict z3, + __m256 * gmx_restrict x4, __m256 * gmx_restrict y4, __m256 * gmx_restrict z4) { - __m128 tA,tB; - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; + __m128 tA, tB; + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; - tA = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); + tA = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); tB = _mm_load_ss(xyz_shift+2); t1 = _mm_loadu_ps(xyz); t2 = _mm_loadu_ps(xyz+4); t3 = _mm_loadu_ps(xyz+8); - tA = _mm_movelh_ps(tA,tB); - t4 = _mm_permute_ps(tA,_MM_SHUFFLE(0,2,1,0)); - t5 = _mm_permute_ps(tA,_MM_SHUFFLE(1,0,2,1)); - t6 = _mm_permute_ps(tA,_MM_SHUFFLE(2,1,0,2)); - - t1 = _mm_add_ps(t1,t4); - t2 = _mm_add_ps(t2,t5); - t3 = _mm_add_ps(t3,t6); - - t12 = _mm_permute_ps(t3,_MM_SHUFFLE(3,3,3,3)); - t11 = _mm_permute_ps(t3,_MM_SHUFFLE(2,2,2,2)); - t10 = _mm_permute_ps(t3,_MM_SHUFFLE(1,1,1,1)); - t9 = _mm_permute_ps(t3,_MM_SHUFFLE(0,0,0,0)); - t8 = _mm_permute_ps(t2,_MM_SHUFFLE(3,3,3,3)); - t7 = _mm_permute_ps(t2,_MM_SHUFFLE(2,2,2,2)); - t6 = _mm_permute_ps(t2,_MM_SHUFFLE(1,1,1,1)); - t5 = _mm_permute_ps(t2,_MM_SHUFFLE(0,0,0,0)); - t4 = _mm_permute_ps(t1,_MM_SHUFFLE(3,3,3,3)); - t3 = _mm_permute_ps(t1,_MM_SHUFFLE(2,2,2,2)); - t2 = _mm_permute_ps(t1,_MM_SHUFFLE(1,1,1,1)); - t1 = _mm_permute_ps(t1,_MM_SHUFFLE(0,0,0,0)); - - *x1 = gmx_mm256_set_m128(t1,t1); - *y1 = gmx_mm256_set_m128(t2,t2); - *z1 = gmx_mm256_set_m128(t3,t3); - *x2 = gmx_mm256_set_m128(t4,t4); - *y2 = gmx_mm256_set_m128(t5,t5); - *z2 = gmx_mm256_set_m128(t6,t6); - *x3 = gmx_mm256_set_m128(t7,t7); - *y3 = gmx_mm256_set_m128(t8,t8); - *z3 = gmx_mm256_set_m128(t9,t9); - *x4 = gmx_mm256_set_m128(t10,t10); - *y4 = gmx_mm256_set_m128(t11,t11); - *z4 = gmx_mm256_set_m128(t12,t12); + tA = _mm_movelh_ps(tA, tB); + t4 = _mm_permute_ps(tA, _MM_SHUFFLE(0, 2, 1, 0)); + t5 = _mm_permute_ps(tA, _MM_SHUFFLE(1, 0, 2, 1)); + t6 = _mm_permute_ps(tA, _MM_SHUFFLE(2, 1, 0, 2)); + + t1 = _mm_add_ps(t1, t4); + t2 = _mm_add_ps(t2, t5); + t3 = _mm_add_ps(t3, t6); + + t12 = _mm_permute_ps(t3, _MM_SHUFFLE(3, 3, 3, 3)); + t11 = _mm_permute_ps(t3, _MM_SHUFFLE(2, 2, 2, 2)); + t10 = _mm_permute_ps(t3, _MM_SHUFFLE(1, 1, 1, 1)); + t9 = _mm_permute_ps(t3, _MM_SHUFFLE(0, 0, 0, 0)); + t8 = _mm_permute_ps(t2, _MM_SHUFFLE(3, 3, 3, 3)); + t7 = _mm_permute_ps(t2, _MM_SHUFFLE(2, 2, 2, 2)); + t6 = _mm_permute_ps(t2, _MM_SHUFFLE(1, 1, 1, 1)); + t5 = _mm_permute_ps(t2, _MM_SHUFFLE(0, 0, 0, 0)); + t4 = _mm_permute_ps(t1, _MM_SHUFFLE(3, 3, 3, 3)); + t3 = _mm_permute_ps(t1, _MM_SHUFFLE(2, 2, 2, 2)); + t2 = _mm_permute_ps(t1, _MM_SHUFFLE(1, 1, 1, 1)); + t1 = _mm_permute_ps(t1, _MM_SHUFFLE(0, 0, 0, 0)); + + *x1 = gmx_mm256_set_m128(t1, t1); + *y1 = gmx_mm256_set_m128(t2, t2); + *z1 = gmx_mm256_set_m128(t3, t3); + *x2 = gmx_mm256_set_m128(t4, t4); + *y2 = gmx_mm256_set_m128(t5, t5); + *z2 = gmx_mm256_set_m128(t6, t6); + *x3 = gmx_mm256_set_m128(t7, t7); + *y3 = gmx_mm256_set_m128(t8, t8); + *z3 = gmx_mm256_set_m128(t9, t9); + *x4 = gmx_mm256_set_m128(t10, t10); + *y4 = gmx_mm256_set_m128(t11, t11); + *z4 = gmx_mm256_set_m128(t12, t12); } @@ -332,13 +332,13 @@ gmx_mm256_load_1rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa const float * gmx_restrict ptrC, const float * gmx_restrict ptrD, __m256 * gmx_restrict x1, __m256 * gmx_restrict y1, __m256 * gmx_restrict z1) { - __m128 t1,t2,t3,t4; - __m128i mask = _mm_set_epi32(0,-1,-1,-1); - t1 = gmx_mm_maskload_ps(ptrA,mask); - t2 = gmx_mm_maskload_ps(ptrB,mask); - t3 = gmx_mm_maskload_ps(ptrC,mask); - t4 = gmx_mm_maskload_ps(ptrD,mask); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + __m128 t1, t2, t3, t4; + __m128i mask = _mm_set_epi32(0, -1, -1, -1); + t1 = gmx_mm_maskload_ps(ptrA, mask); + t2 = gmx_mm_maskload_ps(ptrB, mask); + t3 = gmx_mm_maskload_ps(ptrC, mask); + t4 = gmx_mm_maskload_ps(ptrD, mask); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = _mm256_castps128_ps256(t1); *y1 = _mm256_castps128_ps256(t2); *z1 = _mm256_castps128_ps256(t3); @@ -352,12 +352,12 @@ gmx_mm256_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa __m256 * gmx_restrict x2, __m256 * gmx_restrict y2, __m256 * gmx_restrict z2, __m256 * gmx_restrict x3, __m256 * gmx_restrict y3, __m256 * gmx_restrict z3) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrB); t3 = _mm_loadu_ps(ptrC); t4 = _mm_loadu_ps(ptrD); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = _mm256_castps128_ps256(t1); *y1 = _mm256_castps128_ps256(t2); *z1 = _mm256_castps128_ps256(t3); @@ -366,7 +366,7 @@ gmx_mm256_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa t2 = _mm_loadu_ps(ptrB+4); t3 = _mm_loadu_ps(ptrC+4); t4 = _mm_loadu_ps(ptrD+4); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *y2 = _mm256_castps128_ps256(t1); *z2 = _mm256_castps128_ps256(t2); *x3 = _mm256_castps128_ps256(t3); @@ -375,9 +375,9 @@ gmx_mm256_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa t2 = _mm_load_ss(ptrB+8); t3 = _mm_load_ss(ptrC+8); t4 = _mm_load_ss(ptrD+8); - t1 = _mm_unpacklo_ps(t1,t3); - t3 = _mm_unpacklo_ps(t2,t4); - *z3 = _mm256_castps128_ps256(_mm_unpacklo_ps(t1,t3)); + t1 = _mm_unpacklo_ps(t1, t3); + t3 = _mm_unpacklo_ps(t2, t4); + *z3 = _mm256_castps128_ps256(_mm_unpacklo_ps(t1, t3)); } @@ -390,12 +390,12 @@ gmx_mm256_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa __m256 * gmx_restrict x3, __m256 * gmx_restrict y3, __m256 * gmx_restrict z3, __m256 * gmx_restrict x4, __m256 * gmx_restrict y4, __m256 * gmx_restrict z4) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrB); t3 = _mm_loadu_ps(ptrC); t4 = _mm_loadu_ps(ptrD); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = _mm256_castps128_ps256(t1); *y1 = _mm256_castps128_ps256(t2); *z1 = _mm256_castps128_ps256(t3); @@ -404,7 +404,7 @@ gmx_mm256_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa t2 = _mm_loadu_ps(ptrB+4); t3 = _mm_loadu_ps(ptrC+4); t4 = _mm_loadu_ps(ptrD+4); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *y2 = _mm256_castps128_ps256(t1); *z2 = _mm256_castps128_ps256(t2); *x3 = _mm256_castps128_ps256(t3); @@ -413,7 +413,7 @@ gmx_mm256_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa t2 = _mm_loadu_ps(ptrB+8); t3 = _mm_loadu_ps(ptrC+8); t4 = _mm_loadu_ps(ptrD+8); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *z3 = _mm256_castps128_ps256(t1); *x4 = _mm256_castps128_ps256(t2); *y4 = _mm256_castps128_ps256(t3); @@ -428,22 +428,22 @@ gmx_mm256_load_1rvec_8ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa const float * gmx_restrict ptrG, const float * gmx_restrict ptrH, __m256 * gmx_restrict x1, __m256 * gmx_restrict y1, __m256 * gmx_restrict z1) { - __m256 t1,t2,t3,t4,t5,t6,t7,t8; - __m128i mask = _mm_set_epi32(0,-1,-1,-1); - - t1 = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrE,mask),gmx_mm_maskload_ps(ptrA,mask)); /* - zE yE xE | - zA yA xA */ - t2 = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrF,mask),gmx_mm_maskload_ps(ptrB,mask)); /* - zF yF xF | - zB yB xB */ - t3 = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrG,mask),gmx_mm_maskload_ps(ptrC,mask)); /* - zG yG xG | - zC yC xC */ - t4 = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrH,mask),gmx_mm_maskload_ps(ptrD,mask)); /* - zH yH xH | - zD yD xD */ - - t5 = _mm256_unpacklo_ps(t1,t2); /* yF yE xF xE | yB yA xB xA */ - t6 = _mm256_unpacklo_ps(t3,t4); /* yH yG xH xG | yD yC xD xC */ - t7 = _mm256_unpackhi_ps(t1,t2); /* - - zF zE | - - zB zA */ - t8 = _mm256_unpackhi_ps(t3,t4); /* - - zH zG | - - zD zC */ - - *x1 = _mm256_shuffle_ps(t5,t6,_MM_SHUFFLE(1,0,1,0)); - *y1 = _mm256_shuffle_ps(t5,t6,_MM_SHUFFLE(3,2,3,2)); - *z1 = _mm256_shuffle_ps(t7,t8,_MM_SHUFFLE(1,0,1,0)); + __m256 t1, t2, t3, t4, t5, t6, t7, t8; + __m128i mask = _mm_set_epi32(0, -1, -1, -1); + + t1 = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrE, mask), gmx_mm_maskload_ps(ptrA, mask)); /* - zE yE xE | - zA yA xA */ + t2 = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrF, mask), gmx_mm_maskload_ps(ptrB, mask)); /* - zF yF xF | - zB yB xB */ + t3 = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrG, mask), gmx_mm_maskload_ps(ptrC, mask)); /* - zG yG xG | - zC yC xC */ + t4 = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrH, mask), gmx_mm_maskload_ps(ptrD, mask)); /* - zH yH xH | - zD yD xD */ + + t5 = _mm256_unpacklo_ps(t1, t2); /* yF yE xF xE | yB yA xB xA */ + t6 = _mm256_unpacklo_ps(t3, t4); /* yH yG xH xG | yD yC xD xC */ + t7 = _mm256_unpackhi_ps(t1, t2); /* - - zF zE | - - zB zA */ + t8 = _mm256_unpackhi_ps(t3, t4); /* - - zH zG | - - zD zC */ + + *x1 = _mm256_shuffle_ps(t5, t6, _MM_SHUFFLE(1, 0, 1, 0)); + *y1 = _mm256_shuffle_ps(t5, t6, _MM_SHUFFLE(3, 2, 3, 2)); + *z1 = _mm256_shuffle_ps(t7, t8, _MM_SHUFFLE(1, 0, 1, 0)); } @@ -456,35 +456,35 @@ gmx_mm256_load_3rvec_8ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa __m256 * gmx_restrict x2, __m256 * gmx_restrict y2, __m256 * gmx_restrict z2, __m256 * gmx_restrict x3, __m256 * gmx_restrict y3, __m256 * gmx_restrict z3) { - __m256 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - - t1 = _mm256_loadu_ps(ptrA); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ - t2 = _mm256_loadu_ps(ptrB); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ - t3 = _mm256_loadu_ps(ptrC); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ - t4 = _mm256_loadu_ps(ptrD); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ - t5 = _mm256_loadu_ps(ptrE); /* y3e x3e z2e y2e | x2e z1e y1e x1e */ - t6 = _mm256_loadu_ps(ptrF); /* y3f x3f z2f y2f | x2f z1f y1f x1f */ - t7 = _mm256_loadu_ps(ptrG); /* y3g x3g z2g y2g | x2g z1g y1g x1g */ - t8 = _mm256_loadu_ps(ptrH); /* y3h x3h z2h y2h | x2h z1h y1h x1h */ - - t9 = _mm256_unpacklo_ps(t1,t2); /* z2b z2a y2b y2a | y1b y1a x1b x1a */ - t10 = _mm256_unpackhi_ps(t1,t2); /* y3b y3a x3b x3a | x2b x2a z1b z1a */ - t11 = _mm256_unpacklo_ps(t3,t4); /* z2d z2c y2d y2c | y1d y1c x1d x1c */ - t12 = _mm256_unpackhi_ps(t3,t4); /* y3d y3c x3d x3c | x2d x2c z1d z1c */ - t1 = _mm256_unpacklo_ps(t5,t6); /* z2f z2e y2f y2e | y1f y1e x1f x1e */ - t2 = _mm256_unpackhi_ps(t5,t6); /* y3f y3e x3f x3e | x2f x2e z1f z1e */ - t3 = _mm256_unpacklo_ps(t7,t8); /* z2h z2g y2h y2g | y1h y1g x1h x1g */ - t4 = _mm256_unpackhi_ps(t7,t8); /* y3h y3g x3h x3g | x2h x2g z1h z1g */ - - t5 = _mm256_shuffle_ps(t9,t11,_MM_SHUFFLE(1,0,1,0)); /* y2d y2c y2b y2a | x1d x1c x1b x1a */ - t6 = _mm256_shuffle_ps(t9,t11,_MM_SHUFFLE(3,2,3,2)); /* z2d z2c z2b z2a | y1d y1c y1b y1a */ - t7 = _mm256_shuffle_ps(t10,t12,_MM_SHUFFLE(1,0,1,0)); /* x3d x3c x3b x3a | z1d z1c z1b z1a */ - t8 = _mm256_shuffle_ps(t10,t12,_MM_SHUFFLE(3,2,3,2)); /* y3d y3c y3b y3a | x2d x2c x2b x2a */ - - t9 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(1,0,1,0)); /* y2h y2g y2f y2e | x1h x1g x1f x1e */ - t10 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(3,2,3,2)); /* z2h z2g z2f z2e | y1h y1g y1f y1e */ - t11 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(1,0,1,0)); /* x3h x3g x3f x3e | z1h z1g z1f z1e */ - t12 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(3,2,3,2)); /* y3h y3g y3f y3e | x2h x2g x2f x2e */ + __m256 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + + t1 = _mm256_loadu_ps(ptrA); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ + t2 = _mm256_loadu_ps(ptrB); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ + t3 = _mm256_loadu_ps(ptrC); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ + t4 = _mm256_loadu_ps(ptrD); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ + t5 = _mm256_loadu_ps(ptrE); /* y3e x3e z2e y2e | x2e z1e y1e x1e */ + t6 = _mm256_loadu_ps(ptrF); /* y3f x3f z2f y2f | x2f z1f y1f x1f */ + t7 = _mm256_loadu_ps(ptrG); /* y3g x3g z2g y2g | x2g z1g y1g x1g */ + t8 = _mm256_loadu_ps(ptrH); /* y3h x3h z2h y2h | x2h z1h y1h x1h */ + + t9 = _mm256_unpacklo_ps(t1, t2); /* z2b z2a y2b y2a | y1b y1a x1b x1a */ + t10 = _mm256_unpackhi_ps(t1, t2); /* y3b y3a x3b x3a | x2b x2a z1b z1a */ + t11 = _mm256_unpacklo_ps(t3, t4); /* z2d z2c y2d y2c | y1d y1c x1d x1c */ + t12 = _mm256_unpackhi_ps(t3, t4); /* y3d y3c x3d x3c | x2d x2c z1d z1c */ + t1 = _mm256_unpacklo_ps(t5, t6); /* z2f z2e y2f y2e | y1f y1e x1f x1e */ + t2 = _mm256_unpackhi_ps(t5, t6); /* y3f y3e x3f x3e | x2f x2e z1f z1e */ + t3 = _mm256_unpacklo_ps(t7, t8); /* z2h z2g y2h y2g | y1h y1g x1h x1g */ + t4 = _mm256_unpackhi_ps(t7, t8); /* y3h y3g x3h x3g | x2h x2g z1h z1g */ + + t5 = _mm256_shuffle_ps(t9, t11, _MM_SHUFFLE(1, 0, 1, 0)); /* y2d y2c y2b y2a | x1d x1c x1b x1a */ + t6 = _mm256_shuffle_ps(t9, t11, _MM_SHUFFLE(3, 2, 3, 2)); /* z2d z2c z2b z2a | y1d y1c y1b y1a */ + t7 = _mm256_shuffle_ps(t10, t12, _MM_SHUFFLE(1, 0, 1, 0)); /* x3d x3c x3b x3a | z1d z1c z1b z1a */ + t8 = _mm256_shuffle_ps(t10, t12, _MM_SHUFFLE(3, 2, 3, 2)); /* y3d y3c y3b y3a | x2d x2c x2b x2a */ + + t9 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(1, 0, 1, 0)); /* y2h y2g y2f y2e | x1h x1g x1f x1e */ + t10 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 2, 3, 2)); /* z2h z2g z2f z2e | y1h y1g y1f y1e */ + t11 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(1, 0, 1, 0)); /* x3h x3g x3f x3e | z1h z1g z1f z1e */ + t12 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(3, 2, 3, 2)); /* y3h y3g y3f y3e | x2h x2g x2f x2e */ *x1 = _mm256_permute2f128_ps(t5, t9, 0x20); *y1 = _mm256_permute2f128_ps(t6, t10, 0x20); @@ -496,15 +496,15 @@ gmx_mm256_load_3rvec_8ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa *x3 = _mm256_permute2f128_ps(t7, t11, 0x31); *y3 = _mm256_permute2f128_ps(t8, t12, 0x31); - t1 = gmx_mm256_set_m128(_mm_load_ss(ptrE+8),_mm_load_ss(ptrA+8)); - t2 = gmx_mm256_set_m128(_mm_load_ss(ptrF+8),_mm_load_ss(ptrB+8)); - t3 = gmx_mm256_set_m128(_mm_load_ss(ptrG+8),_mm_load_ss(ptrC+8)); - t4 = gmx_mm256_set_m128(_mm_load_ss(ptrH+8),_mm_load_ss(ptrD+8)); + t1 = gmx_mm256_set_m128(_mm_load_ss(ptrE+8), _mm_load_ss(ptrA+8)); + t2 = gmx_mm256_set_m128(_mm_load_ss(ptrF+8), _mm_load_ss(ptrB+8)); + t3 = gmx_mm256_set_m128(_mm_load_ss(ptrG+8), _mm_load_ss(ptrC+8)); + t4 = gmx_mm256_set_m128(_mm_load_ss(ptrH+8), _mm_load_ss(ptrD+8)); - t1 = _mm256_unpacklo_ps(t1,t3); /* - - z3g z3e | - - z3c z3a */ - t2 = _mm256_unpacklo_ps(t2,t4); /* - - z3h z3f | - - z3d z3b */ + t1 = _mm256_unpacklo_ps(t1, t3); /* - - z3g z3e | - - z3c z3a */ + t2 = _mm256_unpacklo_ps(t2, t4); /* - - z3h z3f | - - z3d z3b */ - *z3 = _mm256_unpacklo_ps(t1,t2); + *z3 = _mm256_unpacklo_ps(t1, t2); } @@ -519,34 +519,34 @@ gmx_mm256_load_4rvec_8ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa __m256 * gmx_restrict x3, __m256 * gmx_restrict y3, __m256 * gmx_restrict z3, __m256 * gmx_restrict x4, __m256 * gmx_restrict y4, __m256 * gmx_restrict z4) { - __m256 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - - t1 = _mm256_loadu_ps(ptrA); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ - t2 = _mm256_loadu_ps(ptrB); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ - t3 = _mm256_loadu_ps(ptrC); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ - t4 = _mm256_loadu_ps(ptrD); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ - t5 = _mm256_loadu_ps(ptrE); /* y3e x3e z2e y2e | x2e z1e y1e x1e */ - t6 = _mm256_loadu_ps(ptrF); /* y3f x3f z2f y2f | x2f z1f y1f x1f */ - t7 = _mm256_loadu_ps(ptrG); /* y3g x3g z2g y2g | x2g z1g y1g x1g */ - t8 = _mm256_loadu_ps(ptrH); /* y3h x3h z2h y2h | x2h z1h y1h x1h */ - - t9 = _mm256_unpacklo_ps(t1,t2); /* z2b z2a y2b y2a | y1b y1a x1b x1a */ - t10 = _mm256_unpackhi_ps(t1,t2); /* y3b y3a x3b x3a | x2b x2a z1b z1a */ - t11 = _mm256_unpacklo_ps(t3,t4); /* z2d z2c y2d y2c | y1d y1c x1d x1c */ - t12 = _mm256_unpackhi_ps(t3,t4); /* y3d y3c x3d x3c | x2d x2c z1d z1c */ - t1 = _mm256_unpacklo_ps(t5,t6); /* z2f z2e y2f y2e | y1f y1e x1f x1e */ - t2 = _mm256_unpackhi_ps(t5,t6); /* y3f y3e x3f x3e | x2f x2e z1f z1e */ - t3 = _mm256_unpacklo_ps(t7,t8); /* z2h z2g y2h y2g | y1h y1g x1h x1g */ - t4 = _mm256_unpackhi_ps(t7,t8); /* y3h y3g x3h x3g | x2h x2g z1h z1g */ - - t5 = _mm256_shuffle_ps(t9,t11,_MM_SHUFFLE(1,0,1,0)); /* y2d y2c y2b y2a | x1d x1c x1b x1a */ - t6 = _mm256_shuffle_ps(t9,t11,_MM_SHUFFLE(3,2,3,2)); /* z2d z2c z2b z2a | y1d y1c y1b y1a */ - t7 = _mm256_shuffle_ps(t10,t12,_MM_SHUFFLE(1,0,1,0)); /* x3d x3c x3b x3a | z1d z1c z1b z1a */ - t8 = _mm256_shuffle_ps(t10,t12,_MM_SHUFFLE(3,2,3,2)); /* y3d y3c y3b y3a | x2d x2c x2b x2a */ - t9 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(1,0,1,0)); /* y2h y2g y2f y2e | x1h x1g x1f x1e */ - t10 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(3,2,3,2)); /* z2h z2g z2f z2e | y1h y1g y1f y1e */ - t11 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(1,0,1,0)); /* x3h x3g x3f x3e | z1h z1g z1f z1e */ - t12 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(3,2,3,2)); /* y3h y3g y3f y3e | x2h x2g x2f x2e */ + __m256 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + + t1 = _mm256_loadu_ps(ptrA); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ + t2 = _mm256_loadu_ps(ptrB); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ + t3 = _mm256_loadu_ps(ptrC); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ + t4 = _mm256_loadu_ps(ptrD); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ + t5 = _mm256_loadu_ps(ptrE); /* y3e x3e z2e y2e | x2e z1e y1e x1e */ + t6 = _mm256_loadu_ps(ptrF); /* y3f x3f z2f y2f | x2f z1f y1f x1f */ + t7 = _mm256_loadu_ps(ptrG); /* y3g x3g z2g y2g | x2g z1g y1g x1g */ + t8 = _mm256_loadu_ps(ptrH); /* y3h x3h z2h y2h | x2h z1h y1h x1h */ + + t9 = _mm256_unpacklo_ps(t1, t2); /* z2b z2a y2b y2a | y1b y1a x1b x1a */ + t10 = _mm256_unpackhi_ps(t1, t2); /* y3b y3a x3b x3a | x2b x2a z1b z1a */ + t11 = _mm256_unpacklo_ps(t3, t4); /* z2d z2c y2d y2c | y1d y1c x1d x1c */ + t12 = _mm256_unpackhi_ps(t3, t4); /* y3d y3c x3d x3c | x2d x2c z1d z1c */ + t1 = _mm256_unpacklo_ps(t5, t6); /* z2f z2e y2f y2e | y1f y1e x1f x1e */ + t2 = _mm256_unpackhi_ps(t5, t6); /* y3f y3e x3f x3e | x2f x2e z1f z1e */ + t3 = _mm256_unpacklo_ps(t7, t8); /* z2h z2g y2h y2g | y1h y1g x1h x1g */ + t4 = _mm256_unpackhi_ps(t7, t8); /* y3h y3g x3h x3g | x2h x2g z1h z1g */ + + t5 = _mm256_shuffle_ps(t9, t11, _MM_SHUFFLE(1, 0, 1, 0)); /* y2d y2c y2b y2a | x1d x1c x1b x1a */ + t6 = _mm256_shuffle_ps(t9, t11, _MM_SHUFFLE(3, 2, 3, 2)); /* z2d z2c z2b z2a | y1d y1c y1b y1a */ + t7 = _mm256_shuffle_ps(t10, t12, _MM_SHUFFLE(1, 0, 1, 0)); /* x3d x3c x3b x3a | z1d z1c z1b z1a */ + t8 = _mm256_shuffle_ps(t10, t12, _MM_SHUFFLE(3, 2, 3, 2)); /* y3d y3c y3b y3a | x2d x2c x2b x2a */ + t9 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(1, 0, 1, 0)); /* y2h y2g y2f y2e | x1h x1g x1f x1e */ + t10 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 2, 3, 2)); /* z2h z2g z2f z2e | y1h y1g y1f y1e */ + t11 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(1, 0, 1, 0)); /* x3h x3g x3f x3e | z1h z1g z1f z1e */ + t12 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(3, 2, 3, 2)); /* y3h y3g y3f y3e | x2h x2g x2f x2e */ *x1 = _mm256_permute2f128_ps(t5, t9, 0x20); *y1 = _mm256_permute2f128_ps(t6, t10, 0x20); @@ -558,118 +558,118 @@ gmx_mm256_load_4rvec_8ptr_swizzle_ps(const float * gmx_restrict ptrA, const floa *x3 = _mm256_permute2f128_ps(t7, t11, 0x31); *y3 = _mm256_permute2f128_ps(t8, t12, 0x31); - t1 = gmx_mm256_set_m128(_mm_loadu_ps(ptrE+8),_mm_loadu_ps(ptrA+8)); /* z4e y4e x4e z3e | z4a y4a x4a z3a */ - t2 = gmx_mm256_set_m128(_mm_loadu_ps(ptrF+8),_mm_loadu_ps(ptrB+8)); /* z4f y4f x4f z3f | z4b y4b x4b z3b */ - t3 = gmx_mm256_set_m128(_mm_loadu_ps(ptrG+8),_mm_loadu_ps(ptrC+8)); /* z4g y4g x4g z3g | z4c y4c x4c z3c */ - t4 = gmx_mm256_set_m128(_mm_loadu_ps(ptrH+8),_mm_loadu_ps(ptrD+8)); /* z4h y4h x4h z3h | z4d y4d x4d z3d */ + t1 = gmx_mm256_set_m128(_mm_loadu_ps(ptrE+8), _mm_loadu_ps(ptrA+8)); /* z4e y4e x4e z3e | z4a y4a x4a z3a */ + t2 = gmx_mm256_set_m128(_mm_loadu_ps(ptrF+8), _mm_loadu_ps(ptrB+8)); /* z4f y4f x4f z3f | z4b y4b x4b z3b */ + t3 = gmx_mm256_set_m128(_mm_loadu_ps(ptrG+8), _mm_loadu_ps(ptrC+8)); /* z4g y4g x4g z3g | z4c y4c x4c z3c */ + t4 = gmx_mm256_set_m128(_mm_loadu_ps(ptrH+8), _mm_loadu_ps(ptrD+8)); /* z4h y4h x4h z3h | z4d y4d x4d z3d */ - t5 = _mm256_unpacklo_ps(t1,t2); /* x4f x4e z3f z3e | x4b x4a z3b z3a */ - t6 = _mm256_unpackhi_ps(t1,t2); /* z4f z4e y4f y4e | z4b z4a y4b y4a */ - t7 = _mm256_unpacklo_ps(t3,t4); /* x4h x4g z3h z3g | x4d x4c z3d z3c */ - t8 = _mm256_unpackhi_ps(t3,t4); /* z4h z4g y4h y4g | z4d z4c y4d y4c */ + t5 = _mm256_unpacklo_ps(t1, t2); /* x4f x4e z3f z3e | x4b x4a z3b z3a */ + t6 = _mm256_unpackhi_ps(t1, t2); /* z4f z4e y4f y4e | z4b z4a y4b y4a */ + t7 = _mm256_unpacklo_ps(t3, t4); /* x4h x4g z3h z3g | x4d x4c z3d z3c */ + t8 = _mm256_unpackhi_ps(t3, t4); /* z4h z4g y4h y4g | z4d z4c y4d y4c */ - *z3 = _mm256_shuffle_ps(t5,t7,_MM_SHUFFLE(1,0,1,0)); /* z3h z3g z3f z3e | z3d z3c z3b z3a */ - *x4 = _mm256_shuffle_ps(t5,t7,_MM_SHUFFLE(3,2,3,2)); /* x4h x4g x4f x4e | x4d x4c x4b x4a */ - *y4 = _mm256_shuffle_ps(t6,t8,_MM_SHUFFLE(1,0,1,0)); /* y4h y4g y4f y4e | y4d y4c y4b y4a */ - *z4 = _mm256_shuffle_ps(t6,t8,_MM_SHUFFLE(3,2,3,2)); /* z4h z4g z4f z4e | z4d z4c z4b z4a */ + *z3 = _mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(1, 0, 1, 0)); /* z3h z3g z3f z3e | z3d z3c z3b z3a */ + *x4 = _mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(3, 2, 3, 2)); /* x4h x4g x4f x4e | x4d x4c x4b x4a */ + *y4 = _mm256_shuffle_ps(t6, t8, _MM_SHUFFLE(1, 0, 1, 0)); /* y4h y4g y4f y4e | y4d y4c y4b y4a */ + *z4 = _mm256_shuffle_ps(t6, t8, _MM_SHUFFLE(3, 2, 3, 2)); /* z4h z4g z4f z4e | z4d z4c z4b z4a */ } static gmx_inline void gmx_mm256_decrement_1rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, - float * gmx_restrict ptrC,float * gmx_restrict ptrD, - __m256 x1, __m256 y1, __m256 z1) + float * gmx_restrict ptrC, float * gmx_restrict ptrD, + __m256 x1, __m256 y1, __m256 z1) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8; + __m128 t1, t2, t3, t4, t5, t6, t7, t8; __m128i mask; /* Construct a mask without executing any data loads */ - mask = _mm_blend_epi16(_mm_setzero_si128(),_mm_cmpeq_epi16(_mm_setzero_si128(),_mm_setzero_si128()),0x3F); - - t3 = _mm_unpacklo_ps(_mm256_castps256_ps128(x1),_mm256_castps256_ps128(y1)); /* y1b x1b y1a x1a */ - t4 = _mm_unpackhi_ps(_mm256_castps256_ps128(x1),_mm256_castps256_ps128(y1)); /* y1d x1d y1c x1c */ - - t1 = _mm_shuffle_ps(t3,_mm256_castps256_ps128(z1),_MM_SHUFFLE(0,0,1,0)); /* - z1a y1a x1a */ - t2 = _mm_shuffle_ps(t3,_mm256_castps256_ps128(z1),_MM_SHUFFLE(0,1,3,2)); /* - z1b y1b x1b */ - t3 = _mm_shuffle_ps(t4,_mm256_castps256_ps128(z1),_MM_SHUFFLE(0,2,1,0)); /* - z1c y1c x1c */ - t4 = _mm_shuffle_ps(t4,_mm256_castps256_ps128(z1),_MM_SHUFFLE(0,3,3,2)); /* - z1d y1d x1d */ - - t5 = gmx_mm_maskload_ps(ptrA,mask); - t6 = gmx_mm_maskload_ps(ptrB,mask); - t7 = gmx_mm_maskload_ps(ptrC,mask); - t8 = gmx_mm_maskload_ps(ptrD,mask); - - t5 = _mm_sub_ps(t5,t1); - t6 = _mm_sub_ps(t6,t2); - t7 = _mm_sub_ps(t7,t3); - t8 = _mm_sub_ps(t8,t4); - - gmx_mm_maskstore_ps(ptrA,mask,t5); - gmx_mm_maskstore_ps(ptrB,mask,t6); - gmx_mm_maskstore_ps(ptrC,mask,t7); - gmx_mm_maskstore_ps(ptrD,mask,t8); + mask = _mm_blend_epi16(_mm_setzero_si128(), _mm_cmpeq_epi16(_mm_setzero_si128(), _mm_setzero_si128()), 0x3F); + + t3 = _mm_unpacklo_ps(_mm256_castps256_ps128(x1), _mm256_castps256_ps128(y1)); /* y1b x1b y1a x1a */ + t4 = _mm_unpackhi_ps(_mm256_castps256_ps128(x1), _mm256_castps256_ps128(y1)); /* y1d x1d y1c x1c */ + + t1 = _mm_shuffle_ps(t3, _mm256_castps256_ps128(z1), _MM_SHUFFLE(0, 0, 1, 0)); /* - z1a y1a x1a */ + t2 = _mm_shuffle_ps(t3, _mm256_castps256_ps128(z1), _MM_SHUFFLE(0, 1, 3, 2)); /* - z1b y1b x1b */ + t3 = _mm_shuffle_ps(t4, _mm256_castps256_ps128(z1), _MM_SHUFFLE(0, 2, 1, 0)); /* - z1c y1c x1c */ + t4 = _mm_shuffle_ps(t4, _mm256_castps256_ps128(z1), _MM_SHUFFLE(0, 3, 3, 2)); /* - z1d y1d x1d */ + + t5 = gmx_mm_maskload_ps(ptrA, mask); + t6 = gmx_mm_maskload_ps(ptrB, mask); + t7 = gmx_mm_maskload_ps(ptrC, mask); + t8 = gmx_mm_maskload_ps(ptrD, mask); + + t5 = _mm_sub_ps(t5, t1); + t6 = _mm_sub_ps(t6, t2); + t7 = _mm_sub_ps(t7, t3); + t8 = _mm_sub_ps(t8, t4); + + gmx_mm_maskstore_ps(ptrA, mask, t5); + gmx_mm_maskstore_ps(ptrB, mask, t6); + gmx_mm_maskstore_ps(ptrC, mask, t7); + gmx_mm_maskstore_ps(ptrD, mask, t8); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_decrement_3rvec_4ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD, \ - x1,y1,z1,x2,y2,z2,x3,y3,z3) \ -{\ - __m256 _t1,_t2,_t3,_t4,_t5,_t6;\ - __m128 _tA,_tB,_tC,_tD;\ +#define gmx_mm256_decrement_3rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \ + x1, y1, z1, x2, y2, z2, x3, y3, z3) \ + { \ + __m256 _t1, _t2, _t3, _t4, _t5, _t6; \ + __m128 _tA, _tB, _tC, _tD; \ \ - _t1 = _mm256_loadu_ps(ptrA);\ - _t2 = _mm256_loadu_ps(ptrB);\ - _t3 = _mm256_loadu_ps(ptrC);\ - _t4 = _mm256_loadu_ps(ptrD);\ - _tA = _mm_load_ss(ptrA+8);\ - _tB = _mm_load_ss(ptrB+8);\ - _tC = _mm_load_ss(ptrC+8);\ - _tD = _mm_load_ss(ptrD+8);\ - _t5 = _mm256_unpacklo_ps(x1,y1);\ - x1 = _mm256_unpackhi_ps(x1,y1);\ - y1 = _mm256_unpacklo_ps(z1,x2);\ - z1 = _mm256_unpackhi_ps(z1,x2);\ - x2 = _mm256_unpacklo_ps(y2,z2);\ - y2 = _mm256_unpackhi_ps(y2,z2);\ - _t6 = _mm256_unpacklo_ps(x3,y3);\ - x3 = _mm256_unpackhi_ps(x3,y3);\ - _t5 = _mm256_insertf128_ps(_t5, _mm256_castps256_ps128(x2), 0x1);\ - x1 = _mm256_insertf128_ps(x1, _mm256_castps256_ps128(y2), 0x1);\ - y1 = _mm256_insertf128_ps(y1, _mm256_castps256_ps128(_t6), 0x1);\ - z1 = _mm256_insertf128_ps(z1, _mm256_castps256_ps128(x3), 0x1);\ - z2 = _mm256_shuffle_ps(_t5,y1,_MM_SHUFFLE(1,0,1,0));\ - _t5 = _mm256_shuffle_ps(_t5,y1,_MM_SHUFFLE(3,2,3,2));\ - y1 = _mm256_shuffle_ps(x1,z1,_MM_SHUFFLE(1,0,1,0));\ - x1 = _mm256_shuffle_ps(x1,z1,_MM_SHUFFLE(3,2,3,2));\ - _t1 = _mm256_sub_ps(_t1,z2);\ - _t2 = _mm256_sub_ps(_t2,_t5);\ - _t3 = _mm256_sub_ps(_t3,y1);\ - _t4 = _mm256_sub_ps(_t4,x1);\ - _tA = _mm_sub_ss(_tA, _mm256_castps256_ps128(z3));\ - _tB = _mm_sub_ss(_tB, _mm_permute_ps(_mm256_castps256_ps128(z3),_MM_SHUFFLE(1,1,1,1)));\ - _tC = _mm_sub_ss(_tC, _mm_permute_ps(_mm256_castps256_ps128(z3),_MM_SHUFFLE(2,2,2,2)));\ - _tD = _mm_sub_ss(_tD, _mm_permute_ps(_mm256_castps256_ps128(z3),_MM_SHUFFLE(3,3,3,3)));\ - _mm256_storeu_ps(ptrA,_t1);\ - _mm256_storeu_ps(ptrB,_t2);\ - _mm256_storeu_ps(ptrC,_t3);\ - _mm256_storeu_ps(ptrD,_t4);\ - _mm_store_ss(ptrA+8,_tA);\ - _mm_store_ss(ptrB+8,_tB);\ - _mm_store_ss(ptrC+8,_tC);\ - _mm_store_ss(ptrD+8,_tD);\ -} + _t1 = _mm256_loadu_ps(ptrA); \ + _t2 = _mm256_loadu_ps(ptrB); \ + _t3 = _mm256_loadu_ps(ptrC); \ + _t4 = _mm256_loadu_ps(ptrD); \ + _tA = _mm_load_ss(ptrA+8); \ + _tB = _mm_load_ss(ptrB+8); \ + _tC = _mm_load_ss(ptrC+8); \ + _tD = _mm_load_ss(ptrD+8); \ + _t5 = _mm256_unpacklo_ps(x1, y1); \ + x1 = _mm256_unpackhi_ps(x1, y1); \ + y1 = _mm256_unpacklo_ps(z1, x2); \ + z1 = _mm256_unpackhi_ps(z1, x2); \ + x2 = _mm256_unpacklo_ps(y2, z2); \ + y2 = _mm256_unpackhi_ps(y2, z2); \ + _t6 = _mm256_unpacklo_ps(x3, y3); \ + x3 = _mm256_unpackhi_ps(x3, y3); \ + _t5 = _mm256_insertf128_ps(_t5, _mm256_castps256_ps128(x2), 0x1); \ + x1 = _mm256_insertf128_ps(x1, _mm256_castps256_ps128(y2), 0x1); \ + y1 = _mm256_insertf128_ps(y1, _mm256_castps256_ps128(_t6), 0x1); \ + z1 = _mm256_insertf128_ps(z1, _mm256_castps256_ps128(x3), 0x1); \ + z2 = _mm256_shuffle_ps(_t5, y1, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t5 = _mm256_shuffle_ps(_t5, y1, _MM_SHUFFLE(3, 2, 3, 2)); \ + y1 = _mm256_shuffle_ps(x1, z1, _MM_SHUFFLE(1, 0, 1, 0)); \ + x1 = _mm256_shuffle_ps(x1, z1, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t1 = _mm256_sub_ps(_t1, z2); \ + _t2 = _mm256_sub_ps(_t2, _t5); \ + _t3 = _mm256_sub_ps(_t3, y1); \ + _t4 = _mm256_sub_ps(_t4, x1); \ + _tA = _mm_sub_ss(_tA, _mm256_castps256_ps128(z3)); \ + _tB = _mm_sub_ss(_tB, _mm_permute_ps(_mm256_castps256_ps128(z3), _MM_SHUFFLE(1, 1, 1, 1))); \ + _tC = _mm_sub_ss(_tC, _mm_permute_ps(_mm256_castps256_ps128(z3), _MM_SHUFFLE(2, 2, 2, 2))); \ + _tD = _mm_sub_ss(_tD, _mm_permute_ps(_mm256_castps256_ps128(z3), _MM_SHUFFLE(3, 3, 3, 3))); \ + _mm256_storeu_ps(ptrA, _t1); \ + _mm256_storeu_ps(ptrB, _t2); \ + _mm256_storeu_ps(ptrC, _t3); \ + _mm256_storeu_ps(ptrD, _t4); \ + _mm_store_ss(ptrA+8, _tA); \ + _mm_store_ss(ptrB+8, _tB); \ + _mm_store_ss(ptrC+8, _tC); \ + _mm_store_ss(ptrD+8, _tD); \ + } #else /* Real function for sane compilers */ static gmx_inline void gmx_mm256_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, - float * gmx_restrict ptrC, float * gmx_restrict ptrD, - __m256 x1, __m256 y1, __m256 z1, - __m256 x2, __m256 y2, __m256 z2, - __m256 x3, __m256 y3, __m256 z3) + float * gmx_restrict ptrC, float * gmx_restrict ptrD, + __m256 x1, __m256 y1, __m256 z1, + __m256 x2, __m256 y2, __m256 z2, + __m256 x3, __m256 y3, __m256 z3) { - __m256 t1,t2,t3,t4,t5,t6; - __m128 tA,tB,tC,tD; + __m256 t1, t2, t3, t4, t5, t6; + __m128 tA, tB, tC, tD; t1 = _mm256_loadu_ps(ptrA); t2 = _mm256_loadu_ps(ptrB); @@ -680,15 +680,15 @@ gmx_mm256_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx tC = _mm_load_ss(ptrC+8); tD = _mm_load_ss(ptrD+8); - t5 = _mm256_unpacklo_ps(x1,y1); /* - - - - | y1b x1b y1a x1a */ - x1 = _mm256_unpackhi_ps(x1,y1); /* - - - - | y1d x1d y1c x1c */ - y1 = _mm256_unpacklo_ps(z1,x2); /* - - - - | x2b z1b x2a z1a */ - z1 = _mm256_unpackhi_ps(z1,x2); /* - - - - | x2d z1d x2c z1c */ + t5 = _mm256_unpacklo_ps(x1, y1); /* - - - - | y1b x1b y1a x1a */ + x1 = _mm256_unpackhi_ps(x1, y1); /* - - - - | y1d x1d y1c x1c */ + y1 = _mm256_unpacklo_ps(z1, x2); /* - - - - | x2b z1b x2a z1a */ + z1 = _mm256_unpackhi_ps(z1, x2); /* - - - - | x2d z1d x2c z1c */ - x2 = _mm256_unpacklo_ps(y2,z2); /* - - - - | z2b y2b z2a y2a */ - y2 = _mm256_unpackhi_ps(y2,z2); /* - - - - | z2d y2d z2c y2c */ - t6 = _mm256_unpacklo_ps(x3,y3); /* - - - - | y3b x3b y3a x3a */ - x3 = _mm256_unpackhi_ps(x3,y3); /* - - - - | y3d x3d y3c x3c */ + x2 = _mm256_unpacklo_ps(y2, z2); /* - - - - | z2b y2b z2a y2a */ + y2 = _mm256_unpackhi_ps(y2, z2); /* - - - - | z2d y2d z2c y2c */ + t6 = _mm256_unpacklo_ps(x3, y3); /* - - - - | y3b x3b y3a x3a */ + x3 = _mm256_unpackhi_ps(x3, y3); /* - - - - | y3d x3d y3c x3c */ t5 = _mm256_insertf128_ps(t5, _mm256_castps256_ps128(x2), 0x1); /* z2b y2b z2a y2a | y1b x1b y1a x1a */ x1 = _mm256_insertf128_ps(x1, _mm256_castps256_ps128(y2), 0x1); /* z2d y2d z2c y2c | y1d x1d y1c x1c */ @@ -696,30 +696,30 @@ gmx_mm256_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx y1 = _mm256_insertf128_ps(y1, _mm256_castps256_ps128(t6), 0x1); /* y3b x3b y3a x3a | x2b z1b x2a z1a */ z1 = _mm256_insertf128_ps(z1, _mm256_castps256_ps128(x3), 0x1); /* y3d x3d y3c x3c | x2d z1d x2c z1c */ - z2 = _mm256_shuffle_ps(t5,y1,_MM_SHUFFLE(1,0,1,0)); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ - t5 = _mm256_shuffle_ps(t5,y1,_MM_SHUFFLE(3,2,3,2)); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ - y1 = _mm256_shuffle_ps(x1,z1,_MM_SHUFFLE(1,0,1,0)); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ - x1 = _mm256_shuffle_ps(x1,z1,_MM_SHUFFLE(3,2,3,2)); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ + z2 = _mm256_shuffle_ps(t5, y1, _MM_SHUFFLE(1, 0, 1, 0)); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ + t5 = _mm256_shuffle_ps(t5, y1, _MM_SHUFFLE(3, 2, 3, 2)); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ + y1 = _mm256_shuffle_ps(x1, z1, _MM_SHUFFLE(1, 0, 1, 0)); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ + x1 = _mm256_shuffle_ps(x1, z1, _MM_SHUFFLE(3, 2, 3, 2)); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ - t1 = _mm256_sub_ps(t1,z2); - t2 = _mm256_sub_ps(t2,t5); - t3 = _mm256_sub_ps(t3,y1); - t4 = _mm256_sub_ps(t4,x1); + t1 = _mm256_sub_ps(t1, z2); + t2 = _mm256_sub_ps(t2, t5); + t3 = _mm256_sub_ps(t3, y1); + t4 = _mm256_sub_ps(t4, x1); tA = _mm_sub_ss(tA, _mm256_castps256_ps128(z3)); - tB = _mm_sub_ss(tB, _mm_permute_ps(_mm256_castps256_ps128(z3),_MM_SHUFFLE(1,1,1,1))); - tC = _mm_sub_ss(tC, _mm_permute_ps(_mm256_castps256_ps128(z3),_MM_SHUFFLE(2,2,2,2))); - tD = _mm_sub_ss(tD, _mm_permute_ps(_mm256_castps256_ps128(z3),_MM_SHUFFLE(3,3,3,3))); + tB = _mm_sub_ss(tB, _mm_permute_ps(_mm256_castps256_ps128(z3), _MM_SHUFFLE(1, 1, 1, 1))); + tC = _mm_sub_ss(tC, _mm_permute_ps(_mm256_castps256_ps128(z3), _MM_SHUFFLE(2, 2, 2, 2))); + tD = _mm_sub_ss(tD, _mm_permute_ps(_mm256_castps256_ps128(z3), _MM_SHUFFLE(3, 3, 3, 3))); /* Here we store a full 256-bit value and a separate 32-bit one; no overlap can happen */ - _mm256_storeu_ps(ptrA,t1); - _mm256_storeu_ps(ptrB,t2); - _mm256_storeu_ps(ptrC,t3); - _mm256_storeu_ps(ptrD,t4); - _mm_store_ss(ptrA+8,tA); - _mm_store_ss(ptrB+8,tB); - _mm_store_ss(ptrC+8,tC); - _mm_store_ss(ptrD+8,tD); + _mm256_storeu_ps(ptrA, t1); + _mm256_storeu_ps(ptrB, t2); + _mm256_storeu_ps(ptrC, t3); + _mm256_storeu_ps(ptrD, t4); + _mm_store_ss(ptrA+8, tA); + _mm_store_ss(ptrB+8, tB); + _mm_store_ss(ptrC+8, tC); + _mm_store_ss(ptrD+8, tD); } #endif @@ -727,73 +727,73 @@ gmx_mm256_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_decrement_4rvec_4ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD, \ - x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4) \ -{\ - __m256 _t1,_t2,_t3,_t4,_t5;\ - __m128 _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH;\ +#define gmx_mm256_decrement_4rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \ + x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) \ + { \ + __m256 _t1, _t2, _t3, _t4, _t5; \ + __m128 _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH; \ \ - _t1 = _mm256_loadu_ps(ptrA);\ - _t2 = _mm256_loadu_ps(ptrB);\ - _t3 = _mm256_loadu_ps(ptrC);\ - _t4 = _mm256_loadu_ps(ptrD);\ - _tA = _mm_loadu_ps(ptrA+8);\ - _tB = _mm_loadu_ps(ptrB+8);\ - _tC = _mm_loadu_ps(ptrC+8);\ - _tD = _mm_loadu_ps(ptrD+8);\ - _t5 = _mm256_unpacklo_ps(x1,y1);\ - x1 = _mm256_unpackhi_ps(x1,y1);\ - y1 = _mm256_unpacklo_ps(z1,x2);\ - z1 = _mm256_unpackhi_ps(z1,x2);\ - x2 = _mm256_unpacklo_ps(y2,z2);\ - y2 = _mm256_unpackhi_ps(y2,z2);\ - z2 = _mm256_unpacklo_ps(x3,y3);\ - x3 = _mm256_unpackhi_ps(x3,y3);\ - y3 = _mm256_unpacklo_ps(z3,x4);\ - z3 = _mm256_unpackhi_ps(z3,x4);\ - x4 = _mm256_unpacklo_ps(y4,z4);\ - y4 = _mm256_unpackhi_ps(y4,z4);\ - x2 = _mm256_insertf128_ps(_t5, _mm256_castps256_ps128(x2), 0x1);\ - x1 = _mm256_insertf128_ps(x1, _mm256_castps256_ps128(y2), 0x1);\ - y1 = _mm256_insertf128_ps(y1, _mm256_castps256_ps128(z2), 0x1);\ - z1 = _mm256_insertf128_ps(z1, _mm256_castps256_ps128(x3), 0x1);\ - z2 = _mm256_shuffle_ps(x2,y1,_MM_SHUFFLE(1,0,1,0));\ - _t5 = _mm256_shuffle_ps(x2,y1,_MM_SHUFFLE(3,2,3,2));\ - y1 = _mm256_shuffle_ps(x1,z1,_MM_SHUFFLE(1,0,1,0));\ - x1 = _mm256_shuffle_ps(x1,z1,_MM_SHUFFLE(3,2,3,2));\ - _tE = _mm_shuffle_ps(_mm256_castps256_ps128(y3),_mm256_castps256_ps128(x4),_MM_SHUFFLE(1,0,1,0));\ - _tF = _mm_shuffle_ps(_mm256_castps256_ps128(y3),_mm256_castps256_ps128(x4),_MM_SHUFFLE(3,2,3,2));\ - _tG = _mm_shuffle_ps(_mm256_castps256_ps128(z3),_mm256_castps256_ps128(y4),_MM_SHUFFLE(1,0,1,0));\ - _tH = _mm_shuffle_ps(_mm256_castps256_ps128(z3),_mm256_castps256_ps128(y4),_MM_SHUFFLE(3,2,3,2));\ - _t1 = _mm256_sub_ps(_t1,z2);\ - _t2 = _mm256_sub_ps(_t2,_t5);\ - _t3 = _mm256_sub_ps(_t3,y1);\ - _t4 = _mm256_sub_ps(_t4,x1);\ - _tA = _mm_sub_ps(_tA,_tE);\ - _tB = _mm_sub_ps(_tB,_tF);\ - _tC = _mm_sub_ps(_tC,_tG);\ - _tD = _mm_sub_ps(_tD,_tH);\ - _mm256_storeu_ps(ptrA,_t1);\ - _mm256_storeu_ps(ptrB,_t2);\ - _mm256_storeu_ps(ptrC,_t3);\ - _mm256_storeu_ps(ptrD,_t4);\ - _mm_storeu_ps(ptrA+8,_tA);\ - _mm_storeu_ps(ptrB+8,_tB);\ - _mm_storeu_ps(ptrC+8,_tC);\ - _mm_storeu_ps(ptrD+8,_tD);\ -} + _t1 = _mm256_loadu_ps(ptrA); \ + _t2 = _mm256_loadu_ps(ptrB); \ + _t3 = _mm256_loadu_ps(ptrC); \ + _t4 = _mm256_loadu_ps(ptrD); \ + _tA = _mm_loadu_ps(ptrA+8); \ + _tB = _mm_loadu_ps(ptrB+8); \ + _tC = _mm_loadu_ps(ptrC+8); \ + _tD = _mm_loadu_ps(ptrD+8); \ + _t5 = _mm256_unpacklo_ps(x1, y1); \ + x1 = _mm256_unpackhi_ps(x1, y1); \ + y1 = _mm256_unpacklo_ps(z1, x2); \ + z1 = _mm256_unpackhi_ps(z1, x2); \ + x2 = _mm256_unpacklo_ps(y2, z2); \ + y2 = _mm256_unpackhi_ps(y2, z2); \ + z2 = _mm256_unpacklo_ps(x3, y3); \ + x3 = _mm256_unpackhi_ps(x3, y3); \ + y3 = _mm256_unpacklo_ps(z3, x4); \ + z3 = _mm256_unpackhi_ps(z3, x4); \ + x4 = _mm256_unpacklo_ps(y4, z4); \ + y4 = _mm256_unpackhi_ps(y4, z4); \ + x2 = _mm256_insertf128_ps(_t5, _mm256_castps256_ps128(x2), 0x1); \ + x1 = _mm256_insertf128_ps(x1, _mm256_castps256_ps128(y2), 0x1); \ + y1 = _mm256_insertf128_ps(y1, _mm256_castps256_ps128(z2), 0x1); \ + z1 = _mm256_insertf128_ps(z1, _mm256_castps256_ps128(x3), 0x1); \ + z2 = _mm256_shuffle_ps(x2, y1, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t5 = _mm256_shuffle_ps(x2, y1, _MM_SHUFFLE(3, 2, 3, 2)); \ + y1 = _mm256_shuffle_ps(x1, z1, _MM_SHUFFLE(1, 0, 1, 0)); \ + x1 = _mm256_shuffle_ps(x1, z1, _MM_SHUFFLE(3, 2, 3, 2)); \ + _tE = _mm_shuffle_ps(_mm256_castps256_ps128(y3), _mm256_castps256_ps128(x4), _MM_SHUFFLE(1, 0, 1, 0)); \ + _tF = _mm_shuffle_ps(_mm256_castps256_ps128(y3), _mm256_castps256_ps128(x4), _MM_SHUFFLE(3, 2, 3, 2)); \ + _tG = _mm_shuffle_ps(_mm256_castps256_ps128(z3), _mm256_castps256_ps128(y4), _MM_SHUFFLE(1, 0, 1, 0)); \ + _tH = _mm_shuffle_ps(_mm256_castps256_ps128(z3), _mm256_castps256_ps128(y4), _MM_SHUFFLE(3, 2, 3, 2)); \ + _t1 = _mm256_sub_ps(_t1, z2); \ + _t2 = _mm256_sub_ps(_t2, _t5); \ + _t3 = _mm256_sub_ps(_t3, y1); \ + _t4 = _mm256_sub_ps(_t4, x1); \ + _tA = _mm_sub_ps(_tA, _tE); \ + _tB = _mm_sub_ps(_tB, _tF); \ + _tC = _mm_sub_ps(_tC, _tG); \ + _tD = _mm_sub_ps(_tD, _tH); \ + _mm256_storeu_ps(ptrA, _t1); \ + _mm256_storeu_ps(ptrB, _t2); \ + _mm256_storeu_ps(ptrC, _t3); \ + _mm256_storeu_ps(ptrD, _t4); \ + _mm_storeu_ps(ptrA+8, _tA); \ + _mm_storeu_ps(ptrB+8, _tB); \ + _mm_storeu_ps(ptrC+8, _tC); \ + _mm_storeu_ps(ptrD+8, _tD); \ + } #else /* Real function for sane compilers */ static gmx_inline void gmx_mm256_decrement_4rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, - float * gmx_restrict ptrC, float * gmx_restrict ptrD, - __m256 x1, __m256 y1, __m256 z1, - __m256 x2, __m256 y2, __m256 z2, - __m256 x3, __m256 y3, __m256 z3, - __m256 x4, __m256 y4, __m256 z4) + float * gmx_restrict ptrC, float * gmx_restrict ptrD, + __m256 x1, __m256 y1, __m256 z1, + __m256 x2, __m256 y2, __m256 z2, + __m256 x3, __m256 y3, __m256 z3, + __m256 x4, __m256 y4, __m256 z4) { - __m256 t1,t2,t3,t4,t5; - __m128 tA,tB,tC,tD,tE,tF,tG,tH; + __m256 t1, t2, t3, t4, t5; + __m128 tA, tB, tC, tD, tE, tF, tG, tH; t1 = _mm256_loadu_ps(ptrA); t2 = _mm256_loadu_ps(ptrB); @@ -804,192 +804,192 @@ gmx_mm256_decrement_4rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx tC = _mm_loadu_ps(ptrC+8); tD = _mm_loadu_ps(ptrD+8); - t5 = _mm256_unpacklo_ps(x1,y1); /* - - - - | y1b x1b y1a x1a */ - x1 = _mm256_unpackhi_ps(x1,y1); /* - - - - | y1d x1d y1c x1c */ - y1 = _mm256_unpacklo_ps(z1,x2); /* - - - - | x2b z1b x2a z1a */ - z1 = _mm256_unpackhi_ps(z1,x2); /* - - - - | x2d z1d x2c z1c */ + t5 = _mm256_unpacklo_ps(x1, y1); /* - - - - | y1b x1b y1a x1a */ + x1 = _mm256_unpackhi_ps(x1, y1); /* - - - - | y1d x1d y1c x1c */ + y1 = _mm256_unpacklo_ps(z1, x2); /* - - - - | x2b z1b x2a z1a */ + z1 = _mm256_unpackhi_ps(z1, x2); /* - - - - | x2d z1d x2c z1c */ - x2 = _mm256_unpacklo_ps(y2,z2); /* - - - - | z2b y2b z2a y2a */ - y2 = _mm256_unpackhi_ps(y2,z2); /* - - - - | z2d y2d z2c y2c */ - z2 = _mm256_unpacklo_ps(x3,y3); /* - - - - | y3b x3b y3a x3a */ - x3 = _mm256_unpackhi_ps(x3,y3); /* - - - - | y3d x3d y3c x3c */ + x2 = _mm256_unpacklo_ps(y2, z2); /* - - - - | z2b y2b z2a y2a */ + y2 = _mm256_unpackhi_ps(y2, z2); /* - - - - | z2d y2d z2c y2c */ + z2 = _mm256_unpacklo_ps(x3, y3); /* - - - - | y3b x3b y3a x3a */ + x3 = _mm256_unpackhi_ps(x3, y3); /* - - - - | y3d x3d y3c x3c */ - y3 = _mm256_unpacklo_ps(z3,x4); /* - - - - | x4b z3b x4a z3a */ - z3 = _mm256_unpackhi_ps(z3,x4); /* - - - - | x4d z3d x4c z3c */ - x4 = _mm256_unpacklo_ps(y4,z4); /* - - - - | z4b y4b z4a y4a */ - y4 = _mm256_unpackhi_ps(y4,z4); /* - - - - | z4d y4d z4c y4c */ + y3 = _mm256_unpacklo_ps(z3, x4); /* - - - - | x4b z3b x4a z3a */ + z3 = _mm256_unpackhi_ps(z3, x4); /* - - - - | x4d z3d x4c z3c */ + x4 = _mm256_unpacklo_ps(y4, z4); /* - - - - | z4b y4b z4a y4a */ + y4 = _mm256_unpackhi_ps(y4, z4); /* - - - - | z4d y4d z4c y4c */ - x2 = _mm256_insertf128_ps(t5, _mm256_castps256_ps128(x2), 0x1); /* z2b y2b z2a y2a | y1b x1b y1a x1a */ - x1 = _mm256_insertf128_ps(x1, _mm256_castps256_ps128(y2), 0x1); /* z2d y2d z2c y2c | y1d x1d y1c x1c */ - y1 = _mm256_insertf128_ps(y1, _mm256_castps256_ps128(z2), 0x1); /* y3b x3b y3a x3a | x2b z1b x2a z1a */ - z1 = _mm256_insertf128_ps(z1, _mm256_castps256_ps128(x3), 0x1); /* y3d x3d y3c x3c | x2d z1d x2c z1c */ + x2 = _mm256_insertf128_ps(t5, _mm256_castps256_ps128(x2), 0x1); /* z2b y2b z2a y2a | y1b x1b y1a x1a */ + x1 = _mm256_insertf128_ps(x1, _mm256_castps256_ps128(y2), 0x1); /* z2d y2d z2c y2c | y1d x1d y1c x1c */ + y1 = _mm256_insertf128_ps(y1, _mm256_castps256_ps128(z2), 0x1); /* y3b x3b y3a x3a | x2b z1b x2a z1a */ + z1 = _mm256_insertf128_ps(z1, _mm256_castps256_ps128(x3), 0x1); /* y3d x3d y3c x3c | x2d z1d x2c z1c */ - z2 = _mm256_shuffle_ps(x2,y1,_MM_SHUFFLE(1,0,1,0)); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ - t5 = _mm256_shuffle_ps(x2,y1,_MM_SHUFFLE(3,2,3,2)); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ - y1 = _mm256_shuffle_ps(x1,z1,_MM_SHUFFLE(1,0,1,0)); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ - x1 = _mm256_shuffle_ps(x1,z1,_MM_SHUFFLE(3,2,3,2)); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ + z2 = _mm256_shuffle_ps(x2, y1, _MM_SHUFFLE(1, 0, 1, 0)); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ + t5 = _mm256_shuffle_ps(x2, y1, _MM_SHUFFLE(3, 2, 3, 2)); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ + y1 = _mm256_shuffle_ps(x1, z1, _MM_SHUFFLE(1, 0, 1, 0)); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ + x1 = _mm256_shuffle_ps(x1, z1, _MM_SHUFFLE(3, 2, 3, 2)); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ - tE = _mm_shuffle_ps(_mm256_castps256_ps128(y3),_mm256_castps256_ps128(x4),_MM_SHUFFLE(1,0,1,0)); /* z4a y4a x4a z3a */ - tF = _mm_shuffle_ps(_mm256_castps256_ps128(y3),_mm256_castps256_ps128(x4),_MM_SHUFFLE(3,2,3,2)); /* z4b y4b x4b z3b */ + tE = _mm_shuffle_ps(_mm256_castps256_ps128(y3), _mm256_castps256_ps128(x4), _MM_SHUFFLE(1, 0, 1, 0)); /* z4a y4a x4a z3a */ + tF = _mm_shuffle_ps(_mm256_castps256_ps128(y3), _mm256_castps256_ps128(x4), _MM_SHUFFLE(3, 2, 3, 2)); /* z4b y4b x4b z3b */ - tG = _mm_shuffle_ps(_mm256_castps256_ps128(z3),_mm256_castps256_ps128(y4),_MM_SHUFFLE(1,0,1,0)); /* z4c y4c x4c z3c */ - tH = _mm_shuffle_ps(_mm256_castps256_ps128(z3),_mm256_castps256_ps128(y4),_MM_SHUFFLE(3,2,3,2)); /* z4d y4d x4d z3d */ + tG = _mm_shuffle_ps(_mm256_castps256_ps128(z3), _mm256_castps256_ps128(y4), _MM_SHUFFLE(1, 0, 1, 0)); /* z4c y4c x4c z3c */ + tH = _mm_shuffle_ps(_mm256_castps256_ps128(z3), _mm256_castps256_ps128(y4), _MM_SHUFFLE(3, 2, 3, 2)); /* z4d y4d x4d z3d */ - t1 = _mm256_sub_ps(t1,z2); - t2 = _mm256_sub_ps(t2,t5); - t3 = _mm256_sub_ps(t3,y1); - t4 = _mm256_sub_ps(t4,x1); + t1 = _mm256_sub_ps(t1, z2); + t2 = _mm256_sub_ps(t2, t5); + t3 = _mm256_sub_ps(t3, y1); + t4 = _mm256_sub_ps(t4, x1); - tA = _mm_sub_ps(tA,tE); - tB = _mm_sub_ps(tB,tF); - tC = _mm_sub_ps(tC,tG); - tD = _mm_sub_ps(tD,tH); + tA = _mm_sub_ps(tA, tE); + tB = _mm_sub_ps(tB, tF); + tC = _mm_sub_ps(tC, tG); + tD = _mm_sub_ps(tD, tH); /* Here we store a full 256-bit value and a separate 128-bit one; no overlap can happen */ - _mm256_storeu_ps(ptrA,t1); - _mm256_storeu_ps(ptrB,t2); - _mm256_storeu_ps(ptrC,t3); - _mm256_storeu_ps(ptrD,t4); - _mm_storeu_ps(ptrA+8,tA); - _mm_storeu_ps(ptrB+8,tB); - _mm_storeu_ps(ptrC+8,tC); - _mm_storeu_ps(ptrD+8,tD); + _mm256_storeu_ps(ptrA, t1); + _mm256_storeu_ps(ptrB, t2); + _mm256_storeu_ps(ptrC, t3); + _mm256_storeu_ps(ptrD, t4); + _mm_storeu_ps(ptrA+8, tA); + _mm_storeu_ps(ptrB+8, tB); + _mm_storeu_ps(ptrC+8, tC); + _mm_storeu_ps(ptrD+8, tD); } #endif static gmx_inline void gmx_mm256_decrement_1rvec_8ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, - float * gmx_restrict ptrC, float * gmx_restrict ptrD, - float * gmx_restrict ptrE, float * gmx_restrict ptrF, - float * gmx_restrict ptrG, float * gmx_restrict ptrH, - __m256 x1, __m256 y1, __m256 z1) + float * gmx_restrict ptrC, float * gmx_restrict ptrD, + float * gmx_restrict ptrE, float * gmx_restrict ptrF, + float * gmx_restrict ptrG, float * gmx_restrict ptrH, + __m256 x1, __m256 y1, __m256 z1) { - __m256 t1,t2,t3,t4,t5,t6; - __m256 tA,tB,tC,tD; + __m256 t1, t2, t3, t4, t5, t6; + __m256 tA, tB, tC, tD; __m128i mask; /* Construct a mask without executing any data loads */ - mask = _mm_blend_epi16(_mm_setzero_si128(),_mm_cmpeq_epi16(_mm_setzero_si128(),_mm_setzero_si128()),0x3F); - - tA = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrE,mask),gmx_mm_maskload_ps(ptrA,mask)); - tB = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrF,mask),gmx_mm_maskload_ps(ptrB,mask)); - tC = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrG,mask),gmx_mm_maskload_ps(ptrC,mask)); - tD = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrH,mask),gmx_mm_maskload_ps(ptrD,mask)); - t1 = _mm256_unpacklo_ps(x1,y1); /* y1f x1f y1e x1e | y1b x1b y1a x1a */ - t2 = _mm256_unpackhi_ps(x1,y1); /* y1h x1h y1g x1g | y1d x1d y1c x1c */ - - t3 = _mm256_shuffle_ps(t1,z1,_MM_SHUFFLE(0,0,1,0)); /* - z1e y1e x1e | - z1a y1a x1a */ - t4 = _mm256_shuffle_ps(t1,z1,_MM_SHUFFLE(0,1,3,2)); /* - z1f y1f x1f | - z1b y1b x1b */ - t5 = _mm256_shuffle_ps(t2,z1,_MM_SHUFFLE(0,2,1,0)); /* - z1g y1g x1g | - z1c y1c x1c */ - t6 = _mm256_shuffle_ps(t2,z1,_MM_SHUFFLE(0,3,3,2)); /* - z1h y1h x1h | - z1d y1d x1d */ - - tA = _mm256_sub_ps(tA,t3); - tB = _mm256_sub_ps(tB,t4); - tC = _mm256_sub_ps(tC,t5); - tD = _mm256_sub_ps(tD,t6); - - gmx_mm_maskstore_ps(ptrA,mask,_mm256_castps256_ps128(tA)); - gmx_mm_maskstore_ps(ptrB,mask,_mm256_castps256_ps128(tB)); - gmx_mm_maskstore_ps(ptrC,mask,_mm256_castps256_ps128(tC)); - gmx_mm_maskstore_ps(ptrD,mask,_mm256_castps256_ps128(tD)); - gmx_mm_maskstore_ps(ptrE,mask,_mm256_extractf128_ps(tA,0x1)); - gmx_mm_maskstore_ps(ptrF,mask,_mm256_extractf128_ps(tB,0x1)); - gmx_mm_maskstore_ps(ptrG,mask,_mm256_extractf128_ps(tC,0x1)); - gmx_mm_maskstore_ps(ptrH,mask,_mm256_extractf128_ps(tD,0x1)); + mask = _mm_blend_epi16(_mm_setzero_si128(), _mm_cmpeq_epi16(_mm_setzero_si128(), _mm_setzero_si128()), 0x3F); + + tA = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrE, mask), gmx_mm_maskload_ps(ptrA, mask)); + tB = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrF, mask), gmx_mm_maskload_ps(ptrB, mask)); + tC = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrG, mask), gmx_mm_maskload_ps(ptrC, mask)); + tD = gmx_mm256_set_m128(gmx_mm_maskload_ps(ptrH, mask), gmx_mm_maskload_ps(ptrD, mask)); + t1 = _mm256_unpacklo_ps(x1, y1); /* y1f x1f y1e x1e | y1b x1b y1a x1a */ + t2 = _mm256_unpackhi_ps(x1, y1); /* y1h x1h y1g x1g | y1d x1d y1c x1c */ + + t3 = _mm256_shuffle_ps(t1, z1, _MM_SHUFFLE(0, 0, 1, 0)); /* - z1e y1e x1e | - z1a y1a x1a */ + t4 = _mm256_shuffle_ps(t1, z1, _MM_SHUFFLE(0, 1, 3, 2)); /* - z1f y1f x1f | - z1b y1b x1b */ + t5 = _mm256_shuffle_ps(t2, z1, _MM_SHUFFLE(0, 2, 1, 0)); /* - z1g y1g x1g | - z1c y1c x1c */ + t6 = _mm256_shuffle_ps(t2, z1, _MM_SHUFFLE(0, 3, 3, 2)); /* - z1h y1h x1h | - z1d y1d x1d */ + + tA = _mm256_sub_ps(tA, t3); + tB = _mm256_sub_ps(tB, t4); + tC = _mm256_sub_ps(tC, t5); + tD = _mm256_sub_ps(tD, t6); + + gmx_mm_maskstore_ps(ptrA, mask, _mm256_castps256_ps128(tA)); + gmx_mm_maskstore_ps(ptrB, mask, _mm256_castps256_ps128(tB)); + gmx_mm_maskstore_ps(ptrC, mask, _mm256_castps256_ps128(tC)); + gmx_mm_maskstore_ps(ptrD, mask, _mm256_castps256_ps128(tD)); + gmx_mm_maskstore_ps(ptrE, mask, _mm256_extractf128_ps(tA, 0x1)); + gmx_mm_maskstore_ps(ptrF, mask, _mm256_extractf128_ps(tB, 0x1)); + gmx_mm_maskstore_ps(ptrG, mask, _mm256_extractf128_ps(tC, 0x1)); + gmx_mm_maskstore_ps(ptrH, mask, _mm256_extractf128_ps(tD, 0x1)); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD,ptrE,ptrF,ptrG,ptrH,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{ \ - __m256 _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11,_t12;\ - __m256 _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH,_tI,_tJ,_tK,_tL;\ +#define gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, ptrE, ptrF, ptrG, ptrH, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m256 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11, _t12; \ + __m256 _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH, _tI, _tJ, _tK, _tL; \ \ - _tA = _mm256_loadu_ps(ptrA);\ - _tB = _mm256_loadu_ps(ptrB);\ - _tC = _mm256_loadu_ps(ptrC);\ - _tD = _mm256_loadu_ps(ptrD);\ - _tE = _mm256_loadu_ps(ptrE);\ - _tF = _mm256_loadu_ps(ptrF);\ - _tG = _mm256_loadu_ps(ptrG);\ - _tH = _mm256_loadu_ps(ptrH);\ - _t1 = _mm256_unpacklo_ps(_x1,_y1);\ - _t2 = _mm256_unpackhi_ps(_x1,_y1);\ - _t3 = _mm256_unpacklo_ps(_z1,_x2);\ - _t4 = _mm256_unpackhi_ps(_z1,_x2);\ - _t5 = _mm256_unpacklo_ps(_y2,_z2);\ - _t6 = _mm256_unpackhi_ps(_y2,_z2);\ - _t7 = _mm256_unpacklo_ps(_x3,_y3);\ - _t8 = _mm256_unpackhi_ps(_x3,_y3);\ - _t9 = _mm256_shuffle_ps(_t1,_t3,_MM_SHUFFLE(1,0,1,0));\ - _t10 = _mm256_shuffle_ps(_t1,_t3,_MM_SHUFFLE(3,2,3,2));\ - _t11 = _mm256_shuffle_ps(_t2,_t4,_MM_SHUFFLE(1,0,1,0));\ - _t12 = _mm256_shuffle_ps(_t2,_t4,_MM_SHUFFLE(3,2,3,2));\ - _t1 = _mm256_shuffle_ps(_t5,_t7,_MM_SHUFFLE(1,0,1,0));\ - _t2 = _mm256_shuffle_ps(_t5,_t7,_MM_SHUFFLE(3,2,3,2));\ - _t3 = _mm256_shuffle_ps(_t6,_t8,_MM_SHUFFLE(1,0,1,0));\ - _t4 = _mm256_shuffle_ps(_t6,_t8,_MM_SHUFFLE(3,2,3,2));\ - _t5 = gmx_mm256_unpack128lo_ps(_t9,_t1);\ - _t6 = gmx_mm256_unpack128hi_ps(_t9,_t1);\ - _t7 = gmx_mm256_unpack128lo_ps(_t10,_t2);\ - _t8 = gmx_mm256_unpack128hi_ps(_t10,_t2);\ - _t1 = gmx_mm256_unpack128lo_ps(_t11,_t3);\ - _t2 = gmx_mm256_unpack128hi_ps(_t11,_t3);\ - _t9 = gmx_mm256_unpack128lo_ps(_t12,_t4);\ - _t10 = gmx_mm256_unpack128hi_ps(_t12,_t4);\ - _tA = _mm256_sub_ps(_tA,_t5);\ - _tB = _mm256_sub_ps(_tB,_t7);\ - _tC = _mm256_sub_ps(_tC,_t1);\ - _tD = _mm256_sub_ps(_tD,_t9);\ - _tE = _mm256_sub_ps(_tE,_t6);\ - _tF = _mm256_sub_ps(_tF,_t8);\ - _tG = _mm256_sub_ps(_tG,_t2);\ - _tH = _mm256_sub_ps(_tH,_t10);\ - _mm256_storeu_ps(ptrA,_tA);\ - _mm256_storeu_ps(ptrB,_tB);\ - _mm256_storeu_ps(ptrC,_tC);\ - _mm256_storeu_ps(ptrD,_tD);\ - _mm256_storeu_ps(ptrE,_tE);\ - _mm256_storeu_ps(ptrF,_tF);\ - _mm256_storeu_ps(ptrG,_tG);\ - _mm256_storeu_ps(ptrH,_tH);\ - _tI = gmx_mm256_set_m128(_mm_load_ss(ptrE+8),_mm_load_ss(ptrA+8));\ - _tJ = gmx_mm256_set_m128(_mm_load_ss(ptrF+8),_mm_load_ss(ptrB+8));\ - _tK = gmx_mm256_set_m128(_mm_load_ss(ptrG+8),_mm_load_ss(ptrC+8));\ - _tL = gmx_mm256_set_m128(_mm_load_ss(ptrH+8),_mm_load_ss(ptrD+8));\ - _tI = _mm256_unpacklo_ps(_tI,_tK);\ - _tJ = _mm256_unpacklo_ps(_tJ,_tL);\ - _tI = _mm256_unpacklo_ps(_tI,_tJ);\ - _tI = _mm256_sub_ps(_tI,_z3);\ - _tJ = _mm256_permute_ps(_tI,_MM_SHUFFLE(1,1,1,1));\ - _tK = _mm256_permute_ps(_tI,_MM_SHUFFLE(2,2,2,2));\ - _tL = _mm256_permute_ps(_tI,_MM_SHUFFLE(3,3,3,3));\ - _mm_store_ss(ptrA+8,_mm256_castps256_ps128(_tI));\ - _mm_store_ss(ptrB+8,_mm256_castps256_ps128(_tJ));\ - _mm_store_ss(ptrC+8,_mm256_castps256_ps128(_tK));\ - _mm_store_ss(ptrD+8,_mm256_castps256_ps128(_tL));\ - _mm_store_ss(ptrE+8,_mm256_extractf128_ps(_tI,0x1));\ - _mm_store_ss(ptrF+8,_mm256_extractf128_ps(_tJ,0x1));\ - _mm_store_ss(ptrG+8,_mm256_extractf128_ps(_tK,0x1));\ - _mm_store_ss(ptrH+8,_mm256_extractf128_ps(_tL,0x1));\ -} + _tA = _mm256_loadu_ps(ptrA); \ + _tB = _mm256_loadu_ps(ptrB); \ + _tC = _mm256_loadu_ps(ptrC); \ + _tD = _mm256_loadu_ps(ptrD); \ + _tE = _mm256_loadu_ps(ptrE); \ + _tF = _mm256_loadu_ps(ptrF); \ + _tG = _mm256_loadu_ps(ptrG); \ + _tH = _mm256_loadu_ps(ptrH); \ + _t1 = _mm256_unpacklo_ps(_x1, _y1); \ + _t2 = _mm256_unpackhi_ps(_x1, _y1); \ + _t3 = _mm256_unpacklo_ps(_z1, _x2); \ + _t4 = _mm256_unpackhi_ps(_z1, _x2); \ + _t5 = _mm256_unpacklo_ps(_y2, _z2); \ + _t6 = _mm256_unpackhi_ps(_y2, _z2); \ + _t7 = _mm256_unpacklo_ps(_x3, _y3); \ + _t8 = _mm256_unpackhi_ps(_x3, _y3); \ + _t9 = _mm256_shuffle_ps(_t1, _t3, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t10 = _mm256_shuffle_ps(_t1, _t3, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t11 = _mm256_shuffle_ps(_t2, _t4, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t12 = _mm256_shuffle_ps(_t2, _t4, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t1 = _mm256_shuffle_ps(_t5, _t7, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t2 = _mm256_shuffle_ps(_t5, _t7, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t3 = _mm256_shuffle_ps(_t6, _t8, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t4 = _mm256_shuffle_ps(_t6, _t8, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t5 = gmx_mm256_unpack128lo_ps(_t9, _t1); \ + _t6 = gmx_mm256_unpack128hi_ps(_t9, _t1); \ + _t7 = gmx_mm256_unpack128lo_ps(_t10, _t2); \ + _t8 = gmx_mm256_unpack128hi_ps(_t10, _t2); \ + _t1 = gmx_mm256_unpack128lo_ps(_t11, _t3); \ + _t2 = gmx_mm256_unpack128hi_ps(_t11, _t3); \ + _t9 = gmx_mm256_unpack128lo_ps(_t12, _t4); \ + _t10 = gmx_mm256_unpack128hi_ps(_t12, _t4); \ + _tA = _mm256_sub_ps(_tA, _t5); \ + _tB = _mm256_sub_ps(_tB, _t7); \ + _tC = _mm256_sub_ps(_tC, _t1); \ + _tD = _mm256_sub_ps(_tD, _t9); \ + _tE = _mm256_sub_ps(_tE, _t6); \ + _tF = _mm256_sub_ps(_tF, _t8); \ + _tG = _mm256_sub_ps(_tG, _t2); \ + _tH = _mm256_sub_ps(_tH, _t10); \ + _mm256_storeu_ps(ptrA, _tA); \ + _mm256_storeu_ps(ptrB, _tB); \ + _mm256_storeu_ps(ptrC, _tC); \ + _mm256_storeu_ps(ptrD, _tD); \ + _mm256_storeu_ps(ptrE, _tE); \ + _mm256_storeu_ps(ptrF, _tF); \ + _mm256_storeu_ps(ptrG, _tG); \ + _mm256_storeu_ps(ptrH, _tH); \ + _tI = gmx_mm256_set_m128(_mm_load_ss(ptrE+8), _mm_load_ss(ptrA+8)); \ + _tJ = gmx_mm256_set_m128(_mm_load_ss(ptrF+8), _mm_load_ss(ptrB+8)); \ + _tK = gmx_mm256_set_m128(_mm_load_ss(ptrG+8), _mm_load_ss(ptrC+8)); \ + _tL = gmx_mm256_set_m128(_mm_load_ss(ptrH+8), _mm_load_ss(ptrD+8)); \ + _tI = _mm256_unpacklo_ps(_tI, _tK); \ + _tJ = _mm256_unpacklo_ps(_tJ, _tL); \ + _tI = _mm256_unpacklo_ps(_tI, _tJ); \ + _tI = _mm256_sub_ps(_tI, _z3); \ + _tJ = _mm256_permute_ps(_tI, _MM_SHUFFLE(1, 1, 1, 1)); \ + _tK = _mm256_permute_ps(_tI, _MM_SHUFFLE(2, 2, 2, 2)); \ + _tL = _mm256_permute_ps(_tI, _MM_SHUFFLE(3, 3, 3, 3)); \ + _mm_store_ss(ptrA+8, _mm256_castps256_ps128(_tI)); \ + _mm_store_ss(ptrB+8, _mm256_castps256_ps128(_tJ)); \ + _mm_store_ss(ptrC+8, _mm256_castps256_ps128(_tK)); \ + _mm_store_ss(ptrD+8, _mm256_castps256_ps128(_tL)); \ + _mm_store_ss(ptrE+8, _mm256_extractf128_ps(_tI, 0x1)); \ + _mm_store_ss(ptrF+8, _mm256_extractf128_ps(_tJ, 0x1)); \ + _mm_store_ss(ptrG+8, _mm256_extractf128_ps(_tK, 0x1)); \ + _mm_store_ss(ptrH+8, _mm256_extractf128_ps(_tL, 0x1)); \ + } #else /* Real function for sane compilers */ static gmx_inline void gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, - float * gmx_restrict ptrC, float * gmx_restrict ptrD, - float * gmx_restrict ptrE, float * gmx_restrict ptrF, - float * gmx_restrict ptrG, float * gmx_restrict ptrH, - __m256 x1, __m256 y1, __m256 z1, - __m256 x2, __m256 y2, __m256 z2, - __m256 x3, __m256 y3, __m256 z3) + float * gmx_restrict ptrC, float * gmx_restrict ptrD, + float * gmx_restrict ptrE, float * gmx_restrict ptrF, + float * gmx_restrict ptrG, float * gmx_restrict ptrH, + __m256 x1, __m256 y1, __m256 z1, + __m256 x2, __m256 y2, __m256 z2, + __m256 x3, __m256 y3, __m256 z3) { - __m256 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - __m256 tA,tB,tC,tD,tE,tF,tG,tH; - __m256 tI,tJ,tK,tL; + __m256 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + __m256 tA, tB, tC, tD, tE, tF, tG, tH; + __m256 tI, tJ, tK, tL; tA = _mm256_loadu_ps(ptrA); tB = _mm256_loadu_ps(ptrB); @@ -1000,75 +1000,75 @@ gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx tG = _mm256_loadu_ps(ptrG); tH = _mm256_loadu_ps(ptrH); - t1 = _mm256_unpacklo_ps(x1,y1); /* y1f x1f y1e x1e | y1b x1b y1a x1a */ - t2 = _mm256_unpackhi_ps(x1,y1); /* y1h x1h y1g x1g | y1d x1d y1c x1c */ - t3 = _mm256_unpacklo_ps(z1,x2); /* x2f z1f x2e z1e | x2b z1b x2a z1a */ - t4 = _mm256_unpackhi_ps(z1,x2); /* x2h z1h x2g z1g | x2d z1d x2c z1c */ - - t5 = _mm256_unpacklo_ps(y2,z2); /* z2f y2f z2e y2e | z2b y2b z2a y2a */ - t6 = _mm256_unpackhi_ps(y2,z2); /* z2h y2h z2g y2g | z2d y2d z2c y2c */ - t7 = _mm256_unpacklo_ps(x3,y3); /* y3f x3f y3e x3e | y3b x3b y3a x3a */ - t8 = _mm256_unpackhi_ps(x3,y3); /* y3h x3h y3g x3g | y3d x3d y3c x3c */ - - t9 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(1,0,1,0)); /* x2e z1e y1e x1e | x2a z1a y1a x1a */ - t10 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(3,2,3,2)); /* x2f z1f y1f x1f | x2b z1b y1b x1b */ - t11 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(1,0,1,0)); /* x2g z1g y1g x1g | x2c z1c y1c x1c */ - t12 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(3,2,3,2)); /* x2h z1h y1h x1h | x2d z1d y1d x1d */ - - t1 = _mm256_shuffle_ps(t5,t7,_MM_SHUFFLE(1,0,1,0)); /* y3e x3e z2e y2e | y3a x3a z2a y2a */ - t2 = _mm256_shuffle_ps(t5,t7,_MM_SHUFFLE(3,2,3,2)); /* y3f x3f z2f y2f | y3b x3b z2b y2b */ - t3 = _mm256_shuffle_ps(t6,t8,_MM_SHUFFLE(1,0,1,0)); /* y3g x3g z2g y2g | y3c x3c z2c y2c */ - t4 = _mm256_shuffle_ps(t6,t8,_MM_SHUFFLE(3,2,3,2)); /* y3h x3h z2h y2h | y3d x3d z2d y2d */ - - t5 = gmx_mm256_unpack128lo_ps(t9,t1); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ - t6 = gmx_mm256_unpack128hi_ps(t9,t1); /* y3e x3e z2e y2e | x2e z1e y1e x1e */ - t7 = gmx_mm256_unpack128lo_ps(t10,t2); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ - t8 = gmx_mm256_unpack128hi_ps(t10,t2); /* y3f x3f z2f y2f | x2f z1f y1f x1f */ - t1 = gmx_mm256_unpack128lo_ps(t11,t3); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ - t2 = gmx_mm256_unpack128hi_ps(t11,t3); /* y3g x3g z2g y2g | x2g z1g y1g x1g */ - t9 = gmx_mm256_unpack128lo_ps(t12,t4); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ - t10 = gmx_mm256_unpack128hi_ps(t12,t4); /* y3h x3h z2h y2h | x2h z1h y1h x1h */ - - tA = _mm256_sub_ps(tA,t5); - tB = _mm256_sub_ps(tB,t7); - tC = _mm256_sub_ps(tC,t1); - tD = _mm256_sub_ps(tD,t9); - tE = _mm256_sub_ps(tE,t6); - tF = _mm256_sub_ps(tF,t8); - tG = _mm256_sub_ps(tG,t2); - tH = _mm256_sub_ps(tH,t10); - - _mm256_storeu_ps(ptrA,tA); - _mm256_storeu_ps(ptrB,tB); - _mm256_storeu_ps(ptrC,tC); - _mm256_storeu_ps(ptrD,tD); - _mm256_storeu_ps(ptrE,tE); - _mm256_storeu_ps(ptrF,tF); - _mm256_storeu_ps(ptrG,tG); - _mm256_storeu_ps(ptrH,tH); - - tI = gmx_mm256_set_m128(_mm_load_ss(ptrE+8),_mm_load_ss(ptrA+8)); - tJ = gmx_mm256_set_m128(_mm_load_ss(ptrF+8),_mm_load_ss(ptrB+8)); - tK = gmx_mm256_set_m128(_mm_load_ss(ptrG+8),_mm_load_ss(ptrC+8)); - tL = gmx_mm256_set_m128(_mm_load_ss(ptrH+8),_mm_load_ss(ptrD+8)); - - tI = _mm256_unpacklo_ps(tI,tK); /* - - zG zE | - - zC zA */ - tJ = _mm256_unpacklo_ps(tJ,tL); /* - - zH zF | - - zD zB */ - tI = _mm256_unpacklo_ps(tI,tJ); /* zH zG zF zE | zD zC zB zA */ - - tI = _mm256_sub_ps(tI,z3); - tJ = _mm256_permute_ps(tI,_MM_SHUFFLE(1,1,1,1)); - tK = _mm256_permute_ps(tI,_MM_SHUFFLE(2,2,2,2)); - tL = _mm256_permute_ps(tI,_MM_SHUFFLE(3,3,3,3)); - - _mm_store_ss(ptrA+8,_mm256_castps256_ps128(tI)); - _mm_store_ss(ptrB+8,_mm256_castps256_ps128(tJ)); - _mm_store_ss(ptrC+8,_mm256_castps256_ps128(tK)); - _mm_store_ss(ptrD+8,_mm256_castps256_ps128(tL)); - _mm_store_ss(ptrE+8,_mm256_extractf128_ps(tI,0x1)); - _mm_store_ss(ptrF+8,_mm256_extractf128_ps(tJ,0x1)); - _mm_store_ss(ptrG+8,_mm256_extractf128_ps(tK,0x1)); - _mm_store_ss(ptrH+8,_mm256_extractf128_ps(tL,0x1)); + t1 = _mm256_unpacklo_ps(x1, y1); /* y1f x1f y1e x1e | y1b x1b y1a x1a */ + t2 = _mm256_unpackhi_ps(x1, y1); /* y1h x1h y1g x1g | y1d x1d y1c x1c */ + t3 = _mm256_unpacklo_ps(z1, x2); /* x2f z1f x2e z1e | x2b z1b x2a z1a */ + t4 = _mm256_unpackhi_ps(z1, x2); /* x2h z1h x2g z1g | x2d z1d x2c z1c */ + + t5 = _mm256_unpacklo_ps(y2, z2); /* z2f y2f z2e y2e | z2b y2b z2a y2a */ + t6 = _mm256_unpackhi_ps(y2, z2); /* z2h y2h z2g y2g | z2d y2d z2c y2c */ + t7 = _mm256_unpacklo_ps(x3, y3); /* y3f x3f y3e x3e | y3b x3b y3a x3a */ + t8 = _mm256_unpackhi_ps(x3, y3); /* y3h x3h y3g x3g | y3d x3d y3c x3c */ + + t9 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(1, 0, 1, 0)); /* x2e z1e y1e x1e | x2a z1a y1a x1a */ + t10 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 2, 3, 2)); /* x2f z1f y1f x1f | x2b z1b y1b x1b */ + t11 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(1, 0, 1, 0)); /* x2g z1g y1g x1g | x2c z1c y1c x1c */ + t12 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(3, 2, 3, 2)); /* x2h z1h y1h x1h | x2d z1d y1d x1d */ + + t1 = _mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(1, 0, 1, 0)); /* y3e x3e z2e y2e | y3a x3a z2a y2a */ + t2 = _mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(3, 2, 3, 2)); /* y3f x3f z2f y2f | y3b x3b z2b y2b */ + t3 = _mm256_shuffle_ps(t6, t8, _MM_SHUFFLE(1, 0, 1, 0)); /* y3g x3g z2g y2g | y3c x3c z2c y2c */ + t4 = _mm256_shuffle_ps(t6, t8, _MM_SHUFFLE(3, 2, 3, 2)); /* y3h x3h z2h y2h | y3d x3d z2d y2d */ + + t5 = gmx_mm256_unpack128lo_ps(t9, t1); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ + t6 = gmx_mm256_unpack128hi_ps(t9, t1); /* y3e x3e z2e y2e | x2e z1e y1e x1e */ + t7 = gmx_mm256_unpack128lo_ps(t10, t2); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ + t8 = gmx_mm256_unpack128hi_ps(t10, t2); /* y3f x3f z2f y2f | x2f z1f y1f x1f */ + t1 = gmx_mm256_unpack128lo_ps(t11, t3); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ + t2 = gmx_mm256_unpack128hi_ps(t11, t3); /* y3g x3g z2g y2g | x2g z1g y1g x1g */ + t9 = gmx_mm256_unpack128lo_ps(t12, t4); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ + t10 = gmx_mm256_unpack128hi_ps(t12, t4); /* y3h x3h z2h y2h | x2h z1h y1h x1h */ + + tA = _mm256_sub_ps(tA, t5); + tB = _mm256_sub_ps(tB, t7); + tC = _mm256_sub_ps(tC, t1); + tD = _mm256_sub_ps(tD, t9); + tE = _mm256_sub_ps(tE, t6); + tF = _mm256_sub_ps(tF, t8); + tG = _mm256_sub_ps(tG, t2); + tH = _mm256_sub_ps(tH, t10); + + _mm256_storeu_ps(ptrA, tA); + _mm256_storeu_ps(ptrB, tB); + _mm256_storeu_ps(ptrC, tC); + _mm256_storeu_ps(ptrD, tD); + _mm256_storeu_ps(ptrE, tE); + _mm256_storeu_ps(ptrF, tF); + _mm256_storeu_ps(ptrG, tG); + _mm256_storeu_ps(ptrH, tH); + + tI = gmx_mm256_set_m128(_mm_load_ss(ptrE+8), _mm_load_ss(ptrA+8)); + tJ = gmx_mm256_set_m128(_mm_load_ss(ptrF+8), _mm_load_ss(ptrB+8)); + tK = gmx_mm256_set_m128(_mm_load_ss(ptrG+8), _mm_load_ss(ptrC+8)); + tL = gmx_mm256_set_m128(_mm_load_ss(ptrH+8), _mm_load_ss(ptrD+8)); + + tI = _mm256_unpacklo_ps(tI, tK); /* - - zG zE | - - zC zA */ + tJ = _mm256_unpacklo_ps(tJ, tL); /* - - zH zF | - - zD zB */ + tI = _mm256_unpacklo_ps(tI, tJ); /* zH zG zF zE | zD zC zB zA */ + + tI = _mm256_sub_ps(tI, z3); + tJ = _mm256_permute_ps(tI, _MM_SHUFFLE(1, 1, 1, 1)); + tK = _mm256_permute_ps(tI, _MM_SHUFFLE(2, 2, 2, 2)); + tL = _mm256_permute_ps(tI, _MM_SHUFFLE(3, 3, 3, 3)); + + _mm_store_ss(ptrA+8, _mm256_castps256_ps128(tI)); + _mm_store_ss(ptrB+8, _mm256_castps256_ps128(tJ)); + _mm_store_ss(ptrC+8, _mm256_castps256_ps128(tK)); + _mm_store_ss(ptrD+8, _mm256_castps256_ps128(tL)); + _mm_store_ss(ptrE+8, _mm256_extractf128_ps(tI, 0x1)); + _mm_store_ss(ptrF+8, _mm256_extractf128_ps(tJ, 0x1)); + _mm_store_ss(ptrG+8, _mm256_extractf128_ps(tK, 0x1)); + _mm_store_ss(ptrH+8, _mm256_extractf128_ps(tL, 0x1)); } #endif @@ -1076,100 +1076,100 @@ gmx_mm256_decrement_3rvec_8ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD,ptrE,ptrF,ptrG,ptrH, \ - _x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ - __m256 _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11,_t12;\ - __m256 _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH,_tI,_tJ,_tK,_tL;\ +#define gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, ptrE, ptrF, ptrG, ptrH, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m256 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11, _t12; \ + __m256 _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH, _tI, _tJ, _tK, _tL; \ \ - _tA = _mm256_loadu_ps(ptrA);\ - _tB = _mm256_loadu_ps(ptrB);\ - _tC = _mm256_loadu_ps(ptrC);\ - _tD = _mm256_loadu_ps(ptrD);\ - _tE = _mm256_loadu_ps(ptrE);\ - _tF = _mm256_loadu_ps(ptrF);\ - _tG = _mm256_loadu_ps(ptrG);\ - _tH = _mm256_loadu_ps(ptrH);\ - _t1 = _mm256_unpacklo_ps(_x1,_y1);\ - _t2 = _mm256_unpackhi_ps(_x1,_y1);\ - _t3 = _mm256_unpacklo_ps(_z1,_x2);\ - _t4 = _mm256_unpackhi_ps(_z1,_x2);\ - _t5 = _mm256_unpacklo_ps(_y2,_z2);\ - _t6 = _mm256_unpackhi_ps(_y2,_z2);\ - _t7 = _mm256_unpacklo_ps(_x3,_y3);\ - _t8 = _mm256_unpackhi_ps(_x3,_y3);\ - _t9 = _mm256_shuffle_ps(_t1,_t3,_MM_SHUFFLE(1,0,1,0));\ - _t10 = _mm256_shuffle_ps(_t1,_t3,_MM_SHUFFLE(3,2,3,2));\ - _t11 = _mm256_shuffle_ps(_t2,_t4,_MM_SHUFFLE(1,0,1,0));\ - _t12 = _mm256_shuffle_ps(_t2,_t4,_MM_SHUFFLE(3,2,3,2));\ - _t1 = _mm256_shuffle_ps(_t5,_t7,_MM_SHUFFLE(1,0,1,0));\ - _t2 = _mm256_shuffle_ps(_t5,_t7,_MM_SHUFFLE(3,2,3,2));\ - _t3 = _mm256_shuffle_ps(_t6,_t8,_MM_SHUFFLE(1,0,1,0));\ - _t4 = _mm256_shuffle_ps(_t6,_t8,_MM_SHUFFLE(3,2,3,2));\ - _t5 = gmx_mm256_unpack128lo_ps(_t9,_t1);\ - _t6 = gmx_mm256_unpack128hi_ps(_t9,_t1);\ - _t7 = gmx_mm256_unpack128lo_ps(_t10,_t2);\ - _t8 = gmx_mm256_unpack128hi_ps(_t10,_t2);\ - _t1 = gmx_mm256_unpack128lo_ps(_t11,_t3);\ - _t2 = gmx_mm256_unpack128hi_ps(_t11,_t3);\ - _t9 = gmx_mm256_unpack128lo_ps(_t12,_t4);\ - _t10 = gmx_mm256_unpack128hi_ps(_t12,_t4);\ - _tA = _mm256_sub_ps(_tA,_t5);\ - _tB = _mm256_sub_ps(_tB,_t7);\ - _tC = _mm256_sub_ps(_tC,_t1);\ - _tD = _mm256_sub_ps(_tD,_t9);\ - _tE = _mm256_sub_ps(_tE,_t6);\ - _tF = _mm256_sub_ps(_tF,_t8);\ - _tG = _mm256_sub_ps(_tG,_t2);\ - _tH = _mm256_sub_ps(_tH,_t10);\ - _mm256_storeu_ps(ptrA,_tA);\ - _mm256_storeu_ps(ptrB,_tB);\ - _mm256_storeu_ps(ptrC,_tC);\ - _mm256_storeu_ps(ptrD,_tD);\ - _mm256_storeu_ps(ptrE,_tE);\ - _mm256_storeu_ps(ptrF,_tF);\ - _mm256_storeu_ps(ptrG,_tG);\ - _mm256_storeu_ps(ptrH,_tH);\ - _tI = gmx_mm256_set_m128(_mm_loadu_ps(ptrE+8),_mm_loadu_ps(ptrA+8));\ - _tJ = gmx_mm256_set_m128(_mm_loadu_ps(ptrF+8),_mm_loadu_ps(ptrB+8));\ - _tK = gmx_mm256_set_m128(_mm_loadu_ps(ptrG+8),_mm_loadu_ps(ptrC+8));\ - _tL = gmx_mm256_set_m128(_mm_loadu_ps(ptrH+8),_mm_loadu_ps(ptrD+8));\ - _t1 = _mm256_unpacklo_ps(_z3,_x4);\ - _t2 = _mm256_unpackhi_ps(_z3,_x4);\ - _t3 = _mm256_unpacklo_ps(_y4,_z4);\ - _t4 = _mm256_unpackhi_ps(_y4,_z4);\ - _t5 = _mm256_shuffle_ps(_t1,_t3,_MM_SHUFFLE(1,0,1,0));\ - _t6 = _mm256_shuffle_ps(_t1,_t3,_MM_SHUFFLE(3,2,3,2));\ - _t7 = _mm256_shuffle_ps(_t2,_t4,_MM_SHUFFLE(1,0,1,0));\ - _t8 = _mm256_shuffle_ps(_t2,_t4,_MM_SHUFFLE(3,2,3,2));\ - _tI = _mm256_sub_ps(_tI,_t5);\ - _tJ = _mm256_sub_ps(_tJ,_t6);\ - _tK = _mm256_sub_ps(_tK,_t7);\ - _tL = _mm256_sub_ps(_tL,_t8);\ - _mm_storeu_ps(ptrA+8,_mm256_castps256_ps128(_tI));\ - _mm_storeu_ps(ptrB+8,_mm256_castps256_ps128(_tJ));\ - _mm_storeu_ps(ptrC+8,_mm256_castps256_ps128(_tK));\ - _mm_storeu_ps(ptrD+8,_mm256_castps256_ps128(_tL));\ - _mm_storeu_ps(ptrE+8,_mm256_extractf128_ps(_tI,0x1));\ - _mm_storeu_ps(ptrF+8,_mm256_extractf128_ps(_tJ,0x1));\ - _mm_storeu_ps(ptrG+8,_mm256_extractf128_ps(_tK,0x1));\ - _mm_storeu_ps(ptrH+8,_mm256_extractf128_ps(_tL,0x1));\ -} + _tA = _mm256_loadu_ps(ptrA); \ + _tB = _mm256_loadu_ps(ptrB); \ + _tC = _mm256_loadu_ps(ptrC); \ + _tD = _mm256_loadu_ps(ptrD); \ + _tE = _mm256_loadu_ps(ptrE); \ + _tF = _mm256_loadu_ps(ptrF); \ + _tG = _mm256_loadu_ps(ptrG); \ + _tH = _mm256_loadu_ps(ptrH); \ + _t1 = _mm256_unpacklo_ps(_x1, _y1); \ + _t2 = _mm256_unpackhi_ps(_x1, _y1); \ + _t3 = _mm256_unpacklo_ps(_z1, _x2); \ + _t4 = _mm256_unpackhi_ps(_z1, _x2); \ + _t5 = _mm256_unpacklo_ps(_y2, _z2); \ + _t6 = _mm256_unpackhi_ps(_y2, _z2); \ + _t7 = _mm256_unpacklo_ps(_x3, _y3); \ + _t8 = _mm256_unpackhi_ps(_x3, _y3); \ + _t9 = _mm256_shuffle_ps(_t1, _t3, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t10 = _mm256_shuffle_ps(_t1, _t3, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t11 = _mm256_shuffle_ps(_t2, _t4, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t12 = _mm256_shuffle_ps(_t2, _t4, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t1 = _mm256_shuffle_ps(_t5, _t7, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t2 = _mm256_shuffle_ps(_t5, _t7, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t3 = _mm256_shuffle_ps(_t6, _t8, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t4 = _mm256_shuffle_ps(_t6, _t8, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t5 = gmx_mm256_unpack128lo_ps(_t9, _t1); \ + _t6 = gmx_mm256_unpack128hi_ps(_t9, _t1); \ + _t7 = gmx_mm256_unpack128lo_ps(_t10, _t2); \ + _t8 = gmx_mm256_unpack128hi_ps(_t10, _t2); \ + _t1 = gmx_mm256_unpack128lo_ps(_t11, _t3); \ + _t2 = gmx_mm256_unpack128hi_ps(_t11, _t3); \ + _t9 = gmx_mm256_unpack128lo_ps(_t12, _t4); \ + _t10 = gmx_mm256_unpack128hi_ps(_t12, _t4); \ + _tA = _mm256_sub_ps(_tA, _t5); \ + _tB = _mm256_sub_ps(_tB, _t7); \ + _tC = _mm256_sub_ps(_tC, _t1); \ + _tD = _mm256_sub_ps(_tD, _t9); \ + _tE = _mm256_sub_ps(_tE, _t6); \ + _tF = _mm256_sub_ps(_tF, _t8); \ + _tG = _mm256_sub_ps(_tG, _t2); \ + _tH = _mm256_sub_ps(_tH, _t10); \ + _mm256_storeu_ps(ptrA, _tA); \ + _mm256_storeu_ps(ptrB, _tB); \ + _mm256_storeu_ps(ptrC, _tC); \ + _mm256_storeu_ps(ptrD, _tD); \ + _mm256_storeu_ps(ptrE, _tE); \ + _mm256_storeu_ps(ptrF, _tF); \ + _mm256_storeu_ps(ptrG, _tG); \ + _mm256_storeu_ps(ptrH, _tH); \ + _tI = gmx_mm256_set_m128(_mm_loadu_ps(ptrE+8), _mm_loadu_ps(ptrA+8)); \ + _tJ = gmx_mm256_set_m128(_mm_loadu_ps(ptrF+8), _mm_loadu_ps(ptrB+8)); \ + _tK = gmx_mm256_set_m128(_mm_loadu_ps(ptrG+8), _mm_loadu_ps(ptrC+8)); \ + _tL = gmx_mm256_set_m128(_mm_loadu_ps(ptrH+8), _mm_loadu_ps(ptrD+8)); \ + _t1 = _mm256_unpacklo_ps(_z3, _x4); \ + _t2 = _mm256_unpackhi_ps(_z3, _x4); \ + _t3 = _mm256_unpacklo_ps(_y4, _z4); \ + _t4 = _mm256_unpackhi_ps(_y4, _z4); \ + _t5 = _mm256_shuffle_ps(_t1, _t3, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t6 = _mm256_shuffle_ps(_t1, _t3, _MM_SHUFFLE(3, 2, 3, 2)); \ + _t7 = _mm256_shuffle_ps(_t2, _t4, _MM_SHUFFLE(1, 0, 1, 0)); \ + _t8 = _mm256_shuffle_ps(_t2, _t4, _MM_SHUFFLE(3, 2, 3, 2)); \ + _tI = _mm256_sub_ps(_tI, _t5); \ + _tJ = _mm256_sub_ps(_tJ, _t6); \ + _tK = _mm256_sub_ps(_tK, _t7); \ + _tL = _mm256_sub_ps(_tL, _t8); \ + _mm_storeu_ps(ptrA+8, _mm256_castps256_ps128(_tI)); \ + _mm_storeu_ps(ptrB+8, _mm256_castps256_ps128(_tJ)); \ + _mm_storeu_ps(ptrC+8, _mm256_castps256_ps128(_tK)); \ + _mm_storeu_ps(ptrD+8, _mm256_castps256_ps128(_tL)); \ + _mm_storeu_ps(ptrE+8, _mm256_extractf128_ps(_tI, 0x1)); \ + _mm_storeu_ps(ptrF+8, _mm256_extractf128_ps(_tJ, 0x1)); \ + _mm_storeu_ps(ptrG+8, _mm256_extractf128_ps(_tK, 0x1)); \ + _mm_storeu_ps(ptrH+8, _mm256_extractf128_ps(_tL, 0x1)); \ + } #else /* Real function for sane compilers */ static gmx_inline void gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, - float * gmx_restrict ptrC, float * gmx_restrict ptrD, - float * gmx_restrict ptrE, float * gmx_restrict ptrF, - float * gmx_restrict ptrG, float * gmx_restrict ptrH, - __m256 x1, __m256 y1, __m256 z1, - __m256 x2, __m256 y2, __m256 z2, - __m256 x3, __m256 y3, __m256 z3, - __m256 x4, __m256 y4, __m256 z4) + float * gmx_restrict ptrC, float * gmx_restrict ptrD, + float * gmx_restrict ptrE, float * gmx_restrict ptrF, + float * gmx_restrict ptrG, float * gmx_restrict ptrH, + __m256 x1, __m256 y1, __m256 z1, + __m256 x2, __m256 y2, __m256 z2, + __m256 x3, __m256 y3, __m256 z3, + __m256 x4, __m256 y4, __m256 z4) { - __m256 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - __m256 tA,tB,tC,tD,tE,tF,tG,tH; - __m256 tI,tJ,tK,tL; + __m256 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + __m256 tA, tB, tC, tD, tE, tF, tG, tH; + __m256 tI, tJ, tK, tL; tA = _mm256_loadu_ps(ptrA); tB = _mm256_loadu_ps(ptrB); @@ -1180,304 +1180,304 @@ gmx_mm256_decrement_4rvec_8ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx tG = _mm256_loadu_ps(ptrG); tH = _mm256_loadu_ps(ptrH); - t1 = _mm256_unpacklo_ps(x1,y1); /* y1f x1f y1e x1e | y1b x1b y1a x1a */ - t2 = _mm256_unpackhi_ps(x1,y1); /* y1h x1h y1g x1g | y1d x1d y1c x1c */ - t3 = _mm256_unpacklo_ps(z1,x2); /* x2f z1f x2e z1e | x2b z1b x2a z1a */ - t4 = _mm256_unpackhi_ps(z1,x2); /* x2h z1h x2g z1g | x2d z1d x2c z1c */ - - t5 = _mm256_unpacklo_ps(y2,z2); /* z2f y2f z2e y2e | z2b y2b z2a y2a */ - t6 = _mm256_unpackhi_ps(y2,z2); /* z2h y2h z2g y2g | z2d y2d z2c y2c */ - t7 = _mm256_unpacklo_ps(x3,y3); /* y3f x3f y3e x3e | y3b x3b y3a x3a */ - t8 = _mm256_unpackhi_ps(x3,y3); /* y3h x3h y3g x3g | y3d x3d y3c x3c */ - - t9 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(1,0,1,0)); /* x2e z1e y1e x1e | x2a z1a y1a x1a */ - t10 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(3,2,3,2)); /* x2f z1f y1f x1f | x2b z1b y1b x1b */ - t11 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(1,0,1,0)); /* x2g z1g y1g x1g | x2c z1c y1c x1c */ - t12 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(3,2,3,2)); /* x2h z1h y1h x1h | x2d z1d y1d x1d */ - - t1 = _mm256_shuffle_ps(t5,t7,_MM_SHUFFLE(1,0,1,0)); /* y3e x3e z2e y2e | y3a x3a z2a y2a */ - t2 = _mm256_shuffle_ps(t5,t7,_MM_SHUFFLE(3,2,3,2)); /* y3f x3f z2f y2f | y3b x3b z2b y2b */ - t3 = _mm256_shuffle_ps(t6,t8,_MM_SHUFFLE(1,0,1,0)); /* y3g x3g z2g y2g | y3c x3c z2c y2c */ - t4 = _mm256_shuffle_ps(t6,t8,_MM_SHUFFLE(3,2,3,2)); /* y3h x3h z2h y2h | y3d x3d z2d y2d */ - - t5 = gmx_mm256_unpack128lo_ps(t9,t1); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ - t6 = gmx_mm256_unpack128hi_ps(t9,t1); /* y3e x3e z2e y2e | x2e z1e y1e x1e */ - t7 = gmx_mm256_unpack128lo_ps(t10,t2); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ - t8 = gmx_mm256_unpack128hi_ps(t10,t2); /* y3f x3f z2f y2f | x2f z1f y1f x1f */ - t1 = gmx_mm256_unpack128lo_ps(t11,t3); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ - t2 = gmx_mm256_unpack128hi_ps(t11,t3); /* y3g x3g z2g y2g | x2g z1g y1g x1g */ - t9 = gmx_mm256_unpack128lo_ps(t12,t4); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ - t10 = gmx_mm256_unpack128hi_ps(t12,t4); /* y3h x3h z2h y2h | x2h z1h y1h x1h */ - - tA = _mm256_sub_ps(tA,t5); - tB = _mm256_sub_ps(tB,t7); - tC = _mm256_sub_ps(tC,t1); - tD = _mm256_sub_ps(tD,t9); - tE = _mm256_sub_ps(tE,t6); - tF = _mm256_sub_ps(tF,t8); - tG = _mm256_sub_ps(tG,t2); - tH = _mm256_sub_ps(tH,t10); - - _mm256_storeu_ps(ptrA,tA); - _mm256_storeu_ps(ptrB,tB); - _mm256_storeu_ps(ptrC,tC); - _mm256_storeu_ps(ptrD,tD); - _mm256_storeu_ps(ptrE,tE); - _mm256_storeu_ps(ptrF,tF); - _mm256_storeu_ps(ptrG,tG); - _mm256_storeu_ps(ptrH,tH); - - tI = gmx_mm256_set_m128(_mm_loadu_ps(ptrE+8),_mm_loadu_ps(ptrA+8)); - tJ = gmx_mm256_set_m128(_mm_loadu_ps(ptrF+8),_mm_loadu_ps(ptrB+8)); - tK = gmx_mm256_set_m128(_mm_loadu_ps(ptrG+8),_mm_loadu_ps(ptrC+8)); - tL = gmx_mm256_set_m128(_mm_loadu_ps(ptrH+8),_mm_loadu_ps(ptrD+8)); - - t1 = _mm256_unpacklo_ps(z3,x4); /* x4f z3f x4e z3e | x4b z3b x4a z3a */ - t2 = _mm256_unpackhi_ps(z3,x4); /* x4h z3h x4g z3g | x4d z3d x4c z3c */ - t3 = _mm256_unpacklo_ps(y4,z4); /* z4f y4f z4e y4e | z4b y4b z4a y4a */ - t4 = _mm256_unpackhi_ps(y4,z4); /* z4h y4h z4g y4g | z4d y4d z4c y4c */ - - t5 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(1,0,1,0)); /* z4e y4e x4e z3e | z4a y4a x4a z3a */ - t6 = _mm256_shuffle_ps(t1,t3,_MM_SHUFFLE(3,2,3,2)); /* z4f y4f x4f z3f | z4b y4b x4b z3b */ - t7 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(1,0,1,0)); /* z4g y4g x4g z3g | z4c y4c x4c z3c */ - t8 = _mm256_shuffle_ps(t2,t4,_MM_SHUFFLE(3,2,3,2)); /* z4h y4h x4h z3h | z4d y4d x4d z3d */ - - tI = _mm256_sub_ps(tI,t5); - tJ = _mm256_sub_ps(tJ,t6); - tK = _mm256_sub_ps(tK,t7); - tL = _mm256_sub_ps(tL,t8); - - _mm_storeu_ps(ptrA+8,_mm256_castps256_ps128(tI)); - _mm_storeu_ps(ptrB+8,_mm256_castps256_ps128(tJ)); - _mm_storeu_ps(ptrC+8,_mm256_castps256_ps128(tK)); - _mm_storeu_ps(ptrD+8,_mm256_castps256_ps128(tL)); - _mm_storeu_ps(ptrE+8,_mm256_extractf128_ps(tI,0x1)); - _mm_storeu_ps(ptrF+8,_mm256_extractf128_ps(tJ,0x1)); - _mm_storeu_ps(ptrG+8,_mm256_extractf128_ps(tK,0x1)); - _mm_storeu_ps(ptrH+8,_mm256_extractf128_ps(tL,0x1)); + t1 = _mm256_unpacklo_ps(x1, y1); /* y1f x1f y1e x1e | y1b x1b y1a x1a */ + t2 = _mm256_unpackhi_ps(x1, y1); /* y1h x1h y1g x1g | y1d x1d y1c x1c */ + t3 = _mm256_unpacklo_ps(z1, x2); /* x2f z1f x2e z1e | x2b z1b x2a z1a */ + t4 = _mm256_unpackhi_ps(z1, x2); /* x2h z1h x2g z1g | x2d z1d x2c z1c */ + + t5 = _mm256_unpacklo_ps(y2, z2); /* z2f y2f z2e y2e | z2b y2b z2a y2a */ + t6 = _mm256_unpackhi_ps(y2, z2); /* z2h y2h z2g y2g | z2d y2d z2c y2c */ + t7 = _mm256_unpacklo_ps(x3, y3); /* y3f x3f y3e x3e | y3b x3b y3a x3a */ + t8 = _mm256_unpackhi_ps(x3, y3); /* y3h x3h y3g x3g | y3d x3d y3c x3c */ + + t9 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(1, 0, 1, 0)); /* x2e z1e y1e x1e | x2a z1a y1a x1a */ + t10 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 2, 3, 2)); /* x2f z1f y1f x1f | x2b z1b y1b x1b */ + t11 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(1, 0, 1, 0)); /* x2g z1g y1g x1g | x2c z1c y1c x1c */ + t12 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(3, 2, 3, 2)); /* x2h z1h y1h x1h | x2d z1d y1d x1d */ + + t1 = _mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(1, 0, 1, 0)); /* y3e x3e z2e y2e | y3a x3a z2a y2a */ + t2 = _mm256_shuffle_ps(t5, t7, _MM_SHUFFLE(3, 2, 3, 2)); /* y3f x3f z2f y2f | y3b x3b z2b y2b */ + t3 = _mm256_shuffle_ps(t6, t8, _MM_SHUFFLE(1, 0, 1, 0)); /* y3g x3g z2g y2g | y3c x3c z2c y2c */ + t4 = _mm256_shuffle_ps(t6, t8, _MM_SHUFFLE(3, 2, 3, 2)); /* y3h x3h z2h y2h | y3d x3d z2d y2d */ + + t5 = gmx_mm256_unpack128lo_ps(t9, t1); /* y3a x3a z2a y2a | x2a z1a y1a x1a */ + t6 = gmx_mm256_unpack128hi_ps(t9, t1); /* y3e x3e z2e y2e | x2e z1e y1e x1e */ + t7 = gmx_mm256_unpack128lo_ps(t10, t2); /* y3b x3b z2b y2b | x2b z1b y1b x1b */ + t8 = gmx_mm256_unpack128hi_ps(t10, t2); /* y3f x3f z2f y2f | x2f z1f y1f x1f */ + t1 = gmx_mm256_unpack128lo_ps(t11, t3); /* y3c x3c z2c y2c | x2c z1c y1c x1c */ + t2 = gmx_mm256_unpack128hi_ps(t11, t3); /* y3g x3g z2g y2g | x2g z1g y1g x1g */ + t9 = gmx_mm256_unpack128lo_ps(t12, t4); /* y3d x3d z2d y2d | x2d z1d y1d x1d */ + t10 = gmx_mm256_unpack128hi_ps(t12, t4); /* y3h x3h z2h y2h | x2h z1h y1h x1h */ + + tA = _mm256_sub_ps(tA, t5); + tB = _mm256_sub_ps(tB, t7); + tC = _mm256_sub_ps(tC, t1); + tD = _mm256_sub_ps(tD, t9); + tE = _mm256_sub_ps(tE, t6); + tF = _mm256_sub_ps(tF, t8); + tG = _mm256_sub_ps(tG, t2); + tH = _mm256_sub_ps(tH, t10); + + _mm256_storeu_ps(ptrA, tA); + _mm256_storeu_ps(ptrB, tB); + _mm256_storeu_ps(ptrC, tC); + _mm256_storeu_ps(ptrD, tD); + _mm256_storeu_ps(ptrE, tE); + _mm256_storeu_ps(ptrF, tF); + _mm256_storeu_ps(ptrG, tG); + _mm256_storeu_ps(ptrH, tH); + + tI = gmx_mm256_set_m128(_mm_loadu_ps(ptrE+8), _mm_loadu_ps(ptrA+8)); + tJ = gmx_mm256_set_m128(_mm_loadu_ps(ptrF+8), _mm_loadu_ps(ptrB+8)); + tK = gmx_mm256_set_m128(_mm_loadu_ps(ptrG+8), _mm_loadu_ps(ptrC+8)); + tL = gmx_mm256_set_m128(_mm_loadu_ps(ptrH+8), _mm_loadu_ps(ptrD+8)); + + t1 = _mm256_unpacklo_ps(z3, x4); /* x4f z3f x4e z3e | x4b z3b x4a z3a */ + t2 = _mm256_unpackhi_ps(z3, x4); /* x4h z3h x4g z3g | x4d z3d x4c z3c */ + t3 = _mm256_unpacklo_ps(y4, z4); /* z4f y4f z4e y4e | z4b y4b z4a y4a */ + t4 = _mm256_unpackhi_ps(y4, z4); /* z4h y4h z4g y4g | z4d y4d z4c y4c */ + + t5 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(1, 0, 1, 0)); /* z4e y4e x4e z3e | z4a y4a x4a z3a */ + t6 = _mm256_shuffle_ps(t1, t3, _MM_SHUFFLE(3, 2, 3, 2)); /* z4f y4f x4f z3f | z4b y4b x4b z3b */ + t7 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(1, 0, 1, 0)); /* z4g y4g x4g z3g | z4c y4c x4c z3c */ + t8 = _mm256_shuffle_ps(t2, t4, _MM_SHUFFLE(3, 2, 3, 2)); /* z4h y4h x4h z3h | z4d y4d x4d z3d */ + + tI = _mm256_sub_ps(tI, t5); + tJ = _mm256_sub_ps(tJ, t6); + tK = _mm256_sub_ps(tK, t7); + tL = _mm256_sub_ps(tL, t8); + + _mm_storeu_ps(ptrA+8, _mm256_castps256_ps128(tI)); + _mm_storeu_ps(ptrB+8, _mm256_castps256_ps128(tJ)); + _mm_storeu_ps(ptrC+8, _mm256_castps256_ps128(tK)); + _mm_storeu_ps(ptrD+8, _mm256_castps256_ps128(tL)); + _mm_storeu_ps(ptrE+8, _mm256_extractf128_ps(tI, 0x1)); + _mm_storeu_ps(ptrF+8, _mm256_extractf128_ps(tJ, 0x1)); + _mm_storeu_ps(ptrG+8, _mm256_extractf128_ps(tK, 0x1)); + _mm_storeu_ps(ptrH+8, _mm256_extractf128_ps(tL, 0x1)); } #endif static gmx_inline void gmx_mm256_update_iforce_1atom_swizzle_ps(__m256 fix1, __m256 fiy1, __m256 fiz1, - float * gmx_restrict fptr, - float * gmx_restrict fshiftptr) + float * gmx_restrict fptr, + float * gmx_restrict fshiftptr) { - __m128 t1,t2,t3; + __m128 t1, t2, t3; - fix1 = _mm256_hadd_ps(fix1,fix1); - fiy1 = _mm256_hadd_ps(fiy1,fiz1); - fix1 = _mm256_hadd_ps(fix1,fiy1); /* fiz1 fiy1 fix1 fix1 (in both lanes) */ + fix1 = _mm256_hadd_ps(fix1, fix1); + fiy1 = _mm256_hadd_ps(fiy1, fiz1); + fix1 = _mm256_hadd_ps(fix1, fiy1); /* fiz1 fiy1 fix1 fix1 (in both lanes) */ /* Add across the two lanes */ - t1 = _mm_add_ps(_mm256_castps256_ps128(fix1),_mm256_extractf128_ps(fix1,0x1)); + t1 = _mm_add_ps(_mm256_castps256_ps128(fix1), _mm256_extractf128_ps(fix1, 0x1)); t2 = _mm_load_ss(fptr); - t2 = _mm_loadh_pi(t2,(__m64 *)(fptr+1)); + t2 = _mm_loadh_pi(t2, (__m64 *)(fptr+1)); t3 = _mm_load_ss(fshiftptr); - t3 = _mm_loadh_pi(t3,(__m64 *)(fshiftptr+1)); + t3 = _mm_loadh_pi(t3, (__m64 *)(fshiftptr+1)); - t2 = _mm_add_ps(t2,t1); - t3 = _mm_add_ps(t3,t1); + t2 = _mm_add_ps(t2, t1); + t3 = _mm_add_ps(t3, t1); - _mm_store_ss(fptr,t2); - _mm_storeh_pi((__m64 *)(fptr+1),t2); - _mm_store_ss(fshiftptr,t3); - _mm_storeh_pi((__m64 *)(fshiftptr+1),t3); + _mm_store_ss(fptr, t2); + _mm_storeh_pi((__m64 *)(fptr+1), t2); + _mm_store_ss(fshiftptr, t3); + _mm_storeh_pi((__m64 *)(fshiftptr+1), t3); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \ - fptr,fshiftptr) \ -{ \ - __m256 _t1,_t2,_t3;\ - __m128 _tA,_tB,_tC;\ +#define gmx_mm256_update_iforce_3atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \ + fptr, fshiftptr) \ + { \ + __m256 _t1, _t2, _t3; \ + __m128 _tA, _tB, _tC; \ \ - fix1 = _mm256_hadd_ps(fix1,fiy1);\ - fiz1 = _mm256_hadd_ps(fiz1,fix2);\ - fiy2 = _mm256_hadd_ps(fiy2,fiz2);\ - fix3 = _mm256_hadd_ps(fix3,fiy3);\ - fiz3 = _mm256_hadd_ps(fiz3,_mm256_setzero_ps());\ - fix1 = _mm256_hadd_ps(fix1,fiz1);\ - fiy2 = _mm256_hadd_ps(fiy2,fix3);\ - fiz3 = _mm256_hadd_ps(fiz3,_mm256_setzero_ps());\ + fix1 = _mm256_hadd_ps(fix1, fiy1); \ + fiz1 = _mm256_hadd_ps(fiz1, fix2); \ + fiy2 = _mm256_hadd_ps(fiy2, fiz2); \ + fix3 = _mm256_hadd_ps(fix3, fiy3); \ + fiz3 = _mm256_hadd_ps(fiz3, _mm256_setzero_ps()); \ + fix1 = _mm256_hadd_ps(fix1, fiz1); \ + fiy2 = _mm256_hadd_ps(fiy2, fix3); \ + fiz3 = _mm256_hadd_ps(fiz3, _mm256_setzero_ps()); \ \ - _t1 = gmx_mm256_unpack128lo_ps(fix1,fiy2);\ - _t2 = gmx_mm256_unpack128hi_ps(fix1,fiy2);\ - _t1 = _mm256_add_ps(_t1,_t2);\ - _tA = _mm_add_ps(_mm256_castps256_ps128(fiz3),_mm256_extractf128_ps(fiz3,0x1));\ - _t3 = _mm256_loadu_ps(fptr);\ - _t3 = _mm256_add_ps(_t3,_t1);\ - _mm256_storeu_ps(fptr,_t3);\ - _tB = _mm_load_ss(fptr+8);\ - _tB = _mm_add_ss(_tB,_tA);\ - _mm_store_ss(fptr+8,_tB);\ + _t1 = gmx_mm256_unpack128lo_ps(fix1, fiy2); \ + _t2 = gmx_mm256_unpack128hi_ps(fix1, fiy2); \ + _t1 = _mm256_add_ps(_t1, _t2); \ + _tA = _mm_add_ps(_mm256_castps256_ps128(fiz3), _mm256_extractf128_ps(fiz3, 0x1)); \ + _t3 = _mm256_loadu_ps(fptr); \ + _t3 = _mm256_add_ps(_t3, _t1); \ + _mm256_storeu_ps(fptr, _t3); \ + _tB = _mm_load_ss(fptr+8); \ + _tB = _mm_add_ss(_tB, _tA); \ + _mm_store_ss(fptr+8, _tB); \ \ - _tB = _mm256_extractf128_ps(_t1,0x1);\ - _tC = _mm_shuffle_ps(_mm256_castps256_ps128(_t1),_tB,_MM_SHUFFLE(1,0,3,3));\ - _tB = _mm_shuffle_ps(_tB,_tA,_MM_SHUFFLE(1,0,3,2));\ - _tC = _mm_permute_ps(_tC,_MM_SHUFFLE(3,3,2,0));\ - _tB = _mm_add_ps(_tB,_mm256_castps256_ps128(_t1));\ - _tA = _mm_add_ps(_tB,_tC);\ - _tA = _mm_blend_ps(_mm_setzero_ps(),_tA,0x7);\ - _tC = _mm_loadu_ps(fshiftptr);\ - _tC = _mm_add_ps(_tC,_tA);\ - _mm_storeu_ps(fshiftptr,_tC);\ -} + _tB = _mm256_extractf128_ps(_t1, 0x1); \ + _tC = _mm_shuffle_ps(_mm256_castps256_ps128(_t1), _tB, _MM_SHUFFLE(1, 0, 3, 3)); \ + _tB = _mm_shuffle_ps(_tB, _tA, _MM_SHUFFLE(1, 0, 3, 2)); \ + _tC = _mm_permute_ps(_tC, _MM_SHUFFLE(3, 3, 2, 0)); \ + _tB = _mm_add_ps(_tB, _mm256_castps256_ps128(_t1)); \ + _tA = _mm_add_ps(_tB, _tC); \ + _tA = _mm_blend_ps(_mm_setzero_ps(), _tA, 0x7); \ + _tC = _mm_loadu_ps(fshiftptr); \ + _tC = _mm_add_ps(_tC, _tA); \ + _mm_storeu_ps(fshiftptr, _tC); \ + } #else /* Real function for sane compilers */ static gmx_inline void gmx_mm256_update_iforce_3atom_swizzle_ps(__m256 fix1, __m256 fiy1, __m256 fiz1, - __m256 fix2, __m256 fiy2, __m256 fiz2, - __m256 fix3, __m256 fiy3, __m256 fiz3, - float * gmx_restrict fptr, - float * gmx_restrict fshiftptr) + __m256 fix2, __m256 fiy2, __m256 fiz2, + __m256 fix3, __m256 fiy3, __m256 fiz3, + float * gmx_restrict fptr, + float * gmx_restrict fshiftptr) { - __m256 t1,t2,t3; - __m128 tA,tB,tC; + __m256 t1, t2, t3; + __m128 tA, tB, tC; - fix1 = _mm256_hadd_ps(fix1,fiy1); /* Y1g+Y1h Y1e+Y1f X1g+X1h X1e+X1f | Y1c+Y1d Y1a+Y1b X1c+X1d X1a+X1b */ - fiz1 = _mm256_hadd_ps(fiz1,fix2); /* X2g+X2h X2e+X2f Z1g+Z1h Z1e+Z1f | X2c+X2d X2a+X2b Z1c+Z1d Z1a+Z1b */ - fiy2 = _mm256_hadd_ps(fiy2,fiz2); /* Z2g+Z2h Z2e+Z2f Y2g+Y2h Y2e+Y2f | Z2c+Z2d Z2a+Z2b Y2c+Y2d Y2a+Y2b */ - fix3 = _mm256_hadd_ps(fix3,fiy3); /* Y3g+Y3h Y3e+Y3f X3g+X3h X3e+X3f | Y3c+Y3d Y3a+Y3b X3c+X3d X3a+X3b */ - fiz3 = _mm256_hadd_ps(fiz3,_mm256_setzero_ps()); /* 0 0 Z3g+Z3h Z3e+Z3f | 0 0 Z3c+Z3d Z3a+Z3b */ + fix1 = _mm256_hadd_ps(fix1, fiy1); /* Y1g+Y1h Y1e+Y1f X1g+X1h X1e+X1f | Y1c+Y1d Y1a+Y1b X1c+X1d X1a+X1b */ + fiz1 = _mm256_hadd_ps(fiz1, fix2); /* X2g+X2h X2e+X2f Z1g+Z1h Z1e+Z1f | X2c+X2d X2a+X2b Z1c+Z1d Z1a+Z1b */ + fiy2 = _mm256_hadd_ps(fiy2, fiz2); /* Z2g+Z2h Z2e+Z2f Y2g+Y2h Y2e+Y2f | Z2c+Z2d Z2a+Z2b Y2c+Y2d Y2a+Y2b */ + fix3 = _mm256_hadd_ps(fix3, fiy3); /* Y3g+Y3h Y3e+Y3f X3g+X3h X3e+X3f | Y3c+Y3d Y3a+Y3b X3c+X3d X3a+X3b */ + fiz3 = _mm256_hadd_ps(fiz3, _mm256_setzero_ps()); /* 0 0 Z3g+Z3h Z3e+Z3f | 0 0 Z3c+Z3d Z3a+Z3b */ - fix1 = _mm256_hadd_ps(fix1,fiz1); /* X2e-h Z1e-h Y1e-h X1e-h | X2a-d Z1a-d Y1a-d X1a-d */ - fiy2 = _mm256_hadd_ps(fiy2,fix3); /* Y3e-h X3e-h Z2e-h Y2e-h | Y3a-d X3a-d Z2a-d Y2a-d */ - fiz3 = _mm256_hadd_ps(fiz3,_mm256_setzero_ps()); /* 0 0 0 Z3e-h | 0 0 0 Z3a-d */ + fix1 = _mm256_hadd_ps(fix1, fiz1); /* X2e-h Z1e-h Y1e-h X1e-h | X2a-d Z1a-d Y1a-d X1a-d */ + fiy2 = _mm256_hadd_ps(fiy2, fix3); /* Y3e-h X3e-h Z2e-h Y2e-h | Y3a-d X3a-d Z2a-d Y2a-d */ + fiz3 = _mm256_hadd_ps(fiz3, _mm256_setzero_ps()); /* 0 0 0 Z3e-h | 0 0 0 Z3a-d */ /* Add across the two lanes by swapping and adding back */ - t1 = gmx_mm256_unpack128lo_ps(fix1,fiy2); /* Y3a-d X3a-d Z2a-d Y2a-d | X2a-d Z1a-d Y1a-d X1a-d */ - t2 = gmx_mm256_unpack128hi_ps(fix1,fiy2); /* Y3e-h X3e-h Z2e-h Y2e-h | X2e-h Z1e-h Y1e-h X1e-h */ - t1 = _mm256_add_ps(t1,t2); /* y3 x3 z2 y2 | x2 z1 y1 x1 */ + t1 = gmx_mm256_unpack128lo_ps(fix1, fiy2); /* Y3a-d X3a-d Z2a-d Y2a-d | X2a-d Z1a-d Y1a-d X1a-d */ + t2 = gmx_mm256_unpack128hi_ps(fix1, fiy2); /* Y3e-h X3e-h Z2e-h Y2e-h | X2e-h Z1e-h Y1e-h X1e-h */ + t1 = _mm256_add_ps(t1, t2); /* y3 x3 z2 y2 | x2 z1 y1 x1 */ - tA = _mm_add_ps(_mm256_castps256_ps128(fiz3),_mm256_extractf128_ps(fiz3,0x1)); /* 0 0 0 z3 */ + tA = _mm_add_ps(_mm256_castps256_ps128(fiz3), _mm256_extractf128_ps(fiz3, 0x1)); /* 0 0 0 z3 */ t3 = _mm256_loadu_ps(fptr); - t3 = _mm256_add_ps(t3,t1); - _mm256_storeu_ps(fptr,t3); + t3 = _mm256_add_ps(t3, t1); + _mm256_storeu_ps(fptr, t3); tB = _mm_load_ss(fptr+8); - tB = _mm_add_ss(tB,tA); - _mm_store_ss(fptr+8,tB); + tB = _mm_add_ss(tB, tA); + _mm_store_ss(fptr+8, tB); /* Add up shift force */ - tB = _mm256_extractf128_ps(t1,0x1); /* y3 x3 z2 y2 */ - tC = _mm_shuffle_ps(_mm256_castps256_ps128(t1),tB,_MM_SHUFFLE(1,0,3,3)); /* z2 y2 x2 x2 */ - tB = _mm_shuffle_ps(tB,tA,_MM_SHUFFLE(1,0,3,2)); /* 0 z3 y3 x3 */ - tC = _mm_permute_ps(tC,_MM_SHUFFLE(3,3,2,0)); /* - z2 y2 x2 */ + tB = _mm256_extractf128_ps(t1, 0x1); /* y3 x3 z2 y2 */ + tC = _mm_shuffle_ps(_mm256_castps256_ps128(t1), tB, _MM_SHUFFLE(1, 0, 3, 3)); /* z2 y2 x2 x2 */ + tB = _mm_shuffle_ps(tB, tA, _MM_SHUFFLE(1, 0, 3, 2)); /* 0 z3 y3 x3 */ + tC = _mm_permute_ps(tC, _MM_SHUFFLE(3, 3, 2, 0)); /* - z2 y2 x2 */ - tB = _mm_add_ps(tB,_mm256_castps256_ps128(t1)); - tA = _mm_add_ps(tB,tC); /* - z y x */ + tB = _mm_add_ps(tB, _mm256_castps256_ps128(t1)); + tA = _mm_add_ps(tB, tC); /* - z y x */ - tA = _mm_blend_ps(_mm_setzero_ps(),tA,0x7); /* 0 z y x */ + tA = _mm_blend_ps(_mm_setzero_ps(), tA, 0x7); /* 0 z y x */ tC = _mm_loadu_ps(fshiftptr); - tC = _mm_add_ps(tC,tA); - _mm_storeu_ps(fshiftptr,tC); + tC = _mm_add_ps(tC, tA); + _mm_storeu_ps(fshiftptr, tC); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm256_update_iforce_4atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \ - fptr,fshiftptr) \ -{ \ - __m256 _t1,_t2,_t3; \ - __m128 _tA,_tB,_tC; \ +#define gmx_mm256_update_iforce_4atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \ + fptr, fshiftptr) \ + { \ + __m256 _t1, _t2, _t3; \ + __m128 _tA, _tB, _tC; \ \ - fix1 = _mm256_hadd_ps(fix1,fiy1);\ - fiz1 = _mm256_hadd_ps(fiz1,fix2);\ - fiy2 = _mm256_hadd_ps(fiy2,fiz2);\ - fix3 = _mm256_hadd_ps(fix3,fiy3);\ - fiz3 = _mm256_hadd_ps(fiz3,fix4);\ - fiy4 = _mm256_hadd_ps(fiy4,fiz4);\ + fix1 = _mm256_hadd_ps(fix1, fiy1); \ + fiz1 = _mm256_hadd_ps(fiz1, fix2); \ + fiy2 = _mm256_hadd_ps(fiy2, fiz2); \ + fix3 = _mm256_hadd_ps(fix3, fiy3); \ + fiz3 = _mm256_hadd_ps(fiz3, fix4); \ + fiy4 = _mm256_hadd_ps(fiy4, fiz4); \ \ - fix1 = _mm256_hadd_ps(fix1,fiz1);\ - fiy2 = _mm256_hadd_ps(fiy2,fix3);\ - fiz3 = _mm256_hadd_ps(fiz3,fiy4);\ + fix1 = _mm256_hadd_ps(fix1, fiz1); \ + fiy2 = _mm256_hadd_ps(fiy2, fix3); \ + fiz3 = _mm256_hadd_ps(fiz3, fiy4); \ \ - _t1 = gmx_mm256_unpack128lo_ps(fix1,fiy2);\ - _t2 = gmx_mm256_unpack128hi_ps(fix1,fiy2);\ - _t1 = _mm256_add_ps(_t1,_t2);\ - _tA = _mm_add_ps(_mm256_castps256_ps128(fiz3),_mm256_extractf128_ps(fiz3,0x1));\ - _t3 = _mm256_loadu_ps(fptr);\ - _t3 = _mm256_add_ps(_t3,_t1);\ - _mm256_storeu_ps(fptr,_t3);\ - _tB = _mm_loadu_ps(fptr+8);\ - _tB = _mm_add_ps(_tB,_tA);\ - _mm_storeu_ps(fptr+8,_tB);\ + _t1 = gmx_mm256_unpack128lo_ps(fix1, fiy2); \ + _t2 = gmx_mm256_unpack128hi_ps(fix1, fiy2); \ + _t1 = _mm256_add_ps(_t1, _t2); \ + _tA = _mm_add_ps(_mm256_castps256_ps128(fiz3), _mm256_extractf128_ps(fiz3, 0x1)); \ + _t3 = _mm256_loadu_ps(fptr); \ + _t3 = _mm256_add_ps(_t3, _t1); \ + _mm256_storeu_ps(fptr, _t3); \ + _tB = _mm_loadu_ps(fptr+8); \ + _tB = _mm_add_ps(_tB, _tA); \ + _mm_storeu_ps(fptr+8, _tB); \ \ - _tB = _mm256_extractf128_ps(_t1,0x1);\ - _tC = _mm_shuffle_ps(_mm256_castps256_ps128(_t1),_tB,_MM_SHUFFLE(1,0,3,3));\ - _tB = _mm_shuffle_ps(_tB,_tA,_MM_SHUFFLE(1,0,3,2));\ - _tC = _mm_permute_ps(_tC,_MM_SHUFFLE(3,3,2,0));\ - _tA = _mm_permute_ps(_tA,_MM_SHUFFLE(0,3,2,1));\ - _tB = _mm_add_ps(_tB,_mm256_castps256_ps128(_t1));\ - _tA = _mm_add_ps(_tA,_tC);\ - _tA = _mm_add_ps(_tA,_tB);\ - _tA = _mm_blend_ps(_mm_setzero_ps(),_tA,0x7);\ - _tC = _mm_loadu_ps(fshiftptr);\ - _tC = _mm_add_ps(_tC,_tA);\ - _mm_storeu_ps(fshiftptr,_tC);\ -} + _tB = _mm256_extractf128_ps(_t1, 0x1); \ + _tC = _mm_shuffle_ps(_mm256_castps256_ps128(_t1), _tB, _MM_SHUFFLE(1, 0, 3, 3)); \ + _tB = _mm_shuffle_ps(_tB, _tA, _MM_SHUFFLE(1, 0, 3, 2)); \ + _tC = _mm_permute_ps(_tC, _MM_SHUFFLE(3, 3, 2, 0)); \ + _tA = _mm_permute_ps(_tA, _MM_SHUFFLE(0, 3, 2, 1)); \ + _tB = _mm_add_ps(_tB, _mm256_castps256_ps128(_t1)); \ + _tA = _mm_add_ps(_tA, _tC); \ + _tA = _mm_add_ps(_tA, _tB); \ + _tA = _mm_blend_ps(_mm_setzero_ps(), _tA, 0x7); \ + _tC = _mm_loadu_ps(fshiftptr); \ + _tC = _mm_add_ps(_tC, _tA); \ + _mm_storeu_ps(fshiftptr, _tC); \ + } #else /* Real function for sane compilers */ static gmx_inline void gmx_mm256_update_iforce_4atom_swizzle_ps(__m256 fix1, __m256 fiy1, __m256 fiz1, - __m256 fix2, __m256 fiy2, __m256 fiz2, - __m256 fix3, __m256 fiy3, __m256 fiz3, - __m256 fix4, __m256 fiy4, __m256 fiz4, - float * gmx_restrict fptr, - float * gmx_restrict fshiftptr) + __m256 fix2, __m256 fiy2, __m256 fiz2, + __m256 fix3, __m256 fiy3, __m256 fiz3, + __m256 fix4, __m256 fiy4, __m256 fiz4, + float * gmx_restrict fptr, + float * gmx_restrict fshiftptr) { - __m256 t1,t2,t3; - __m128 tA,tB,tC; + __m256 t1, t2, t3; + __m128 tA, tB, tC; - fix1 = _mm256_hadd_ps(fix1,fiy1); /* Y1g+Y1h Y1e+Y1f X1g+X1h X1e+X1f | Y1c+Y1d Y1a+Y1b X1c+X1d X1a+X1b */ - fiz1 = _mm256_hadd_ps(fiz1,fix2); /* X2g+X2h X2e+X2f Z1g+Z1h Z1e+Z1f | X2c+X2d X2a+X2b Z1c+Z1d Z1a+Z1b */ - fiy2 = _mm256_hadd_ps(fiy2,fiz2); /* Z2g+Z2h Z2e+Z2f Y2g+Y2h Y2e+Y2f | Z2c+Z2d Z2a+Z2b Y2c+Y2d Y2a+Y2b */ - fix3 = _mm256_hadd_ps(fix3,fiy3); /* Y3g+Y3h Y3e+Y3f X3g+X3h X3e+X3f | Y3c+Y3d Y3a+Y3b X3c+X3d X3a+X3b */ - fiz3 = _mm256_hadd_ps(fiz3,fix4); /* X4g+X4h X4e+X4f Z3g+Z3h Z3e+Z3f | X4c+X4d X4a+X4b Z3c+Z3d Z3a+Z3b */ - fiy4 = _mm256_hadd_ps(fiy4,fiz4); /* Z4g+Z4h Z4e+Z4f Y4g+Y4h Y4e+Y4f | Z4c+Z4d Z4a+Z4b Y4c+Y4d Y4a+Y4b */ + fix1 = _mm256_hadd_ps(fix1, fiy1); /* Y1g+Y1h Y1e+Y1f X1g+X1h X1e+X1f | Y1c+Y1d Y1a+Y1b X1c+X1d X1a+X1b */ + fiz1 = _mm256_hadd_ps(fiz1, fix2); /* X2g+X2h X2e+X2f Z1g+Z1h Z1e+Z1f | X2c+X2d X2a+X2b Z1c+Z1d Z1a+Z1b */ + fiy2 = _mm256_hadd_ps(fiy2, fiz2); /* Z2g+Z2h Z2e+Z2f Y2g+Y2h Y2e+Y2f | Z2c+Z2d Z2a+Z2b Y2c+Y2d Y2a+Y2b */ + fix3 = _mm256_hadd_ps(fix3, fiy3); /* Y3g+Y3h Y3e+Y3f X3g+X3h X3e+X3f | Y3c+Y3d Y3a+Y3b X3c+X3d X3a+X3b */ + fiz3 = _mm256_hadd_ps(fiz3, fix4); /* X4g+X4h X4e+X4f Z3g+Z3h Z3e+Z3f | X4c+X4d X4a+X4b Z3c+Z3d Z3a+Z3b */ + fiy4 = _mm256_hadd_ps(fiy4, fiz4); /* Z4g+Z4h Z4e+Z4f Y4g+Y4h Y4e+Y4f | Z4c+Z4d Z4a+Z4b Y4c+Y4d Y4a+Y4b */ - fix1 = _mm256_hadd_ps(fix1,fiz1); /* X2e-h Z1e-h Y1e-h X1e-h | X2a-d Z1a-d Y1a-d X1a-d */ - fiy2 = _mm256_hadd_ps(fiy2,fix3); /* Y3e-h X3e-h Z2e-h Y2e-h | Y3a-d X3a-d Z2a-d Y2a-d */ - fiz3 = _mm256_hadd_ps(fiz3,fiy4); /* Z4e-h Y4e-h X4e-h Z3e-h | Z4a-d Y4a-d X4a-d Z3a-d */ + fix1 = _mm256_hadd_ps(fix1, fiz1); /* X2e-h Z1e-h Y1e-h X1e-h | X2a-d Z1a-d Y1a-d X1a-d */ + fiy2 = _mm256_hadd_ps(fiy2, fix3); /* Y3e-h X3e-h Z2e-h Y2e-h | Y3a-d X3a-d Z2a-d Y2a-d */ + fiz3 = _mm256_hadd_ps(fiz3, fiy4); /* Z4e-h Y4e-h X4e-h Z3e-h | Z4a-d Y4a-d X4a-d Z3a-d */ /* Add across the two lanes by swapping and adding back */ - t1 = gmx_mm256_unpack128lo_ps(fix1,fiy2); /* Y3a-d X3a-d Z2a-d Y2a-d | X2a-d Z1a-d Y1a-d X1a-d */ - t2 = gmx_mm256_unpack128hi_ps(fix1,fiy2); /* Y3e-h X3e-h Z2e-h Y2e-h | X2e-h Z1e-h Y1e-h X1e-h */ - t1 = _mm256_add_ps(t1,t2); /* y3 x3 z2 y2 | x2 z1 y1 x1 */ + t1 = gmx_mm256_unpack128lo_ps(fix1, fiy2); /* Y3a-d X3a-d Z2a-d Y2a-d | X2a-d Z1a-d Y1a-d X1a-d */ + t2 = gmx_mm256_unpack128hi_ps(fix1, fiy2); /* Y3e-h X3e-h Z2e-h Y2e-h | X2e-h Z1e-h Y1e-h X1e-h */ + t1 = _mm256_add_ps(t1, t2); /* y3 x3 z2 y2 | x2 z1 y1 x1 */ - tA = _mm_add_ps(_mm256_castps256_ps128(fiz3),_mm256_extractf128_ps(fiz3,0x1)); /* z4 y4 x4 z3 */ + tA = _mm_add_ps(_mm256_castps256_ps128(fiz3), _mm256_extractf128_ps(fiz3, 0x1)); /* z4 y4 x4 z3 */ t3 = _mm256_loadu_ps(fptr); - t3 = _mm256_add_ps(t3,t1); - _mm256_storeu_ps(fptr,t3); + t3 = _mm256_add_ps(t3, t1); + _mm256_storeu_ps(fptr, t3); tB = _mm_loadu_ps(fptr+8); - tB = _mm_add_ps(tB,tA); - _mm_storeu_ps(fptr+8,tB); + tB = _mm_add_ps(tB, tA); + _mm_storeu_ps(fptr+8, tB); /* Add up shift force */ - tB = _mm256_extractf128_ps(t1,0x1); /* y3 x3 z2 y2 */ - tC = _mm_shuffle_ps(_mm256_castps256_ps128(t1),tB,_MM_SHUFFLE(1,0,3,3)); /* z2 y2 x2 x2 */ - tB = _mm_shuffle_ps(tB,tA,_MM_SHUFFLE(1,0,3,2)); /* 0 z3 y3 x3 */ - tC = _mm_permute_ps(tC,_MM_SHUFFLE(3,3,2,0)); /* - z2 y2 x2 */ - tA = _mm_permute_ps(tA,_MM_SHUFFLE(0,3,2,1)); /* - z4 y4 x4 */ + tB = _mm256_extractf128_ps(t1, 0x1); /* y3 x3 z2 y2 */ + tC = _mm_shuffle_ps(_mm256_castps256_ps128(t1), tB, _MM_SHUFFLE(1, 0, 3, 3)); /* z2 y2 x2 x2 */ + tB = _mm_shuffle_ps(tB, tA, _MM_SHUFFLE(1, 0, 3, 2)); /* 0 z3 y3 x3 */ + tC = _mm_permute_ps(tC, _MM_SHUFFLE(3, 3, 2, 0)); /* - z2 y2 x2 */ + tA = _mm_permute_ps(tA, _MM_SHUFFLE(0, 3, 2, 1)); /* - z4 y4 x4 */ - tB = _mm_add_ps(tB,_mm256_castps256_ps128(t1)); - tA = _mm_add_ps(tA,tC); - tA = _mm_add_ps(tA,tB); + tB = _mm_add_ps(tB, _mm256_castps256_ps128(t1)); + tA = _mm_add_ps(tA, tC); + tA = _mm_add_ps(tA, tB); - tA = _mm_blend_ps(_mm_setzero_ps(),tA,0x7); /* 0 z y x */ + tA = _mm_blend_ps(_mm_setzero_ps(), tA, 0x7); /* 0 z y x */ tC = _mm_loadu_ps(fshiftptr); - tC = _mm_add_ps(tC,tA); - _mm_storeu_ps(fshiftptr,tC); + tC = _mm_add_ps(tC, tA); + _mm_storeu_ps(fshiftptr, tC); } #endif @@ -1488,28 +1488,28 @@ gmx_mm256_update_1pot_ps(__m256 pot1, float * gmx_restrict ptrA) { __m128 t1; - pot1 = _mm256_hadd_ps(pot1,pot1); - pot1 = _mm256_hadd_ps(pot1,pot1); + pot1 = _mm256_hadd_ps(pot1, pot1); + pot1 = _mm256_hadd_ps(pot1, pot1); - t1 = _mm_add_ps(_mm256_castps256_ps128(pot1),_mm256_extractf128_ps(pot1,0x1)); + t1 = _mm_add_ps(_mm256_castps256_ps128(pot1), _mm256_extractf128_ps(pot1, 0x1)); - _mm_store_ss(ptrA,_mm_add_ss(_mm_load_ss(ptrA),t1)); + _mm_store_ss(ptrA, _mm_add_ss(_mm_load_ss(ptrA), t1)); } static gmx_inline void gmx_mm256_update_2pot_ps(__m256 pot1, float * gmx_restrict ptrA, __m256 pot2, float * gmx_restrict ptrB) { - __m128 t1,t2; + __m128 t1, t2; - pot1 = _mm256_hadd_ps(pot1,pot2); - pot1 = _mm256_hadd_ps(pot1,pot1); + pot1 = _mm256_hadd_ps(pot1, pot2); + pot1 = _mm256_hadd_ps(pot1, pot1); - t1 = _mm_add_ps(_mm256_castps256_ps128(pot1),_mm256_extractf128_ps(pot1,0x1)); + t1 = _mm_add_ps(_mm256_castps256_ps128(pot1), _mm256_extractf128_ps(pot1, 0x1)); - t2 = _mm_permute_ps(t1,_MM_SHUFFLE(1,1,1,1)); - _mm_store_ss(ptrA,_mm_add_ss(_mm_load_ss(ptrA),t1)); - _mm_store_ss(ptrB,_mm_add_ss(_mm_load_ss(ptrB),t2)); + t2 = _mm_permute_ps(t1, _MM_SHUFFLE(1, 1, 1, 1)); + _mm_store_ss(ptrA, _mm_add_ss(_mm_load_ss(ptrA), t1)); + _mm_store_ss(ptrB, _mm_add_ss(_mm_load_ss(ptrB), t2)); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.c index f316f44605..7d71b2ce66 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.c @@ -241,7 +241,7 @@ nb_kernel_t nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_avx_256_single; nb_kernel_info_t -kernellist_avx_256_single[] = + kernellist_avx_256_single[] = { { nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_256_single, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_avx_256_single", "avx_256_single", "None", "None", "LennardJones", "None", "ParticleParticle", "", "PotentialAndForce" }, { nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_256_single, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_avx_256_single", "avx_256_single", "None", "None", "LennardJones", "None", "ParticleParticle", "", "Force" }, @@ -460,6 +460,6 @@ kernellist_avx_256_single[] = }; int -kernellist_avx_256_single_size = sizeof(kernellist_avx_256_single)/sizeof(kernellist_avx_256_single[0]); + kernellist_avx_256_single_size = sizeof(kernellist_avx_256_single)/sizeof(kernellist_avx_256_single[0]); #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.h index b8c3987b8f..c2faa27268 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_avx_256_single/nb_kernel_avx_256_single.h @@ -27,10 +27,10 @@ /* List of kernels for this architecture with metadata about them */ extern nb_kernel_info_t -kernellist_avx_256_single[]; + kernellist_avx_256_single[]; /* Length of kernellist_c */ extern int -kernellist_avx_256_single_size; + kernellist_avx_256_single_size; #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_c/nb_kernel_allvsall.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_c/nb_kernel_allvsall.c index 25dbb9c075..0bf2a40107 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_c/nb_kernel_allvsall.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_c/nb_kernel_allvsall.c @@ -10,16 +10,16 @@ * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for * a full list of developers and information, check out http://www.gromacs.org * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) any + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) any * later version. * As a special exception, you may use this file as part of a free software * library without restriction. Specifically, if other files instantiate * templates or use macros or inline functions from this file, or you compile * this file and link it with other files to produce an executable, this * file does not by itself cause the resulting executable to be covered by - * the GNU Lesser General Public License. + * the GNU Lesser General Public License. * * In plain-speak: do not worry about classes/macros/templates either - only * changes to the library have to be LGPL, not an application linking with it. @@ -41,19 +41,19 @@ #include "nb_kernel_allvsall.h" #include "nrnb.h" -typedef struct +typedef struct { real ** pvdwparam; int * jindex; int ** exclusion_mask; -} +} gmx_allvsall_data_t; - -static int -calc_maxoffset(int i,int natoms) + +static int +calc_maxoffset(int i, int natoms) { int maxoffset; - + if ((natoms % 2) == 1) { /* Odd number of atoms, easy */ @@ -66,22 +66,22 @@ calc_maxoffset(int i,int natoms) { if ((i % 2) == 0) { - maxoffset=natoms/2; + maxoffset = natoms/2; } else { - maxoffset=natoms/2-1; + maxoffset = natoms/2-1; } } else { if ((i % 2) == 1) { - maxoffset=natoms/2; + maxoffset = natoms/2; } else { - maxoffset=natoms/2-1; + maxoffset = natoms/2-1; } } } @@ -90,32 +90,32 @@ calc_maxoffset(int i,int natoms) /* natoms/2 = odd */ if ((i % 2) == 0) { - maxoffset=natoms/2; + maxoffset = natoms/2; } else { - maxoffset=natoms/2-1; + maxoffset = natoms/2-1; } } - + return maxoffset; } static void setup_exclusions_and_indices(gmx_allvsall_data_t * aadata, - t_blocka * excl, + t_blocka * excl, int natoms) { - int i,j,k,iexcl; - int nj0,nj1; + int i, j, k, iexcl; + int nj0, nj1; int max_offset; int max_excl_offset; int nj; - + /* This routine can appear to be a bit complex, but it is mostly book-keeping. * To enable the fast all-vs-all kernel we need to be able to stream through all coordinates - * whether they should interact or not. + * whether they should interact or not. * * To avoid looping over the exclusions, we create a simple mask that is 1 if the interaction * should be present, otherwise 0. Since exclusions typically only occur when i & j are close, @@ -123,110 +123,110 @@ setup_exclusions_and_indices(gmx_allvsall_data_t * aadata, * which we need to check exclusions, and the end point. * This way we only have to allocate a short exclusion mask per i atom. */ - + /* Allocate memory for our modified jindex array */ - snew(aadata->jindex,3*natoms); - + snew(aadata->jindex, 3*natoms); + /* Pointer to lists with exclusion masks */ - snew(aadata->exclusion_mask,natoms); - - for(i=0;iexclusion_mask, natoms); + + for (i = 0; i < natoms; i++) { /* Start */ aadata->jindex[3*i] = i+1; - max_offset = calc_maxoffset(i,natoms); - + max_offset = calc_maxoffset(i, natoms); + /* Exclusions */ nj0 = excl->index[i]; nj1 = excl->index[i+1]; /* first check the max range */ max_excl_offset = -1; - - for(j=nj0; ja[j]; - + k = iexcl - i; - - if( k+natoms <= max_offset ) + + if (k+natoms <= max_offset) { - k+=natoms; + k += natoms; } - + max_excl_offset = (k > max_excl_offset) ? k : max_excl_offset; } - + max_excl_offset = (max_offset < max_excl_offset) ? max_offset : max_excl_offset; - - aadata->jindex[3*i+1] = i+1+max_excl_offset; - - snew(aadata->exclusion_mask[i],max_excl_offset); + aadata->jindex[3*i+1] = i+1+max_excl_offset; + + + snew(aadata->exclusion_mask[i], max_excl_offset); /* Include everything by default */ - for(j=0;jexclusion_mask[i][j] = 0xFFFFFFFF; } - + /* Go through exclusions again */ - for(j=nj0; ja[j]; - + k = iexcl - i; - - if( k+natoms <= max_offset ) + + if (k+natoms <= max_offset) { - k+=natoms; + k += natoms; } - - if(k>0 && k<=max_excl_offset) + + if (k > 0 && k <= max_excl_offset) { /* Excluded, kill it! */ aadata->exclusion_mask[i][k-1] = 0; } } - + /* End */ - aadata->jindex[3*i+2] = i+1+max_offset; + aadata->jindex[3*i+2] = i+1+max_offset; } } static void setup_aadata(gmx_allvsall_data_t ** p_aadata, - t_blocka * excl, + t_blocka * excl, int natoms, int * type, int ntype, real * pvdwparam) { - int i,j,idx; - gmx_allvsall_data_t *aadata; - real *p; - - snew(aadata,1); - *p_aadata = aadata; - + int i, j, idx; + gmx_allvsall_data_t *aadata; + real *p; + + snew(aadata, 1); + *p_aadata = aadata; + /* Generate vdw params */ - snew(aadata->pvdwparam,ntype); - - for(i=0;ipvdwparam, ntype); + + for (i = 0; i < ntype; i++) { - snew(aadata->pvdwparam[i],2*natoms); + snew(aadata->pvdwparam[i], 2*natoms); p = aadata->pvdwparam[i]; /* Lets keep it simple and use multiple steps - first create temp. c6/c12 arrays */ - for(j=0;jchargeA; - type = mdatoms->typeA; - facel = fr->epsfac; + charge = mdatoms->chargeA; + type = mdatoms->typeA; + facel = fr->epsfac; natoms = mdatoms->nr; - ni0 = mdatoms->start; - ni1 = mdatoms->start+mdatoms->homenr; + ni0 = mdatoms->start; + ni1 = mdatoms->start+mdatoms->homenr; aadata = fr->AllvsAll_work; excl = kernel_data->exclusions; Vc = kernel_data->energygrp_elec; Vvdw = kernel_data->energygrp_vdw; - if(aadata==NULL) - { - setup_aadata(&aadata,excl,natoms,type,fr->ntype,fr->nbfp); + if (aadata == NULL) + { + setup_aadata(&aadata, excl, natoms, type, fr->ntype, fr->nbfp); fr->AllvsAll_work = aadata; - } - - for(i=ni0; ipvdwparam[type[i]]; - - /* Zero the potential energy for this list */ - Vvdwtot = 0.0; + + /* Zero the potential energy for this list */ + Vvdwtot = 0.0; vctot = 0.0; - /* Clear i atom forces */ + /* Clear i atom forces */ fix = 0.0; fiy = 0.0; fiz = 0.0; - - /* Load limits for loop over neighbors */ - nj0 = aadata->jindex[3*i]; - nj1 = aadata->jindex[3*i+1]; - nj2 = aadata->jindex[3*i+2]; + + /* Load limits for loop over neighbors */ + nj0 = aadata->jindex[3*i]; + nj1 = aadata->jindex[3*i+1]; + nj2 = aadata->jindex[3*i+2]; mask = aadata->exclusion_mask[i]; - + /* Prologue part, including exclusion mask */ - for(j=nj0; jjindex,3*natoms); - + snew(aadata->jindex, 3*natoms); + /* Pointer to lists with exclusion masks */ - snew(aadata->exclusion_mask,natoms); - - for(i=0;iexclusion_mask, natoms); + + for (i = 0; i < natoms; i++) { /* Start */ aadata->jindex[3*i] = i+1; - max_offset = calc_maxoffset(i,natoms); + max_offset = calc_maxoffset(i, natoms); /* Exclusions */ nj0 = excl->index[i]; @@ -143,91 +143,91 @@ setup_exclusions_and_indices(gmx_allvsall_data_t * aadata, /* first check the max range */ max_excl_offset = -1; - - for(j=nj0; ja[j]; - + k = iexcl - i; - - if( k+natoms <= max_offset ) + + if (k+natoms <= max_offset) { - k+=natoms; + k += natoms; } - + max_excl_offset = (k > max_excl_offset) ? k : max_excl_offset; } - + max_excl_offset = (max_offset < max_excl_offset) ? max_offset : max_excl_offset; - - aadata->jindex[3*i+1] = i+1+max_excl_offset; - - snew(aadata->exclusion_mask[i],max_excl_offset); + + aadata->jindex[3*i+1] = i+1+max_excl_offset; + + snew(aadata->exclusion_mask[i], max_excl_offset); /* Include everything by default */ - for(j=0;jexclusion_mask[i][j] = 0xFFFFFFFF; } - + /* Go through exclusions again */ - for(j=nj0; ja[j]; - + k = iexcl - i; - - if( k+natoms <= max_offset ) + + if (k+natoms <= max_offset) { - k+=natoms; + k += natoms; } - - if(k>0 && k<=max_excl_offset) + + if (k > 0 && k <= max_excl_offset) { /* Excluded, kill it! */ aadata->exclusion_mask[i][k-1] = 0; } } - + /* End */ - aadata->jindex[3*i+2] = i+1+max_offset; + aadata->jindex[3*i+2] = i+1+max_offset; } } static void setup_aadata(gmx_allvsall_data_t ** p_aadata, - t_blocka * excl, + t_blocka * excl, int natoms, int * type, int ntype, real * pvdwparam) { - int i,j,idx; - gmx_allvsall_data_t *aadata; - real *p; - - snew(aadata,1); - *p_aadata = aadata; - + int i, j, idx; + gmx_allvsall_data_t *aadata; + real *p; + + snew(aadata, 1); + *p_aadata = aadata; + /* Generate vdw params */ - snew(aadata->pvdwparam,ntype); - - for(i=0;ipvdwparam, ntype); + + for (i = 0; i < ntype; i++) { - snew(aadata->pvdwparam[i],2*natoms); + snew(aadata->pvdwparam[i], 2*natoms); p = aadata->pvdwparam[i]; /* Lets keep it simple and use multiple steps - first create temp. c6/c12 arrays */ - for(j=0;jchargeA; - type = mdatoms->typeA; + charge = mdatoms->chargeA; + type = mdatoms->typeA; gbfactor = ((1.0/fr->epsilon_r) - (1.0/fr->gb_epsilon_solvent)); - facel = fr->epsfac; + facel = fr->epsfac; GBtab = fr->gbtab.data; gbtabscale = fr->gbtab.scale; invsqrta = fr->invsqrta; @@ -290,128 +290,128 @@ nb_kernel_allvsallgb(t_nblist * nlist, vpol = kernel_data->energygrp_polarization; natoms = mdatoms->nr; - ni0 = mdatoms->start; - ni1 = mdatoms->start+mdatoms->homenr; - + ni0 = mdatoms->start; + ni1 = mdatoms->start+mdatoms->homenr; + aadata = fr->AllvsAll_work; excl = kernel_data->exclusions; Vc = kernel_data->energygrp_elec; Vvdw = kernel_data->energygrp_vdw; - if(aadata==NULL) - { - setup_aadata(&aadata,excl,natoms,type,fr->ntype,fr->nbfp); + if (aadata == NULL) + { + setup_aadata(&aadata, excl, natoms, type, fr->ntype, fr->nbfp); fr->AllvsAll_work = aadata; - } + } + + for (i = ni0; i < ni1; i++) + { + /* We assume shifts are NOT used for all-vs-all interactions */ - for(i=ni0; ipvdwparam[type[i]]; - - /* Zero the potential energy for this list */ - Vvdwtot = 0.0; + + /* Zero the potential energy for this list */ + Vvdwtot = 0.0; vctot = 0.0; vgbtot = 0.0; - dvdasum = 0.0; + dvdasum = 0.0; - /* Clear i atom forces */ + /* Clear i atom forces */ fix = 0.0; fiy = 0.0; fiz = 0.0; - - /* Load limits for loop over neighbors */ - nj0 = aadata->jindex[3*i]; - nj1 = aadata->jindex[3*i+1]; - nj2 = aadata->jindex[3*i+2]; + + /* Load limits for loop over neighbors */ + nj0 = aadata->jindex[3*i]; + nj1 = aadata->jindex[3*i+1]; + nj2 = aadata->jindex[3*i+2]; mask = aadata->exclusion_mask[i]; - + /* Prologue part, including exclusion mask */ - for(j=nj0; j3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_1ptr_swizzle_pd(ptrA,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ - __m128d _t1,_t2,_t3,_t4,_t5;\ - _t1 = _mm_loadu_pd(ptrA);\ - _t2 = _mm_loadu_pd(ptrA+2);\ - _t3 = _mm_loadu_pd(ptrA+4);\ - _t4 = _mm_loadu_pd(ptrA+6);\ - _t5 = _mm_load_sd(ptrA+8);\ - _x1 = _mm_unpacklo_pd(_x1,_y1);\ - _z1 = _mm_unpacklo_pd(_z1,_x2);\ - _y2 = _mm_unpacklo_pd(_y2,_z2);\ - _x3 = _mm_unpacklo_pd(_x3,_y3);\ - _t1 = _mm_sub_pd(_t1,_x1);\ - _t2 = _mm_sub_pd(_t2,_z1);\ - _t3 = _mm_sub_pd(_t3,_y2);\ - _t4 = _mm_sub_pd(_t4,_x3);\ - _t5 = _mm_sub_sd(_t5,_z3);\ - _mm_storeu_pd(ptrA,_t1);\ - _mm_storeu_pd(ptrA+2,_t2);\ - _mm_storeu_pd(ptrA+4,_t3);\ - _mm_storeu_pd(ptrA+6,_t4);\ - _mm_store_sd(ptrA+8,_t5);\ -} +#define gmx_mm_decrement_3rvec_1ptr_swizzle_pd(ptrA, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_load_sd(ptrA+8); \ + _x1 = _mm_unpacklo_pd(_x1, _y1); \ + _z1 = _mm_unpacklo_pd(_z1, _x2); \ + _y2 = _mm_unpacklo_pd(_y2, _z2); \ + _x3 = _mm_unpacklo_pd(_x3, _y3); \ + _t1 = _mm_sub_pd(_t1, _x1); \ + _t2 = _mm_sub_pd(_t2, _z1); \ + _t3 = _mm_sub_pd(_t3, _y2); \ + _t4 = _mm_sub_pd(_t4, _x3); \ + _t5 = _mm_sub_sd(_t5, _z3); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_store_sd(ptrA+8, _t5); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -452,7 +452,7 @@ gmx_mm_decrement_3rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, __m128d x2, __m128d y2, __m128d z2, __m128d x3, __m128d y3, __m128d z3) { - __m128d t1,t2,t3,t4,t5; + __m128d t1, t2, t3, t4, t5; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -460,50 +460,50 @@ gmx_mm_decrement_3rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, t4 = _mm_loadu_pd(ptrA+6); t5 = _mm_load_sd(ptrA+8); - x1 = _mm_unpacklo_pd(x1,y1); - z1 = _mm_unpacklo_pd(z1,x2); - y2 = _mm_unpacklo_pd(y2,z2); - x3 = _mm_unpacklo_pd(x3,y3); + x1 = _mm_unpacklo_pd(x1, y1); + z1 = _mm_unpacklo_pd(z1, x2); + y2 = _mm_unpacklo_pd(y2, z2); + x3 = _mm_unpacklo_pd(x3, y3); /* nothing to be done for z3 */ - t1 = _mm_sub_pd(t1,x1); - t2 = _mm_sub_pd(t2,z1); - t3 = _mm_sub_pd(t3,y2); - t4 = _mm_sub_pd(t4,x3); - t5 = _mm_sub_sd(t5,z3); - _mm_storeu_pd(ptrA,t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_store_sd(ptrA+8,t5); + t1 = _mm_sub_pd(t1, x1); + t2 = _mm_sub_pd(t2, z1); + t3 = _mm_sub_pd(t3, y2); + t4 = _mm_sub_pd(t4, x3); + t5 = _mm_sub_sd(t5, z3); + _mm_storeu_pd(ptrA, t1); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_store_sd(ptrA+8, t5); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_1ptr_swizzle_pd(ptrA,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ - __m128d _t1,_t2,_t3,_t4,_t5,_t6;\ - _t1 = _mm_loadu_pd(ptrA);\ - _t2 = _mm_loadu_pd(ptrA+2);\ - _t3 = _mm_loadu_pd(ptrA+4);\ - _t4 = _mm_loadu_pd(ptrA+6);\ - _t5 = _mm_loadu_pd(ptrA+8);\ - _t6 = _mm_loadu_pd(ptrA+10);\ - _x1 = _mm_unpacklo_pd(_x1,_y1);\ - _z1 = _mm_unpacklo_pd(_z1,_x2);\ - _y2 = _mm_unpacklo_pd(_y2,_z2);\ - _x3 = _mm_unpacklo_pd(_x3,_y3);\ - _z3 = _mm_unpacklo_pd(_z3,_x4);\ - _y4 = _mm_unpacklo_pd(_y4,_z4);\ - _mm_storeu_pd(ptrA, _mm_sub_pd( _t1,_x1 ));\ - _mm_storeu_pd(ptrA+2, _mm_sub_pd( _t2,_z1 ));\ - _mm_storeu_pd(ptrA+4, _mm_sub_pd( _t3,_y2 ));\ - _mm_storeu_pd(ptrA+6, _mm_sub_pd( _t4,_x3 ));\ - _mm_storeu_pd(ptrA+8, _mm_sub_pd( _t5,_z3 ));\ - _mm_storeu_pd(ptrA+10, _mm_sub_pd( _t6,_y4 ));\ -} +#define gmx_mm_decrement_4rvec_1ptr_swizzle_pd(ptrA, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_loadu_pd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrA+10); \ + _x1 = _mm_unpacklo_pd(_x1, _y1); \ + _z1 = _mm_unpacklo_pd(_z1, _x2); \ + _y2 = _mm_unpacklo_pd(_y2, _z2); \ + _x3 = _mm_unpacklo_pd(_x3, _y3); \ + _z3 = _mm_unpacklo_pd(_z3, _x4); \ + _y4 = _mm_unpacklo_pd(_y4, _z4); \ + _mm_storeu_pd(ptrA, _mm_sub_pd( _t1, _x1 )); \ + _mm_storeu_pd(ptrA+2, _mm_sub_pd( _t2, _z1 )); \ + _mm_storeu_pd(ptrA+4, _mm_sub_pd( _t3, _y2 )); \ + _mm_storeu_pd(ptrA+6, _mm_sub_pd( _t4, _x3 )); \ + _mm_storeu_pd(ptrA+8, _mm_sub_pd( _t5, _z3 )); \ + _mm_storeu_pd(ptrA+10, _mm_sub_pd( _t6, _y4 )); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -513,7 +513,7 @@ gmx_mm_decrement_4rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, __m128d x3, __m128d y3, __m128d z3, __m128d x4, __m128d y4, __m128d z4) { - __m128d t1,t2,t3,t4,t5,t6; + __m128d t1, t2, t3, t4, t5, t6; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -522,19 +522,19 @@ gmx_mm_decrement_4rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, t5 = _mm_loadu_pd(ptrA+8); t6 = _mm_loadu_pd(ptrA+10); - x1 = _mm_unpacklo_pd(x1,y1); - z1 = _mm_unpacklo_pd(z1,x2); - y2 = _mm_unpacklo_pd(y2,z2); - x3 = _mm_unpacklo_pd(x3,y3); - z3 = _mm_unpacklo_pd(z3,x4); - y4 = _mm_unpacklo_pd(y4,z4); - - _mm_storeu_pd(ptrA, _mm_sub_pd( t1,x1 )); - _mm_storeu_pd(ptrA+2, _mm_sub_pd( t2,z1 )); - _mm_storeu_pd(ptrA+4, _mm_sub_pd( t3,y2 )); - _mm_storeu_pd(ptrA+6, _mm_sub_pd( t4,x3 )); - _mm_storeu_pd(ptrA+8, _mm_sub_pd( t5,z3 )); - _mm_storeu_pd(ptrA+10, _mm_sub_pd( t6,y4 )); + x1 = _mm_unpacklo_pd(x1, y1); + z1 = _mm_unpacklo_pd(z1, x2); + y2 = _mm_unpacklo_pd(y2, z2); + x3 = _mm_unpacklo_pd(x3, y3); + z3 = _mm_unpacklo_pd(z3, x4); + y4 = _mm_unpacklo_pd(y4, z4); + + _mm_storeu_pd(ptrA, _mm_sub_pd( t1, x1 )); + _mm_storeu_pd(ptrA+2, _mm_sub_pd( t2, z1 )); + _mm_storeu_pd(ptrA+4, _mm_sub_pd( t3, y2 )); + _mm_storeu_pd(ptrA+6, _mm_sub_pd( t4, x3 )); + _mm_storeu_pd(ptrA+8, _mm_sub_pd( t5, z3 )); + _mm_storeu_pd(ptrA+10, _mm_sub_pd( t6, y4 )); } #endif @@ -543,75 +543,75 @@ static gmx_inline void gmx_mm_decrement_1rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, __m128d x1, __m128d y1, __m128d z1) { - __m128d t1,t2,t3,t4,t5,t6,t7; + __m128d t1, t2, t3, t4, t5, t6, t7; t1 = _mm_loadu_pd(ptrA); t2 = _mm_load_sd(ptrA+2); t3 = _mm_loadu_pd(ptrB); t4 = _mm_load_sd(ptrB+2); - t5 = _mm_unpacklo_pd(x1,y1); - t6 = _mm_unpackhi_pd(x1,y1); - t7 = _mm_unpackhi_pd(z1,z1); + t5 = _mm_unpacklo_pd(x1, y1); + t6 = _mm_unpackhi_pd(x1, y1); + t7 = _mm_unpackhi_pd(z1, z1); - t1 = _mm_sub_pd(t1,t5); - t2 = _mm_sub_sd(t2,z1); + t1 = _mm_sub_pd(t1, t5); + t2 = _mm_sub_sd(t2, z1); - t3 = _mm_sub_pd(t3,t6); - t4 = _mm_sub_sd(t4,t7); + t3 = _mm_sub_pd(t3, t6); + t4 = _mm_sub_sd(t4, t7); - _mm_storeu_pd(ptrA,t1); - _mm_store_sd(ptrA+2,t2); - _mm_storeu_pd(ptrB,t3); - _mm_store_sd(ptrB+2,t4); + _mm_storeu_pd(ptrA, t1); + _mm_store_sd(ptrA+2, t2); + _mm_storeu_pd(ptrB, t3); + _mm_store_sd(ptrB+2, t4); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_2ptr_swizzle_pd(ptrA,ptrB,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ - __m128d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10;\ - __m128d _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH,_tI;\ - _t1 = _mm_loadu_pd(ptrA);\ - _t2 = _mm_loadu_pd(ptrA+2);\ - _t3 = _mm_loadu_pd(ptrA+4);\ - _t4 = _mm_loadu_pd(ptrA+6);\ - _t5 = _mm_load_sd(ptrA+8);\ - _t6 = _mm_loadu_pd(ptrB);\ - _t7 = _mm_loadu_pd(ptrB+2);\ - _t8 = _mm_loadu_pd(ptrB+4);\ - _t9 = _mm_loadu_pd(ptrB+6);\ - _t10 = _mm_load_sd(ptrB+8);\ - _tA = _mm_unpacklo_pd(_x1,_y1);\ - _tB = _mm_unpackhi_pd(_x1,_y1);\ - _tC = _mm_unpacklo_pd(_z1,_x2);\ - _tD = _mm_unpackhi_pd(_z1,_x2);\ - _tE = _mm_unpacklo_pd(_y2,_z2);\ - _tF = _mm_unpackhi_pd(_y2,_z2);\ - _tG = _mm_unpacklo_pd(_x3,_y3);\ - _tH = _mm_unpackhi_pd(_x3,_y3);\ - _tI = _mm_unpackhi_pd(_z3,_z3);\ - _t1 = _mm_sub_pd(_t1,_tA);\ - _t2 = _mm_sub_pd(_t2,_tC);\ - _t3 = _mm_sub_pd(_t3,_tE);\ - _t4 = _mm_sub_pd(_t4,_tG);\ - _t5 = _mm_sub_sd(_t5,_z3);\ - _t6 = _mm_sub_pd(_t6,_tB);\ - _t7 = _mm_sub_pd(_t7,_tD);\ - _t8 = _mm_sub_pd(_t8,_tF);\ - _t9 = _mm_sub_pd(_t9,_tH);\ - _t10 = _mm_sub_sd(_t10,_tI);\ - _mm_storeu_pd(ptrA,_t1);\ - _mm_storeu_pd(ptrA+2,_t2);\ - _mm_storeu_pd(ptrA+4,_t3);\ - _mm_storeu_pd(ptrA+6,_t4);\ - _mm_store_sd(ptrA+8,_t5);\ - _mm_storeu_pd(ptrB,_t6);\ - _mm_storeu_pd(ptrB+2,_t7);\ - _mm_storeu_pd(ptrB+4,_t8);\ - _mm_storeu_pd(ptrB+6,_t9);\ - _mm_store_sd(ptrB+8,_t10);\ -} +#define gmx_mm_decrement_3rvec_2ptr_swizzle_pd(ptrA, ptrB, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \ + __m128d _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH, _tI; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_load_sd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrB); \ + _t7 = _mm_loadu_pd(ptrB+2); \ + _t8 = _mm_loadu_pd(ptrB+4); \ + _t9 = _mm_loadu_pd(ptrB+6); \ + _t10 = _mm_load_sd(ptrB+8); \ + _tA = _mm_unpacklo_pd(_x1, _y1); \ + _tB = _mm_unpackhi_pd(_x1, _y1); \ + _tC = _mm_unpacklo_pd(_z1, _x2); \ + _tD = _mm_unpackhi_pd(_z1, _x2); \ + _tE = _mm_unpacklo_pd(_y2, _z2); \ + _tF = _mm_unpackhi_pd(_y2, _z2); \ + _tG = _mm_unpacklo_pd(_x3, _y3); \ + _tH = _mm_unpackhi_pd(_x3, _y3); \ + _tI = _mm_unpackhi_pd(_z3, _z3); \ + _t1 = _mm_sub_pd(_t1, _tA); \ + _t2 = _mm_sub_pd(_t2, _tC); \ + _t3 = _mm_sub_pd(_t3, _tE); \ + _t4 = _mm_sub_pd(_t4, _tG); \ + _t5 = _mm_sub_sd(_t5, _z3); \ + _t6 = _mm_sub_pd(_t6, _tB); \ + _t7 = _mm_sub_pd(_t7, _tD); \ + _t8 = _mm_sub_pd(_t8, _tF); \ + _t9 = _mm_sub_pd(_t9, _tH); \ + _t10 = _mm_sub_sd(_t10, _tI); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_store_sd(ptrA+8, _t5); \ + _mm_storeu_pd(ptrB, _t6); \ + _mm_storeu_pd(ptrB+2, _t7); \ + _mm_storeu_pd(ptrB+4, _t8); \ + _mm_storeu_pd(ptrB+6, _t9); \ + _mm_store_sd(ptrB+8, _t10); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -620,8 +620,8 @@ gmx_mm_decrement_3rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ __m128d x2, __m128d y2, __m128d z2, __m128d x3, __m128d y3, __m128d z3) { - __m128d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; - __m128d tA,tB,tC,tD,tE,tF,tG,tH,tI; + __m128d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; + __m128d tA, tB, tC, tD, tE, tF, tG, tH, tI; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -634,97 +634,97 @@ gmx_mm_decrement_3rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ t9 = _mm_loadu_pd(ptrB+6); t10 = _mm_load_sd(ptrB+8); - tA = _mm_unpacklo_pd(x1,y1); - tB = _mm_unpackhi_pd(x1,y1); - tC = _mm_unpacklo_pd(z1,x2); - tD = _mm_unpackhi_pd(z1,x2); - tE = _mm_unpacklo_pd(y2,z2); - tF = _mm_unpackhi_pd(y2,z2); - tG = _mm_unpacklo_pd(x3,y3); - tH = _mm_unpackhi_pd(x3,y3); - tI = _mm_unpackhi_pd(z3,z3); - - t1 = _mm_sub_pd(t1,tA); - t2 = _mm_sub_pd(t2,tC); - t3 = _mm_sub_pd(t3,tE); - t4 = _mm_sub_pd(t4,tG); - t5 = _mm_sub_sd(t5,z3); - - t6 = _mm_sub_pd(t6,tB); - t7 = _mm_sub_pd(t7,tD); - t8 = _mm_sub_pd(t8,tF); - t9 = _mm_sub_pd(t9,tH); - t10 = _mm_sub_sd(t10,tI); - - _mm_storeu_pd(ptrA,t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_store_sd(ptrA+8,t5); - _mm_storeu_pd(ptrB,t6); - _mm_storeu_pd(ptrB+2,t7); - _mm_storeu_pd(ptrB+4,t8); - _mm_storeu_pd(ptrB+6,t9); - _mm_store_sd(ptrB+8,t10); + tA = _mm_unpacklo_pd(x1, y1); + tB = _mm_unpackhi_pd(x1, y1); + tC = _mm_unpacklo_pd(z1, x2); + tD = _mm_unpackhi_pd(z1, x2); + tE = _mm_unpacklo_pd(y2, z2); + tF = _mm_unpackhi_pd(y2, z2); + tG = _mm_unpacklo_pd(x3, y3); + tH = _mm_unpackhi_pd(x3, y3); + tI = _mm_unpackhi_pd(z3, z3); + + t1 = _mm_sub_pd(t1, tA); + t2 = _mm_sub_pd(t2, tC); + t3 = _mm_sub_pd(t3, tE); + t4 = _mm_sub_pd(t4, tG); + t5 = _mm_sub_sd(t5, z3); + + t6 = _mm_sub_pd(t6, tB); + t7 = _mm_sub_pd(t7, tD); + t8 = _mm_sub_pd(t8, tF); + t9 = _mm_sub_pd(t9, tH); + t10 = _mm_sub_sd(t10, tI); + + _mm_storeu_pd(ptrA, t1); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_store_sd(ptrA+8, t5); + _mm_storeu_pd(ptrB, t6); + _mm_storeu_pd(ptrB+2, t7); + _mm_storeu_pd(ptrB+4, t8); + _mm_storeu_pd(ptrB+6, t9); + _mm_store_sd(ptrB+8, t10); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_2ptr_swizzle_pd(ptrA,ptrB,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ - __m128d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11,_t12;\ - __m128d _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH,_tI,_tJ,_tK,_tL;\ - _t1 = _mm_loadu_pd(ptrA);\ - _t2 = _mm_loadu_pd(ptrA+2);\ - _t3 = _mm_loadu_pd(ptrA+4);\ - _t4 = _mm_loadu_pd(ptrA+6);\ - _t5 = _mm_loadu_pd(ptrA+8);\ - _t6 = _mm_loadu_pd(ptrA+10);\ - _t7 = _mm_loadu_pd(ptrB);\ - _t8 = _mm_loadu_pd(ptrB+2);\ - _t9 = _mm_loadu_pd(ptrB+4);\ - _t10 = _mm_loadu_pd(ptrB+6);\ - _t11 = _mm_loadu_pd(ptrB+8);\ - _t12 = _mm_loadu_pd(ptrB+10);\ - _tA = _mm_unpacklo_pd(_x1,_y1);\ - _tB = _mm_unpackhi_pd(_x1,_y1);\ - _tC = _mm_unpacklo_pd(_z1,_x2);\ - _tD = _mm_unpackhi_pd(_z1,_x2);\ - _tE = _mm_unpacklo_pd(_y2,_z2);\ - _tF = _mm_unpackhi_pd(_y2,_z2);\ - _tG = _mm_unpacklo_pd(_x3,_y3);\ - _tH = _mm_unpackhi_pd(_x3,_y3);\ - _tI = _mm_unpacklo_pd(_z3,_x4);\ - _tJ = _mm_unpackhi_pd(_z3,_x4);\ - _tK = _mm_unpacklo_pd(_y4,_z4);\ - _tL = _mm_unpackhi_pd(_y4,_z4);\ - _t1 = _mm_sub_pd(_t1,_tA);\ - _t2 = _mm_sub_pd(_t2,_tC);\ - _t3 = _mm_sub_pd(_t3,_tE);\ - _t4 = _mm_sub_pd(_t4,_tG);\ - _t5 = _mm_sub_pd(_t5,_tI);\ - _t6 = _mm_sub_pd(_t6,_tK);\ - _t7 = _mm_sub_pd(_t7,_tB);\ - _t8 = _mm_sub_pd(_t8,_tD);\ - _t9 = _mm_sub_pd(_t9,_tF);\ - _t10 = _mm_sub_pd(_t10,_tH);\ - _t11 = _mm_sub_pd(_t11,_tJ);\ - _t12 = _mm_sub_pd(_t12,_tL);\ - _mm_storeu_pd(ptrA, _t1);\ - _mm_storeu_pd(ptrA+2,_t2);\ - _mm_storeu_pd(ptrA+4,_t3);\ - _mm_storeu_pd(ptrA+6,_t4);\ - _mm_storeu_pd(ptrA+8,_t5);\ - _mm_storeu_pd(ptrA+10,_t6);\ - _mm_storeu_pd(ptrB, _t7);\ - _mm_storeu_pd(ptrB+2,_t8);\ - _mm_storeu_pd(ptrB+4,_t9);\ - _mm_storeu_pd(ptrB+6,_t10);\ - _mm_storeu_pd(ptrB+8,_t11);\ - _mm_storeu_pd(ptrB+10,_t12);\ -} +#define gmx_mm_decrement_4rvec_2ptr_swizzle_pd(ptrA, ptrB, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11, _t12; \ + __m128d _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH, _tI, _tJ, _tK, _tL; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_loadu_pd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrA+10); \ + _t7 = _mm_loadu_pd(ptrB); \ + _t8 = _mm_loadu_pd(ptrB+2); \ + _t9 = _mm_loadu_pd(ptrB+4); \ + _t10 = _mm_loadu_pd(ptrB+6); \ + _t11 = _mm_loadu_pd(ptrB+8); \ + _t12 = _mm_loadu_pd(ptrB+10); \ + _tA = _mm_unpacklo_pd(_x1, _y1); \ + _tB = _mm_unpackhi_pd(_x1, _y1); \ + _tC = _mm_unpacklo_pd(_z1, _x2); \ + _tD = _mm_unpackhi_pd(_z1, _x2); \ + _tE = _mm_unpacklo_pd(_y2, _z2); \ + _tF = _mm_unpackhi_pd(_y2, _z2); \ + _tG = _mm_unpacklo_pd(_x3, _y3); \ + _tH = _mm_unpackhi_pd(_x3, _y3); \ + _tI = _mm_unpacklo_pd(_z3, _x4); \ + _tJ = _mm_unpackhi_pd(_z3, _x4); \ + _tK = _mm_unpacklo_pd(_y4, _z4); \ + _tL = _mm_unpackhi_pd(_y4, _z4); \ + _t1 = _mm_sub_pd(_t1, _tA); \ + _t2 = _mm_sub_pd(_t2, _tC); \ + _t3 = _mm_sub_pd(_t3, _tE); \ + _t4 = _mm_sub_pd(_t4, _tG); \ + _t5 = _mm_sub_pd(_t5, _tI); \ + _t6 = _mm_sub_pd(_t6, _tK); \ + _t7 = _mm_sub_pd(_t7, _tB); \ + _t8 = _mm_sub_pd(_t8, _tD); \ + _t9 = _mm_sub_pd(_t9, _tF); \ + _t10 = _mm_sub_pd(_t10, _tH); \ + _t11 = _mm_sub_pd(_t11, _tJ); \ + _t12 = _mm_sub_pd(_t12, _tL); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_storeu_pd(ptrA+8, _t5); \ + _mm_storeu_pd(ptrA+10, _t6); \ + _mm_storeu_pd(ptrB, _t7); \ + _mm_storeu_pd(ptrB+2, _t8); \ + _mm_storeu_pd(ptrB+4, _t9); \ + _mm_storeu_pd(ptrB+6, _t10); \ + _mm_storeu_pd(ptrB+8, _t11); \ + _mm_storeu_pd(ptrB+10, _t12); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -734,8 +734,8 @@ gmx_mm_decrement_4rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ __m128d x3, __m128d y3, __m128d z3, __m128d x4, __m128d y4, __m128d z4) { - __m128d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - __m128d tA,tB,tC,tD,tE,tF,tG,tH,tI,tJ,tK,tL; + __m128d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + __m128d tA, tB, tC, tD, tE, tF, tG, tH, tI, tJ, tK, tL; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -750,45 +750,45 @@ gmx_mm_decrement_4rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ t11 = _mm_loadu_pd(ptrB+8); t12 = _mm_loadu_pd(ptrB+10); - tA = _mm_unpacklo_pd(x1,y1); - tB = _mm_unpackhi_pd(x1,y1); - tC = _mm_unpacklo_pd(z1,x2); - tD = _mm_unpackhi_pd(z1,x2); - tE = _mm_unpacklo_pd(y2,z2); - tF = _mm_unpackhi_pd(y2,z2); - tG = _mm_unpacklo_pd(x3,y3); - tH = _mm_unpackhi_pd(x3,y3); - tI = _mm_unpacklo_pd(z3,x4); - tJ = _mm_unpackhi_pd(z3,x4); - tK = _mm_unpacklo_pd(y4,z4); - tL = _mm_unpackhi_pd(y4,z4); - - t1 = _mm_sub_pd(t1,tA); - t2 = _mm_sub_pd(t2,tC); - t3 = _mm_sub_pd(t3,tE); - t4 = _mm_sub_pd(t4,tG); - t5 = _mm_sub_pd(t5,tI); - t6 = _mm_sub_pd(t6,tK); - - t7 = _mm_sub_pd(t7,tB); - t8 = _mm_sub_pd(t8,tD); - t9 = _mm_sub_pd(t9,tF); - t10 = _mm_sub_pd(t10,tH); - t11 = _mm_sub_pd(t11,tJ); - t12 = _mm_sub_pd(t12,tL); + tA = _mm_unpacklo_pd(x1, y1); + tB = _mm_unpackhi_pd(x1, y1); + tC = _mm_unpacklo_pd(z1, x2); + tD = _mm_unpackhi_pd(z1, x2); + tE = _mm_unpacklo_pd(y2, z2); + tF = _mm_unpackhi_pd(y2, z2); + tG = _mm_unpacklo_pd(x3, y3); + tH = _mm_unpackhi_pd(x3, y3); + tI = _mm_unpacklo_pd(z3, x4); + tJ = _mm_unpackhi_pd(z3, x4); + tK = _mm_unpacklo_pd(y4, z4); + tL = _mm_unpackhi_pd(y4, z4); + + t1 = _mm_sub_pd(t1, tA); + t2 = _mm_sub_pd(t2, tC); + t3 = _mm_sub_pd(t3, tE); + t4 = _mm_sub_pd(t4, tG); + t5 = _mm_sub_pd(t5, tI); + t6 = _mm_sub_pd(t6, tK); + + t7 = _mm_sub_pd(t7, tB); + t8 = _mm_sub_pd(t8, tD); + t9 = _mm_sub_pd(t9, tF); + t10 = _mm_sub_pd(t10, tH); + t11 = _mm_sub_pd(t11, tJ); + t12 = _mm_sub_pd(t12, tL); _mm_storeu_pd(ptrA, t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_storeu_pd(ptrA+8,t5); - _mm_storeu_pd(ptrA+10,t6); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_storeu_pd(ptrA+8, t5); + _mm_storeu_pd(ptrA+10, t6); _mm_storeu_pd(ptrB, t7); - _mm_storeu_pd(ptrB+2,t8); - _mm_storeu_pd(ptrB+4,t9); - _mm_storeu_pd(ptrB+6,t10); - _mm_storeu_pd(ptrB+8,t11); - _mm_storeu_pd(ptrB+10,t12); + _mm_storeu_pd(ptrB+2, t8); + _mm_storeu_pd(ptrB+4, t9); + _mm_storeu_pd(ptrB+6, t10); + _mm_storeu_pd(ptrB+8, t11); + _mm_storeu_pd(ptrB+10, t12); } #endif @@ -801,15 +801,15 @@ gmx_mm_update_iforce_1atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - __m128d t1,t2,t3; + __m128d t1, t2, t3; /* transpose data */ - t1 = fix1; - fix1 = _mm_unpacklo_pd(fix1,fiy1); /* y0 x0 */ - fiy1 = _mm_unpackhi_pd(t1,fiy1); /* y1 x1 */ + t1 = fix1; + fix1 = _mm_unpacklo_pd(fix1, fiy1); /* y0 x0 */ + fiy1 = _mm_unpackhi_pd(t1, fiy1); /* y1 x1 */ - fix1 = _mm_add_pd(fix1,fiy1); - fiz1 = _mm_add_sd( fiz1, _mm_unpackhi_pd(fiz1,fiz1 )); + fix1 = _mm_add_pd(fix1, fiy1); + fiz1 = _mm_add_sd( fiz1, _mm_unpackhi_pd(fiz1, fiz1 )); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_store_sd( fptr+2, _mm_add_sd( _mm_load_sd(fptr+2), fiz1 )); @@ -820,35 +820,35 @@ gmx_mm_update_iforce_1atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \ - fptr,fshiftptr) \ -{\ - __m128d _t1,_t2;\ - GMX_MM_TRANSPOSE2_PD(fix1,fiy1);\ - GMX_MM_TRANSPOSE2_PD(fiz1,fix2);\ - GMX_MM_TRANSPOSE2_PD(fiy2,fiz2);\ - _t1 = fix3;\ - fix3 = _mm_unpacklo_pd(fix3,fiy3);\ - fiy3 = _mm_unpackhi_pd(_t1,fiy3);\ - fix1 = _mm_add_pd(fix1,fiy1);\ - fiz1 = _mm_add_pd(fiz1,fix2);\ - fiy2 = _mm_add_pd(fiy2,fiz2);\ - fix3 = _mm_add_pd(fix3,fiy3);\ - fiz3 = _mm_add_sd( fiz3, _mm_unpackhi_pd(fiz3,fiz3));\ - _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 ));\ - _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 ));\ - _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 ));\ - _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 ));\ - _mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 ));\ - fix1 = _mm_add_pd(fix1,fix3);\ - _t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1));\ - fix1 = _mm_add_pd(fix1,_t1);\ - _t2 = _mm_shuffle_pd(fiy2,fiy2,_MM_SHUFFLE2(1,1));\ - fiz1 = _mm_add_sd(fiz1,fiz3);\ - fiz1 = _mm_add_sd(fiz1,_t2);\ - _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 ));\ - _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 ));\ -} +#define gmx_mm_update_iforce_3atom_swizzle_pd(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \ + fptr, fshiftptr) \ + { \ + __m128d _t1, _t2; \ + GMX_MM_TRANSPOSE2_PD(fix1, fiy1); \ + GMX_MM_TRANSPOSE2_PD(fiz1, fix2); \ + GMX_MM_TRANSPOSE2_PD(fiy2, fiz2); \ + _t1 = fix3; \ + fix3 = _mm_unpacklo_pd(fix3, fiy3); \ + fiy3 = _mm_unpackhi_pd(_t1, fiy3); \ + fix1 = _mm_add_pd(fix1, fiy1); \ + fiz1 = _mm_add_pd(fiz1, fix2); \ + fiy2 = _mm_add_pd(fiy2, fiz2); \ + fix3 = _mm_add_pd(fix3, fiy3); \ + fiz3 = _mm_add_sd( fiz3, _mm_unpackhi_pd(fiz3, fiz3)); \ + _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); \ + _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); \ + _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 )); \ + _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); \ + _mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 )); \ + fix1 = _mm_add_pd(fix1, fix3); \ + _t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); \ + fix1 = _mm_add_pd(fix1, _t1); \ + _t2 = _mm_shuffle_pd(fiy2, fiy2, _MM_SHUFFLE2(1, 1)); \ + fiz1 = _mm_add_sd(fiz1, fiz3); \ + fiz1 = _mm_add_sd(fiz1, _t2); \ + _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); \ + _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -858,22 +858,22 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - __m128d t1,t2; + __m128d t1, t2; /* transpose data */ - GMX_MM_TRANSPOSE2_PD(fix1,fiy1); - GMX_MM_TRANSPOSE2_PD(fiz1,fix2); - GMX_MM_TRANSPOSE2_PD(fiy2,fiz2); - t1 = fix3; - fix3 = _mm_unpacklo_pd(fix3,fiy3); /* y0 x0 */ - fiy3 = _mm_unpackhi_pd(t1,fiy3); /* y1 x1 */ + GMX_MM_TRANSPOSE2_PD(fix1, fiy1); + GMX_MM_TRANSPOSE2_PD(fiz1, fix2); + GMX_MM_TRANSPOSE2_PD(fiy2, fiz2); + t1 = fix3; + fix3 = _mm_unpacklo_pd(fix3, fiy3); /* y0 x0 */ + fiy3 = _mm_unpackhi_pd(t1, fiy3); /* y1 x1 */ - fix1 = _mm_add_pd(fix1,fiy1); - fiz1 = _mm_add_pd(fiz1,fix2); - fiy2 = _mm_add_pd(fiy2,fiz2); + fix1 = _mm_add_pd(fix1, fiy1); + fiz1 = _mm_add_pd(fiz1, fix2); + fiy2 = _mm_add_pd(fiy2, fiz2); - fix3 = _mm_add_pd(fix3,fiy3); - fiz3 = _mm_add_sd( fiz3, _mm_unpackhi_pd(fiz3,fiz3)); + fix3 = _mm_add_pd(fix3, fiy3); + fiz3 = _mm_add_sd( fiz3, _mm_unpackhi_pd(fiz3, fiz3)); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); @@ -881,13 +881,13 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); _mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 )); - fix1 = _mm_add_pd(fix1,fix3); - t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1)); - fix1 = _mm_add_pd(fix1,t1); /* x and y sums */ + fix1 = _mm_add_pd(fix1, fix3); + t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); + fix1 = _mm_add_pd(fix1, t1); /* x and y sums */ - t2 = _mm_shuffle_pd(fiy2,fiy2,_MM_SHUFFLE2(1,1)); - fiz1 = _mm_add_sd(fiz1,fiz3); - fiz1 = _mm_add_sd(fiz1,t2); /* z sum */ + t2 = _mm_shuffle_pd(fiy2, fiy2, _MM_SHUFFLE2(1, 1)); + fiz1 = _mm_add_sd(fiz1, fiz3); + fiz1 = _mm_add_sd(fiz1, t2); /* z sum */ _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); @@ -897,39 +897,39 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_4atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \ - fptr,fshiftptr) \ -{\ - __m128d _t1,_t2;\ - GMX_MM_TRANSPOSE2_PD(fix1,fiy1);\ - GMX_MM_TRANSPOSE2_PD(fiz1,fix2);\ - GMX_MM_TRANSPOSE2_PD(fiy2,fiz2);\ - GMX_MM_TRANSPOSE2_PD(fix3,fiy3);\ - GMX_MM_TRANSPOSE2_PD(fiz3,fix4);\ - GMX_MM_TRANSPOSE2_PD(fiy4,fiz4);\ - fix1 = _mm_add_pd(fix1,fiy1);\ - fiz1 = _mm_add_pd(fiz1,fix2);\ - fiy2 = _mm_add_pd(fiy2,fiz2);\ - fix3 = _mm_add_pd(fix3,fiy3);\ - fiz3 = _mm_add_pd(fiz3,fix4);\ - fiy4 = _mm_add_pd(fiy4,fiz4);\ - _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 ));\ - _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 ));\ - _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 ));\ - _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 ));\ - _mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 ));\ - _mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 ));\ - _t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1));\ - fix1 = _mm_add_pd(fix1,_t1);\ - _t2 = _mm_shuffle_pd(fiz3,fiy4,_MM_SHUFFLE2(0,1));\ - fix3 = _mm_add_pd(fix3,_t2);\ - fix1 = _mm_add_pd(fix1,fix3);\ - fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2,fiy2));\ - fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4,fiy4));\ - fiz1 = _mm_add_sd(fiz1,fiz3);\ - _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 ));\ - _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 ));\ -} +#define gmx_mm_update_iforce_4atom_swizzle_pd(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \ + fptr, fshiftptr) \ + { \ + __m128d _t1, _t2; \ + GMX_MM_TRANSPOSE2_PD(fix1, fiy1); \ + GMX_MM_TRANSPOSE2_PD(fiz1, fix2); \ + GMX_MM_TRANSPOSE2_PD(fiy2, fiz2); \ + GMX_MM_TRANSPOSE2_PD(fix3, fiy3); \ + GMX_MM_TRANSPOSE2_PD(fiz3, fix4); \ + GMX_MM_TRANSPOSE2_PD(fiy4, fiz4); \ + fix1 = _mm_add_pd(fix1, fiy1); \ + fiz1 = _mm_add_pd(fiz1, fix2); \ + fiy2 = _mm_add_pd(fiy2, fiz2); \ + fix3 = _mm_add_pd(fix3, fiy3); \ + fiz3 = _mm_add_pd(fiz3, fix4); \ + fiy4 = _mm_add_pd(fiy4, fiz4); \ + _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); \ + _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); \ + _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 )); \ + _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); \ + _mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 )); \ + _mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 )); \ + _t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); \ + fix1 = _mm_add_pd(fix1, _t1); \ + _t2 = _mm_shuffle_pd(fiz3, fiy4, _MM_SHUFFLE2(0, 1)); \ + fix3 = _mm_add_pd(fix3, _t2); \ + fix1 = _mm_add_pd(fix1, fix3); \ + fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2, fiy2)); \ + fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4, fiy4)); \ + fiz1 = _mm_add_sd(fiz1, fiz3); \ + _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); \ + _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -940,22 +940,22 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - __m128d t1,t2; + __m128d t1, t2; /* transpose data */ - GMX_MM_TRANSPOSE2_PD(fix1,fiy1); - GMX_MM_TRANSPOSE2_PD(fiz1,fix2); - GMX_MM_TRANSPOSE2_PD(fiy2,fiz2); - GMX_MM_TRANSPOSE2_PD(fix3,fiy3); - GMX_MM_TRANSPOSE2_PD(fiz3,fix4); - GMX_MM_TRANSPOSE2_PD(fiy4,fiz4); - - fix1 = _mm_add_pd(fix1,fiy1); - fiz1 = _mm_add_pd(fiz1,fix2); - fiy2 = _mm_add_pd(fiy2,fiz2); - fix3 = _mm_add_pd(fix3,fiy3); - fiz3 = _mm_add_pd(fiz3,fix4); - fiy4 = _mm_add_pd(fiy4,fiz4); + GMX_MM_TRANSPOSE2_PD(fix1, fiy1); + GMX_MM_TRANSPOSE2_PD(fiz1, fix2); + GMX_MM_TRANSPOSE2_PD(fiy2, fiz2); + GMX_MM_TRANSPOSE2_PD(fix3, fiy3); + GMX_MM_TRANSPOSE2_PD(fiz3, fix4); + GMX_MM_TRANSPOSE2_PD(fiy4, fiz4); + + fix1 = _mm_add_pd(fix1, fiy1); + fiz1 = _mm_add_pd(fiz1, fix2); + fiy2 = _mm_add_pd(fiy2, fiz2); + fix3 = _mm_add_pd(fix3, fiy3); + fiz3 = _mm_add_pd(fiz3, fix4); + fiy4 = _mm_add_pd(fiy4, fiz4); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); @@ -964,15 +964,15 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, _mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 )); _mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 )); - t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1)); - fix1 = _mm_add_pd(fix1,t1); - t2 = _mm_shuffle_pd(fiz3,fiy4,_MM_SHUFFLE2(0,1)); - fix3 = _mm_add_pd(fix3,t2); - fix1 = _mm_add_pd(fix1,fix3); /* x and y sums */ + t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); + fix1 = _mm_add_pd(fix1, t1); + t2 = _mm_shuffle_pd(fiz3, fiy4, _MM_SHUFFLE2(0, 1)); + fix3 = _mm_add_pd(fix3, t2); + fix1 = _mm_add_pd(fix1, fix3); /* x and y sums */ - fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2,fiy2)); - fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4,fiy4)); - fiz1 = _mm_add_sd(fiz1,fiz3); /* z sum */ + fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2, fiy2)); + fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4, fiy4)); + fiz1 = _mm_add_sd(fiz1, fiz3); /* z sum */ _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); @@ -983,20 +983,20 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, static gmx_inline void gmx_mm_update_1pot_pd(__m128d pot1, double * gmx_restrict ptrA) { - pot1 = _mm_add_pd(pot1, _mm_unpackhi_pd(pot1,pot1)); - _mm_store_sd(ptrA,_mm_add_sd(pot1,_mm_load_sd(ptrA))); + pot1 = _mm_add_pd(pot1, _mm_unpackhi_pd(pot1, pot1)); + _mm_store_sd(ptrA, _mm_add_sd(pot1, _mm_load_sd(ptrA))); } static gmx_inline void gmx_mm_update_2pot_pd(__m128d pot1, double * gmx_restrict ptrA, __m128d pot2, double * gmx_restrict ptrB) { - GMX_MM_TRANSPOSE2_PD(pot1,pot2); - pot1 = _mm_add_pd(pot1,pot2); - pot2 = _mm_unpackhi_pd(pot1,pot1); + GMX_MM_TRANSPOSE2_PD(pot1, pot2); + pot1 = _mm_add_pd(pot1, pot2); + pot2 = _mm_unpackhi_pd(pot1, pot1); - _mm_store_sd(ptrA,_mm_add_sd(pot1,_mm_load_sd(ptrA))); - _mm_store_sd(ptrB,_mm_add_sd(pot2,_mm_load_sd(ptrB))); + _mm_store_sd(ptrA, _mm_add_sd(pot1, _mm_load_sd(ptrA))); + _mm_store_sd(ptrB, _mm_add_sd(pot2, _mm_load_sd(ptrB))); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.c index 95a7ef2f7c..bc3dd87a78 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.c @@ -241,7 +241,7 @@ nb_kernel_t nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_sse2_double; nb_kernel_info_t -kernellist_sse2_double[] = + kernellist_sse2_double[] = { { nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse2_double, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse2_double", "sse2_double", "None", "None", "LennardJones", "None", "ParticleParticle", "", "PotentialAndForce" }, { nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse2_double, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse2_double", "sse2_double", "None", "None", "LennardJones", "None", "ParticleParticle", "", "Force" }, @@ -460,6 +460,6 @@ kernellist_sse2_double[] = }; int -kernellist_sse2_double_size = sizeof(kernellist_sse2_double)/sizeof(kernellist_sse2_double[0]); + kernellist_sse2_double_size = sizeof(kernellist_sse2_double)/sizeof(kernellist_sse2_double[0]); #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.h index 3e89ad9ebb..6af3d3d394 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_double/nb_kernel_sse2_double.h @@ -27,10 +27,10 @@ /* List of kernels for this architecture with metadata about them */ extern nb_kernel_info_t -kernellist_sse2_double[]; + kernellist_sse2_double[]; /* Length of kernellist_c */ extern int -kernellist_sse2_double_size; + kernellist_sse2_double_size; #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/kernelutil_x86_sse2_single.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/kernelutil_x86_sse2_single.h index 2783121820..2f2bc03528 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/kernelutil_x86_sse2_single.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/kernelutil_x86_sse2_single.h @@ -9,16 +9,16 @@ * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for * a full list of developers and information, check out http://www.gromacs.org * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) any + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) any * later version. * As a special exception, you may use this file as part of a free software * library without restriction. Specifically, if other files instantiate * templates or use macros or inline functions from this file, or you compile * this file and link it with other files to produce an executable, this * file does not by itself cause the resulting executable to be covered by - * the GNU Lesser General Public License. + * the GNU Lesser General Public License. * * In plain-speak: do not worry about classes/macros/templates either - only * changes to the library have to be LGPL, not an application linking with it. @@ -37,18 +37,18 @@ /* Normal sum of four xmm registers */ -#define gmx_mm_sum4_ps(t0,t1,t2,t3) _mm_add_ps(_mm_add_ps(t0,t1),_mm_add_ps(t2,t3)) +#define gmx_mm_sum4_ps(t0, t1, t2, t3) _mm_add_ps(_mm_add_ps(t0, t1), _mm_add_ps(t2, t3)) static gmx_inline __m128 gmx_mm_calc_rsq_ps(__m128 dx, __m128 dy, __m128 dz) { - return _mm_add_ps( _mm_add_ps( _mm_mul_ps(dx,dx), _mm_mul_ps(dy,dy) ), _mm_mul_ps(dz,dz) ); + return _mm_add_ps( _mm_add_ps( _mm_mul_ps(dx, dx), _mm_mul_ps(dy, dy) ), _mm_mul_ps(dz, dz) ); } static int gmx_mm_any_lt(__m128 a, __m128 b) { - return _mm_movemask_ps(_mm_cmplt_ps(a,b)); + return _mm_movemask_ps(_mm_cmplt_ps(a, b)); } /* Load a single value from 1-4 places, merge into xmm register */ @@ -59,11 +59,11 @@ gmx_mm_load_4real_swizzle_ps(const float * gmx_restrict ptrA, const float * gmx_restrict ptrC, const float * gmx_restrict ptrD) { - __m128 t1,t2; + __m128 t1, t2; - t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA),_mm_load_ss(ptrC)); - t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB),_mm_load_ss(ptrD)); - return _mm_unpacklo_ps(t1,t2); + t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA), _mm_load_ss(ptrC)); + t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB), _mm_load_ss(ptrD)); + return _mm_unpacklo_ps(t1, t2); } static void @@ -71,17 +71,17 @@ gmx_mm_store_4real_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, float * gmx_restrict ptrC, float * gmx_restrict ptrD, - __m128 xmm1) + __m128 xmm1) { - __m128 t2,t3,t4; - - t3 = _mm_movehl_ps(_mm_setzero_ps(),xmm1); - t2 = _mm_shuffle_ps(xmm1,xmm1,_MM_SHUFFLE(1,1,1,1)); - t4 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(1,1,1,1)); - _mm_store_ss(ptrA,xmm1); - _mm_store_ss(ptrB,t2); - _mm_store_ss(ptrC,t3); - _mm_store_ss(ptrD,t4); + __m128 t2, t3, t4; + + t3 = _mm_movehl_ps(_mm_setzero_ps(), xmm1); + t2 = _mm_shuffle_ps(xmm1, xmm1, _MM_SHUFFLE(1, 1, 1, 1)); + t4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 1, 1, 1)); + _mm_store_ss(ptrA, xmm1); + _mm_store_ss(ptrB, t2); + _mm_store_ss(ptrC, t3); + _mm_store_ss(ptrD, t4); } /* Similar to store, but increments value in memory */ @@ -93,9 +93,9 @@ gmx_mm_increment_4real_swizzle_ps(float * gmx_restrict ptrA, { __m128 tmp; - tmp = gmx_mm_load_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD); - tmp = _mm_add_ps(tmp,xmm1); - gmx_mm_store_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD,tmp); + tmp = gmx_mm_load_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD); + tmp = _mm_add_ps(tmp, xmm1); + gmx_mm_store_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD, tmp); } @@ -104,19 +104,19 @@ gmx_mm_load_4pair_swizzle_ps(const float * gmx_restrict p1, const float * gmx_restrict p2, const float * gmx_restrict p3, const float * gmx_restrict p4, - __m128 * gmx_restrict c6, - __m128 * gmx_restrict c12) + __m128 * gmx_restrict c6, + __m128 * gmx_restrict c12) { - __m128 t1,t2,t3,t4; - - t1 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p1); /* - - c12a c6a */ - t2 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p2); /* - - c12b c6b */ - t3 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p3); /* - - c12c c6c */ - t4 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p4); /* - - c12d c6d */ - t1 = _mm_unpacklo_ps(t1,t2); - t2 = _mm_unpacklo_ps(t3,t4); - *c6 = _mm_movelh_ps(t1,t2); - *c12 = _mm_movehl_ps(t2,t1); + __m128 t1, t2, t3, t4; + + t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p1); /* - - c12a c6a */ + t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p2); /* - - c12b c6b */ + t3 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p3); /* - - c12c c6c */ + t4 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p4); /* - - c12d c6d */ + t1 = _mm_unpacklo_ps(t1, t2); + t2 = _mm_unpacklo_ps(t3, t4); + *c6 = _mm_movelh_ps(t1, t2); + *c12 = _mm_movehl_ps(t2, t1); } /* Routines to load 1-4 rvec from 4 places. @@ -128,74 +128,74 @@ gmx_mm_load_4pair_swizzle_ps(const float * gmx_restrict p1, static gmx_inline void gmx_mm_load_shift_and_1rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, - __m128 * gmx_restrict y1, - __m128 * gmx_restrict z1) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, + __m128 * gmx_restrict y1, + __m128 * gmx_restrict z1) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; - t1 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); - t2 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz); + t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); + t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz); t3 = _mm_load_ss(xyz_shift+2); t4 = _mm_load_ss(xyz+2); - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ss(t3,t4); + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ss(t3, t4); - *x1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(0,0,0,0)); + *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0)); } static gmx_inline void gmx_mm_load_shift_and_3rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, - __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, - __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, + __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, + __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) { - __m128 tA,tB; - __m128 t1,t2,t3,t4,t5,t6; + __m128 tA, tB; + __m128 t1, t2, t3, t4, t5, t6; - tA = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); + tA = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); tB = _mm_load_ss(xyz_shift+2); t1 = _mm_loadu_ps(xyz); t2 = _mm_loadu_ps(xyz+4); t3 = _mm_load_ss(xyz+8); - tA = _mm_movelh_ps(tA,tB); - t4 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(0,2,1,0)); - t5 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(1,0,2,1)); - t6 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(2,1,0,2)); - - t1 = _mm_add_ps(t1,t4); - t2 = _mm_add_ps(t2,t5); - t3 = _mm_add_ss(t3,t6); - - *x1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(2,2,2,2)); - *x2 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(3,3,3,3)); - *y2 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(0,0,0,0)); - *z2 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(1,1,1,1)); - *x3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(2,2,2,2)); - *y3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(3,3,3,3)); - *z3 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(0,0,0,0)); + tA = _mm_movelh_ps(tA, tB); + t4 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(0, 2, 1, 0)); + t5 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(1, 0, 2, 1)); + t6 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(2, 1, 0, 2)); + + t1 = _mm_add_ps(t1, t4); + t2 = _mm_add_ps(t2, t5); + t3 = _mm_add_ss(t3, t6); + + *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(2, 2, 2, 2)); + *x2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 3, 3)); + *y2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 0)); + *z2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(1, 1, 1, 1)); + *x3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(2, 2, 2, 2)); + *y3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(3, 3, 3, 3)); + *z3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0)); } static gmx_inline void gmx_mm_load_shift_and_4rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, - __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, - __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, - __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, + __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, + __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, + __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) { - __m128 tA,tB; - __m128 t1,t2,t3,t4,t5,t6; + __m128 tA, tB; + __m128 t1, t2, t3, t4, t5, t6; tA = _mm_castpd_ps(_mm_load_sd((const double *)xyz_shift)); tB = _mm_load_ss(xyz_shift+2); @@ -204,27 +204,27 @@ gmx_mm_load_shift_and_4rvec_broadcast_ps(const float * gmx_restrict xyz_shift, t2 = _mm_loadu_ps(xyz+4); t3 = _mm_loadu_ps(xyz+8); - tA = _mm_movelh_ps(tA,tB); - t4 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(0,2,1,0)); - t5 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(1,0,2,1)); - t6 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(2,1,0,2)); - - t1 = _mm_add_ps(t1,t4); - t2 = _mm_add_ps(t2,t5); - t3 = _mm_add_ps(t3,t6); - - *x1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(2,2,2,2)); - *x2 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(3,3,3,3)); - *y2 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(0,0,0,0)); - *z2 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(1,1,1,1)); - *x3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(2,2,2,2)); - *y3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(3,3,3,3)); - *z3 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(0,0,0,0)); - *x4 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(1,1,1,1)); - *y4 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(2,2,2,2)); - *z4 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(3,3,3,3)); + tA = _mm_movelh_ps(tA, tB); + t4 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(0, 2, 1, 0)); + t5 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(1, 0, 2, 1)); + t6 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(2, 1, 0, 2)); + + t1 = _mm_add_ps(t1, t4); + t2 = _mm_add_ps(t2, t5); + t3 = _mm_add_ps(t3, t6); + + *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(2, 2, 2, 2)); + *x2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 3, 3)); + *y2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 0)); + *z2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(1, 1, 1, 1)); + *x3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(2, 2, 2, 2)); + *y3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(3, 3, 3, 3)); + *z3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0)); + *x4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 1, 1, 1)); + *y4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(2, 2, 2, 2)); + *z4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(3, 3, 3, 3)); } @@ -237,22 +237,22 @@ gmx_mm_load_1rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8; + __m128 t1, t2, t3, t4, t5, t6, t7, t8; t1 = _mm_castpd_ps(_mm_load_sd((const double *)ptrA)); t2 = _mm_castpd_ps(_mm_load_sd((const double *)ptrB)); t3 = _mm_castpd_ps(_mm_load_sd((const double *)ptrC)); t4 = _mm_castpd_ps(_mm_load_sd((const double *)ptrD)); - t5 = _mm_load_ss(ptrA+2); - t6 = _mm_load_ss(ptrB+2); - t7 = _mm_load_ss(ptrC+2); - t8 = _mm_load_ss(ptrD+2); - t1 = _mm_unpacklo_ps(t1,t2); - t3 = _mm_unpacklo_ps(t3,t4); - *x1 = _mm_movelh_ps(t1,t3); - *y1 = _mm_movehl_ps(t3,t1); - t5 = _mm_unpacklo_ps(t5,t6); - t7 = _mm_unpacklo_ps(t7,t8); - *z1 = _mm_movelh_ps(t5,t7); + t5 = _mm_load_ss(ptrA+2); + t6 = _mm_load_ss(ptrB+2); + t7 = _mm_load_ss(ptrC+2); + t8 = _mm_load_ss(ptrD+2); + t1 = _mm_unpacklo_ps(t1, t2); + t3 = _mm_unpacklo_ps(t3, t4); + *x1 = _mm_movelh_ps(t1, t3); + *y1 = _mm_movehl_ps(t3, t1); + t5 = _mm_unpacklo_ps(t5, t6); + t7 = _mm_unpacklo_ps(t7, t8); + *z1 = _mm_movelh_ps(t5, t7); } @@ -265,12 +265,12 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrB); t3 = _mm_loadu_ps(ptrC); t4 = _mm_loadu_ps(ptrD); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = t1; *y1 = t2; *z1 = t3; @@ -279,7 +279,7 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, t2 = _mm_loadu_ps(ptrB+4); t3 = _mm_loadu_ps(ptrC+4); t4 = _mm_loadu_ps(ptrD+4); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *y2 = t1; *z2 = t2; *x3 = t3; @@ -288,9 +288,9 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, t2 = _mm_load_ss(ptrB+8); t3 = _mm_load_ss(ptrC+8); t4 = _mm_load_ss(ptrD+8); - t1 = _mm_unpacklo_ps(t1,t3); - t3 = _mm_unpacklo_ps(t2,t4); - *z3 = _mm_unpacklo_ps(t1,t3); + t1 = _mm_unpacklo_ps(t1, t3); + t3 = _mm_unpacklo_ps(t2, t4); + *z3 = _mm_unpacklo_ps(t1, t3); } @@ -304,12 +304,12 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrB); t3 = _mm_loadu_ps(ptrC); t4 = _mm_loadu_ps(ptrD); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = t1; *y1 = t2; *z1 = t3; @@ -318,7 +318,7 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, t2 = _mm_loadu_ps(ptrB+4); t3 = _mm_loadu_ps(ptrC+4); t4 = _mm_loadu_ps(ptrD+4); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *y2 = t1; *z2 = t2; *x3 = t3; @@ -327,7 +327,7 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, t2 = _mm_loadu_ps(ptrB+8); t3 = _mm_loadu_ps(ptrC+8); t4 = _mm_loadu_ps(ptrD+8); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *z3 = t1; *x4 = t2; *y4 = t3; @@ -342,101 +342,101 @@ gmx_mm_decrement_1rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrD, __m128 x1, __m128 y1, __m128 z1) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - t5 = _mm_unpacklo_ps(y1,z1); - t6 = _mm_unpackhi_ps(y1,z1); - t7 = _mm_shuffle_ps(x1,t5,_MM_SHUFFLE(1,0,0,0)); - t8 = _mm_shuffle_ps(x1,t5,_MM_SHUFFLE(3,2,0,1)); - t9 = _mm_shuffle_ps(x1,t6,_MM_SHUFFLE(1,0,0,2)); - t10 = _mm_shuffle_ps(x1,t6,_MM_SHUFFLE(3,2,0,3)); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + t5 = _mm_unpacklo_ps(y1, z1); + t6 = _mm_unpackhi_ps(y1, z1); + t7 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(1, 0, 0, 0)); + t8 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(3, 2, 0, 1)); + t9 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(1, 0, 0, 2)); + t10 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(3, 2, 0, 3)); t1 = _mm_load_ss(ptrA); - t1 = _mm_loadh_pi(t1,(__m64 *)(ptrA+1)); - t1 = _mm_sub_ps(t1,t7); - _mm_store_ss(ptrA,t1); - _mm_storeh_pi((__m64 *)(ptrA+1),t1); + t1 = _mm_loadh_pi(t1, (__m64 *)(ptrA+1)); + t1 = _mm_sub_ps(t1, t7); + _mm_store_ss(ptrA, t1); + _mm_storeh_pi((__m64 *)(ptrA+1), t1); t2 = _mm_load_ss(ptrB); - t2 = _mm_loadh_pi(t2,(__m64 *)(ptrB+1)); - t2 = _mm_sub_ps(t2,t8); - _mm_store_ss(ptrB,t2); - _mm_storeh_pi((__m64 *)(ptrB+1),t2); + t2 = _mm_loadh_pi(t2, (__m64 *)(ptrB+1)); + t2 = _mm_sub_ps(t2, t8); + _mm_store_ss(ptrB, t2); + _mm_storeh_pi((__m64 *)(ptrB+1), t2); t3 = _mm_load_ss(ptrC); - t3 = _mm_loadh_pi(t3,(__m64 *)(ptrC+1)); - t3 = _mm_sub_ps(t3,t9); - _mm_store_ss(ptrC,t3); - _mm_storeh_pi((__m64 *)(ptrC+1),t3); + t3 = _mm_loadh_pi(t3, (__m64 *)(ptrC+1)); + t3 = _mm_sub_ps(t3, t9); + _mm_store_ss(ptrC, t3); + _mm_storeh_pi((__m64 *)(ptrC+1), t3); t4 = _mm_load_ss(ptrD); - t4 = _mm_loadh_pi(t4,(__m64 *)(ptrD+1)); - t4 = _mm_sub_ps(t4,t10); - _mm_store_ss(ptrD,t4); - _mm_storeh_pi((__m64 *)(ptrD+1),t4); + t4 = _mm_loadh_pi(t4, (__m64 *)(ptrD+1)); + t4 = _mm_sub_ps(t4, t10); + _mm_store_ss(ptrD, t4); + _mm_storeh_pi((__m64 *)(ptrD+1), t4); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_4ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD, \ -_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ -__m128 _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10;\ -__m128 _t11,_t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19;\ -__m128 _t20,_t21,_t22,_t23,_t24,_t25;\ -_t13 = _mm_unpackhi_ps(_x1,_y1);\ -_x1 = _mm_unpacklo_ps(_x1,_y1);\ -_t14 = _mm_unpackhi_ps(_z1,_x2);\ -_z1 = _mm_unpacklo_ps(_z1,_x2);\ -_t15 = _mm_unpackhi_ps(_y2,_z2);\ -_y2 = _mm_unpacklo_ps(_y2,_z2);\ -_t16 = _mm_unpackhi_ps(_x3,_y3);\ -_x3 = _mm_unpacklo_ps(_x3,_y3);\ -_t17 = _mm_shuffle_ps(_z3,_z3,_MM_SHUFFLE(0,0,0,1));\ -_t18 = _mm_movehl_ps(_z3,_z3);\ -_t19 = _mm_shuffle_ps(_t18,_t18,_MM_SHUFFLE(0,0,0,1));\ -_t20 = _mm_movelh_ps(_x1,_z1);\ -_t21 = _mm_movehl_ps(_z1,_x1);\ -_t22 = _mm_movelh_ps(_t13,_t14);\ -_t14 = _mm_movehl_ps(_t14,_t13);\ -_t23 = _mm_movelh_ps(_y2,_x3);\ -_t24 = _mm_movehl_ps(_x3,_y2);\ -_t25 = _mm_movelh_ps(_t15,_t16);\ -_t16 = _mm_movehl_ps(_t16,_t15);\ -_t1 = _mm_loadu_ps(ptrA);\ -_t2 = _mm_loadu_ps(ptrA+4);\ -_t3 = _mm_load_ss(ptrA+8);\ -_t1 = _mm_sub_ps(_t1,_t20);\ -_t2 = _mm_sub_ps(_t2,_t23);\ -_t3 = _mm_sub_ss(_t3,_z3);\ -_mm_storeu_ps(ptrA,_t1);\ -_mm_storeu_ps(ptrA+4,_t2);\ -_mm_store_ss(ptrA+8,_t3);\ -_t4 = _mm_loadu_ps(ptrB);\ -_t5 = _mm_loadu_ps(ptrB+4);\ -_t6 = _mm_load_ss(ptrB+8);\ -_t4 = _mm_sub_ps(_t4,_t21);\ -_t5 = _mm_sub_ps(_t5,_t24);\ -_t6 = _mm_sub_ss(_t6,_t17);\ -_mm_storeu_ps(ptrB,_t4);\ -_mm_storeu_ps(ptrB+4,_t5);\ -_mm_store_ss(ptrB+8,_t6);\ -_t7 = _mm_loadu_ps(ptrC);\ -_t8 = _mm_loadu_ps(ptrC+4);\ -_t9 = _mm_load_ss(ptrC+8);\ -_t7 = _mm_sub_ps(_t7,_t22);\ -_t8 = _mm_sub_ps(_t8,_t25);\ -_t9 = _mm_sub_ss(_t9,_t18);\ -_mm_storeu_ps(ptrC,_t7);\ -_mm_storeu_ps(ptrC+4,_t8);\ -_mm_store_ss(ptrC+8,_t9);\ -_t10 = _mm_loadu_ps(ptrD);\ -_t11 = _mm_loadu_ps(ptrD+4);\ -_t12 = _mm_load_ss(ptrD+8);\ -_t10 = _mm_sub_ps(_t10,_t14);\ -_t11 = _mm_sub_ps(_t11,_t16);\ -_t12 = _mm_sub_ss(_t12,_t19);\ -_mm_storeu_ps(ptrD,_t10);\ -_mm_storeu_ps(ptrD+4,_t11);\ -_mm_store_ss(ptrD+8,_t12);\ -} +#define gmx_mm_decrement_3rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \ + __m128 _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19; \ + __m128 _t20, _t21, _t22, _t23, _t24, _t25; \ + _t13 = _mm_unpackhi_ps(_x1, _y1); \ + _x1 = _mm_unpacklo_ps(_x1, _y1); \ + _t14 = _mm_unpackhi_ps(_z1, _x2); \ + _z1 = _mm_unpacklo_ps(_z1, _x2); \ + _t15 = _mm_unpackhi_ps(_y2, _z2); \ + _y2 = _mm_unpacklo_ps(_y2, _z2); \ + _t16 = _mm_unpackhi_ps(_x3, _y3); \ + _x3 = _mm_unpacklo_ps(_x3, _y3); \ + _t17 = _mm_shuffle_ps(_z3, _z3, _MM_SHUFFLE(0, 0, 0, 1)); \ + _t18 = _mm_movehl_ps(_z3, _z3); \ + _t19 = _mm_shuffle_ps(_t18, _t18, _MM_SHUFFLE(0, 0, 0, 1)); \ + _t20 = _mm_movelh_ps(_x1, _z1); \ + _t21 = _mm_movehl_ps(_z1, _x1); \ + _t22 = _mm_movelh_ps(_t13, _t14); \ + _t14 = _mm_movehl_ps(_t14, _t13); \ + _t23 = _mm_movelh_ps(_y2, _x3); \ + _t24 = _mm_movehl_ps(_x3, _y2); \ + _t25 = _mm_movelh_ps(_t15, _t16); \ + _t16 = _mm_movehl_ps(_t16, _t15); \ + _t1 = _mm_loadu_ps(ptrA); \ + _t2 = _mm_loadu_ps(ptrA+4); \ + _t3 = _mm_load_ss(ptrA+8); \ + _t1 = _mm_sub_ps(_t1, _t20); \ + _t2 = _mm_sub_ps(_t2, _t23); \ + _t3 = _mm_sub_ss(_t3, _z3); \ + _mm_storeu_ps(ptrA, _t1); \ + _mm_storeu_ps(ptrA+4, _t2); \ + _mm_store_ss(ptrA+8, _t3); \ + _t4 = _mm_loadu_ps(ptrB); \ + _t5 = _mm_loadu_ps(ptrB+4); \ + _t6 = _mm_load_ss(ptrB+8); \ + _t4 = _mm_sub_ps(_t4, _t21); \ + _t5 = _mm_sub_ps(_t5, _t24); \ + _t6 = _mm_sub_ss(_t6, _t17); \ + _mm_storeu_ps(ptrB, _t4); \ + _mm_storeu_ps(ptrB+4, _t5); \ + _mm_store_ss(ptrB+8, _t6); \ + _t7 = _mm_loadu_ps(ptrC); \ + _t8 = _mm_loadu_ps(ptrC+4); \ + _t9 = _mm_load_ss(ptrC+8); \ + _t7 = _mm_sub_ps(_t7, _t22); \ + _t8 = _mm_sub_ps(_t8, _t25); \ + _t9 = _mm_sub_ss(_t9, _t18); \ + _mm_storeu_ps(ptrC, _t7); \ + _mm_storeu_ps(ptrC+4, _t8); \ + _mm_store_ss(ptrC+8, _t9); \ + _t10 = _mm_loadu_ps(ptrD); \ + _t11 = _mm_loadu_ps(ptrD+4); \ + _t12 = _mm_load_ss(ptrD+8); \ + _t10 = _mm_sub_ps(_t10, _t14); \ + _t11 = _mm_sub_ps(_t11, _t16); \ + _t12 = _mm_sub_ss(_t12, _t19); \ + _mm_storeu_ps(ptrD, _t10); \ + _mm_storeu_ps(ptrD+4, _t11); \ + _mm_store_ss(ptrD+8, _t12); \ + } #else /* Real function for sane compilers */ static void @@ -446,138 +446,138 @@ gmx_mm_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_re __m128 x2, __m128 y2, __m128 z2, __m128 x3, __m128 y3, __m128 z3) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; - __m128 t11,t12,t13,t14,t15,t16,t17,t18,t19; - __m128 t20,t21,t22,t23,t24,t25; - - t13 = _mm_unpackhi_ps(x1,y1); - x1 = _mm_unpacklo_ps(x1,y1); - t14 = _mm_unpackhi_ps(z1,x2); - z1 = _mm_unpacklo_ps(z1,x2); - t15 = _mm_unpackhi_ps(y2,z2); - y2 = _mm_unpacklo_ps(y2,z2); - t16 = _mm_unpackhi_ps(x3,y3); - x3 = _mm_unpacklo_ps(x3,y3); - t17 = _mm_shuffle_ps(z3,z3,_MM_SHUFFLE(0,0,0,1)); - t18 = _mm_movehl_ps(z3,z3); - t19 = _mm_shuffle_ps(t18,t18,_MM_SHUFFLE(0,0,0,1)); - t20 = _mm_movelh_ps(x1,z1); - t21 = _mm_movehl_ps(z1,x1); - t22 = _mm_movelh_ps(t13,t14); - t14 = _mm_movehl_ps(t14,t13); - t23 = _mm_movelh_ps(y2,x3); - t24 = _mm_movehl_ps(x3,y2); - t25 = _mm_movelh_ps(t15,t16); - t16 = _mm_movehl_ps(t16,t15); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; + __m128 t11, t12, t13, t14, t15, t16, t17, t18, t19; + __m128 t20, t21, t22, t23, t24, t25; + + t13 = _mm_unpackhi_ps(x1, y1); + x1 = _mm_unpacklo_ps(x1, y1); + t14 = _mm_unpackhi_ps(z1, x2); + z1 = _mm_unpacklo_ps(z1, x2); + t15 = _mm_unpackhi_ps(y2, z2); + y2 = _mm_unpacklo_ps(y2, z2); + t16 = _mm_unpackhi_ps(x3, y3); + x3 = _mm_unpacklo_ps(x3, y3); + t17 = _mm_shuffle_ps(z3, z3, _MM_SHUFFLE(0, 0, 0, 1)); + t18 = _mm_movehl_ps(z3, z3); + t19 = _mm_shuffle_ps(t18, t18, _MM_SHUFFLE(0, 0, 0, 1)); + t20 = _mm_movelh_ps(x1, z1); + t21 = _mm_movehl_ps(z1, x1); + t22 = _mm_movelh_ps(t13, t14); + t14 = _mm_movehl_ps(t14, t13); + t23 = _mm_movelh_ps(y2, x3); + t24 = _mm_movehl_ps(x3, y2); + t25 = _mm_movelh_ps(t15, t16); + t16 = _mm_movehl_ps(t16, t15); t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrA+4); t3 = _mm_load_ss(ptrA+8); - t1 = _mm_sub_ps(t1,t20); - t2 = _mm_sub_ps(t2,t23); - t3 = _mm_sub_ss(t3,z3); - _mm_storeu_ps(ptrA,t1); - _mm_storeu_ps(ptrA+4,t2); - _mm_store_ss(ptrA+8,t3); + t1 = _mm_sub_ps(t1, t20); + t2 = _mm_sub_ps(t2, t23); + t3 = _mm_sub_ss(t3, z3); + _mm_storeu_ps(ptrA, t1); + _mm_storeu_ps(ptrA+4, t2); + _mm_store_ss(ptrA+8, t3); t4 = _mm_loadu_ps(ptrB); t5 = _mm_loadu_ps(ptrB+4); t6 = _mm_load_ss(ptrB+8); - t4 = _mm_sub_ps(t4,t21); - t5 = _mm_sub_ps(t5,t24); - t6 = _mm_sub_ss(t6,t17); - _mm_storeu_ps(ptrB,t4); - _mm_storeu_ps(ptrB+4,t5); - _mm_store_ss(ptrB+8,t6); + t4 = _mm_sub_ps(t4, t21); + t5 = _mm_sub_ps(t5, t24); + t6 = _mm_sub_ss(t6, t17); + _mm_storeu_ps(ptrB, t4); + _mm_storeu_ps(ptrB+4, t5); + _mm_store_ss(ptrB+8, t6); t7 = _mm_loadu_ps(ptrC); t8 = _mm_loadu_ps(ptrC+4); t9 = _mm_load_ss(ptrC+8); - t7 = _mm_sub_ps(t7,t22); - t8 = _mm_sub_ps(t8,t25); - t9 = _mm_sub_ss(t9,t18); - _mm_storeu_ps(ptrC,t7); - _mm_storeu_ps(ptrC+4,t8); - _mm_store_ss(ptrC+8,t9); + t7 = _mm_sub_ps(t7, t22); + t8 = _mm_sub_ps(t8, t25); + t9 = _mm_sub_ss(t9, t18); + _mm_storeu_ps(ptrC, t7); + _mm_storeu_ps(ptrC+4, t8); + _mm_store_ss(ptrC+8, t9); t10 = _mm_loadu_ps(ptrD); t11 = _mm_loadu_ps(ptrD+4); t12 = _mm_load_ss(ptrD+8); - t10 = _mm_sub_ps(t10,t14); - t11 = _mm_sub_ps(t11,t16); - t12 = _mm_sub_ss(t12,t19); - _mm_storeu_ps(ptrD,t10); - _mm_storeu_ps(ptrD+4,t11); - _mm_store_ss(ptrD+8,t12); + t10 = _mm_sub_ps(t10, t14); + t11 = _mm_sub_ps(t11, t16); + t12 = _mm_sub_ss(t12, t19); + _mm_storeu_ps(ptrD, t10); + _mm_storeu_ps(ptrD+4, t11); + _mm_store_ss(ptrD+8, t12); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_4ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD, \ -_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ -__m128 _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11;\ -__m128 _t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19,_t20,_t21,_t22;\ -__m128 _t23,_t24;\ -_t13 = _mm_unpackhi_ps(_x1,_y1);\ -_x1 = _mm_unpacklo_ps(_x1,_y1);\ -_t14 = _mm_unpackhi_ps(_z1,_x2);\ -_z1 = _mm_unpacklo_ps(_z1,_x2);\ -_t15 = _mm_unpackhi_ps(_y2,_z2);\ -_y2 = _mm_unpacklo_ps(_y2,_z2);\ -_t16 = _mm_unpackhi_ps(_x3,_y3);\ -_x3 = _mm_unpacklo_ps(_x3,_y3);\ -_t17 = _mm_unpackhi_ps(_z3,_x4);\ -_z3 = _mm_unpacklo_ps(_z3,_x4);\ -_t18 = _mm_unpackhi_ps(_y4,_z4);\ -_y4 = _mm_unpacklo_ps(_y4,_z4);\ -_t19 = _mm_movelh_ps(_x1,_z1);\ -_z1 = _mm_movehl_ps(_z1,_x1);\ -_t20 = _mm_movelh_ps(_t13,_t14);\ -_t14 = _mm_movehl_ps(_t14,_t13);\ -_t21 = _mm_movelh_ps(_y2,_x3);\ -_x3 = _mm_movehl_ps(_x3,_y2);\ -_t22 = _mm_movelh_ps(_t15,_t16);\ -_t16 = _mm_movehl_ps(_t16,_t15);\ -_t23 = _mm_movelh_ps(_z3,_y4);\ -_y4 = _mm_movehl_ps(_y4,_z3);\ -_t24 = _mm_movelh_ps(_t17,_t18);\ -_t18 = _mm_movehl_ps(_t18,_t17);\ -_t1 = _mm_loadu_ps(ptrA);\ -_t2 = _mm_loadu_ps(ptrA+4);\ -_t3 = _mm_loadu_ps(ptrA+8);\ -_t1 = _mm_sub_ps(_t1,_t19);\ -_t2 = _mm_sub_ps(_t2,_t21);\ -_t3 = _mm_sub_ps(_t3,_t23);\ -_mm_storeu_ps(ptrA,_t1);\ -_mm_storeu_ps(ptrA+4,_t2);\ -_mm_storeu_ps(ptrA+8,_t3);\ -_t4 = _mm_loadu_ps(ptrB);\ -_t5 = _mm_loadu_ps(ptrB+4);\ -_t6 = _mm_loadu_ps(ptrB+8);\ -_t4 = _mm_sub_ps(_t4,_z1);\ -_t5 = _mm_sub_ps(_t5,_x3);\ -_t6 = _mm_sub_ps(_t6,_y4);\ -_mm_storeu_ps(ptrB,_t4);\ -_mm_storeu_ps(ptrB+4,_t5);\ -_mm_storeu_ps(ptrB+8,_t6);\ -_t7 = _mm_loadu_ps(ptrC);\ -_t8 = _mm_loadu_ps(ptrC+4);\ -_t9 = _mm_loadu_ps(ptrC+8);\ -_t7 = _mm_sub_ps(_t7,_t20);\ -_t8 = _mm_sub_ps(_t8,_t22);\ -_t9 = _mm_sub_ps(_t9,_t24);\ -_mm_storeu_ps(ptrC,_t7);\ -_mm_storeu_ps(ptrC+4,_t8);\ -_mm_storeu_ps(ptrC+8,_t9);\ -_t10 = _mm_loadu_ps(ptrD);\ -_t11 = _mm_loadu_ps(ptrD+4);\ -_t12 = _mm_loadu_ps(ptrD+8);\ -_t10 = _mm_sub_ps(_t10,_t14);\ -_t11 = _mm_sub_ps(_t11,_t16);\ -_t12 = _mm_sub_ps(_t12,_t18);\ -_mm_storeu_ps(ptrD,_t10);\ -_mm_storeu_ps(ptrD+4,_t11);\ -_mm_storeu_ps(ptrD+8,_t12);\ -} +#define gmx_mm_decrement_4rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11; \ + __m128 _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20, _t21, _t22; \ + __m128 _t23, _t24; \ + _t13 = _mm_unpackhi_ps(_x1, _y1); \ + _x1 = _mm_unpacklo_ps(_x1, _y1); \ + _t14 = _mm_unpackhi_ps(_z1, _x2); \ + _z1 = _mm_unpacklo_ps(_z1, _x2); \ + _t15 = _mm_unpackhi_ps(_y2, _z2); \ + _y2 = _mm_unpacklo_ps(_y2, _z2); \ + _t16 = _mm_unpackhi_ps(_x3, _y3); \ + _x3 = _mm_unpacklo_ps(_x3, _y3); \ + _t17 = _mm_unpackhi_ps(_z3, _x4); \ + _z3 = _mm_unpacklo_ps(_z3, _x4); \ + _t18 = _mm_unpackhi_ps(_y4, _z4); \ + _y4 = _mm_unpacklo_ps(_y4, _z4); \ + _t19 = _mm_movelh_ps(_x1, _z1); \ + _z1 = _mm_movehl_ps(_z1, _x1); \ + _t20 = _mm_movelh_ps(_t13, _t14); \ + _t14 = _mm_movehl_ps(_t14, _t13); \ + _t21 = _mm_movelh_ps(_y2, _x3); \ + _x3 = _mm_movehl_ps(_x3, _y2); \ + _t22 = _mm_movelh_ps(_t15, _t16); \ + _t16 = _mm_movehl_ps(_t16, _t15); \ + _t23 = _mm_movelh_ps(_z3, _y4); \ + _y4 = _mm_movehl_ps(_y4, _z3); \ + _t24 = _mm_movelh_ps(_t17, _t18); \ + _t18 = _mm_movehl_ps(_t18, _t17); \ + _t1 = _mm_loadu_ps(ptrA); \ + _t2 = _mm_loadu_ps(ptrA+4); \ + _t3 = _mm_loadu_ps(ptrA+8); \ + _t1 = _mm_sub_ps(_t1, _t19); \ + _t2 = _mm_sub_ps(_t2, _t21); \ + _t3 = _mm_sub_ps(_t3, _t23); \ + _mm_storeu_ps(ptrA, _t1); \ + _mm_storeu_ps(ptrA+4, _t2); \ + _mm_storeu_ps(ptrA+8, _t3); \ + _t4 = _mm_loadu_ps(ptrB); \ + _t5 = _mm_loadu_ps(ptrB+4); \ + _t6 = _mm_loadu_ps(ptrB+8); \ + _t4 = _mm_sub_ps(_t4, _z1); \ + _t5 = _mm_sub_ps(_t5, _x3); \ + _t6 = _mm_sub_ps(_t6, _y4); \ + _mm_storeu_ps(ptrB, _t4); \ + _mm_storeu_ps(ptrB+4, _t5); \ + _mm_storeu_ps(ptrB+8, _t6); \ + _t7 = _mm_loadu_ps(ptrC); \ + _t8 = _mm_loadu_ps(ptrC+4); \ + _t9 = _mm_loadu_ps(ptrC+8); \ + _t7 = _mm_sub_ps(_t7, _t20); \ + _t8 = _mm_sub_ps(_t8, _t22); \ + _t9 = _mm_sub_ps(_t9, _t24); \ + _mm_storeu_ps(ptrC, _t7); \ + _mm_storeu_ps(ptrC+4, _t8); \ + _mm_storeu_ps(ptrC+8, _t9); \ + _t10 = _mm_loadu_ps(ptrD); \ + _t11 = _mm_loadu_ps(ptrD+4); \ + _t12 = _mm_loadu_ps(ptrD+8); \ + _t10 = _mm_sub_ps(_t10, _t14); \ + _t11 = _mm_sub_ps(_t11, _t16); \ + _t12 = _mm_sub_ps(_t12, _t18); \ + _mm_storeu_ps(ptrD, _t10); \ + _mm_storeu_ps(ptrD+4, _t11); \ + _mm_storeu_ps(ptrD+8, _t12); \ + } #else /* Real function for sane compilers */ static void @@ -588,69 +588,69 @@ gmx_mm_decrement_4rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_re __m128 x3, __m128 y3, __m128 z3, __m128 x4, __m128 y4, __m128 z4) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; - __m128 t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22; - __m128 t23,t24; - t13 = _mm_unpackhi_ps(x1,y1); - x1 = _mm_unpacklo_ps(x1,y1); - t14 = _mm_unpackhi_ps(z1,x2); - z1 = _mm_unpacklo_ps(z1,x2); - t15 = _mm_unpackhi_ps(y2,z2); - y2 = _mm_unpacklo_ps(y2,z2); - t16 = _mm_unpackhi_ps(x3,y3); - x3 = _mm_unpacklo_ps(x3,y3); - t17 = _mm_unpackhi_ps(z3,x4); - z3 = _mm_unpacklo_ps(z3,x4); - t18 = _mm_unpackhi_ps(y4,z4); - y4 = _mm_unpacklo_ps(y4,z4); - t19 = _mm_movelh_ps(x1,z1); - z1 = _mm_movehl_ps(z1,x1); - t20 = _mm_movelh_ps(t13,t14); - t14 = _mm_movehl_ps(t14,t13); - t21 = _mm_movelh_ps(y2,x3); - x3 = _mm_movehl_ps(x3,y2); - t22 = _mm_movelh_ps(t15,t16); - t16 = _mm_movehl_ps(t16,t15); - t23 = _mm_movelh_ps(z3,y4); - y4 = _mm_movehl_ps(y4,z3); - t24 = _mm_movelh_ps(t17,t18); - t18 = _mm_movehl_ps(t18,t17); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; + __m128 t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22; + __m128 t23, t24; + t13 = _mm_unpackhi_ps(x1, y1); + x1 = _mm_unpacklo_ps(x1, y1); + t14 = _mm_unpackhi_ps(z1, x2); + z1 = _mm_unpacklo_ps(z1, x2); + t15 = _mm_unpackhi_ps(y2, z2); + y2 = _mm_unpacklo_ps(y2, z2); + t16 = _mm_unpackhi_ps(x3, y3); + x3 = _mm_unpacklo_ps(x3, y3); + t17 = _mm_unpackhi_ps(z3, x4); + z3 = _mm_unpacklo_ps(z3, x4); + t18 = _mm_unpackhi_ps(y4, z4); + y4 = _mm_unpacklo_ps(y4, z4); + t19 = _mm_movelh_ps(x1, z1); + z1 = _mm_movehl_ps(z1, x1); + t20 = _mm_movelh_ps(t13, t14); + t14 = _mm_movehl_ps(t14, t13); + t21 = _mm_movelh_ps(y2, x3); + x3 = _mm_movehl_ps(x3, y2); + t22 = _mm_movelh_ps(t15, t16); + t16 = _mm_movehl_ps(t16, t15); + t23 = _mm_movelh_ps(z3, y4); + y4 = _mm_movehl_ps(y4, z3); + t24 = _mm_movelh_ps(t17, t18); + t18 = _mm_movehl_ps(t18, t17); t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrA+4); t3 = _mm_loadu_ps(ptrA+8); - t1 = _mm_sub_ps(t1,t19); - t2 = _mm_sub_ps(t2,t21); - t3 = _mm_sub_ps(t3,t23); - _mm_storeu_ps(ptrA,t1); - _mm_storeu_ps(ptrA+4,t2); - _mm_storeu_ps(ptrA+8,t3); + t1 = _mm_sub_ps(t1, t19); + t2 = _mm_sub_ps(t2, t21); + t3 = _mm_sub_ps(t3, t23); + _mm_storeu_ps(ptrA, t1); + _mm_storeu_ps(ptrA+4, t2); + _mm_storeu_ps(ptrA+8, t3); t4 = _mm_loadu_ps(ptrB); t5 = _mm_loadu_ps(ptrB+4); t6 = _mm_loadu_ps(ptrB+8); - t4 = _mm_sub_ps(t4,z1); - t5 = _mm_sub_ps(t5,x3); - t6 = _mm_sub_ps(t6,y4); - _mm_storeu_ps(ptrB,t4); - _mm_storeu_ps(ptrB+4,t5); - _mm_storeu_ps(ptrB+8,t6); + t4 = _mm_sub_ps(t4, z1); + t5 = _mm_sub_ps(t5, x3); + t6 = _mm_sub_ps(t6, y4); + _mm_storeu_ps(ptrB, t4); + _mm_storeu_ps(ptrB+4, t5); + _mm_storeu_ps(ptrB+8, t6); t7 = _mm_loadu_ps(ptrC); t8 = _mm_loadu_ps(ptrC+4); t9 = _mm_loadu_ps(ptrC+8); - t7 = _mm_sub_ps(t7,t20); - t8 = _mm_sub_ps(t8,t22); - t9 = _mm_sub_ps(t9,t24); - _mm_storeu_ps(ptrC,t7); - _mm_storeu_ps(ptrC+4,t8); - _mm_storeu_ps(ptrC+8,t9); + t7 = _mm_sub_ps(t7, t20); + t8 = _mm_sub_ps(t8, t22); + t9 = _mm_sub_ps(t9, t24); + _mm_storeu_ps(ptrC, t7); + _mm_storeu_ps(ptrC+4, t8); + _mm_storeu_ps(ptrC+8, t9); t10 = _mm_loadu_ps(ptrD); t11 = _mm_loadu_ps(ptrD+4); t12 = _mm_loadu_ps(ptrD+8); - t10 = _mm_sub_ps(t10,t14); - t11 = _mm_sub_ps(t11,t16); - t12 = _mm_sub_ps(t12,t18); - _mm_storeu_ps(ptrD,t10); - _mm_storeu_ps(ptrD+4,t11); - _mm_storeu_ps(ptrD+8,t12); + t10 = _mm_sub_ps(t10, t14); + t11 = _mm_sub_ps(t11, t16); + t12 = _mm_sub_ps(t12, t18); + _mm_storeu_ps(ptrD, t10); + _mm_storeu_ps(ptrD+4, t11); + _mm_storeu_ps(ptrD+8, t12); } #endif @@ -660,57 +660,57 @@ gmx_mm_update_iforce_1atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t1,t2,t3; + __m128 t1, t2, t3; /* transpose data */ t1 = fix1; - _MM_TRANSPOSE4_PS(fix1,t1,fiy1,fiz1); - fix1 = _mm_add_ps(_mm_add_ps(fix1,t1), _mm_add_ps(fiy1,fiz1)); + _MM_TRANSPOSE4_PS(fix1, t1, fiy1, fiz1); + fix1 = _mm_add_ps(_mm_add_ps(fix1, t1), _mm_add_ps(fiy1, fiz1)); t2 = _mm_load_ss(fptr); - t2 = _mm_loadh_pi(t2,(__m64 *)(fptr+1)); + t2 = _mm_loadh_pi(t2, (__m64 *)(fptr+1)); t3 = _mm_load_ss(fshiftptr); - t3 = _mm_loadh_pi(t3,(__m64 *)(fshiftptr+1)); + t3 = _mm_loadh_pi(t3, (__m64 *)(fshiftptr+1)); - t2 = _mm_add_ps(t2,fix1); - t3 = _mm_add_ps(t3,fix1); + t2 = _mm_add_ps(t2, fix1); + t3 = _mm_add_ps(t3, fix1); - _mm_store_ss(fptr,t2); - _mm_storeh_pi((__m64 *)(fptr+1),t2); - _mm_store_ss(fshiftptr,t3); - _mm_storeh_pi((__m64 *)(fshiftptr+1),t3); + _mm_store_ss(fptr, t2); + _mm_storeh_pi((__m64 *)(fptr+1), t2); + _mm_store_ss(fshiftptr, t3); + _mm_storeh_pi((__m64 *)(fshiftptr+1), t3); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \ - fptr,fshiftptr) \ -{\ - __m128 _t1,_t2,_t3,_t4;\ +#define gmx_mm_update_iforce_3atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \ + fptr, fshiftptr) \ + { \ + __m128 _t1, _t2, _t3, _t4; \ \ - _MM_TRANSPOSE4_PS(fix1,fiy1,fiz1,fix2);\ - _MM_TRANSPOSE4_PS(fiy2,fiz2,fix3,fiy3);\ - _t2 = _mm_movehl_ps(_mm_setzero_ps(),fiz3);\ - _t1 = _mm_shuffle_ps(fiz3,fiz3,_MM_SHUFFLE(0,0,0,1));\ - _t3 = _mm_shuffle_ps(_t2,_t2,_MM_SHUFFLE(0,0,0,1));\ - fix1 = _mm_add_ps(_mm_add_ps(fix1,fiy1), _mm_add_ps(fiz1,fix2));\ - fiy2 = _mm_add_ps(_mm_add_ps(fiy2,fiz2), _mm_add_ps(fix3,fiy3));\ - fiz3 = _mm_add_ss(_mm_add_ps(fiz3,_t1) , _mm_add_ps(_t2,_t3));\ - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) ));\ - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4)));\ - _mm_store_ss (fptr+8,_mm_add_ss(fiz3,_mm_load_ss(fptr+8) ));\ - _t4 = _mm_load_ss(fshiftptr+2);\ - _t4 = _mm_loadh_pi(_t4,(__m64 *)(fshiftptr));\ - _t1 = _mm_shuffle_ps(fiz3,fix1,_MM_SHUFFLE(1,0,0,0));\ - _t2 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(3,2,2,2));\ - _t3 = _mm_shuffle_ps(fiy2,fix1,_MM_SHUFFLE(3,3,0,1));\ - _t3 = _mm_shuffle_ps(_t3 ,_t3 ,_MM_SHUFFLE(1,2,0,0));\ - _t1 = _mm_add_ps(_t1,_t2);\ - _t3 = _mm_add_ps(_t3,_t4);\ - _t1 = _mm_add_ps(_t1,_t3);\ - _mm_store_ss(fshiftptr+2,_t1);\ - _mm_storeh_pi((__m64 *)(fshiftptr),_t1);\ -} + _MM_TRANSPOSE4_PS(fix1, fiy1, fiz1, fix2); \ + _MM_TRANSPOSE4_PS(fiy2, fiz2, fix3, fiy3); \ + _t2 = _mm_movehl_ps(_mm_setzero_ps(), fiz3); \ + _t1 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(0, 0, 0, 1)); \ + _t3 = _mm_shuffle_ps(_t2, _t2, _MM_SHUFFLE(0, 0, 0, 1)); \ + fix1 = _mm_add_ps(_mm_add_ps(fix1, fiy1), _mm_add_ps(fiz1, fix2)); \ + fiy2 = _mm_add_ps(_mm_add_ps(fiy2, fiz2), _mm_add_ps(fix3, fiy3)); \ + fiz3 = _mm_add_ss(_mm_add_ps(fiz3, _t1), _mm_add_ps(_t2, _t3)); \ + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \ + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \ + _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) )); \ + _t4 = _mm_load_ss(fshiftptr+2); \ + _t4 = _mm_loadh_pi(_t4, (__m64 *)(fshiftptr)); \ + _t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); \ + _t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); \ + _t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); \ + _t3 = _mm_shuffle_ps(_t3, _t3, _MM_SHUFFLE(1, 2, 0, 0)); \ + _t1 = _mm_add_ps(_t1, _t2); \ + _t3 = _mm_add_ps(_t3, _t4); \ + _t1 = _mm_add_ps(_t1, _t3); \ + _mm_store_ss(fshiftptr+2, _t1); \ + _mm_storeh_pi((__m64 *)(fshiftptr), _t1); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -720,69 +720,69 @@ gmx_mm_update_iforce_3atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; /* transpose data */ - _MM_TRANSPOSE4_PS(fix1,fiy1,fiz1,fix2); - _MM_TRANSPOSE4_PS(fiy2,fiz2,fix3,fiy3); - t2 = _mm_movehl_ps(_mm_setzero_ps(),fiz3); - t1 = _mm_shuffle_ps(fiz3,fiz3,_MM_SHUFFLE(0,0,0,1)); - t3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(0,0,0,1)); + _MM_TRANSPOSE4_PS(fix1, fiy1, fiz1, fix2); + _MM_TRANSPOSE4_PS(fiy2, fiz2, fix3, fiy3); + t2 = _mm_movehl_ps(_mm_setzero_ps(), fiz3); + t1 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(0, 0, 0, 1)); + t3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 1)); - fix1 = _mm_add_ps(_mm_add_ps(fix1,fiy1), _mm_add_ps(fiz1,fix2)); - fiy2 = _mm_add_ps(_mm_add_ps(fiy2,fiz2), _mm_add_ps(fix3,fiy3)); - fiz3 = _mm_add_ss(_mm_add_ps(fiz3,t1) , _mm_add_ps(t2,t3)); + fix1 = _mm_add_ps(_mm_add_ps(fix1, fiy1), _mm_add_ps(fiz1, fix2)); + fiy2 = _mm_add_ps(_mm_add_ps(fiy2, fiz2), _mm_add_ps(fix3, fiy3)); + fiz3 = _mm_add_ss(_mm_add_ps(fiz3, t1), _mm_add_ps(t2, t3)); - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) )); - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4))); - _mm_store_ss (fptr+8,_mm_add_ss(fiz3,_mm_load_ss(fptr+8) )); + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); + _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) )); t4 = _mm_load_ss(fshiftptr+2); - t4 = _mm_loadh_pi(t4,(__m64 *)(fshiftptr)); + t4 = _mm_loadh_pi(t4, (__m64 *)(fshiftptr)); - t1 = _mm_shuffle_ps(fiz3,fix1,_MM_SHUFFLE(1,0,0,0)); /* fiy1 fix1 - fiz3 */ - t2 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(3,2,2,2)); /* fiy3 fix3 - fiz1 */ - t3 = _mm_shuffle_ps(fiy2,fix1,_MM_SHUFFLE(3,3,0,1)); /* fix2 fix2 fiy2 fiz2 */ - t3 = _mm_shuffle_ps(t3 ,t3 ,_MM_SHUFFLE(1,2,0,0)); /* fiy2 fix2 - fiz2 */ + t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); /* fiy1 fix1 - fiz3 */ + t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); /* fiy3 fix3 - fiz1 */ + t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); /* fix2 fix2 fiy2 fiz2 */ + t3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 2, 0, 0)); /* fiy2 fix2 - fiz2 */ - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ps(t3,t4); - t1 = _mm_add_ps(t1,t3); /* y x - z */ + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ps(t3, t4); + t1 = _mm_add_ps(t1, t3); /* y x - z */ - _mm_store_ss(fshiftptr+2,t1); - _mm_storeh_pi((__m64 *)(fshiftptr),t1); + _mm_store_ss(fshiftptr+2, t1); + _mm_storeh_pi((__m64 *)(fshiftptr), t1); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_4atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \ - fptr,fshiftptr) \ -{\ - __m128 _t1,_t2,_t3,_t4,_t5;\ - _MM_TRANSPOSE4_PS(fix1,fiy1,fiz1,fix2);\ - _MM_TRANSPOSE4_PS(fiy2,fiz2,fix3,fiy3);\ - _MM_TRANSPOSE4_PS(fiz3,fix4,fiy4,fiz4);\ - fix1 = _mm_add_ps(_mm_add_ps(fix1,fiy1), _mm_add_ps(fiz1,fix2));\ - fiy2 = _mm_add_ps(_mm_add_ps(fiy2,fiz2), _mm_add_ps(fix3,fiy3));\ - fiz3 = _mm_add_ps(_mm_add_ps(fiz3,fix4), _mm_add_ps(fiy4,fiz4));\ - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) ));\ - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4)));\ - _mm_storeu_ps(fptr+8,_mm_add_ps(fiz3,_mm_loadu_ps(fptr+8)));\ - _t5 = _mm_load_ss(fshiftptr+2);\ - _t5 = _mm_loadh_pi(_t5,(__m64 *)(fshiftptr));\ - _t1 = _mm_shuffle_ps(fix1,fix1,_MM_SHUFFLE(1,0,2,2));\ - _t2 = _mm_shuffle_ps(fiy2,fiy2,_MM_SHUFFLE(3,2,1,1));\ - _t3 = _mm_shuffle_ps(fiz3,fiz3,_MM_SHUFFLE(2,1,0,0));\ - _t4 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(0,0,3,3));\ - _t4 = _mm_shuffle_ps(fiz3,_t4 ,_MM_SHUFFLE(2,0,3,3));\ - _t1 = _mm_add_ps(_t1,_t2);\ - _t3 = _mm_add_ps(_t3,_t4);\ - _t1 = _mm_add_ps(_t1,_t3);\ - _t5 = _mm_add_ps(_t5,_t1);\ - _mm_store_ss(fshiftptr+2,_t5);\ - _mm_storeh_pi((__m64 *)(fshiftptr),_t5);\ -} +#define gmx_mm_update_iforce_4atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \ + fptr, fshiftptr) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5; \ + _MM_TRANSPOSE4_PS(fix1, fiy1, fiz1, fix2); \ + _MM_TRANSPOSE4_PS(fiy2, fiz2, fix3, fiy3); \ + _MM_TRANSPOSE4_PS(fiz3, fix4, fiy4, fiz4); \ + fix1 = _mm_add_ps(_mm_add_ps(fix1, fiy1), _mm_add_ps(fiz1, fix2)); \ + fiy2 = _mm_add_ps(_mm_add_ps(fiy2, fiz2), _mm_add_ps(fix3, fiy3)); \ + fiz3 = _mm_add_ps(_mm_add_ps(fiz3, fix4), _mm_add_ps(fiy4, fiz4)); \ + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \ + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \ + _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8))); \ + _t5 = _mm_load_ss(fshiftptr+2); \ + _t5 = _mm_loadh_pi(_t5, (__m64 *)(fshiftptr)); \ + _t1 = _mm_shuffle_ps(fix1, fix1, _MM_SHUFFLE(1, 0, 2, 2)); \ + _t2 = _mm_shuffle_ps(fiy2, fiy2, _MM_SHUFFLE(3, 2, 1, 1)); \ + _t3 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(2, 1, 0, 0)); \ + _t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3)); \ + _t4 = _mm_shuffle_ps(fiz3, _t4, _MM_SHUFFLE(2, 0, 3, 3)); \ + _t1 = _mm_add_ps(_t1, _t2); \ + _t3 = _mm_add_ps(_t3, _t4); \ + _t1 = _mm_add_ps(_t1, _t3); \ + _t5 = _mm_add_ps(_t5, _t1); \ + _mm_store_ss(fshiftptr+2, _t5); \ + _mm_storeh_pi((__m64 *)(fshiftptr), _t5); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -793,37 +793,37 @@ gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t1,t2,t3,t4,t5; + __m128 t1, t2, t3, t4, t5; /* transpose data */ - _MM_TRANSPOSE4_PS(fix1,fiy1,fiz1,fix2); - _MM_TRANSPOSE4_PS(fiy2,fiz2,fix3,fiy3); - _MM_TRANSPOSE4_PS(fiz3,fix4,fiy4,fiz4); + _MM_TRANSPOSE4_PS(fix1, fiy1, fiz1, fix2); + _MM_TRANSPOSE4_PS(fiy2, fiz2, fix3, fiy3); + _MM_TRANSPOSE4_PS(fiz3, fix4, fiy4, fiz4); - fix1 = _mm_add_ps(_mm_add_ps(fix1,fiy1), _mm_add_ps(fiz1,fix2)); - fiy2 = _mm_add_ps(_mm_add_ps(fiy2,fiz2), _mm_add_ps(fix3,fiy3)); - fiz3 = _mm_add_ps(_mm_add_ps(fiz3,fix4), _mm_add_ps(fiy4,fiz4)); + fix1 = _mm_add_ps(_mm_add_ps(fix1, fiy1), _mm_add_ps(fiz1, fix2)); + fiy2 = _mm_add_ps(_mm_add_ps(fiy2, fiz2), _mm_add_ps(fix3, fiy3)); + fiz3 = _mm_add_ps(_mm_add_ps(fiz3, fix4), _mm_add_ps(fiy4, fiz4)); - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) )); - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4))); - _mm_storeu_ps(fptr+8,_mm_add_ps(fiz3,_mm_loadu_ps(fptr+8))); + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); + _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8))); t5 = _mm_load_ss(fshiftptr+2); - t5 = _mm_loadh_pi(t5,(__m64 *)(fshiftptr)); + t5 = _mm_loadh_pi(t5, (__m64 *)(fshiftptr)); - t1 = _mm_shuffle_ps(fix1,fix1,_MM_SHUFFLE(1,0,2,2)); - t2 = _mm_shuffle_ps(fiy2,fiy2,_MM_SHUFFLE(3,2,1,1)); - t3 = _mm_shuffle_ps(fiz3,fiz3,_MM_SHUFFLE(2,1,0,0)); - t4 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(0,0,3,3)); - t4 = _mm_shuffle_ps(fiz3,t4 ,_MM_SHUFFLE(2,0,3,3)); + t1 = _mm_shuffle_ps(fix1, fix1, _MM_SHUFFLE(1, 0, 2, 2)); + t2 = _mm_shuffle_ps(fiy2, fiy2, _MM_SHUFFLE(3, 2, 1, 1)); + t3 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(2, 1, 0, 0)); + t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3)); + t4 = _mm_shuffle_ps(fiz3, t4, _MM_SHUFFLE(2, 0, 3, 3)); - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ps(t3,t4); - t1 = _mm_add_ps(t1,t3); - t5 = _mm_add_ps(t5,t1); + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ps(t3, t4); + t1 = _mm_add_ps(t1, t3); + t5 = _mm_add_ps(t5, t1); - _mm_store_ss(fshiftptr+2,t5); - _mm_storeh_pi((__m64 *)(fshiftptr),t5); + _mm_store_ss(fshiftptr+2, t5); + _mm_storeh_pi((__m64 *)(fshiftptr), t5); } #endif @@ -831,24 +831,24 @@ gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, static void gmx_mm_update_1pot_ps(__m128 pot1, float * gmx_restrict ptrA) { - pot1 = _mm_add_ps(pot1,_mm_movehl_ps(_mm_setzero_ps(),pot1)); - pot1 = _mm_add_ps(pot1,_mm_shuffle_ps(pot1,pot1,_MM_SHUFFLE(0,0,0,1))); - _mm_store_ss(ptrA,_mm_add_ss(pot1,_mm_load_ss(ptrA))); + pot1 = _mm_add_ps(pot1, _mm_movehl_ps(_mm_setzero_ps(), pot1)); + pot1 = _mm_add_ps(pot1, _mm_shuffle_ps(pot1, pot1, _MM_SHUFFLE(0, 0, 0, 1))); + _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA))); } static void gmx_mm_update_2pot_ps(__m128 pot1, float * gmx_restrict ptrA, __m128 pot2, float * gmx_restrict ptrB) { - __m128 t1,t2; - t1 = _mm_movehl_ps(pot2,pot1); - t2 = _mm_movelh_ps(pot1,pot2); - t1 = _mm_add_ps(t1,t2); - t2 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(3,3,1,1)); - pot1 = _mm_add_ps(t1,t2); - pot2 = _mm_movehl_ps(t2,pot1); - _mm_store_ss(ptrA,_mm_add_ss(pot1,_mm_load_ss(ptrA))); - _mm_store_ss(ptrB,_mm_add_ss(pot2,_mm_load_ss(ptrB))); + __m128 t1, t2; + t1 = _mm_movehl_ps(pot2, pot1); + t2 = _mm_movelh_ps(pot1, pot2); + t1 = _mm_add_ps(t1, t2); + t2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 1, 1)); + pot1 = _mm_add_ps(t1, t2); + pot2 = _mm_movehl_ps(t2, pot1); + _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA))); + _mm_store_ss(ptrB, _mm_add_ss(pot2, _mm_load_ss(ptrB))); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.c index ddaa369874..2a5aa767d9 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.c @@ -241,7 +241,7 @@ nb_kernel_t nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_sse2_single; nb_kernel_info_t -kernellist_sse2_single[] = + kernellist_sse2_single[] = { { nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse2_single, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse2_single", "sse2_single", "None", "None", "LennardJones", "None", "ParticleParticle", "", "PotentialAndForce" }, { nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse2_single, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse2_single", "sse2_single", "None", "None", "LennardJones", "None", "ParticleParticle", "", "Force" }, @@ -460,6 +460,6 @@ kernellist_sse2_single[] = }; int -kernellist_sse2_single_size = sizeof(kernellist_sse2_single)/sizeof(kernellist_sse2_single[0]); + kernellist_sse2_single_size = sizeof(kernellist_sse2_single)/sizeof(kernellist_sse2_single[0]); #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.h index dab81ab6c8..b76be077fd 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse2_single/nb_kernel_sse2_single.h @@ -27,10 +27,10 @@ /* List of kernels for this architecture with metadata about them */ extern nb_kernel_info_t -kernellist_sse2_single[]; + kernellist_sse2_single[]; /* Length of kernellist_c */ extern int -kernellist_sse2_single_size; + kernellist_sse2_single_size; #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/kernelutil_x86_sse4_1_double.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/kernelutil_x86_sse4_1_double.h index f304aa5d22..a20139d071 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/kernelutil_x86_sse4_1_double.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/kernelutil_x86_sse4_1_double.h @@ -37,18 +37,18 @@ /* Normal sum of four ymm registers */ -#define gmx_mm_sum4_pd(t0,t1,t2,t3) _mm_add_pd(_mm_add_pd(t0,t1),_mm_add_pd(t2,t3)) +#define gmx_mm_sum4_pd(t0, t1, t2, t3) _mm_add_pd(_mm_add_pd(t0, t1), _mm_add_pd(t2, t3)) static int gmx_mm_any_lt(__m128d a, __m128d b) { - return _mm_movemask_pd(_mm_cmplt_pd(a,b)); + return _mm_movemask_pd(_mm_cmplt_pd(a, b)); } static gmx_inline __m128d gmx_mm_calc_rsq_pd(__m128d dx, __m128d dy, __m128d dz) { - return _mm_add_pd( _mm_add_pd( _mm_mul_pd(dx,dx), _mm_mul_pd(dy,dy) ), _mm_mul_pd(dz,dz) ); + return _mm_add_pd( _mm_add_pd( _mm_mul_pd(dx, dx), _mm_mul_pd(dy, dy) ), _mm_mul_pd(dz, dz) ); } @@ -57,7 +57,7 @@ static gmx_inline __m128d gmx_mm_load_2real_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB) { - return _mm_unpacklo_pd(_mm_load_sd(ptrA),_mm_load_sd(ptrB)); + return _mm_unpacklo_pd(_mm_load_sd(ptrA), _mm_load_sd(ptrB)); } static gmx_inline __m128d @@ -70,19 +70,19 @@ gmx_mm_load_1real_pd(const double * gmx_restrict ptrA) static gmx_inline void gmx_mm_store_2real_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, - __m128d xmm1) + __m128d xmm1) { __m128d t2; - t2 = _mm_unpackhi_pd(xmm1,xmm1); - _mm_store_sd(ptrA,xmm1); - _mm_store_sd(ptrB,t2); + t2 = _mm_unpackhi_pd(xmm1, xmm1); + _mm_store_sd(ptrA, xmm1); + _mm_store_sd(ptrB, t2); } static gmx_inline void gmx_mm_store_1real_pd(double * gmx_restrict ptrA, __m128d xmm1) { - _mm_store_sd(ptrA,xmm1); + _mm_store_sd(ptrA, xmm1); } @@ -93,11 +93,11 @@ gmx_mm_increment_2real_swizzle_pd(double * gmx_restrict ptrA, { __m128d t1; - t1 = _mm_unpackhi_pd(xmm1,xmm1); - xmm1 = _mm_add_sd(xmm1,_mm_load_sd(ptrA)); - t1 = _mm_add_sd(t1,_mm_load_sd(ptrB)); - _mm_store_sd(ptrA,xmm1); - _mm_store_sd(ptrB,t1); + t1 = _mm_unpackhi_pd(xmm1, xmm1); + xmm1 = _mm_add_sd(xmm1, _mm_load_sd(ptrA)); + t1 = _mm_add_sd(t1, _mm_load_sd(ptrB)); + _mm_store_sd(ptrA, xmm1); + _mm_store_sd(ptrB, t1); } static gmx_inline void @@ -106,29 +106,29 @@ gmx_mm_increment_1real_pd(double * gmx_restrict ptrA, __m128d xmm1) __m128d tmp; tmp = gmx_mm_load_1real_pd(ptrA); - tmp = _mm_add_sd(tmp,xmm1); - gmx_mm_store_1real_pd(ptrA,tmp); + tmp = _mm_add_sd(tmp, xmm1); + gmx_mm_store_1real_pd(ptrA, tmp); } static gmx_inline void gmx_mm_load_2pair_swizzle_pd(const double * gmx_restrict p1, const double * gmx_restrict p2, - __m128d * gmx_restrict c6, - __m128d * gmx_restrict c12) + __m128d * gmx_restrict c6, + __m128d * gmx_restrict c12) { - __m128d t1,t2,t3; + __m128d t1, t2, t3; t1 = _mm_loadu_pd(p1); t2 = _mm_loadu_pd(p2); - *c6 = _mm_unpacklo_pd(t1,t2); - *c12 = _mm_unpackhi_pd(t1,t2); + *c6 = _mm_unpacklo_pd(t1, t2); + *c12 = _mm_unpackhi_pd(t1, t2); } static gmx_inline void gmx_mm_load_1pair_swizzle_pd(const double * gmx_restrict p1, - __m128d * gmx_restrict c6, - __m128d * gmx_restrict c12) + __m128d * gmx_restrict c6, + __m128d * gmx_restrict c12) { *c6 = _mm_load_sd(p1); *c12 = _mm_load_sd(p1+1); @@ -138,35 +138,35 @@ gmx_mm_load_1pair_swizzle_pd(const double * gmx_restrict p1, static gmx_inline void gmx_mm_load_shift_and_1rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m128d * gmx_restrict x1, - __m128d * gmx_restrict y1, - __m128d * gmx_restrict z1) + const double * gmx_restrict xyz, + __m128d * gmx_restrict x1, + __m128d * gmx_restrict y1, + __m128d * gmx_restrict z1) { - __m128d mem_xy,mem_z,mem_sxy,mem_sz; + __m128d mem_xy, mem_z, mem_sxy, mem_sz; mem_xy = _mm_loadu_pd(xyz); mem_z = _mm_load_sd(xyz+2); mem_sxy = _mm_loadu_pd(xyz_shift); mem_sz = _mm_load_sd(xyz_shift+2); - mem_xy = _mm_add_pd(mem_xy,mem_sxy); - mem_z = _mm_add_pd(mem_z,mem_sz); + mem_xy = _mm_add_pd(mem_xy, mem_sxy); + mem_z = _mm_add_pd(mem_z, mem_sz); - *x1 = _mm_shuffle_pd(mem_xy,mem_xy,_MM_SHUFFLE2(0,0)); - *y1 = _mm_shuffle_pd(mem_xy,mem_xy,_MM_SHUFFLE2(1,1)); - *z1 = _mm_shuffle_pd(mem_z,mem_z,_MM_SHUFFLE2(0,0)); + *x1 = _mm_shuffle_pd(mem_xy, mem_xy, _MM_SHUFFLE2(0, 0)); + *y1 = _mm_shuffle_pd(mem_xy, mem_xy, _MM_SHUFFLE2(1, 1)); + *z1 = _mm_shuffle_pd(mem_z, mem_z, _MM_SHUFFLE2(0, 0)); } static gmx_inline void gmx_mm_load_shift_and_3rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1, - __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, - __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3) + const double * gmx_restrict xyz, + __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1, + __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, + __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3) { - __m128d t1,t2,t3,t4,t5,sxy,sz,szx,syz; + __m128d t1, t2, t3, t4, t5, sxy, sz, szx, syz; t1 = _mm_loadu_pd(xyz); t2 = _mm_loadu_pd(xyz+2); @@ -176,36 +176,36 @@ gmx_mm_load_shift_and_3rvec_broadcast_pd(const double * gmx_restrict xyz_shift, sxy = _mm_loadu_pd(xyz_shift); sz = _mm_load_sd(xyz_shift+2); - szx = _mm_shuffle_pd(sz,sxy,_MM_SHUFFLE2(0,0)); - syz = _mm_shuffle_pd(sxy,sz,_MM_SHUFFLE2(0,1)); - - t1 = _mm_add_pd(t1,sxy); - t2 = _mm_add_pd(t2,szx); - t3 = _mm_add_pd(t3,syz); - t4 = _mm_add_pd(t4,sxy); - t5 = _mm_add_sd(t5,sz); - - *x1 = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(0,0)); - *y1 = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(1,1)); - *z1 = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(0,0)); - *x2 = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(1,1)); - *y2 = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(0,0)); - *z2 = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(1,1)); - *x3 = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(0,0)); - *y3 = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(1,1)); - *z3 = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(0,0)); + szx = _mm_shuffle_pd(sz, sxy, _MM_SHUFFLE2(0, 0)); + syz = _mm_shuffle_pd(sxy, sz, _MM_SHUFFLE2(0, 1)); + + t1 = _mm_add_pd(t1, sxy); + t2 = _mm_add_pd(t2, szx); + t3 = _mm_add_pd(t3, syz); + t4 = _mm_add_pd(t4, sxy); + t5 = _mm_add_sd(t5, sz); + + *x1 = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(0, 0)); + *y1 = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(1, 1)); + *z1 = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(0, 0)); + *x2 = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(1, 1)); + *y2 = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(0, 0)); + *z2 = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(1, 1)); + *x3 = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(0, 0)); + *y3 = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(1, 1)); + *z3 = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(0, 0)); } static gmx_inline void gmx_mm_load_shift_and_4rvec_broadcast_pd(const double * gmx_restrict xyz_shift, - const double * gmx_restrict xyz, - __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1, - __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, - __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3, - __m128d * gmx_restrict x4, __m128d * gmx_restrict y4, __m128d * gmx_restrict z4) + const double * gmx_restrict xyz, + __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1, + __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, + __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3, + __m128d * gmx_restrict x4, __m128d * gmx_restrict y4, __m128d * gmx_restrict z4) { - __m128d t1,t2,t3,t4,t5,t6,sxy,sz,szx,syz; + __m128d t1, t2, t3, t4, t5, t6, sxy, sz, szx, syz; t1 = _mm_loadu_pd(xyz); t2 = _mm_loadu_pd(xyz+2); @@ -216,28 +216,28 @@ gmx_mm_load_shift_and_4rvec_broadcast_pd(const double * gmx_restrict xyz_shift, sxy = _mm_loadu_pd(xyz_shift); sz = _mm_load_sd(xyz_shift+2); - szx = _mm_shuffle_pd(sz,sxy,_MM_SHUFFLE2(0,0)); - syz = _mm_shuffle_pd(sxy,sz,_MM_SHUFFLE2(0,1)); - - t1 = _mm_add_pd(t1,sxy); - t2 = _mm_add_pd(t2,szx); - t3 = _mm_add_pd(t3,syz); - t4 = _mm_add_pd(t4,sxy); - t5 = _mm_add_pd(t5,szx); - t6 = _mm_add_pd(t6,syz); - - *x1 = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(0,0)); - *y1 = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(1,1)); - *z1 = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(0,0)); - *x2 = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(1,1)); - *y2 = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(0,0)); - *z2 = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(1,1)); - *x3 = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(0,0)); - *y3 = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(1,1)); - *z3 = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(0,0)); - *x4 = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(1,1)); - *y4 = _mm_shuffle_pd(t6,t6,_MM_SHUFFLE2(0,0)); - *z4 = _mm_shuffle_pd(t6,t6,_MM_SHUFFLE2(1,1)); + szx = _mm_shuffle_pd(sz, sxy, _MM_SHUFFLE2(0, 0)); + syz = _mm_shuffle_pd(sxy, sz, _MM_SHUFFLE2(0, 1)); + + t1 = _mm_add_pd(t1, sxy); + t2 = _mm_add_pd(t2, szx); + t3 = _mm_add_pd(t3, syz); + t4 = _mm_add_pd(t4, sxy); + t5 = _mm_add_pd(t5, szx); + t6 = _mm_add_pd(t6, syz); + + *x1 = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(0, 0)); + *y1 = _mm_shuffle_pd(t1, t1, _MM_SHUFFLE2(1, 1)); + *z1 = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(0, 0)); + *x2 = _mm_shuffle_pd(t2, t2, _MM_SHUFFLE2(1, 1)); + *y2 = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(0, 0)); + *z2 = _mm_shuffle_pd(t3, t3, _MM_SHUFFLE2(1, 1)); + *x3 = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(0, 0)); + *y3 = _mm_shuffle_pd(t4, t4, _MM_SHUFFLE2(1, 1)); + *z3 = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(0, 0)); + *x4 = _mm_shuffle_pd(t5, t5, _MM_SHUFFLE2(1, 1)); + *y4 = _mm_shuffle_pd(t6, t6, _MM_SHUFFLE2(0, 0)); + *z4 = _mm_shuffle_pd(t6, t6, _MM_SHUFFLE2(1, 1)); } @@ -296,15 +296,15 @@ gmx_mm_load_1rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB, __m128d * gmx_restrict x1, __m128d * gmx_restrict y1, __m128d * gmx_restrict z1) { - __m128d t1,t2,t3,t4; + __m128d t1, t2, t3, t4; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrB); t3 = _mm_load_sd(ptrA+2); t4 = _mm_load_sd(ptrB+2); - GMX_MM_TRANSPOSE2_PD(t1,t2); + GMX_MM_TRANSPOSE2_PD(t1, t2); *x1 = t1; *y1 = t2; - *z1 = _mm_unpacklo_pd(t3,t4); + *z1 = _mm_unpacklo_pd(t3, t4); } @@ -314,7 +314,7 @@ gmx_mm_load_3rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double __m128d * gmx_restrict x2, __m128d * gmx_restrict y2, __m128d * gmx_restrict z2, __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3) { - __m128d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; + __m128d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrB); t3 = _mm_loadu_pd(ptrA+2); @@ -325,10 +325,10 @@ gmx_mm_load_3rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double t8 = _mm_loadu_pd(ptrB+6); t9 = _mm_load_sd(ptrA+8); t10 = _mm_load_sd(ptrB+8); - GMX_MM_TRANSPOSE2_PD(t1,t2); - GMX_MM_TRANSPOSE2_PD(t3,t4); - GMX_MM_TRANSPOSE2_PD(t5,t6); - GMX_MM_TRANSPOSE2_PD(t7,t8); + GMX_MM_TRANSPOSE2_PD(t1, t2); + GMX_MM_TRANSPOSE2_PD(t3, t4); + GMX_MM_TRANSPOSE2_PD(t5, t6); + GMX_MM_TRANSPOSE2_PD(t7, t8); *x1 = t1; *y1 = t2; *z1 = t3; @@ -337,7 +337,7 @@ gmx_mm_load_3rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double *z2 = t6; *x3 = t7; *y3 = t8; - *z3 = _mm_unpacklo_pd(t9,t10); + *z3 = _mm_unpacklo_pd(t9, t10); } @@ -348,16 +348,16 @@ gmx_mm_load_4rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double __m128d * gmx_restrict x3, __m128d * gmx_restrict y3, __m128d * gmx_restrict z3, __m128d * gmx_restrict x4, __m128d * gmx_restrict y4, __m128d * gmx_restrict z4) { - __m128d t1,t2,t3,t4,t5,t6; + __m128d t1, t2, t3, t4, t5, t6; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrB); t3 = _mm_loadu_pd(ptrA+2); t4 = _mm_loadu_pd(ptrB+2); t5 = _mm_loadu_pd(ptrA+4); t6 = _mm_loadu_pd(ptrB+4); - GMX_MM_TRANSPOSE2_PD(t1,t2); - GMX_MM_TRANSPOSE2_PD(t3,t4); - GMX_MM_TRANSPOSE2_PD(t5,t6); + GMX_MM_TRANSPOSE2_PD(t1, t2); + GMX_MM_TRANSPOSE2_PD(t3, t4); + GMX_MM_TRANSPOSE2_PD(t5, t6); *x1 = t1; *y1 = t2; *z1 = t3; @@ -370,9 +370,9 @@ gmx_mm_load_4rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double t4 = _mm_loadu_pd(ptrB+8); t5 = _mm_loadu_pd(ptrA+10); t6 = _mm_loadu_pd(ptrB+10); - GMX_MM_TRANSPOSE2_PD(t1,t2); - GMX_MM_TRANSPOSE2_PD(t3,t4); - GMX_MM_TRANSPOSE2_PD(t5,t6); + GMX_MM_TRANSPOSE2_PD(t1, t2); + GMX_MM_TRANSPOSE2_PD(t3, t4); + GMX_MM_TRANSPOSE2_PD(t5, t6); *x3 = t1; *y3 = t2; *z3 = t3; @@ -385,18 +385,18 @@ gmx_mm_load_4rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double /* Routines to decrement rvec in memory, typically use for j particle force updates */ static gmx_inline void gmx_mm_decrement_1rvec_1ptr_noswizzle_pd(double * gmx_restrict ptrA, - __m128d xy, __m128d z) + __m128d xy, __m128d z) { - __m128d t1,t2; + __m128d t1, t2; t1 = _mm_loadu_pd(ptrA); t2 = _mm_load_sd(ptrA+2); - t1 = _mm_sub_pd(t1,xy); - t2 = _mm_sub_sd(t2,z); + t1 = _mm_sub_pd(t1, xy); + t2 = _mm_sub_sd(t2, z); - _mm_storeu_pd(ptrA,t1); - _mm_store_sd(ptrA+2,t2); + _mm_storeu_pd(ptrA, t1); + _mm_store_sd(ptrA+2, t2); } @@ -404,46 +404,46 @@ static gmx_inline void gmx_mm_decrement_1rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, __m128d x1, __m128d y1, __m128d z1) { - __m128d t1,t2,t3; + __m128d t1, t2, t3; t1 = _mm_load_sd(ptrA); t2 = _mm_load_sd(ptrA+1); t3 = _mm_load_sd(ptrA+2); - t1 = _mm_sub_sd(t1,x1); - t2 = _mm_sub_sd(t2,y1); - t3 = _mm_sub_sd(t3,z1); - _mm_store_sd(ptrA,t1); - _mm_store_sd(ptrA+1,t2); - _mm_store_sd(ptrA+2,t3); + t1 = _mm_sub_sd(t1, x1); + t2 = _mm_sub_sd(t2, y1); + t3 = _mm_sub_sd(t3, z1); + _mm_store_sd(ptrA, t1); + _mm_store_sd(ptrA+1, t2); + _mm_store_sd(ptrA+2, t3); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_1ptr_swizzle_pd(ptrA,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ -__m128d _t1,_t2,_t3,_t4,_t5;\ -_t1 = _mm_loadu_pd(ptrA);\ -_t2 = _mm_loadu_pd(ptrA+2);\ -_t3 = _mm_loadu_pd(ptrA+4);\ -_t4 = _mm_loadu_pd(ptrA+6);\ -_t5 = _mm_load_sd(ptrA+8);\ -_x1 = _mm_unpacklo_pd(_x1,_y1);\ -_z1 = _mm_unpacklo_pd(_z1,_x2);\ -_y2 = _mm_unpacklo_pd(_y2,_z2);\ -_x3 = _mm_unpacklo_pd(_x3,_y3);\ -_t1 = _mm_sub_pd(_t1,_x1);\ -_t2 = _mm_sub_pd(_t2,_z1);\ -_t3 = _mm_sub_pd(_t3,_y2);\ -_t4 = _mm_sub_pd(_t4,_x3);\ -_t5 = _mm_sub_sd(_t5,_z3);\ -_mm_storeu_pd(ptrA,_t1);\ -_mm_storeu_pd(ptrA+2,_t2);\ -_mm_storeu_pd(ptrA+4,_t3);\ -_mm_storeu_pd(ptrA+6,_t4);\ -_mm_store_sd(ptrA+8,_t5);\ -} +#define gmx_mm_decrement_3rvec_1ptr_swizzle_pd(ptrA, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_load_sd(ptrA+8); \ + _x1 = _mm_unpacklo_pd(_x1, _y1); \ + _z1 = _mm_unpacklo_pd(_z1, _x2); \ + _y2 = _mm_unpacklo_pd(_y2, _z2); \ + _x3 = _mm_unpacklo_pd(_x3, _y3); \ + _t1 = _mm_sub_pd(_t1, _x1); \ + _t2 = _mm_sub_pd(_t2, _z1); \ + _t3 = _mm_sub_pd(_t3, _y2); \ + _t4 = _mm_sub_pd(_t4, _x3); \ + _t5 = _mm_sub_sd(_t5, _z3); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_store_sd(ptrA+8, _t5); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -452,7 +452,7 @@ gmx_mm_decrement_3rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, __m128d x2, __m128d y2, __m128d z2, __m128d x3, __m128d y3, __m128d z3) { - __m128d t1,t2,t3,t4,t5; + __m128d t1, t2, t3, t4, t5; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -460,50 +460,50 @@ gmx_mm_decrement_3rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, t4 = _mm_loadu_pd(ptrA+6); t5 = _mm_load_sd(ptrA+8); - x1 = _mm_unpacklo_pd(x1,y1); - z1 = _mm_unpacklo_pd(z1,x2); - y2 = _mm_unpacklo_pd(y2,z2); - x3 = _mm_unpacklo_pd(x3,y3); + x1 = _mm_unpacklo_pd(x1, y1); + z1 = _mm_unpacklo_pd(z1, x2); + y2 = _mm_unpacklo_pd(y2, z2); + x3 = _mm_unpacklo_pd(x3, y3); /* nothing to be done for z3 */ - t1 = _mm_sub_pd(t1,x1); - t2 = _mm_sub_pd(t2,z1); - t3 = _mm_sub_pd(t3,y2); - t4 = _mm_sub_pd(t4,x3); - t5 = _mm_sub_sd(t5,z3); - _mm_storeu_pd(ptrA,t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_store_sd(ptrA+8,t5); + t1 = _mm_sub_pd(t1, x1); + t2 = _mm_sub_pd(t2, z1); + t3 = _mm_sub_pd(t3, y2); + t4 = _mm_sub_pd(t4, x3); + t5 = _mm_sub_sd(t5, z3); + _mm_storeu_pd(ptrA, t1); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_store_sd(ptrA+8, t5); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_1ptr_swizzle_pd(ptrA,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ -__m128d _t1,_t2,_t3,_t4,_t5,_t6;\ -_t1 = _mm_loadu_pd(ptrA);\ -_t2 = _mm_loadu_pd(ptrA+2);\ -_t3 = _mm_loadu_pd(ptrA+4);\ -_t4 = _mm_loadu_pd(ptrA+6);\ -_t5 = _mm_loadu_pd(ptrA+8);\ -_t6 = _mm_loadu_pd(ptrA+10);\ -_x1 = _mm_unpacklo_pd(_x1,_y1);\ -_z1 = _mm_unpacklo_pd(_z1,_x2);\ -_y2 = _mm_unpacklo_pd(_y2,_z2);\ -_x3 = _mm_unpacklo_pd(_x3,_y3);\ -_z3 = _mm_unpacklo_pd(_z3,_x4);\ -_y4 = _mm_unpacklo_pd(_y4,_z4);\ -_mm_storeu_pd(ptrA, _mm_sub_pd( _t1,_x1 ));\ -_mm_storeu_pd(ptrA+2, _mm_sub_pd( _t2,_z1 ));\ -_mm_storeu_pd(ptrA+4, _mm_sub_pd( _t3,_y2 ));\ -_mm_storeu_pd(ptrA+6, _mm_sub_pd( _t4,_x3 ));\ -_mm_storeu_pd(ptrA+8, _mm_sub_pd( _t5,_z3 ));\ -_mm_storeu_pd(ptrA+10, _mm_sub_pd( _t6,_y4 ));\ -} +#define gmx_mm_decrement_4rvec_1ptr_swizzle_pd(ptrA, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_loadu_pd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrA+10); \ + _x1 = _mm_unpacklo_pd(_x1, _y1); \ + _z1 = _mm_unpacklo_pd(_z1, _x2); \ + _y2 = _mm_unpacklo_pd(_y2, _z2); \ + _x3 = _mm_unpacklo_pd(_x3, _y3); \ + _z3 = _mm_unpacklo_pd(_z3, _x4); \ + _y4 = _mm_unpacklo_pd(_y4, _z4); \ + _mm_storeu_pd(ptrA, _mm_sub_pd( _t1, _x1 )); \ + _mm_storeu_pd(ptrA+2, _mm_sub_pd( _t2, _z1 )); \ + _mm_storeu_pd(ptrA+4, _mm_sub_pd( _t3, _y2 )); \ + _mm_storeu_pd(ptrA+6, _mm_sub_pd( _t4, _x3 )); \ + _mm_storeu_pd(ptrA+8, _mm_sub_pd( _t5, _z3 )); \ + _mm_storeu_pd(ptrA+10, _mm_sub_pd( _t6, _y4 )); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -513,7 +513,7 @@ gmx_mm_decrement_4rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, __m128d x3, __m128d y3, __m128d z3, __m128d x4, __m128d y4, __m128d z4) { - __m128d t1,t2,t3,t4,t5,t6; + __m128d t1, t2, t3, t4, t5, t6; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -522,19 +522,19 @@ gmx_mm_decrement_4rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA, t5 = _mm_loadu_pd(ptrA+8); t6 = _mm_loadu_pd(ptrA+10); - x1 = _mm_unpacklo_pd(x1,y1); - z1 = _mm_unpacklo_pd(z1,x2); - y2 = _mm_unpacklo_pd(y2,z2); - x3 = _mm_unpacklo_pd(x3,y3); - z3 = _mm_unpacklo_pd(z3,x4); - y4 = _mm_unpacklo_pd(y4,z4); - - _mm_storeu_pd(ptrA, _mm_sub_pd( t1,x1 )); - _mm_storeu_pd(ptrA+2, _mm_sub_pd( t2,z1 )); - _mm_storeu_pd(ptrA+4, _mm_sub_pd( t3,y2 )); - _mm_storeu_pd(ptrA+6, _mm_sub_pd( t4,x3 )); - _mm_storeu_pd(ptrA+8, _mm_sub_pd( t5,z3 )); - _mm_storeu_pd(ptrA+10, _mm_sub_pd( t6,y4 )); + x1 = _mm_unpacklo_pd(x1, y1); + z1 = _mm_unpacklo_pd(z1, x2); + y2 = _mm_unpacklo_pd(y2, z2); + x3 = _mm_unpacklo_pd(x3, y3); + z3 = _mm_unpacklo_pd(z3, x4); + y4 = _mm_unpacklo_pd(y4, z4); + + _mm_storeu_pd(ptrA, _mm_sub_pd( t1, x1 )); + _mm_storeu_pd(ptrA+2, _mm_sub_pd( t2, z1 )); + _mm_storeu_pd(ptrA+4, _mm_sub_pd( t3, y2 )); + _mm_storeu_pd(ptrA+6, _mm_sub_pd( t4, x3 )); + _mm_storeu_pd(ptrA+8, _mm_sub_pd( t5, z3 )); + _mm_storeu_pd(ptrA+10, _mm_sub_pd( t6, y4 )); } #endif @@ -543,75 +543,75 @@ static gmx_inline void gmx_mm_decrement_1rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB, __m128d x1, __m128d y1, __m128d z1) { - __m128d t1,t2,t3,t4,t5,t6,t7; + __m128d t1, t2, t3, t4, t5, t6, t7; t1 = _mm_loadu_pd(ptrA); t2 = _mm_load_sd(ptrA+2); t3 = _mm_loadu_pd(ptrB); t4 = _mm_load_sd(ptrB+2); - t5 = _mm_unpacklo_pd(x1,y1); - t6 = _mm_unpackhi_pd(x1,y1); - t7 = _mm_unpackhi_pd(z1,z1); + t5 = _mm_unpacklo_pd(x1, y1); + t6 = _mm_unpackhi_pd(x1, y1); + t7 = _mm_unpackhi_pd(z1, z1); - t1 = _mm_sub_pd(t1,t5); - t2 = _mm_sub_sd(t2,z1); + t1 = _mm_sub_pd(t1, t5); + t2 = _mm_sub_sd(t2, z1); - t3 = _mm_sub_pd(t3,t6); - t4 = _mm_sub_sd(t4,t7); + t3 = _mm_sub_pd(t3, t6); + t4 = _mm_sub_sd(t4, t7); - _mm_storeu_pd(ptrA,t1); - _mm_store_sd(ptrA+2,t2); - _mm_storeu_pd(ptrB,t3); - _mm_store_sd(ptrB+2,t4); + _mm_storeu_pd(ptrA, t1); + _mm_store_sd(ptrA+2, t2); + _mm_storeu_pd(ptrB, t3); + _mm_store_sd(ptrB+2, t4); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_2ptr_swizzle_pd(ptrA,ptrB,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ -__m128d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10;\ -__m128d _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH,_tI;\ -_t1 = _mm_loadu_pd(ptrA);\ -_t2 = _mm_loadu_pd(ptrA+2);\ -_t3 = _mm_loadu_pd(ptrA+4);\ -_t4 = _mm_loadu_pd(ptrA+6);\ -_t5 = _mm_load_sd(ptrA+8);\ -_t6 = _mm_loadu_pd(ptrB);\ -_t7 = _mm_loadu_pd(ptrB+2);\ -_t8 = _mm_loadu_pd(ptrB+4);\ -_t9 = _mm_loadu_pd(ptrB+6);\ -_t10 = _mm_load_sd(ptrB+8);\ -_tA = _mm_unpacklo_pd(_x1,_y1);\ -_tB = _mm_unpackhi_pd(_x1,_y1);\ -_tC = _mm_unpacklo_pd(_z1,_x2);\ -_tD = _mm_unpackhi_pd(_z1,_x2);\ -_tE = _mm_unpacklo_pd(_y2,_z2);\ -_tF = _mm_unpackhi_pd(_y2,_z2);\ -_tG = _mm_unpacklo_pd(_x3,_y3);\ -_tH = _mm_unpackhi_pd(_x3,_y3);\ -_tI = _mm_unpackhi_pd(_z3,_z3);\ -_t1 = _mm_sub_pd(_t1,_tA);\ -_t2 = _mm_sub_pd(_t2,_tC);\ -_t3 = _mm_sub_pd(_t3,_tE);\ -_t4 = _mm_sub_pd(_t4,_tG);\ -_t5 = _mm_sub_sd(_t5,_z3);\ -_t6 = _mm_sub_pd(_t6,_tB);\ -_t7 = _mm_sub_pd(_t7,_tD);\ -_t8 = _mm_sub_pd(_t8,_tF);\ -_t9 = _mm_sub_pd(_t9,_tH);\ -_t10 = _mm_sub_sd(_t10,_tI);\ -_mm_storeu_pd(ptrA,_t1);\ -_mm_storeu_pd(ptrA+2,_t2);\ -_mm_storeu_pd(ptrA+4,_t3);\ -_mm_storeu_pd(ptrA+6,_t4);\ -_mm_store_sd(ptrA+8,_t5);\ -_mm_storeu_pd(ptrB,_t6);\ -_mm_storeu_pd(ptrB+2,_t7);\ -_mm_storeu_pd(ptrB+4,_t8);\ -_mm_storeu_pd(ptrB+6,_t9);\ -_mm_store_sd(ptrB+8,_t10);\ -} +#define gmx_mm_decrement_3rvec_2ptr_swizzle_pd(ptrA, ptrB, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \ + __m128d _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH, _tI; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_load_sd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrB); \ + _t7 = _mm_loadu_pd(ptrB+2); \ + _t8 = _mm_loadu_pd(ptrB+4); \ + _t9 = _mm_loadu_pd(ptrB+6); \ + _t10 = _mm_load_sd(ptrB+8); \ + _tA = _mm_unpacklo_pd(_x1, _y1); \ + _tB = _mm_unpackhi_pd(_x1, _y1); \ + _tC = _mm_unpacklo_pd(_z1, _x2); \ + _tD = _mm_unpackhi_pd(_z1, _x2); \ + _tE = _mm_unpacklo_pd(_y2, _z2); \ + _tF = _mm_unpackhi_pd(_y2, _z2); \ + _tG = _mm_unpacklo_pd(_x3, _y3); \ + _tH = _mm_unpackhi_pd(_x3, _y3); \ + _tI = _mm_unpackhi_pd(_z3, _z3); \ + _t1 = _mm_sub_pd(_t1, _tA); \ + _t2 = _mm_sub_pd(_t2, _tC); \ + _t3 = _mm_sub_pd(_t3, _tE); \ + _t4 = _mm_sub_pd(_t4, _tG); \ + _t5 = _mm_sub_sd(_t5, _z3); \ + _t6 = _mm_sub_pd(_t6, _tB); \ + _t7 = _mm_sub_pd(_t7, _tD); \ + _t8 = _mm_sub_pd(_t8, _tF); \ + _t9 = _mm_sub_pd(_t9, _tH); \ + _t10 = _mm_sub_sd(_t10, _tI); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_store_sd(ptrA+8, _t5); \ + _mm_storeu_pd(ptrB, _t6); \ + _mm_storeu_pd(ptrB+2, _t7); \ + _mm_storeu_pd(ptrB+4, _t8); \ + _mm_storeu_pd(ptrB+6, _t9); \ + _mm_store_sd(ptrB+8, _t10); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -620,8 +620,8 @@ gmx_mm_decrement_3rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ __m128d x2, __m128d y2, __m128d z2, __m128d x3, __m128d y3, __m128d z3) { - __m128d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; - __m128d tA,tB,tC,tD,tE,tF,tG,tH,tI; + __m128d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; + __m128d tA, tB, tC, tD, tE, tF, tG, tH, tI; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -634,97 +634,97 @@ gmx_mm_decrement_3rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ t9 = _mm_loadu_pd(ptrB+6); t10 = _mm_load_sd(ptrB+8); - tA = _mm_unpacklo_pd(x1,y1); - tB = _mm_unpackhi_pd(x1,y1); - tC = _mm_unpacklo_pd(z1,x2); - tD = _mm_unpackhi_pd(z1,x2); - tE = _mm_unpacklo_pd(y2,z2); - tF = _mm_unpackhi_pd(y2,z2); - tG = _mm_unpacklo_pd(x3,y3); - tH = _mm_unpackhi_pd(x3,y3); - tI = _mm_unpackhi_pd(z3,z3); - - t1 = _mm_sub_pd(t1,tA); - t2 = _mm_sub_pd(t2,tC); - t3 = _mm_sub_pd(t3,tE); - t4 = _mm_sub_pd(t4,tG); - t5 = _mm_sub_sd(t5,z3); - - t6 = _mm_sub_pd(t6,tB); - t7 = _mm_sub_pd(t7,tD); - t8 = _mm_sub_pd(t8,tF); - t9 = _mm_sub_pd(t9,tH); - t10 = _mm_sub_sd(t10,tI); - - _mm_storeu_pd(ptrA,t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_store_sd(ptrA+8,t5); - _mm_storeu_pd(ptrB,t6); - _mm_storeu_pd(ptrB+2,t7); - _mm_storeu_pd(ptrB+4,t8); - _mm_storeu_pd(ptrB+6,t9); - _mm_store_sd(ptrB+8,t10); + tA = _mm_unpacklo_pd(x1, y1); + tB = _mm_unpackhi_pd(x1, y1); + tC = _mm_unpacklo_pd(z1, x2); + tD = _mm_unpackhi_pd(z1, x2); + tE = _mm_unpacklo_pd(y2, z2); + tF = _mm_unpackhi_pd(y2, z2); + tG = _mm_unpacklo_pd(x3, y3); + tH = _mm_unpackhi_pd(x3, y3); + tI = _mm_unpackhi_pd(z3, z3); + + t1 = _mm_sub_pd(t1, tA); + t2 = _mm_sub_pd(t2, tC); + t3 = _mm_sub_pd(t3, tE); + t4 = _mm_sub_pd(t4, tG); + t5 = _mm_sub_sd(t5, z3); + + t6 = _mm_sub_pd(t6, tB); + t7 = _mm_sub_pd(t7, tD); + t8 = _mm_sub_pd(t8, tF); + t9 = _mm_sub_pd(t9, tH); + t10 = _mm_sub_sd(t10, tI); + + _mm_storeu_pd(ptrA, t1); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_store_sd(ptrA+8, t5); + _mm_storeu_pd(ptrB, t6); + _mm_storeu_pd(ptrB+2, t7); + _mm_storeu_pd(ptrB+4, t8); + _mm_storeu_pd(ptrB+6, t9); + _mm_store_sd(ptrB+8, t10); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_2ptr_swizzle_pd(ptrA,ptrB,_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ -__m128d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11,_t12;\ -__m128d _tA,_tB,_tC,_tD,_tE,_tF,_tG,_tH,_tI,_tJ,_tK,_tL;\ -_t1 = _mm_loadu_pd(ptrA);\ -_t2 = _mm_loadu_pd(ptrA+2);\ -_t3 = _mm_loadu_pd(ptrA+4);\ -_t4 = _mm_loadu_pd(ptrA+6);\ -_t5 = _mm_loadu_pd(ptrA+8);\ -_t6 = _mm_loadu_pd(ptrA+10);\ -_t7 = _mm_loadu_pd(ptrB);\ -_t8 = _mm_loadu_pd(ptrB+2);\ -_t9 = _mm_loadu_pd(ptrB+4);\ -_t10 = _mm_loadu_pd(ptrB+6);\ -_t11 = _mm_loadu_pd(ptrB+8);\ -_t12 = _mm_loadu_pd(ptrB+10);\ -_tA = _mm_unpacklo_pd(_x1,_y1);\ -_tB = _mm_unpackhi_pd(_x1,_y1);\ -_tC = _mm_unpacklo_pd(_z1,_x2);\ -_tD = _mm_unpackhi_pd(_z1,_x2);\ -_tE = _mm_unpacklo_pd(_y2,_z2);\ -_tF = _mm_unpackhi_pd(_y2,_z2);\ -_tG = _mm_unpacklo_pd(_x3,_y3);\ -_tH = _mm_unpackhi_pd(_x3,_y3);\ -_tI = _mm_unpacklo_pd(_z3,_x4);\ -_tJ = _mm_unpackhi_pd(_z3,_x4);\ -_tK = _mm_unpacklo_pd(_y4,_z4);\ -_tL = _mm_unpackhi_pd(_y4,_z4);\ -_t1 = _mm_sub_pd(_t1,_tA);\ -_t2 = _mm_sub_pd(_t2,_tC);\ -_t3 = _mm_sub_pd(_t3,_tE);\ -_t4 = _mm_sub_pd(_t4,_tG);\ -_t5 = _mm_sub_pd(_t5,_tI);\ -_t6 = _mm_sub_pd(_t6,_tK);\ -_t7 = _mm_sub_pd(_t7,_tB);\ -_t8 = _mm_sub_pd(_t8,_tD);\ -_t9 = _mm_sub_pd(_t9,_tF);\ -_t10 = _mm_sub_pd(_t10,_tH);\ -_t11 = _mm_sub_pd(_t11,_tJ);\ -_t12 = _mm_sub_pd(_t12,_tL);\ -_mm_storeu_pd(ptrA, _t1);\ -_mm_storeu_pd(ptrA+2,_t2);\ -_mm_storeu_pd(ptrA+4,_t3);\ -_mm_storeu_pd(ptrA+6,_t4);\ -_mm_storeu_pd(ptrA+8,_t5);\ -_mm_storeu_pd(ptrA+10,_t6);\ -_mm_storeu_pd(ptrB, _t7);\ -_mm_storeu_pd(ptrB+2,_t8);\ -_mm_storeu_pd(ptrB+4,_t9);\ -_mm_storeu_pd(ptrB+6,_t10);\ -_mm_storeu_pd(ptrB+8,_t11);\ -_mm_storeu_pd(ptrB+10,_t12);\ -} +#define gmx_mm_decrement_4rvec_2ptr_swizzle_pd(ptrA, ptrB, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128d _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11, _t12; \ + __m128d _tA, _tB, _tC, _tD, _tE, _tF, _tG, _tH, _tI, _tJ, _tK, _tL; \ + _t1 = _mm_loadu_pd(ptrA); \ + _t2 = _mm_loadu_pd(ptrA+2); \ + _t3 = _mm_loadu_pd(ptrA+4); \ + _t4 = _mm_loadu_pd(ptrA+6); \ + _t5 = _mm_loadu_pd(ptrA+8); \ + _t6 = _mm_loadu_pd(ptrA+10); \ + _t7 = _mm_loadu_pd(ptrB); \ + _t8 = _mm_loadu_pd(ptrB+2); \ + _t9 = _mm_loadu_pd(ptrB+4); \ + _t10 = _mm_loadu_pd(ptrB+6); \ + _t11 = _mm_loadu_pd(ptrB+8); \ + _t12 = _mm_loadu_pd(ptrB+10); \ + _tA = _mm_unpacklo_pd(_x1, _y1); \ + _tB = _mm_unpackhi_pd(_x1, _y1); \ + _tC = _mm_unpacklo_pd(_z1, _x2); \ + _tD = _mm_unpackhi_pd(_z1, _x2); \ + _tE = _mm_unpacklo_pd(_y2, _z2); \ + _tF = _mm_unpackhi_pd(_y2, _z2); \ + _tG = _mm_unpacklo_pd(_x3, _y3); \ + _tH = _mm_unpackhi_pd(_x3, _y3); \ + _tI = _mm_unpacklo_pd(_z3, _x4); \ + _tJ = _mm_unpackhi_pd(_z3, _x4); \ + _tK = _mm_unpacklo_pd(_y4, _z4); \ + _tL = _mm_unpackhi_pd(_y4, _z4); \ + _t1 = _mm_sub_pd(_t1, _tA); \ + _t2 = _mm_sub_pd(_t2, _tC); \ + _t3 = _mm_sub_pd(_t3, _tE); \ + _t4 = _mm_sub_pd(_t4, _tG); \ + _t5 = _mm_sub_pd(_t5, _tI); \ + _t6 = _mm_sub_pd(_t6, _tK); \ + _t7 = _mm_sub_pd(_t7, _tB); \ + _t8 = _mm_sub_pd(_t8, _tD); \ + _t9 = _mm_sub_pd(_t9, _tF); \ + _t10 = _mm_sub_pd(_t10, _tH); \ + _t11 = _mm_sub_pd(_t11, _tJ); \ + _t12 = _mm_sub_pd(_t12, _tL); \ + _mm_storeu_pd(ptrA, _t1); \ + _mm_storeu_pd(ptrA+2, _t2); \ + _mm_storeu_pd(ptrA+4, _t3); \ + _mm_storeu_pd(ptrA+6, _t4); \ + _mm_storeu_pd(ptrA+8, _t5); \ + _mm_storeu_pd(ptrA+10, _t6); \ + _mm_storeu_pd(ptrB, _t7); \ + _mm_storeu_pd(ptrB+2, _t8); \ + _mm_storeu_pd(ptrB+4, _t9); \ + _mm_storeu_pd(ptrB+6, _t10); \ + _mm_storeu_pd(ptrB+8, _t11); \ + _mm_storeu_pd(ptrB+10, _t12); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -734,8 +734,8 @@ gmx_mm_decrement_4rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ __m128d x3, __m128d y3, __m128d z3, __m128d x4, __m128d y4, __m128d z4) { - __m128d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - __m128d tA,tB,tC,tD,tE,tF,tG,tH,tI,tJ,tK,tL; + __m128d t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + __m128d tA, tB, tC, tD, tE, tF, tG, tH, tI, tJ, tK, tL; t1 = _mm_loadu_pd(ptrA); t2 = _mm_loadu_pd(ptrA+2); @@ -750,45 +750,45 @@ gmx_mm_decrement_4rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_ t11 = _mm_loadu_pd(ptrB+8); t12 = _mm_loadu_pd(ptrB+10); - tA = _mm_unpacklo_pd(x1,y1); - tB = _mm_unpackhi_pd(x1,y1); - tC = _mm_unpacklo_pd(z1,x2); - tD = _mm_unpackhi_pd(z1,x2); - tE = _mm_unpacklo_pd(y2,z2); - tF = _mm_unpackhi_pd(y2,z2); - tG = _mm_unpacklo_pd(x3,y3); - tH = _mm_unpackhi_pd(x3,y3); - tI = _mm_unpacklo_pd(z3,x4); - tJ = _mm_unpackhi_pd(z3,x4); - tK = _mm_unpacklo_pd(y4,z4); - tL = _mm_unpackhi_pd(y4,z4); - - t1 = _mm_sub_pd(t1,tA); - t2 = _mm_sub_pd(t2,tC); - t3 = _mm_sub_pd(t3,tE); - t4 = _mm_sub_pd(t4,tG); - t5 = _mm_sub_pd(t5,tI); - t6 = _mm_sub_pd(t6,tK); - - t7 = _mm_sub_pd(t7,tB); - t8 = _mm_sub_pd(t8,tD); - t9 = _mm_sub_pd(t9,tF); - t10 = _mm_sub_pd(t10,tH); - t11 = _mm_sub_pd(t11,tJ); - t12 = _mm_sub_pd(t12,tL); + tA = _mm_unpacklo_pd(x1, y1); + tB = _mm_unpackhi_pd(x1, y1); + tC = _mm_unpacklo_pd(z1, x2); + tD = _mm_unpackhi_pd(z1, x2); + tE = _mm_unpacklo_pd(y2, z2); + tF = _mm_unpackhi_pd(y2, z2); + tG = _mm_unpacklo_pd(x3, y3); + tH = _mm_unpackhi_pd(x3, y3); + tI = _mm_unpacklo_pd(z3, x4); + tJ = _mm_unpackhi_pd(z3, x4); + tK = _mm_unpacklo_pd(y4, z4); + tL = _mm_unpackhi_pd(y4, z4); + + t1 = _mm_sub_pd(t1, tA); + t2 = _mm_sub_pd(t2, tC); + t3 = _mm_sub_pd(t3, tE); + t4 = _mm_sub_pd(t4, tG); + t5 = _mm_sub_pd(t5, tI); + t6 = _mm_sub_pd(t6, tK); + + t7 = _mm_sub_pd(t7, tB); + t8 = _mm_sub_pd(t8, tD); + t9 = _mm_sub_pd(t9, tF); + t10 = _mm_sub_pd(t10, tH); + t11 = _mm_sub_pd(t11, tJ); + t12 = _mm_sub_pd(t12, tL); _mm_storeu_pd(ptrA, t1); - _mm_storeu_pd(ptrA+2,t2); - _mm_storeu_pd(ptrA+4,t3); - _mm_storeu_pd(ptrA+6,t4); - _mm_storeu_pd(ptrA+8,t5); - _mm_storeu_pd(ptrA+10,t6); + _mm_storeu_pd(ptrA+2, t2); + _mm_storeu_pd(ptrA+4, t3); + _mm_storeu_pd(ptrA+6, t4); + _mm_storeu_pd(ptrA+8, t5); + _mm_storeu_pd(ptrA+10, t6); _mm_storeu_pd(ptrB, t7); - _mm_storeu_pd(ptrB+2,t8); - _mm_storeu_pd(ptrB+4,t9); - _mm_storeu_pd(ptrB+6,t10); - _mm_storeu_pd(ptrB+8,t11); - _mm_storeu_pd(ptrB+10,t12); + _mm_storeu_pd(ptrB+2, t8); + _mm_storeu_pd(ptrB+4, t9); + _mm_storeu_pd(ptrB+6, t10); + _mm_storeu_pd(ptrB+8, t11); + _mm_storeu_pd(ptrB+10, t12); } #endif @@ -800,8 +800,8 @@ gmx_mm_update_iforce_1atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - fix1 = _mm_hadd_pd(fix1,fiy1); - fiz1 = _mm_hadd_pd(fiz1,fiz1); + fix1 = _mm_hadd_pd(fix1, fiy1); + fiz1 = _mm_hadd_pd(fiz1, fiz1); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_store_sd( fptr+2, _mm_add_sd( _mm_load_sd(fptr+2), fiz1 )); @@ -813,29 +813,29 @@ gmx_mm_update_iforce_1atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \ - fptr,fshiftptr) \ -{\ - __m128d _t1,_t2;\ - fix1 = _mm_hadd_pd(fix1,fiy1);\ - fiz1 = _mm_hadd_pd(fiz1,fix2);\ - fiy2 = _mm_hadd_pd(fiy2,fiz2);\ - fix3 = _mm_hadd_pd(fix3,fiy3);\ - fiz3 = _mm_hadd_pd(fiz3,fiz3);\ - _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 ));\ - _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 ));\ - _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 ));\ - _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 ));\ - _mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 ));\ - fix1 = _mm_add_pd(fix1,fix3);\ - _t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1));\ - fix1 = _mm_add_pd(fix1,_t1);\ - _t2 = _mm_shuffle_pd(fiy2,fiy2,_MM_SHUFFLE2(1,1));\ - fiz1 = _mm_add_sd(fiz1,fiz3);\ - fiz1 = _mm_add_sd(fiz1,_t2);\ - _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 ));\ - _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 ));\ -} +#define gmx_mm_update_iforce_3atom_swizzle_pd(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \ + fptr, fshiftptr) \ + { \ + __m128d _t1, _t2; \ + fix1 = _mm_hadd_pd(fix1, fiy1); \ + fiz1 = _mm_hadd_pd(fiz1, fix2); \ + fiy2 = _mm_hadd_pd(fiy2, fiz2); \ + fix3 = _mm_hadd_pd(fix3, fiy3); \ + fiz3 = _mm_hadd_pd(fiz3, fiz3); \ + _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); \ + _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); \ + _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 )); \ + _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); \ + _mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 )); \ + fix1 = _mm_add_pd(fix1, fix3); \ + _t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); \ + fix1 = _mm_add_pd(fix1, _t1); \ + _t2 = _mm_shuffle_pd(fiy2, fiy2, _MM_SHUFFLE2(1, 1)); \ + fiz1 = _mm_add_sd(fiz1, fiz3); \ + fiz1 = _mm_add_sd(fiz1, _t2); \ + _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); \ + _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -845,13 +845,13 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - __m128d t1,t2; + __m128d t1, t2; - fix1 = _mm_hadd_pd(fix1,fiy1); - fiz1 = _mm_hadd_pd(fiz1,fix2); - fiy2 = _mm_hadd_pd(fiy2,fiz2); - fix3 = _mm_hadd_pd(fix3,fiy3); - fiz3 = _mm_hadd_pd(fiz3,fiz3); + fix1 = _mm_hadd_pd(fix1, fiy1); + fiz1 = _mm_hadd_pd(fiz1, fix2); + fiy2 = _mm_hadd_pd(fiy2, fiz2); + fix3 = _mm_hadd_pd(fix3, fiy3); + fiz3 = _mm_hadd_pd(fiz3, fiz3); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); @@ -859,13 +859,13 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); _mm_store_sd( fptr+8, _mm_add_sd( _mm_load_sd(fptr+8), fiz3 )); - fix1 = _mm_add_pd(fix1,fix3); - t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1)); - fix1 = _mm_add_pd(fix1,t1); /* x and y sums */ + fix1 = _mm_add_pd(fix1, fix3); + t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); + fix1 = _mm_add_pd(fix1, t1); /* x and y sums */ - t2 = _mm_shuffle_pd(fiy2,fiy2,_MM_SHUFFLE2(1,1)); - fiz1 = _mm_add_sd(fiz1,fiz3); - fiz1 = _mm_add_sd(fiz1,t2); /* z sum */ + t2 = _mm_shuffle_pd(fiy2, fiy2, _MM_SHUFFLE2(1, 1)); + fiz1 = _mm_add_sd(fiz1, fiz3); + fiz1 = _mm_add_sd(fiz1, t2); /* z sum */ _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); @@ -874,33 +874,33 @@ gmx_mm_update_iforce_3atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_4atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \ - fptr,fshiftptr) \ -{\ - __m128d _t1,_t2;\ - fix1 = _mm_hadd_pd(fix1,fiy1);\ - fiz1 = _mm_hadd_pd(fiz1,fix2);\ - fiy2 = _mm_hadd_pd(fiy2,fiz2);\ - fix3 = _mm_hadd_pd(fix3,fiy3);\ - fiz3 = _mm_hadd_pd(fiz3,fix4);\ - fiy4 = _mm_hadd_pd(fiy4,fiz4);\ - _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 ));\ - _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 ));\ - _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 ));\ - _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 ));\ - _mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 ));\ - _mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 ));\ - _t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1));\ - fix1 = _mm_add_pd(fix1,_t1);\ - _t2 = _mm_shuffle_pd(fiz3,fiy4,_MM_SHUFFLE2(0,1));\ - fix3 = _mm_add_pd(fix3,_t2);\ - fix1 = _mm_add_pd(fix1,fix3);\ - fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2,fiy2));\ - fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4,fiy4));\ - fiz1 = _mm_add_sd(fiz1,fiz3);\ - _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 ));\ - _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 ));\ -} +#define gmx_mm_update_iforce_4atom_swizzle_pd(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \ + fptr, fshiftptr) \ + { \ + __m128d _t1, _t2; \ + fix1 = _mm_hadd_pd(fix1, fiy1); \ + fiz1 = _mm_hadd_pd(fiz1, fix2); \ + fiy2 = _mm_hadd_pd(fiy2, fiz2); \ + fix3 = _mm_hadd_pd(fix3, fiy3); \ + fiz3 = _mm_hadd_pd(fiz3, fix4); \ + fiy4 = _mm_hadd_pd(fiy4, fiz4); \ + _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); \ + _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); \ + _mm_storeu_pd( fptr+4, _mm_add_pd( _mm_loadu_pd(fptr+4), fiy2 )); \ + _mm_storeu_pd( fptr+6, _mm_add_pd( _mm_loadu_pd(fptr+6), fix3 )); \ + _mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 )); \ + _mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 )); \ + _t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); \ + fix1 = _mm_add_pd(fix1, _t1); \ + _t2 = _mm_shuffle_pd(fiz3, fiy4, _MM_SHUFFLE2(0, 1)); \ + fix3 = _mm_add_pd(fix3, _t2); \ + fix1 = _mm_add_pd(fix1, fix3); \ + fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2, fiy2)); \ + fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4, fiy4)); \ + fiz1 = _mm_add_sd(fiz1, fiz3); \ + _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); \ + _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -911,14 +911,14 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, double * gmx_restrict fptr, double * gmx_restrict fshiftptr) { - __m128d t1,t2; + __m128d t1, t2; - fix1 = _mm_hadd_pd(fix1,fiy1); - fiz1 = _mm_hadd_pd(fiz1,fix2); - fiy2 = _mm_hadd_pd(fiy2,fiz2); - fix3 = _mm_hadd_pd(fix3,fiy3); - fiz3 = _mm_hadd_pd(fiz3,fix4); - fiy4 = _mm_hadd_pd(fiy4,fiz4); + fix1 = _mm_hadd_pd(fix1, fiy1); + fiz1 = _mm_hadd_pd(fiz1, fix2); + fiy2 = _mm_hadd_pd(fiy2, fiz2); + fix3 = _mm_hadd_pd(fix3, fiy3); + fiz3 = _mm_hadd_pd(fiz3, fix4); + fiy4 = _mm_hadd_pd(fiy4, fiz4); _mm_storeu_pd( fptr, _mm_add_pd( _mm_loadu_pd(fptr), fix1 )); _mm_storeu_pd( fptr+2, _mm_add_pd( _mm_loadu_pd(fptr+2), fiz1 )); @@ -927,15 +927,15 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, _mm_storeu_pd( fptr+8, _mm_add_pd( _mm_loadu_pd(fptr+8), fiz3 )); _mm_storeu_pd( fptr+10, _mm_add_pd( _mm_loadu_pd(fptr+10), fiy4 )); - t1 = _mm_shuffle_pd(fiz1,fiy2,_MM_SHUFFLE2(0,1)); - fix1 = _mm_add_pd(fix1,t1); - t2 = _mm_shuffle_pd(fiz3,fiy4,_MM_SHUFFLE2(0,1)); - fix3 = _mm_add_pd(fix3,t2); - fix1 = _mm_add_pd(fix1,fix3); /* x and y sums */ + t1 = _mm_shuffle_pd(fiz1, fiy2, _MM_SHUFFLE2(0, 1)); + fix1 = _mm_add_pd(fix1, t1); + t2 = _mm_shuffle_pd(fiz3, fiy4, _MM_SHUFFLE2(0, 1)); + fix3 = _mm_add_pd(fix3, t2); + fix1 = _mm_add_pd(fix1, fix3); /* x and y sums */ - fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2,fiy2)); - fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4,fiy4)); - fiz1 = _mm_add_sd(fiz1,fiz3); /* z sum */ + fiz1 = _mm_add_sd(fiz1, _mm_unpackhi_pd(fiy2, fiy2)); + fiz3 = _mm_add_sd(fiz3, _mm_unpackhi_pd(fiy4, fiy4)); + fiz1 = _mm_add_sd(fiz1, fiz3); /* z sum */ _mm_storeu_pd( fshiftptr, _mm_add_pd( _mm_loadu_pd(fshiftptr), fix1 )); _mm_store_sd( fshiftptr+2, _mm_add_sd( _mm_load_sd(fshiftptr+2), fiz1 )); @@ -945,19 +945,19 @@ gmx_mm_update_iforce_4atom_swizzle_pd(__m128d fix1, __m128d fiy1, __m128d fiz1, static gmx_inline void gmx_mm_update_1pot_pd(__m128d pot1, double * gmx_restrict ptrA) { - pot1 = _mm_hadd_pd(pot1,pot1); - _mm_store_sd(ptrA,_mm_add_sd(pot1,_mm_load_sd(ptrA))); + pot1 = _mm_hadd_pd(pot1, pot1); + _mm_store_sd(ptrA, _mm_add_sd(pot1, _mm_load_sd(ptrA))); } static gmx_inline void gmx_mm_update_2pot_pd(__m128d pot1, double * gmx_restrict ptrA, __m128d pot2, double * gmx_restrict ptrB) { - pot1 = _mm_hadd_pd(pot1,pot2); - pot2 = _mm_unpackhi_pd(pot1,pot1); + pot1 = _mm_hadd_pd(pot1, pot2); + pot2 = _mm_unpackhi_pd(pot1, pot1); - _mm_store_sd(ptrA,_mm_add_sd(pot1,_mm_load_sd(ptrA))); - _mm_store_sd(ptrB,_mm_add_sd(pot2,_mm_load_sd(ptrB))); + _mm_store_sd(ptrA, _mm_add_sd(pot1, _mm_load_sd(ptrA))); + _mm_store_sd(ptrB, _mm_add_sd(pot2, _mm_load_sd(ptrB))); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.c index cf5b908609..8d02013eb8 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.c @@ -241,7 +241,7 @@ nb_kernel_t nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_sse4_1_double; nb_kernel_info_t -kernellist_sse4_1_double[] = + kernellist_sse4_1_double[] = { { nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse4_1_double, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse4_1_double", "sse4_1_double", "None", "None", "LennardJones", "None", "ParticleParticle", "", "PotentialAndForce" }, { nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse4_1_double, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse4_1_double", "sse4_1_double", "None", "None", "LennardJones", "None", "ParticleParticle", "", "Force" }, @@ -460,6 +460,6 @@ kernellist_sse4_1_double[] = }; int -kernellist_sse4_1_double_size = sizeof(kernellist_sse4_1_double)/sizeof(kernellist_sse4_1_double[0]); + kernellist_sse4_1_double_size = sizeof(kernellist_sse4_1_double)/sizeof(kernellist_sse4_1_double[0]); #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.h index fa28b477aa..a8e8bf071a 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_double/nb_kernel_sse4_1_double.h @@ -27,10 +27,10 @@ /* List of kernels for this architecture with metadata about them */ extern nb_kernel_info_t -kernellist_sse4_1_double[]; + kernellist_sse4_1_double[]; /* Length of kernellist_c */ extern int -kernellist_sse4_1_double_size; + kernellist_sse4_1_double_size; #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/kernelutil_x86_sse4_1_single.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/kernelutil_x86_sse4_1_single.h index 0f19ea8bfb..689b1f79c6 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/kernelutil_x86_sse4_1_single.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/kernelutil_x86_sse4_1_single.h @@ -9,16 +9,16 @@ * written by Erik Lindahl, David van der Spoel, Berk Hess, and others - for * a full list of developers and information, check out http://www.gromacs.org * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) any + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) any * later version. * As a special exception, you may use this file as part of a free software * library without restriction. Specifically, if other files instantiate * templates or use macros or inline functions from this file, or you compile * this file and link it with other files to produce an executable, this * file does not by itself cause the resulting executable to be covered by - * the GNU Lesser General Public License. + * the GNU Lesser General Public License. * * In plain-speak: do not worry about classes/macros/templates either - only * changes to the library have to be LGPL, not an application linking with it. @@ -37,18 +37,18 @@ #define gmx_restrict /* Normal sum of four xmm registers */ -#define gmx_mm_sum4_ps(t0,t1,t2,t3) _mm_add_ps(_mm_add_ps(t0,t1),_mm_add_ps(t2,t3)) +#define gmx_mm_sum4_ps(t0, t1, t2, t3) _mm_add_ps(_mm_add_ps(t0, t1), _mm_add_ps(t2, t3)) static gmx_inline __m128 gmx_mm_calc_rsq_ps(__m128 dx, __m128 dy, __m128 dz) { - return _mm_add_ps( _mm_add_ps( _mm_mul_ps(dx,dx), _mm_mul_ps(dy,dy) ), _mm_mul_ps(dz,dz) ); + return _mm_add_ps( _mm_add_ps( _mm_mul_ps(dx, dx), _mm_mul_ps(dy, dy) ), _mm_mul_ps(dz, dz) ); } static gmx_inline int gmx_mm_any_lt(__m128 a, __m128 b) { - return _mm_movemask_ps(_mm_cmplt_ps(a,b)); + return _mm_movemask_ps(_mm_cmplt_ps(a, b)); } /* Load a single value from 1-4 places, merge into xmm register */ @@ -59,11 +59,11 @@ gmx_mm_load_4real_swizzle_ps(const float * gmx_restrict ptrA, const float * gmx_restrict ptrC, const float * gmx_restrict ptrD) { - __m128 t1,t2; + __m128 t1, t2; - t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA),_mm_load_ss(ptrC)); - t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB),_mm_load_ss(ptrD)); - return _mm_unpacklo_ps(t1,t2); + t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA), _mm_load_ss(ptrC)); + t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB), _mm_load_ss(ptrD)); + return _mm_unpacklo_ps(t1, t2); } static gmx_inline void @@ -71,17 +71,17 @@ gmx_mm_store_4real_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB, float * gmx_restrict ptrC, float * gmx_restrict ptrD, - __m128 xmm1) + __m128 xmm1) { - __m128 t2,t3,t4; - - t3 = _mm_movehl_ps(_mm_setzero_ps(),xmm1); - t2 = _mm_shuffle_ps(xmm1,xmm1,_MM_SHUFFLE(1,1,1,1)); - t4 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(1,1,1,1)); - _mm_store_ss(ptrA,xmm1); - _mm_store_ss(ptrB,t2); - _mm_store_ss(ptrC,t3); - _mm_store_ss(ptrD,t4); + __m128 t2, t3, t4; + + t3 = _mm_movehl_ps(_mm_setzero_ps(), xmm1); + t2 = _mm_shuffle_ps(xmm1, xmm1, _MM_SHUFFLE(1, 1, 1, 1)); + t4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 1, 1, 1)); + _mm_store_ss(ptrA, xmm1); + _mm_store_ss(ptrB, t2); + _mm_store_ss(ptrC, t3); + _mm_store_ss(ptrD, t4); } /* Similar to store, but increments value in memory */ @@ -93,9 +93,9 @@ gmx_mm_increment_4real_swizzle_ps(float * gmx_restrict ptrA, { __m128 tmp; - tmp = gmx_mm_load_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD); - tmp = _mm_add_ps(tmp,xmm1); - gmx_mm_store_4real_swizzle_ps(ptrA,ptrB,ptrC,ptrD,tmp); + tmp = gmx_mm_load_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD); + tmp = _mm_add_ps(tmp, xmm1); + gmx_mm_store_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD, tmp); } @@ -104,92 +104,92 @@ gmx_mm_load_4pair_swizzle_ps(const float * gmx_restrict p1, const float * gmx_restrict p2, const float * gmx_restrict p3, const float * gmx_restrict p4, - __m128 * gmx_restrict c6, - __m128 * gmx_restrict c12) + __m128 * gmx_restrict c6, + __m128 * gmx_restrict c12) { - __m128 t1,t2,t3,t4; - - t1 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p1); /* - - c12a c6a */ - t2 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p2); /* - - c12b c6b */ - t3 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p3); /* - - c12c c6c */ - t4 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)p4); /* - - c12d c6d */ - t1 = _mm_unpacklo_ps(t1,t2); - t2 = _mm_unpacklo_ps(t3,t4); - *c6 = _mm_movelh_ps(t1,t2); - *c12 = _mm_movehl_ps(t2,t1); + __m128 t1, t2, t3, t4; + + t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p1); /* - - c12a c6a */ + t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p2); /* - - c12b c6b */ + t3 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p3); /* - - c12c c6c */ + t4 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p4); /* - - c12d c6d */ + t1 = _mm_unpacklo_ps(t1, t2); + t2 = _mm_unpacklo_ps(t3, t4); + *c6 = _mm_movelh_ps(t1, t2); + *c12 = _mm_movehl_ps(t2, t1); } static gmx_inline void gmx_mm_load_shift_and_1rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, - __m128 * gmx_restrict y1, - __m128 * gmx_restrict z1) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, + __m128 * gmx_restrict y1, + __m128 * gmx_restrict z1) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; - t1 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); - t2 = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz); + t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); + t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz); t3 = _mm_load_ss(xyz_shift+2); t4 = _mm_load_ss(xyz+2); - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ss(t3,t4); + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ss(t3, t4); - *x1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(0,0,0,0)); + *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0)); } static gmx_inline void gmx_mm_load_shift_and_3rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, - __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, - __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, + __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, + __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) { - __m128 tA,tB; - __m128 t1,t2,t3,t4,t5,t6; + __m128 tA, tB; + __m128 t1, t2, t3, t4, t5, t6; - tA = _mm_loadl_pi(_mm_setzero_ps(),(__m64 *)xyz_shift); + tA = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift); tB = _mm_load_ss(xyz_shift+2); t1 = _mm_loadu_ps(xyz); t2 = _mm_loadu_ps(xyz+4); t3 = _mm_load_ss(xyz+8); - tA = _mm_movelh_ps(tA,tB); - t4 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(0,2,1,0)); - t5 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(1,0,2,1)); - t6 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(2,1,0,2)); - - t1 = _mm_add_ps(t1,t4); - t2 = _mm_add_ps(t2,t5); - t3 = _mm_add_ss(t3,t6); - - *x1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(2,2,2,2)); - *x2 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(3,3,3,3)); - *y2 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(0,0,0,0)); - *z2 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(1,1,1,1)); - *x3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(2,2,2,2)); - *y3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(3,3,3,3)); - *z3 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(0,0,0,0)); + tA = _mm_movelh_ps(tA, tB); + t4 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(0, 2, 1, 0)); + t5 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(1, 0, 2, 1)); + t6 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(2, 1, 0, 2)); + + t1 = _mm_add_ps(t1, t4); + t2 = _mm_add_ps(t2, t5); + t3 = _mm_add_ss(t3, t6); + + *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(2, 2, 2, 2)); + *x2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 3, 3)); + *y2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 0)); + *z2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(1, 1, 1, 1)); + *x3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(2, 2, 2, 2)); + *y3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(3, 3, 3, 3)); + *z3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0)); } static gmx_inline void gmx_mm_load_shift_and_4rvec_broadcast_ps(const float * gmx_restrict xyz_shift, - const float * gmx_restrict xyz, - __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, - __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, - __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, - __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) + const float * gmx_restrict xyz, + __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1, + __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, + __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, + __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) { - __m128 tA,tB; - __m128 t1,t2,t3,t4,t5,t6; + __m128 tA, tB; + __m128 t1, t2, t3, t4, t5, t6; tA = _mm_castpd_ps(_mm_load_sd((const double *)xyz_shift)); tB = _mm_load_ss(xyz_shift+2); @@ -198,27 +198,27 @@ gmx_mm_load_shift_and_4rvec_broadcast_ps(const float * gmx_restrict xyz_shift, t2 = _mm_loadu_ps(xyz+4); t3 = _mm_loadu_ps(xyz+8); - tA = _mm_movelh_ps(tA,tB); - t4 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(0,2,1,0)); - t5 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(1,0,2,1)); - t6 = _mm_shuffle_ps(tA,tA,_MM_SHUFFLE(2,1,0,2)); - - t1 = _mm_add_ps(t1,t4); - t2 = _mm_add_ps(t2,t5); - t3 = _mm_add_ps(t3,t6); - - *x1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(0,0,0,0)); - *y1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(1,1,1,1)); - *z1 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(2,2,2,2)); - *x2 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(3,3,3,3)); - *y2 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(0,0,0,0)); - *z2 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(1,1,1,1)); - *x3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(2,2,2,2)); - *y3 = _mm_shuffle_ps(t2,t2,_MM_SHUFFLE(3,3,3,3)); - *z3 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(0,0,0,0)); - *x4 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(1,1,1,1)); - *y4 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(2,2,2,2)); - *z4 = _mm_shuffle_ps(t3,t3,_MM_SHUFFLE(3,3,3,3)); + tA = _mm_movelh_ps(tA, tB); + t4 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(0, 2, 1, 0)); + t5 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(1, 0, 2, 1)); + t6 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(2, 1, 0, 2)); + + t1 = _mm_add_ps(t1, t4); + t2 = _mm_add_ps(t2, t5); + t3 = _mm_add_ps(t3, t6); + + *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0)); + *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1)); + *z1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(2, 2, 2, 2)); + *x2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 3, 3)); + *y2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 0)); + *z2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(1, 1, 1, 1)); + *x3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(2, 2, 2, 2)); + *y3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(3, 3, 3, 3)); + *z3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0)); + *x4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 1, 1, 1)); + *y4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(2, 2, 2, 2)); + *z4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(3, 3, 3, 3)); } @@ -231,22 +231,22 @@ gmx_mm_load_1rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8; + __m128 t1, t2, t3, t4, t5, t6, t7, t8; t1 = _mm_castpd_ps(_mm_load_sd((const double *)ptrA)); t2 = _mm_castpd_ps(_mm_load_sd((const double *)ptrB)); t3 = _mm_castpd_ps(_mm_load_sd((const double *)ptrC)); t4 = _mm_castpd_ps(_mm_load_sd((const double *)ptrD)); - t5 = _mm_load_ss(ptrA+2); - t6 = _mm_load_ss(ptrB+2); - t7 = _mm_load_ss(ptrC+2); - t8 = _mm_load_ss(ptrD+2); - t1 = _mm_unpacklo_ps(t1,t2); - t3 = _mm_unpacklo_ps(t3,t4); - *x1 = _mm_movelh_ps(t1,t3); - *y1 = _mm_movehl_ps(t3,t1); - t5 = _mm_unpacklo_ps(t5,t6); - t7 = _mm_unpacklo_ps(t7,t8); - *z1 = _mm_movelh_ps(t5,t7); + t5 = _mm_load_ss(ptrA+2); + t6 = _mm_load_ss(ptrB+2); + t7 = _mm_load_ss(ptrC+2); + t8 = _mm_load_ss(ptrD+2); + t1 = _mm_unpacklo_ps(t1, t2); + t3 = _mm_unpacklo_ps(t3, t4); + *x1 = _mm_movelh_ps(t1, t3); + *y1 = _mm_movehl_ps(t3, t1); + t5 = _mm_unpacklo_ps(t5, t6); + t7 = _mm_unpacklo_ps(t7, t8); + *z1 = _mm_movelh_ps(t5, t7); } @@ -259,12 +259,12 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2, __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrA ) ); t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrB ) ); t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrC ) ); t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrD ) ); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = t1; *y1 = t2; *z1 = t3; @@ -273,7 +273,7 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+4) ) ); t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+4) ) ); t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+4) ) ); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *y2 = t1; *z2 = t2; *x3 = t3; @@ -282,9 +282,9 @@ gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, t2 = _mm_load_ss(ptrB+8); t3 = _mm_load_ss(ptrC+8); t4 = _mm_load_ss(ptrD+8); - t1 = _mm_unpacklo_ps(t1,t3); - t3 = _mm_unpacklo_ps(t2,t4); - *z3 = _mm_unpacklo_ps(t1,t3); + t1 = _mm_unpacklo_ps(t1, t3); + t3 = _mm_unpacklo_ps(t2, t4); + *z3 = _mm_unpacklo_ps(t1, t3); } @@ -298,12 +298,12 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3, __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA) ) ); t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB) ) ); t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC) ) ); t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD) ) ); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *x1 = t1; *y1 = t2; *z1 = t3; @@ -312,7 +312,7 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+4) ) ); t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+4) ) ); t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+4) ) ); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *y2 = t1; *z2 = t2; *x3 = t3; @@ -321,7 +321,7 @@ gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA, t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+8) ) ); t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+8) ) ); t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+8) ) ); - _MM_TRANSPOSE4_PS(t1,t2,t3,t4); + _MM_TRANSPOSE4_PS(t1, t2, t3, t4); *z3 = t1; *x4 = t2; *y4 = t3; @@ -337,101 +337,101 @@ gmx_mm_decrement_1rvec_4ptr_swizzle_ps(float * ptrA, float * ptrD, __m128 x1, __m128 y1, __m128 z1) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12; - t5 = _mm_unpacklo_ps(y1,z1); - t6 = _mm_unpackhi_ps(y1,z1); - t7 = _mm_shuffle_ps(x1,t5,_MM_SHUFFLE(1,0,0,0)); - t8 = _mm_shuffle_ps(x1,t5,_MM_SHUFFLE(3,2,0,1)); - t9 = _mm_shuffle_ps(x1,t6,_MM_SHUFFLE(1,0,0,2)); - t10 = _mm_shuffle_ps(x1,t6,_MM_SHUFFLE(3,2,0,3)); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12; + t5 = _mm_unpacklo_ps(y1, z1); + t6 = _mm_unpackhi_ps(y1, z1); + t7 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(1, 0, 0, 0)); + t8 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(3, 2, 0, 1)); + t9 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(1, 0, 0, 2)); + t10 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(3, 2, 0, 3)); t1 = _mm_load_ss(ptrA); - t1 = _mm_loadh_pi(t1,(__m64 *)(ptrA+1)); - t1 = _mm_sub_ps(t1,t7); - _mm_store_ss(ptrA,t1); - _mm_storeh_pi((__m64 *)(ptrA+1),t1); + t1 = _mm_loadh_pi(t1, (__m64 *)(ptrA+1)); + t1 = _mm_sub_ps(t1, t7); + _mm_store_ss(ptrA, t1); + _mm_storeh_pi((__m64 *)(ptrA+1), t1); t2 = _mm_load_ss(ptrB); - t2 = _mm_loadh_pi(t2,(__m64 *)(ptrB+1)); - t2 = _mm_sub_ps(t2,t8); - _mm_store_ss(ptrB,t2); - _mm_storeh_pi((__m64 *)(ptrB+1),t2); + t2 = _mm_loadh_pi(t2, (__m64 *)(ptrB+1)); + t2 = _mm_sub_ps(t2, t8); + _mm_store_ss(ptrB, t2); + _mm_storeh_pi((__m64 *)(ptrB+1), t2); t3 = _mm_load_ss(ptrC); - t3 = _mm_loadh_pi(t3,(__m64 *)(ptrC+1)); - t3 = _mm_sub_ps(t3,t9); - _mm_store_ss(ptrC,t3); - _mm_storeh_pi((__m64 *)(ptrC+1),t3); + t3 = _mm_loadh_pi(t3, (__m64 *)(ptrC+1)); + t3 = _mm_sub_ps(t3, t9); + _mm_store_ss(ptrC, t3); + _mm_storeh_pi((__m64 *)(ptrC+1), t3); t4 = _mm_load_ss(ptrD); - t4 = _mm_loadh_pi(t4,(__m64 *)(ptrD+1)); - t4 = _mm_sub_ps(t4,t10); - _mm_store_ss(ptrD,t4); - _mm_storeh_pi((__m64 *)(ptrD+1),t4); + t4 = _mm_loadh_pi(t4, (__m64 *)(ptrD+1)); + t4 = _mm_sub_ps(t4, t10); + _mm_store_ss(ptrD, t4); + _mm_storeh_pi((__m64 *)(ptrD+1), t4); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_3rvec_4ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD, \ -_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \ -{\ -__m128 _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10;\ -__m128 _t11,_t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19;\ -__m128 _t20,_t21,_t22,_t23,_t24,_t25;\ -_t13 = _mm_unpackhi_ps(_x1,_y1);\ -_x1 = _mm_unpacklo_ps(_x1,_y1);\ -_t14 = _mm_unpackhi_ps(_z1,_x2);\ -_z1 = _mm_unpacklo_ps(_z1,_x2);\ -_t15 = _mm_unpackhi_ps(_y2,_z2);\ -_y2 = _mm_unpacklo_ps(_y2,_z2);\ -_t16 = _mm_unpackhi_ps(_x3,_y3);\ -_x3 = _mm_unpacklo_ps(_x3,_y3);\ -_t17 = _mm_shuffle_ps(_z3,_z3,_MM_SHUFFLE(0,0,0,1));\ -_t18 = _mm_movehl_ps(_z3,_z3);\ -_t19 = _mm_shuffle_ps(_t18,_t18,_MM_SHUFFLE(0,0,0,1));\ -_t20 = _mm_movelh_ps(_x1,_z1);\ -_t21 = _mm_movehl_ps(_z1,_x1);\ -_t22 = _mm_movelh_ps(_t13,_t14);\ -_t14 = _mm_movehl_ps(_t14,_t13);\ -_t23 = _mm_movelh_ps(_y2,_x3);\ -_t24 = _mm_movehl_ps(_x3,_y2);\ -_t25 = _mm_movelh_ps(_t15,_t16);\ -_t16 = _mm_movehl_ps(_t16,_t15);\ -_t1 = _mm_loadu_ps(ptrA);\ -_t2 = _mm_loadu_ps(ptrA+4);\ -_t3 = _mm_load_ss(ptrA+8);\ -_t1 = _mm_sub_ps(_t1,_t20);\ -_t2 = _mm_sub_ps(_t2,_t23);\ -_t3 = _mm_sub_ss(_t3,_z3);\ -_mm_storeu_ps(ptrA,_t1);\ -_mm_storeu_ps(ptrA+4,_t2);\ -_mm_store_ss(ptrA+8,_t3);\ -_t4 = _mm_loadu_ps(ptrB);\ -_t5 = _mm_loadu_ps(ptrB+4);\ -_t6 = _mm_load_ss(ptrB+8);\ -_t4 = _mm_sub_ps(_t4,_t21);\ -_t5 = _mm_sub_ps(_t5,_t24);\ -_t6 = _mm_sub_ss(_t6,_t17);\ -_mm_storeu_ps(ptrB,_t4);\ -_mm_storeu_ps(ptrB+4,_t5);\ -_mm_store_ss(ptrB+8,_t6);\ -_t7 = _mm_loadu_ps(ptrC);\ -_t8 = _mm_loadu_ps(ptrC+4);\ -_t9 = _mm_load_ss(ptrC+8);\ -_t7 = _mm_sub_ps(_t7,_t22);\ -_t8 = _mm_sub_ps(_t8,_t25);\ -_t9 = _mm_sub_ss(_t9,_t18);\ -_mm_storeu_ps(ptrC,_t7);\ -_mm_storeu_ps(ptrC+4,_t8);\ -_mm_store_ss(ptrC+8,_t9);\ -_t10 = _mm_loadu_ps(ptrD);\ -_t11 = _mm_loadu_ps(ptrD+4);\ -_t12 = _mm_load_ss(ptrD+8);\ -_t10 = _mm_sub_ps(_t10,_t14);\ -_t11 = _mm_sub_ps(_t11,_t16);\ -_t12 = _mm_sub_ss(_t12,_t19);\ -_mm_storeu_ps(ptrD,_t10);\ -_mm_storeu_ps(ptrD+4,_t11);\ -_mm_store_ss(ptrD+8,_t12);\ -} +#define gmx_mm_decrement_3rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \ + __m128 _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19; \ + __m128 _t20, _t21, _t22, _t23, _t24, _t25; \ + _t13 = _mm_unpackhi_ps(_x1, _y1); \ + _x1 = _mm_unpacklo_ps(_x1, _y1); \ + _t14 = _mm_unpackhi_ps(_z1, _x2); \ + _z1 = _mm_unpacklo_ps(_z1, _x2); \ + _t15 = _mm_unpackhi_ps(_y2, _z2); \ + _y2 = _mm_unpacklo_ps(_y2, _z2); \ + _t16 = _mm_unpackhi_ps(_x3, _y3); \ + _x3 = _mm_unpacklo_ps(_x3, _y3); \ + _t17 = _mm_shuffle_ps(_z3, _z3, _MM_SHUFFLE(0, 0, 0, 1)); \ + _t18 = _mm_movehl_ps(_z3, _z3); \ + _t19 = _mm_shuffle_ps(_t18, _t18, _MM_SHUFFLE(0, 0, 0, 1)); \ + _t20 = _mm_movelh_ps(_x1, _z1); \ + _t21 = _mm_movehl_ps(_z1, _x1); \ + _t22 = _mm_movelh_ps(_t13, _t14); \ + _t14 = _mm_movehl_ps(_t14, _t13); \ + _t23 = _mm_movelh_ps(_y2, _x3); \ + _t24 = _mm_movehl_ps(_x3, _y2); \ + _t25 = _mm_movelh_ps(_t15, _t16); \ + _t16 = _mm_movehl_ps(_t16, _t15); \ + _t1 = _mm_loadu_ps(ptrA); \ + _t2 = _mm_loadu_ps(ptrA+4); \ + _t3 = _mm_load_ss(ptrA+8); \ + _t1 = _mm_sub_ps(_t1, _t20); \ + _t2 = _mm_sub_ps(_t2, _t23); \ + _t3 = _mm_sub_ss(_t3, _z3); \ + _mm_storeu_ps(ptrA, _t1); \ + _mm_storeu_ps(ptrA+4, _t2); \ + _mm_store_ss(ptrA+8, _t3); \ + _t4 = _mm_loadu_ps(ptrB); \ + _t5 = _mm_loadu_ps(ptrB+4); \ + _t6 = _mm_load_ss(ptrB+8); \ + _t4 = _mm_sub_ps(_t4, _t21); \ + _t5 = _mm_sub_ps(_t5, _t24); \ + _t6 = _mm_sub_ss(_t6, _t17); \ + _mm_storeu_ps(ptrB, _t4); \ + _mm_storeu_ps(ptrB+4, _t5); \ + _mm_store_ss(ptrB+8, _t6); \ + _t7 = _mm_loadu_ps(ptrC); \ + _t8 = _mm_loadu_ps(ptrC+4); \ + _t9 = _mm_load_ss(ptrC+8); \ + _t7 = _mm_sub_ps(_t7, _t22); \ + _t8 = _mm_sub_ps(_t8, _t25); \ + _t9 = _mm_sub_ss(_t9, _t18); \ + _mm_storeu_ps(ptrC, _t7); \ + _mm_storeu_ps(ptrC+4, _t8); \ + _mm_store_ss(ptrC+8, _t9); \ + _t10 = _mm_loadu_ps(ptrD); \ + _t11 = _mm_loadu_ps(ptrD+4); \ + _t12 = _mm_load_ss(ptrD+8); \ + _t10 = _mm_sub_ps(_t10, _t14); \ + _t11 = _mm_sub_ps(_t11, _t16); \ + _t12 = _mm_sub_ss(_t12, _t19); \ + _mm_storeu_ps(ptrD, _t10); \ + _mm_storeu_ps(ptrD+4, _t11); \ + _mm_store_ss(ptrD+8, _t12); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -441,29 +441,29 @@ gmx_mm_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_re __m128 x2, __m128 y2, __m128 z2, __m128 x3, __m128 y3, __m128 z3) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; - __m128 t11,t12,t13,t14,t15,t16,t17,t18,t19; - __m128 t20,t21,t22,t23,t24,t25; - - t13 = _mm_unpackhi_ps(x1,y1); - x1 = _mm_unpacklo_ps(x1,y1); - t14 = _mm_unpackhi_ps(z1,x2); - z1 = _mm_unpacklo_ps(z1,x2); - t15 = _mm_unpackhi_ps(y2,z2); - y2 = _mm_unpacklo_ps(y2,z2); - t16 = _mm_unpackhi_ps(x3,y3); - x3 = _mm_unpacklo_ps(x3,y3); - t17 = _mm_shuffle_ps(z3,z3,_MM_SHUFFLE(0,0,0,1)); - t18 = _mm_movehl_ps(z3,z3); - t19 = _mm_shuffle_ps(t18,t18,_MM_SHUFFLE(0,0,0,1)); - t20 = _mm_movelh_ps(x1,z1); - t21 = _mm_movehl_ps(z1,x1); - t22 = _mm_movelh_ps(t13,t14); - t14 = _mm_movehl_ps(t14,t13); - t23 = _mm_movelh_ps(y2,x3); - t24 = _mm_movehl_ps(x3,y2); - t25 = _mm_movelh_ps(t15,t16); - t16 = _mm_movehl_ps(t16,t15); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10; + __m128 t11, t12, t13, t14, t15, t16, t17, t18, t19; + __m128 t20, t21, t22, t23, t24, t25; + + t13 = _mm_unpackhi_ps(x1, y1); + x1 = _mm_unpacklo_ps(x1, y1); + t14 = _mm_unpackhi_ps(z1, x2); + z1 = _mm_unpacklo_ps(z1, x2); + t15 = _mm_unpackhi_ps(y2, z2); + y2 = _mm_unpacklo_ps(y2, z2); + t16 = _mm_unpackhi_ps(x3, y3); + x3 = _mm_unpacklo_ps(x3, y3); + t17 = _mm_shuffle_ps(z3, z3, _MM_SHUFFLE(0, 0, 0, 1)); + t18 = _mm_movehl_ps(z3, z3); + t19 = _mm_shuffle_ps(t18, t18, _MM_SHUFFLE(0, 0, 0, 1)); + t20 = _mm_movelh_ps(x1, z1); + t21 = _mm_movehl_ps(z1, x1); + t22 = _mm_movelh_ps(t13, t14); + t14 = _mm_movehl_ps(t14, t13); + t23 = _mm_movelh_ps(y2, x3); + t24 = _mm_movehl_ps(x3, y2); + t25 = _mm_movelh_ps(t15, t16); + t16 = _mm_movehl_ps(t16, t15); t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrA+4); t3 = _mm_load_ss(ptrA+8); @@ -477,102 +477,102 @@ gmx_mm_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_re t11 = _mm_loadu_ps(ptrD+4); t12 = _mm_load_ss(ptrD+8); - t1 = _mm_sub_ps(t1,t20); - t2 = _mm_sub_ps(t2,t23); - t3 = _mm_sub_ss(t3,z3); - _mm_storeu_ps(ptrA,t1); - _mm_storeu_ps(ptrA+4,t2); - _mm_store_ss(ptrA+8,t3); - t4 = _mm_sub_ps(t4,t21); - t5 = _mm_sub_ps(t5,t24); - t6 = _mm_sub_ss(t6,t17); - _mm_storeu_ps(ptrB,t4); - _mm_storeu_ps(ptrB+4,t5); - _mm_store_ss(ptrB+8,t6); - t7 = _mm_sub_ps(t7,t22); - t8 = _mm_sub_ps(t8,t25); - t9 = _mm_sub_ss(t9,t18); - _mm_storeu_ps(ptrC,t7); - _mm_storeu_ps(ptrC+4,t8); - _mm_store_ss(ptrC+8,t9); - t10 = _mm_sub_ps(t10,t14); - t11 = _mm_sub_ps(t11,t16); - t12 = _mm_sub_ss(t12,t19); - _mm_storeu_ps(ptrD,t10); - _mm_storeu_ps(ptrD+4,t11); - _mm_store_ss(ptrD+8,t12); + t1 = _mm_sub_ps(t1, t20); + t2 = _mm_sub_ps(t2, t23); + t3 = _mm_sub_ss(t3, z3); + _mm_storeu_ps(ptrA, t1); + _mm_storeu_ps(ptrA+4, t2); + _mm_store_ss(ptrA+8, t3); + t4 = _mm_sub_ps(t4, t21); + t5 = _mm_sub_ps(t5, t24); + t6 = _mm_sub_ss(t6, t17); + _mm_storeu_ps(ptrB, t4); + _mm_storeu_ps(ptrB+4, t5); + _mm_store_ss(ptrB+8, t6); + t7 = _mm_sub_ps(t7, t22); + t8 = _mm_sub_ps(t8, t25); + t9 = _mm_sub_ss(t9, t18); + _mm_storeu_ps(ptrC, t7); + _mm_storeu_ps(ptrC+4, t8); + _mm_store_ss(ptrC+8, t9); + t10 = _mm_sub_ps(t10, t14); + t11 = _mm_sub_ps(t11, t16); + t12 = _mm_sub_ss(t12, t19); + _mm_storeu_ps(ptrD, t10); + _mm_storeu_ps(ptrD+4, t11); + _mm_store_ss(ptrD+8, t12); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_decrement_4rvec_4ptr_swizzle_ps(ptrA,ptrB,ptrC,ptrD, \ -_x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \ -{\ -__m128 _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11;\ -__m128 _t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19,_t20,_t21,_t22;\ -__m128 _t23,_t24;\ -_t13 = _mm_unpackhi_ps(_x1,_y1);\ -_x1 = _mm_unpacklo_ps(_x1,_y1);\ -_t14 = _mm_unpackhi_ps(_z1,_x2);\ -_z1 = _mm_unpacklo_ps(_z1,_x2);\ -_t15 = _mm_unpackhi_ps(_y2,_z2);\ -_y2 = _mm_unpacklo_ps(_y2,_z2);\ -_t16 = _mm_unpackhi_ps(_x3,_y3);\ -_x3 = _mm_unpacklo_ps(_x3,_y3);\ -_t17 = _mm_unpackhi_ps(_z3,_x4);\ -_z3 = _mm_unpacklo_ps(_z3,_x4);\ -_t18 = _mm_unpackhi_ps(_y4,_z4);\ -_y4 = _mm_unpacklo_ps(_y4,_z4);\ -_t19 = _mm_movelh_ps(_x1,_z1);\ -_z1 = _mm_movehl_ps(_z1,_x1);\ -_t20 = _mm_movelh_ps(_t13,_t14);\ -_t14 = _mm_movehl_ps(_t14,_t13);\ -_t21 = _mm_movelh_ps(_y2,_x3);\ -_x3 = _mm_movehl_ps(_x3,_y2);\ -_t22 = _mm_movelh_ps(_t15,_t16);\ -_t16 = _mm_movehl_ps(_t16,_t15);\ -_t23 = _mm_movelh_ps(_z3,_y4);\ -_y4 = _mm_movehl_ps(_y4,_z3);\ -_t24 = _mm_movelh_ps(_t17,_t18);\ -_t18 = _mm_movehl_ps(_t18,_t17);\ -_t1 = _mm_loadu_ps(ptrA);\ -_t2 = _mm_loadu_ps(ptrA+4);\ -_t3 = _mm_loadu_ps(ptrA+8);\ -_t1 = _mm_sub_ps(_t1,_t19);\ -_t2 = _mm_sub_ps(_t2,_t21);\ -_t3 = _mm_sub_ps(_t3,_t23);\ -_mm_storeu_ps(ptrA,_t1);\ -_mm_storeu_ps(ptrA+4,_t2);\ -_mm_storeu_ps(ptrA+8,_t3);\ -_t4 = _mm_loadu_ps(ptrB);\ -_t5 = _mm_loadu_ps(ptrB+4);\ -_t6 = _mm_loadu_ps(ptrB+8);\ -_t4 = _mm_sub_ps(_t4,_z1);\ -_t5 = _mm_sub_ps(_t5,_x3);\ -_t6 = _mm_sub_ps(_t6,_y4);\ -_mm_storeu_ps(ptrB,_t4);\ -_mm_storeu_ps(ptrB+4,_t5);\ -_mm_storeu_ps(ptrB+8,_t6);\ -_t7 = _mm_loadu_ps(ptrC);\ -_t8 = _mm_loadu_ps(ptrC+4);\ -_t9 = _mm_loadu_ps(ptrC+8);\ -_t7 = _mm_sub_ps(_t7,_t20);\ -_t8 = _mm_sub_ps(_t8,_t22);\ -_t9 = _mm_sub_ps(_t9,_t24);\ -_mm_storeu_ps(ptrC,_t7);\ -_mm_storeu_ps(ptrC+4,_t8);\ -_mm_storeu_ps(ptrC+8,_t9);\ -_t10 = _mm_loadu_ps(ptrD);\ -_t11 = _mm_loadu_ps(ptrD+4);\ -_t12 = _mm_loadu_ps(ptrD+8);\ -_t10 = _mm_sub_ps(_t10,_t14);\ -_t11 = _mm_sub_ps(_t11,_t16);\ -_t12 = _mm_sub_ps(_t12,_t18);\ -_mm_storeu_ps(ptrD,_t10);\ -_mm_storeu_ps(ptrD+4,_t11);\ -_mm_storeu_ps(ptrD+8,_t12);\ -} +#define gmx_mm_decrement_4rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \ + _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11; \ + __m128 _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20, _t21, _t22; \ + __m128 _t23, _t24; \ + _t13 = _mm_unpackhi_ps(_x1, _y1); \ + _x1 = _mm_unpacklo_ps(_x1, _y1); \ + _t14 = _mm_unpackhi_ps(_z1, _x2); \ + _z1 = _mm_unpacklo_ps(_z1, _x2); \ + _t15 = _mm_unpackhi_ps(_y2, _z2); \ + _y2 = _mm_unpacklo_ps(_y2, _z2); \ + _t16 = _mm_unpackhi_ps(_x3, _y3); \ + _x3 = _mm_unpacklo_ps(_x3, _y3); \ + _t17 = _mm_unpackhi_ps(_z3, _x4); \ + _z3 = _mm_unpacklo_ps(_z3, _x4); \ + _t18 = _mm_unpackhi_ps(_y4, _z4); \ + _y4 = _mm_unpacklo_ps(_y4, _z4); \ + _t19 = _mm_movelh_ps(_x1, _z1); \ + _z1 = _mm_movehl_ps(_z1, _x1); \ + _t20 = _mm_movelh_ps(_t13, _t14); \ + _t14 = _mm_movehl_ps(_t14, _t13); \ + _t21 = _mm_movelh_ps(_y2, _x3); \ + _x3 = _mm_movehl_ps(_x3, _y2); \ + _t22 = _mm_movelh_ps(_t15, _t16); \ + _t16 = _mm_movehl_ps(_t16, _t15); \ + _t23 = _mm_movelh_ps(_z3, _y4); \ + _y4 = _mm_movehl_ps(_y4, _z3); \ + _t24 = _mm_movelh_ps(_t17, _t18); \ + _t18 = _mm_movehl_ps(_t18, _t17); \ + _t1 = _mm_loadu_ps(ptrA); \ + _t2 = _mm_loadu_ps(ptrA+4); \ + _t3 = _mm_loadu_ps(ptrA+8); \ + _t1 = _mm_sub_ps(_t1, _t19); \ + _t2 = _mm_sub_ps(_t2, _t21); \ + _t3 = _mm_sub_ps(_t3, _t23); \ + _mm_storeu_ps(ptrA, _t1); \ + _mm_storeu_ps(ptrA+4, _t2); \ + _mm_storeu_ps(ptrA+8, _t3); \ + _t4 = _mm_loadu_ps(ptrB); \ + _t5 = _mm_loadu_ps(ptrB+4); \ + _t6 = _mm_loadu_ps(ptrB+8); \ + _t4 = _mm_sub_ps(_t4, _z1); \ + _t5 = _mm_sub_ps(_t5, _x3); \ + _t6 = _mm_sub_ps(_t6, _y4); \ + _mm_storeu_ps(ptrB, _t4); \ + _mm_storeu_ps(ptrB+4, _t5); \ + _mm_storeu_ps(ptrB+8, _t6); \ + _t7 = _mm_loadu_ps(ptrC); \ + _t8 = _mm_loadu_ps(ptrC+4); \ + _t9 = _mm_loadu_ps(ptrC+8); \ + _t7 = _mm_sub_ps(_t7, _t20); \ + _t8 = _mm_sub_ps(_t8, _t22); \ + _t9 = _mm_sub_ps(_t9, _t24); \ + _mm_storeu_ps(ptrC, _t7); \ + _mm_storeu_ps(ptrC+4, _t8); \ + _mm_storeu_ps(ptrC+8, _t9); \ + _t10 = _mm_loadu_ps(ptrD); \ + _t11 = _mm_loadu_ps(ptrD+4); \ + _t12 = _mm_loadu_ps(ptrD+8); \ + _t10 = _mm_sub_ps(_t10, _t14); \ + _t11 = _mm_sub_ps(_t11, _t16); \ + _t12 = _mm_sub_ps(_t12, _t18); \ + _mm_storeu_ps(ptrD, _t10); \ + _mm_storeu_ps(ptrD+4, _t11); \ + _mm_storeu_ps(ptrD+8, _t12); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -583,69 +583,69 @@ gmx_mm_decrement_4rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_re __m128 x3, __m128 y3, __m128 z3, __m128 x4, __m128 y4, __m128 z4) { - __m128 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; - __m128 t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22; - __m128 t23,t24; - t13 = _mm_unpackhi_ps(x1,y1); - x1 = _mm_unpacklo_ps(x1,y1); - t14 = _mm_unpackhi_ps(z1,x2); - z1 = _mm_unpacklo_ps(z1,x2); - t15 = _mm_unpackhi_ps(y2,z2); - y2 = _mm_unpacklo_ps(y2,z2); - t16 = _mm_unpackhi_ps(x3,y3); - x3 = _mm_unpacklo_ps(x3,y3); - t17 = _mm_unpackhi_ps(z3,x4); - z3 = _mm_unpacklo_ps(z3,x4); - t18 = _mm_unpackhi_ps(y4,z4); - y4 = _mm_unpacklo_ps(y4,z4); - t19 = _mm_movelh_ps(x1,z1); - z1 = _mm_movehl_ps(z1,x1); - t20 = _mm_movelh_ps(t13,t14); - t14 = _mm_movehl_ps(t14,t13); - t21 = _mm_movelh_ps(y2,x3); - x3 = _mm_movehl_ps(x3,y2); - t22 = _mm_movelh_ps(t15,t16); - t16 = _mm_movehl_ps(t16,t15); - t23 = _mm_movelh_ps(z3,y4); - y4 = _mm_movehl_ps(y4,z3); - t24 = _mm_movelh_ps(t17,t18); - t18 = _mm_movehl_ps(t18,t17); + __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; + __m128 t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22; + __m128 t23, t24; + t13 = _mm_unpackhi_ps(x1, y1); + x1 = _mm_unpacklo_ps(x1, y1); + t14 = _mm_unpackhi_ps(z1, x2); + z1 = _mm_unpacklo_ps(z1, x2); + t15 = _mm_unpackhi_ps(y2, z2); + y2 = _mm_unpacklo_ps(y2, z2); + t16 = _mm_unpackhi_ps(x3, y3); + x3 = _mm_unpacklo_ps(x3, y3); + t17 = _mm_unpackhi_ps(z3, x4); + z3 = _mm_unpacklo_ps(z3, x4); + t18 = _mm_unpackhi_ps(y4, z4); + y4 = _mm_unpacklo_ps(y4, z4); + t19 = _mm_movelh_ps(x1, z1); + z1 = _mm_movehl_ps(z1, x1); + t20 = _mm_movelh_ps(t13, t14); + t14 = _mm_movehl_ps(t14, t13); + t21 = _mm_movelh_ps(y2, x3); + x3 = _mm_movehl_ps(x3, y2); + t22 = _mm_movelh_ps(t15, t16); + t16 = _mm_movehl_ps(t16, t15); + t23 = _mm_movelh_ps(z3, y4); + y4 = _mm_movehl_ps(y4, z3); + t24 = _mm_movelh_ps(t17, t18); + t18 = _mm_movehl_ps(t18, t17); t1 = _mm_loadu_ps(ptrA); t2 = _mm_loadu_ps(ptrA+4); t3 = _mm_loadu_ps(ptrA+8); - t1 = _mm_sub_ps(t1,t19); - t2 = _mm_sub_ps(t2,t21); - t3 = _mm_sub_ps(t3,t23); - _mm_storeu_ps(ptrA,t1); - _mm_storeu_ps(ptrA+4,t2); - _mm_storeu_ps(ptrA+8,t3); + t1 = _mm_sub_ps(t1, t19); + t2 = _mm_sub_ps(t2, t21); + t3 = _mm_sub_ps(t3, t23); + _mm_storeu_ps(ptrA, t1); + _mm_storeu_ps(ptrA+4, t2); + _mm_storeu_ps(ptrA+8, t3); t4 = _mm_loadu_ps(ptrB); t5 = _mm_loadu_ps(ptrB+4); t6 = _mm_loadu_ps(ptrB+8); - t4 = _mm_sub_ps(t4,z1); - t5 = _mm_sub_ps(t5,x3); - t6 = _mm_sub_ps(t6,y4); - _mm_storeu_ps(ptrB,t4); - _mm_storeu_ps(ptrB+4,t5); - _mm_storeu_ps(ptrB+8,t6); + t4 = _mm_sub_ps(t4, z1); + t5 = _mm_sub_ps(t5, x3); + t6 = _mm_sub_ps(t6, y4); + _mm_storeu_ps(ptrB, t4); + _mm_storeu_ps(ptrB+4, t5); + _mm_storeu_ps(ptrB+8, t6); t7 = _mm_loadu_ps(ptrC); t8 = _mm_loadu_ps(ptrC+4); t9 = _mm_loadu_ps(ptrC+8); - t7 = _mm_sub_ps(t7,t20); - t8 = _mm_sub_ps(t8,t22); - t9 = _mm_sub_ps(t9,t24); - _mm_storeu_ps(ptrC,t7); - _mm_storeu_ps(ptrC+4,t8); - _mm_storeu_ps(ptrC+8,t9); + t7 = _mm_sub_ps(t7, t20); + t8 = _mm_sub_ps(t8, t22); + t9 = _mm_sub_ps(t9, t24); + _mm_storeu_ps(ptrC, t7); + _mm_storeu_ps(ptrC+4, t8); + _mm_storeu_ps(ptrC+8, t9); t10 = _mm_loadu_ps(ptrD); t11 = _mm_loadu_ps(ptrD+4); t12 = _mm_loadu_ps(ptrD+8); - t10 = _mm_sub_ps(t10,t14); - t11 = _mm_sub_ps(t11,t16); - t12 = _mm_sub_ps(t12,t18); - _mm_storeu_ps(ptrD,t10); - _mm_storeu_ps(ptrD+4,t11); - _mm_storeu_ps(ptrD+8,t12); + t10 = _mm_sub_ps(t10, t14); + t11 = _mm_sub_ps(t11, t16); + t12 = _mm_sub_ps(t12, t18); + _mm_storeu_ps(ptrD, t10); + _mm_storeu_ps(ptrD+4, t11); + _mm_storeu_ps(ptrD+8, t12); } #endif @@ -655,57 +655,57 @@ gmx_mm_update_iforce_1atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t2,t3; + __m128 t2, t3; - fix1 = _mm_hadd_ps(fix1,fix1); - fiy1 = _mm_hadd_ps(fiy1,fiz1); + fix1 = _mm_hadd_ps(fix1, fix1); + fiy1 = _mm_hadd_ps(fiy1, fiz1); - fix1 = _mm_hadd_ps(fix1,fiy1); /* fiz1 fiy1 fix1 fix1 */ + fix1 = _mm_hadd_ps(fix1, fiy1); /* fiz1 fiy1 fix1 fix1 */ t2 = _mm_load_ss(fptr); - t2 = _mm_loadh_pi(t2,(__m64 *)(fptr+1)); + t2 = _mm_loadh_pi(t2, (__m64 *)(fptr+1)); t3 = _mm_load_ss(fshiftptr); - t3 = _mm_loadh_pi(t3,(__m64 *)(fshiftptr+1)); + t3 = _mm_loadh_pi(t3, (__m64 *)(fshiftptr+1)); - t2 = _mm_add_ps(t2,fix1); - t3 = _mm_add_ps(t3,fix1); + t2 = _mm_add_ps(t2, fix1); + t3 = _mm_add_ps(t3, fix1); - _mm_store_ss(fptr,t2); - _mm_storeh_pi((__m64 *)(fptr+1),t2); - _mm_store_ss(fshiftptr,t3); - _mm_storeh_pi((__m64 *)(fshiftptr+1),t3); + _mm_store_ss(fptr, t2); + _mm_storeh_pi((__m64 *)(fptr+1), t2); + _mm_store_ss(fshiftptr, t3); + _mm_storeh_pi((__m64 *)(fshiftptr+1), t3); } #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_3atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \ -fptr,fshiftptr) \ -{\ -__m128 _t1,_t2,_t3,_t4;\ +#define gmx_mm_update_iforce_3atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \ + fptr, fshiftptr) \ + { \ + __m128 _t1, _t2, _t3, _t4; \ \ -fix1 = _mm_hadd_ps(fix1,fiy1);\ -fiz1 = _mm_hadd_ps(fiz1,fix2);\ -fiy2 = _mm_hadd_ps(fiy2,fiz2);\ -fix3 = _mm_hadd_ps(fix3,fiy3);\ -fiz3 = _mm_hadd_ps(fiz3,fiz3);\ -fix1 = _mm_hadd_ps(fix1,fiz1);\ -fiy2 = _mm_hadd_ps(fiy2,fix3);\ -fiz3 = _mm_hadd_ps(fiz3,fiz3);\ -_mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) ));\ -_mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4)));\ -_mm_store_ss (fptr+8,_mm_add_ss(fiz3,_mm_load_ss(fptr+8) ));\ -_t4 = _mm_load_ss(fshiftptr+2);\ -_t4 = _mm_loadh_pi(_t4,(__m64 *)(fshiftptr));\ -_t1 = _mm_shuffle_ps(fiz3,fix1,_MM_SHUFFLE(1,0,0,0));\ -_t2 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(3,2,2,2));\ -_t3 = _mm_shuffle_ps(fiy2,fix1,_MM_SHUFFLE(3,3,0,1));\ -_t3 = _mm_shuffle_ps(_t3,_t3,_MM_SHUFFLE(1,2,0,0));\ -_t1 = _mm_add_ps(_t1,_t2);\ -_t3 = _mm_add_ps(_t3,_t4);\ -_t1 = _mm_add_ps(_t1,_t3);\ -_mm_store_ss(fshiftptr+2,_t1);\ -_mm_storeh_pi((__m64 *)(fshiftptr),_t1);\ -} + fix1 = _mm_hadd_ps(fix1, fiy1); \ + fiz1 = _mm_hadd_ps(fiz1, fix2); \ + fiy2 = _mm_hadd_ps(fiy2, fiz2); \ + fix3 = _mm_hadd_ps(fix3, fiy3); \ + fiz3 = _mm_hadd_ps(fiz3, fiz3); \ + fix1 = _mm_hadd_ps(fix1, fiz1); \ + fiy2 = _mm_hadd_ps(fiy2, fix3); \ + fiz3 = _mm_hadd_ps(fiz3, fiz3); \ + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \ + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \ + _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) )); \ + _t4 = _mm_load_ss(fshiftptr+2); \ + _t4 = _mm_loadh_pi(_t4, (__m64 *)(fshiftptr)); \ + _t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); \ + _t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); \ + _t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); \ + _t3 = _mm_shuffle_ps(_t3, _t3, _MM_SHUFFLE(1, 2, 0, 0)); \ + _t1 = _mm_add_ps(_t1, _t2); \ + _t3 = _mm_add_ps(_t3, _t4); \ + _t1 = _mm_add_ps(_t1, _t3); \ + _mm_store_ss(fshiftptr+2, _t1); \ + _mm_storeh_pi((__m64 *)(fshiftptr), _t1); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -715,72 +715,72 @@ gmx_mm_update_iforce_3atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t1,t2,t3,t4; + __m128 t1, t2, t3, t4; - fix1 = _mm_hadd_ps(fix1,fiy1); - fiz1 = _mm_hadd_ps(fiz1,fix2); - fiy2 = _mm_hadd_ps(fiy2,fiz2); - fix3 = _mm_hadd_ps(fix3,fiy3); - fiz3 = _mm_hadd_ps(fiz3,fiz3); + fix1 = _mm_hadd_ps(fix1, fiy1); + fiz1 = _mm_hadd_ps(fiz1, fix2); + fiy2 = _mm_hadd_ps(fiy2, fiz2); + fix3 = _mm_hadd_ps(fix3, fiy3); + fiz3 = _mm_hadd_ps(fiz3, fiz3); - fix1 = _mm_hadd_ps(fix1,fiz1); /* fix2 fiz1 fiy1 fix1 */ - fiy2 = _mm_hadd_ps(fiy2,fix3); /* fiy3 fix3 fiz2 fiy2 */ - fiz3 = _mm_hadd_ps(fiz3,fiz3); /* - - - fiz3 */ + fix1 = _mm_hadd_ps(fix1, fiz1); /* fix2 fiz1 fiy1 fix1 */ + fiy2 = _mm_hadd_ps(fiy2, fix3); /* fiy3 fix3 fiz2 fiy2 */ + fiz3 = _mm_hadd_ps(fiz3, fiz3); /* - - - fiz3 */ - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) )); - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4))); - _mm_store_ss (fptr+8,_mm_add_ss(fiz3,_mm_load_ss(fptr+8) )); + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); + _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) )); t4 = _mm_load_ss(fshiftptr+2); - t4 = _mm_loadh_pi(t4,(__m64 *)(fshiftptr)); + t4 = _mm_loadh_pi(t4, (__m64 *)(fshiftptr)); - t1 = _mm_shuffle_ps(fiz3,fix1,_MM_SHUFFLE(1,0,0,0)); /* fiy1 fix1 - fiz3 */ - t2 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(3,2,2,2)); /* fiy3 fix3 - fiz1 */ - t3 = _mm_shuffle_ps(fiy2,fix1,_MM_SHUFFLE(3,3,0,1)); /* fix2 fix2 fiy2 fiz2 */ - t3 = _mm_shuffle_ps(t3 ,t3 ,_MM_SHUFFLE(1,2,0,0)); /* fiy2 fix2 - fiz2 */ + t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); /* fiy1 fix1 - fiz3 */ + t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); /* fiy3 fix3 - fiz1 */ + t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); /* fix2 fix2 fiy2 fiz2 */ + t3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 2, 0, 0)); /* fiy2 fix2 - fiz2 */ - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ps(t3,t4); - t1 = _mm_add_ps(t1,t3); /* y x - z */ + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ps(t3, t4); + t1 = _mm_add_ps(t1, t3); /* y x - z */ - _mm_store_ss(fshiftptr+2,t1); - _mm_storeh_pi((__m64 *)(fshiftptr),t1); + _mm_store_ss(fshiftptr+2, t1); + _mm_storeh_pi((__m64 *)(fshiftptr), t1); } #endif #if defined (_MSC_VER) && defined(_M_IX86) /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */ -#define gmx_mm_update_iforce_4atom_swizzle_ps(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \ -fptr,fshiftptr) \ -{\ -__m128 _t1,_t2,_t3,_t4,_t5;\ +#define gmx_mm_update_iforce_4atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \ + fptr, fshiftptr) \ + { \ + __m128 _t1, _t2, _t3, _t4, _t5; \ \ -fix1 = _mm_hadd_ps(fix1,fiy1);\ -fiz1 = _mm_hadd_ps(fiz1,fix2);\ -fiy2 = _mm_hadd_ps(fiy2,fiz2);\ -fix3 = _mm_hadd_ps(fix3,fiy3);\ -fiz3 = _mm_hadd_ps(fiz3,fix4);\ -fiy4 = _mm_hadd_ps(fiy4,fiz4);\ -fix1 = _mm_hadd_ps(fix1,fiz1);\ -fiy2 = _mm_hadd_ps(fiy2,fix3);\ -fiz3 = _mm_hadd_ps(fiz3,fiy4);\ -_mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) ));\ -_mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4)));\ -_mm_storeu_ps(fptr+8,_mm_add_ps(fiz3,_mm_loadu_ps(fptr+8)));\ -_t5 = _mm_load_ss(fshiftptr+2);\ -_t5 = _mm_loadh_pi(_t5,(__m64 *)(fshiftptr));\ -_t1 = _mm_shuffle_ps(fix1,fix1,_MM_SHUFFLE(1,0,2,2));\ -_t2 = _mm_shuffle_ps(fiy2,fiy2,_MM_SHUFFLE(3,2,1,1));\ -_t3 = _mm_shuffle_ps(fiz3,fiz3,_MM_SHUFFLE(2,1,0,0));\ -_t4 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(0,0,3,3));\ -_t4 = _mm_shuffle_ps(fiz3,_t4 ,_MM_SHUFFLE(2,0,3,3));\ -_t1 = _mm_add_ps(_t1,_t2);\ -_t3 = _mm_add_ps(_t3,_t4);\ -_t1 = _mm_add_ps(_t1,_t3);\ -_t5 = _mm_add_ps(_t5,_t1);\ -_mm_store_ss(fshiftptr+2,_t5);\ -_mm_storeh_pi((__m64 *)(fshiftptr),_t5);\ -} + fix1 = _mm_hadd_ps(fix1, fiy1); \ + fiz1 = _mm_hadd_ps(fiz1, fix2); \ + fiy2 = _mm_hadd_ps(fiy2, fiz2); \ + fix3 = _mm_hadd_ps(fix3, fiy3); \ + fiz3 = _mm_hadd_ps(fiz3, fix4); \ + fiy4 = _mm_hadd_ps(fiy4, fiz4); \ + fix1 = _mm_hadd_ps(fix1, fiz1); \ + fiy2 = _mm_hadd_ps(fiy2, fix3); \ + fiz3 = _mm_hadd_ps(fiz3, fiy4); \ + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \ + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \ + _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8))); \ + _t5 = _mm_load_ss(fshiftptr+2); \ + _t5 = _mm_loadh_pi(_t5, (__m64 *)(fshiftptr)); \ + _t1 = _mm_shuffle_ps(fix1, fix1, _MM_SHUFFLE(1, 0, 2, 2)); \ + _t2 = _mm_shuffle_ps(fiy2, fiy2, _MM_SHUFFLE(3, 2, 1, 1)); \ + _t3 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(2, 1, 0, 0)); \ + _t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3)); \ + _t4 = _mm_shuffle_ps(fiz3, _t4, _MM_SHUFFLE(2, 0, 3, 3)); \ + _t1 = _mm_add_ps(_t1, _t2); \ + _t3 = _mm_add_ps(_t3, _t4); \ + _t1 = _mm_add_ps(_t1, _t3); \ + _t5 = _mm_add_ps(_t5, _t1); \ + _mm_store_ss(fshiftptr+2, _t5); \ + _mm_storeh_pi((__m64 *)(fshiftptr), _t5); \ + } #else /* Real function for sane compilers */ static gmx_inline void @@ -791,39 +791,39 @@ gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, float * gmx_restrict fptr, float * gmx_restrict fshiftptr) { - __m128 t1,t2,t3,t4,t5; + __m128 t1, t2, t3, t4, t5; - fix1 = _mm_hadd_ps(fix1,fiy1); - fiz1 = _mm_hadd_ps(fiz1,fix2); - fiy2 = _mm_hadd_ps(fiy2,fiz2); - fix3 = _mm_hadd_ps(fix3,fiy3); - fiz3 = _mm_hadd_ps(fiz3,fix4); - fiy4 = _mm_hadd_ps(fiy4,fiz4); + fix1 = _mm_hadd_ps(fix1, fiy1); + fiz1 = _mm_hadd_ps(fiz1, fix2); + fiy2 = _mm_hadd_ps(fiy2, fiz2); + fix3 = _mm_hadd_ps(fix3, fiy3); + fiz3 = _mm_hadd_ps(fiz3, fix4); + fiy4 = _mm_hadd_ps(fiy4, fiz4); - fix1 = _mm_hadd_ps(fix1,fiz1); /* fix2 fiz1 fiy1 fix1 */ - fiy2 = _mm_hadd_ps(fiy2,fix3); /* fiy3 fix3 fiz2 fiy2 */ - fiz3 = _mm_hadd_ps(fiz3,fiy4); /* fiz4 fiy4 fix4 fiz3 */ + fix1 = _mm_hadd_ps(fix1, fiz1); /* fix2 fiz1 fiy1 fix1 */ + fiy2 = _mm_hadd_ps(fiy2, fix3); /* fiy3 fix3 fiz2 fiy2 */ + fiz3 = _mm_hadd_ps(fiz3, fiy4); /* fiz4 fiy4 fix4 fiz3 */ - _mm_storeu_ps(fptr, _mm_add_ps(fix1,_mm_loadu_ps(fptr) )); - _mm_storeu_ps(fptr+4,_mm_add_ps(fiy2,_mm_loadu_ps(fptr+4))); - _mm_storeu_ps(fptr+8,_mm_add_ps(fiz3,_mm_loadu_ps(fptr+8))); + _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); + _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); + _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8))); t5 = _mm_load_ss(fshiftptr+2); - t5 = _mm_loadh_pi(t5,(__m64 *)(fshiftptr)); + t5 = _mm_loadh_pi(t5, (__m64 *)(fshiftptr)); - t1 = _mm_shuffle_ps(fix1,fix1,_MM_SHUFFLE(1,0,2,2)); - t2 = _mm_shuffle_ps(fiy2,fiy2,_MM_SHUFFLE(3,2,1,1)); - t3 = _mm_shuffle_ps(fiz3,fiz3,_MM_SHUFFLE(2,1,0,0)); - t4 = _mm_shuffle_ps(fix1,fiy2,_MM_SHUFFLE(0,0,3,3)); - t4 = _mm_shuffle_ps(fiz3,t4 ,_MM_SHUFFLE(2,0,3,3)); + t1 = _mm_shuffle_ps(fix1, fix1, _MM_SHUFFLE(1, 0, 2, 2)); + t2 = _mm_shuffle_ps(fiy2, fiy2, _MM_SHUFFLE(3, 2, 1, 1)); + t3 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(2, 1, 0, 0)); + t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3)); + t4 = _mm_shuffle_ps(fiz3, t4, _MM_SHUFFLE(2, 0, 3, 3)); - t1 = _mm_add_ps(t1,t2); - t3 = _mm_add_ps(t3,t4); - t1 = _mm_add_ps(t1,t3); - t5 = _mm_add_ps(t5,t1); + t1 = _mm_add_ps(t1, t2); + t3 = _mm_add_ps(t3, t4); + t1 = _mm_add_ps(t1, t3); + t5 = _mm_add_ps(t5, t1); - _mm_store_ss(fshiftptr+2,t5); - _mm_storeh_pi((__m64 *)(fshiftptr),t5); + _mm_store_ss(fshiftptr+2, t5); + _mm_storeh_pi((__m64 *)(fshiftptr), t5); } #endif @@ -831,24 +831,24 @@ gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1, static gmx_inline void gmx_mm_update_1pot_ps(__m128 pot1, float * gmx_restrict ptrA) { - pot1 = _mm_add_ps(pot1,_mm_movehl_ps(_mm_setzero_ps(),pot1)); - pot1 = _mm_add_ps(pot1,_mm_shuffle_ps(pot1,pot1,_MM_SHUFFLE(0,0,0,1))); - _mm_store_ss(ptrA,_mm_add_ss(pot1,_mm_load_ss(ptrA))); + pot1 = _mm_add_ps(pot1, _mm_movehl_ps(_mm_setzero_ps(), pot1)); + pot1 = _mm_add_ps(pot1, _mm_shuffle_ps(pot1, pot1, _MM_SHUFFLE(0, 0, 0, 1))); + _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA))); } static gmx_inline void gmx_mm_update_2pot_ps(__m128 pot1, float * gmx_restrict ptrA, __m128 pot2, float * gmx_restrict ptrB) { - __m128 t1,t2; - t1 = _mm_movehl_ps(pot2,pot1); - t2 = _mm_movelh_ps(pot1,pot2); - t1 = _mm_add_ps(t1,t2); - t2 = _mm_shuffle_ps(t1,t1,_MM_SHUFFLE(3,3,1,1)); - pot1 = _mm_add_ps(t1,t2); - pot2 = _mm_movehl_ps(t2,pot1); - _mm_store_ss(ptrA,_mm_add_ss(pot1,_mm_load_ss(ptrA))); - _mm_store_ss(ptrB,_mm_add_ss(pot2,_mm_load_ss(ptrB))); + __m128 t1, t2; + t1 = _mm_movehl_ps(pot2, pot1); + t2 = _mm_movelh_ps(pot1, pot2); + t1 = _mm_add_ps(t1, t2); + t2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 1, 1)); + pot1 = _mm_add_ps(t1, t2); + pot2 = _mm_movehl_ps(t2, pot1); + _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA))); + _mm_store_ss(ptrB, _mm_add_ss(pot2, _mm_load_ss(ptrB))); } diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.c b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.c index 6deaef13a1..6c15bd3f8c 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.c +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.c @@ -241,7 +241,7 @@ nb_kernel_t nb_kernel_ElecRF_VdwCSTab_GeomW4W4_F_sse4_1_single; nb_kernel_info_t -kernellist_sse4_1_single[] = + kernellist_sse4_1_single[] = { { nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse4_1_single, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_VF_sse4_1_single", "sse4_1_single", "None", "None", "LennardJones", "None", "ParticleParticle", "", "PotentialAndForce" }, { nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse4_1_single, "nb_kernel_ElecNone_VdwLJ_GeomP1P1_F_sse4_1_single", "sse4_1_single", "None", "None", "LennardJones", "None", "ParticleParticle", "", "Force" }, @@ -460,6 +460,6 @@ kernellist_sse4_1_single[] = }; int -kernellist_sse4_1_single_size = sizeof(kernellist_sse4_1_single)/sizeof(kernellist_sse4_1_single[0]); + kernellist_sse4_1_single_size = sizeof(kernellist_sse4_1_single)/sizeof(kernellist_sse4_1_single[0]); #endif diff --git a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.h b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.h index a8054157a1..7ee1e025af 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.h +++ b/src/gromacs/gmxlib/nonbonded/nb_kernel_sse4_1_single/nb_kernel_sse4_1_single.h @@ -27,10 +27,10 @@ /* List of kernels for this architecture with metadata about them */ extern nb_kernel_info_t -kernellist_sse4_1_single[]; + kernellist_sse4_1_single[]; /* Length of kernellist_c */ extern int -kernellist_sse4_1_single_size; + kernellist_sse4_1_single_size; #endif diff --git a/src/gromacs/gmxlib/nonbonded/nonbonded.c b/src/gromacs/gmxlib/nonbonded/nonbonded.c index b7c1ef046f..67535fcb10 100644 --- a/src/gromacs/gmxlib/nonbonded/nonbonded.c +++ b/src/gromacs/gmxlib/nonbonded/nonbonded.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -113,41 +113,41 @@ gmx_nonbonded_setup(FILE * fplog, tMPI_Thread_mutex_lock(&nonbonded_setup_mutex); #endif /* Here we are guaranteed only one thread made it. */ - if(nonbonded_setup_done==FALSE) + if (nonbonded_setup_done == FALSE) { - if(bGenericKernelOnly==FALSE) + if (bGenericKernelOnly == FALSE) { /* Add the generic kernels to the structure stored statically in nb_kernel.c */ - nb_kernel_list_add_kernels(kernellist_c,kernellist_c_size); - - if(!(fr!=NULL && fr->use_cpu_acceleration==FALSE)) + nb_kernel_list_add_kernels(kernellist_c, kernellist_c_size); + + if (!(fr != NULL && fr->use_cpu_acceleration == FALSE)) { /* Add interaction-specific kernels for different architectures */ /* Single precision */ #if (defined GMX_CPU_ACCELERATION_X86_SSE2) && !(defined GMX_DOUBLE) - nb_kernel_list_add_kernels(kernellist_sse2_single,kernellist_sse2_single_size); + nb_kernel_list_add_kernels(kernellist_sse2_single, kernellist_sse2_single_size); #endif #if (defined GMX_CPU_ACCELERATION_X86_SSE4_1) && !(defined GMX_DOUBLE) - nb_kernel_list_add_kernels(kernellist_sse4_1_single,kernellist_sse4_1_single_size); + nb_kernel_list_add_kernels(kernellist_sse4_1_single, kernellist_sse4_1_single_size); #endif #if (defined GMX_CPU_ACCELERATION_X86_AVX_128_FMA) && !(defined GMX_DOUBLE) - nb_kernel_list_add_kernels(kernellist_avx_128_fma_single,kernellist_avx_128_fma_single_size); + nb_kernel_list_add_kernels(kernellist_avx_128_fma_single, kernellist_avx_128_fma_single_size); #endif #if (defined GMX_CPU_ACCELERATION_X86_AVX_256) && !(defined GMX_DOUBLE) - nb_kernel_list_add_kernels(kernellist_avx_256_single,kernellist_avx_256_single_size); + nb_kernel_list_add_kernels(kernellist_avx_256_single, kernellist_avx_256_single_size); #endif /* Double precision */ #if (defined GMX_CPU_ACCELERATION_X86_SSE2 && defined GMX_DOUBLE) - nb_kernel_list_add_kernels(kernellist_sse2_double,kernellist_sse2_double_size); + nb_kernel_list_add_kernels(kernellist_sse2_double, kernellist_sse2_double_size); #endif #if (defined GMX_CPU_ACCELERATION_X86_SSE4_1 && defined GMX_DOUBLE) - nb_kernel_list_add_kernels(kernellist_sse4_1_double,kernellist_sse4_1_double_size); + nb_kernel_list_add_kernels(kernellist_sse4_1_double, kernellist_sse4_1_double_size); #endif #if (defined GMX_CPU_ACCELERATION_X86_AVX_128_FMA && defined GMX_DOUBLE) - nb_kernel_list_add_kernels(kernellist_avx_128_fma_double,kernellist_avx_128_fma_double_size); + nb_kernel_list_add_kernels(kernellist_avx_128_fma_double, kernellist_avx_128_fma_double_size); #endif #if (defined GMX_CPU_ACCELERATION_X86_AVX_256 && defined GMX_DOUBLE) - nb_kernel_list_add_kernels(kernellist_avx_256_double,kernellist_avx_256_double_size); + nb_kernel_list_add_kernels(kernellist_avx_256_double, kernellist_avx_256_double_size); #endif ; /* empty statement to avoid a completely empty block */ } @@ -155,7 +155,7 @@ gmx_nonbonded_setup(FILE * fplog, /* Create a hash for faster lookups */ nb_kernel_list_hash_init(); - nonbonded_setup_done=TRUE; + nonbonded_setup_done = TRUE; } #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&nonbonded_setup_mutex); @@ -219,16 +219,16 @@ gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl) int narch = asize(arch_and_padding); int i; - if(nonbonded_setup_done==FALSE) + if (nonbonded_setup_done == FALSE) { /* We typically call this setup routine before starting timers, * but if that has not been done for whatever reason we do it now. */ - gmx_nonbonded_setup(NULL,NULL,FALSE); + gmx_nonbonded_setup(NULL, NULL, FALSE); } /* Not used yet */ - other=""; + other = ""; nl->kernelptr_vf = NULL; nl->kernelptr_v = NULL; @@ -240,61 +240,62 @@ gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl) vdw_mod = eintmod_names[nl->ivdwmod]; geom = gmx_nblist_geometry_names[nl->igeometry]; - if(nl->type==GMX_NBLIST_INTERACTION_ADRESS){ - nl->kernelptr_vf = gmx_nb_generic_adress_kernel; - nl->kernelptr_f = gmx_nb_generic_adress_kernel; + if (nl->type == GMX_NBLIST_INTERACTION_ADRESS) + { + nl->kernelptr_vf = gmx_nb_generic_adress_kernel; + nl->kernelptr_f = gmx_nb_generic_adress_kernel; nl->simd_padding_width = 1; return; } - if(nl->type==GMX_NBLIST_INTERACTION_FREE_ENERGY) + if (nl->type == GMX_NBLIST_INTERACTION_FREE_ENERGY) { - nl->kernelptr_vf = gmx_nb_free_energy_kernel; - nl->kernelptr_f = gmx_nb_free_energy_kernel; + nl->kernelptr_vf = gmx_nb_free_energy_kernel; + nl->kernelptr_f = gmx_nb_free_energy_kernel; nl->simd_padding_width = 1; } - else if(!gmx_strcasecmp_min(geom,"CG-CG")) + else if (!gmx_strcasecmp_min(geom, "CG-CG")) { - nl->kernelptr_vf = gmx_nb_generic_cg_kernel; - nl->kernelptr_f = gmx_nb_generic_cg_kernel; + nl->kernelptr_vf = gmx_nb_generic_cg_kernel; + nl->kernelptr_f = gmx_nb_generic_cg_kernel; nl->simd_padding_width = 1; } else { /* Try to find a specific kernel first */ - for(i=0;ikernelptr_vf==NULL ;i++) + for (i = 0; i < narch && nl->kernelptr_vf == NULL; i++) { - nl->kernelptr_vf = nb_kernel_list_findkernel(log,arch_and_padding[i].arch,elec,elec_mod,vdw,vdw_mod,geom,other,"PotentialAndForce"); + nl->kernelptr_vf = nb_kernel_list_findkernel(log, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "PotentialAndForce"); nl->simd_padding_width = arch_and_padding[i].simd_padding_width; } - for(i=0;ikernelptr_f==NULL ;i++) + for (i = 0; i < narch && nl->kernelptr_f == NULL; i++) { - nl->kernelptr_f = nb_kernel_list_findkernel(log,arch_and_padding[i].arch,elec,elec_mod,vdw,vdw_mod,geom,other,"Force"); + nl->kernelptr_f = nb_kernel_list_findkernel(log, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "Force"); nl->simd_padding_width = arch_and_padding[i].simd_padding_width; /* If there is not force-only optimized kernel, is there a potential & force one? */ - if(nl->kernelptr_f == NULL) + if (nl->kernelptr_f == NULL) { - nl->kernelptr_f = nb_kernel_list_findkernel(NULL,arch_and_padding[i].arch,elec,elec_mod,vdw,vdw_mod,geom,other,"PotentialAndForce"); + nl->kernelptr_f = nb_kernel_list_findkernel(NULL, arch_and_padding[i].arch, elec, elec_mod, vdw, vdw_mod, geom, other, "PotentialAndForce"); nl->simd_padding_width = arch_and_padding[i].simd_padding_width; } } - + /* Give up, pick a generic one instead */ - if(nl->kernelptr_vf==NULL) + if (nl->kernelptr_vf == NULL) { - nl->kernelptr_vf = gmx_nb_generic_kernel; - nl->kernelptr_f = gmx_nb_generic_kernel; + nl->kernelptr_vf = gmx_nb_generic_kernel; + nl->kernelptr_f = gmx_nb_generic_kernel; nl->simd_padding_width = 1; - if(debug) + if (debug) { fprintf(debug, "WARNING - Slow generic NB kernel used for neighborlist with\n" " Elec: '%s', Modifier: '%s'\n" " Vdw: '%s', Modifier: '%s'\n" " Geom: '%s', Other: '%s'\n\n", - elec,elec_mod,vdw,vdw_mod,geom,other); + elec, elec_mod, vdw, vdw_mod, geom, other); } } } @@ -302,66 +303,66 @@ gmx_nonbonded_set_kernel_pointers(FILE *log, t_nblist *nl) return; } -void do_nonbonded(t_commrec *cr,t_forcerec *fr, - rvec x[],rvec f_shortrange[],rvec f_longrange[],t_mdatoms *mdatoms,t_blocka *excl, - gmx_grppairener_t *grppener,rvec box_size, - t_nrnb *nrnb,real *lambda, real *dvdl, - int nls,int eNL,int flags) +void do_nonbonded(t_commrec *cr, t_forcerec *fr, + rvec x[], rvec f_shortrange[], rvec f_longrange[], t_mdatoms *mdatoms, t_blocka *excl, + gmx_grppairener_t *grppener, rvec box_size, + t_nrnb *nrnb, real *lambda, real *dvdl, + int nls, int eNL, int flags) { - t_nblist * nlist; - int n,n0,n1,i,i0,i1,sz,range; - t_nblists * nblists; + t_nblist * nlist; + int n, n0, n1, i, i0, i1, sz, range; + t_nblists * nblists; nb_kernel_data_t kernel_data; - nb_kernel_t * kernelptr=NULL; + nb_kernel_t * kernelptr = NULL; rvec * f; - + kernel_data.flags = flags; kernel_data.exclusions = excl; kernel_data.lambda = lambda; kernel_data.dvdl = dvdl; - - if(fr->bAllvsAll) + + if (fr->bAllvsAll) { return; } - + if (eNL >= 0) { - i0 = eNL; - i1 = i0+1; + i0 = eNL; + i1 = i0+1; + } + else + { + i0 = 0; + i1 = eNL_NR; + } + + if (nls >= 0) + { + n0 = nls; + n1 = nls+1; } else { - i0 = 0; - i1 = eNL_NR; - } - - if (nls >= 0) - { - n0 = nls; - n1 = nls+1; - } - else - { - n0 = 0; - n1 = fr->nnblists; - } - - for(n=n0; (nnblists[n]; + n0 = 0; + n1 = fr->nnblists; + } + + for (n = n0; (n < n1); n++) + { + nblists = &fr->nblists[n]; kernel_data.table_elec = &nblists->table_elec; kernel_data.table_vdw = &nblists->table_vdw; kernel_data.table_elec_vdw = &nblists->table_elec_vdw; - for(range=0;range<2;range++) + for (range = 0; range < 2; range++) { /* Are we doing short/long-range? */ - if(range==0) + if (range == 0) { /* Short-range */ - if(!(flags & GMX_NONBONDED_DO_SR)) + if (!(flags & GMX_NONBONDED_DO_SR)) { continue; } @@ -371,10 +372,10 @@ void do_nonbonded(t_commrec *cr,t_forcerec *fr, nlist = nblists->nlist_sr; f = f_shortrange; } - else if(range==1) + else if (range == 1) { /* Long-range */ - if(!(flags & GMX_NONBONDED_DO_LR)) + if (!(flags & GMX_NONBONDED_DO_LR)) { continue; } @@ -385,11 +386,11 @@ void do_nonbonded(t_commrec *cr,t_forcerec *fr, f = f_longrange; } - for(i=i0; (i 0) { - if(flags & GMX_NONBONDED_DO_POTENTIAL) + if (flags & GMX_NONBONDED_DO_POTENTIAL) { /* Potential and force */ kernelptr = (nb_kernel_t *)nlist[i].kernelptr_vf; @@ -400,20 +401,20 @@ void do_nonbonded(t_commrec *cr,t_forcerec *fr, kernelptr = (nb_kernel_t *)nlist[i].kernelptr_f; } - if(nlist[i].type!=GMX_NBLIST_INTERACTION_FREE_ENERGY && (flags & GMX_NONBONDED_DO_FOREIGNLAMBDA)) + if (nlist[i].type != GMX_NBLIST_INTERACTION_FREE_ENERGY && (flags & GMX_NONBONDED_DO_FOREIGNLAMBDA)) { /* We don't need the non-perturbed interactions */ continue; } - (*kernelptr)(&(nlist[i]),x,f,fr,mdatoms,&kernel_data,nrnb); - } + (*kernelptr)(&(nlist[i]), x, f, fr, mdatoms, &kernel_data, nrnb); + } } } } } static void -nb_listed_warning_rlimit(const rvec *x,int ai, int aj,int * global_atom_index,real r, real rlimit) +nb_listed_warning_rlimit(const rvec *x, int ai, int aj, int * global_atom_index, real r, real rlimit) { gmx_warning("Listed nonbonded interaction between particles %d and %d\n" "at distance %.3f which is larger than the table limit %.3f nm.\n\n" @@ -425,14 +426,14 @@ nb_listed_warning_rlimit(const rvec *x,int ai, int aj,int * global_atom_index,re "IMPORTANT: This should not happen in a stable simulation, so there is\n" "probably something wrong with your system. Only change the table-extension\n" "distance in the mdp file if you are really sure that is the reason.\n", - glatnr(global_atom_index,ai),glatnr(global_atom_index,aj),r,rlimit); + glatnr(global_atom_index, ai), glatnr(global_atom_index, aj), r, rlimit); if (debug) { fprintf(debug, "%8f %8f %8f\n%8f %8f %8f\n1-4 (%d,%d) interaction not within cut-off! r=%g. Ignored\n", - x[ai][XX],x[ai][YY],x[ai][ZZ],x[aj][XX],x[aj][YY],x[aj][ZZ], - glatnr(global_atom_index,ai),glatnr(global_atom_index,aj),r); + x[ai][XX], x[ai][YY], x[ai][ZZ], x[aj][XX], x[aj][YY], x[aj][ZZ], + glatnr(global_atom_index, ai), glatnr(global_atom_index, aj), r); } } @@ -443,10 +444,10 @@ nb_listed_warning_rlimit(const rvec *x,int ai, int aj,int * global_atom_index,re * extra functional call for every single pair listed in the topology. */ static real -nb_evaluate_single(real r2, real tabscale,real *vftab, +nb_evaluate_single(real r2, real tabscale, real *vftab, real qq, real c6, real c12, real *velec, real *vvdw) { - real rinv,r,rtab,eps,eps2,Y,F,Geps,Heps2,Fp,VVe,FFe,VVd,FFd,VVr,FFr,fscal; + real rinv, r, rtab, eps, eps2, Y, F, Geps, Heps2, Fp, VVe, FFe, VVd, FFd, VVr, FFr, fscal; int ntab; /* Do the tabulated interactions - first table lookup */ @@ -492,33 +493,34 @@ nb_evaluate_single(real r2, real tabscale,real *vftab, real -do_nonbonded_listed(int ftype,int nbonds, - const t_iatom iatoms[],const t_iparams iparams[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real *lambda, real *dvdl, - const t_mdatoms *md, - const t_forcerec *fr,gmx_grppairener_t *grppener, - int *global_atom_index) +do_nonbonded_listed(int ftype, int nbonds, + const t_iatom iatoms[], const t_iparams iparams[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real *lambda, real *dvdl, + const t_mdatoms *md, + const t_forcerec *fr, gmx_grppairener_t *grppener, + int *global_atom_index) { - int ielec,ivdw; - real qq,c6,c12; + int ielec, ivdw; + real qq, c6, c12; rvec dx; ivec dt; - int i,j,itype,ai,aj,gid; + int i, j, itype, ai, aj, gid; int fshift_index; - real r2,rinv; - real fscal,velec,vvdw; + real r2, rinv; + real fscal, velec, vvdw; real * energygrp_elec; real * energygrp_vdw; - static gmx_bool warned_rlimit=FALSE; + static gmx_bool warned_rlimit = FALSE; /* Free energy stuff */ gmx_bool bFreeEnergy; - real LFC[2],LFV[2],DLF[2],lfac_coul[2],lfac_vdw[2],dlfac_coul[2],dlfac_vdw[2]; - real qqB,c6B,c12B,sigma2_def,sigma2_min; - - - switch (ftype) { + real LFC[2], LFV[2], DLF[2], lfac_coul[2], lfac_vdw[2], dlfac_coul[2], dlfac_vdw[2]; + real qqB, c6B, c12B, sigma2_def, sigma2_min; + + + switch (ftype) + { case F_LJ14: case F_LJC14_Q: energygrp_elec = grppener->ener[egCOUL14]; @@ -531,11 +533,11 @@ do_nonbonded_listed(int ftype,int nbonds, default: energygrp_elec = NULL; /* Keep compiler happy */ energygrp_vdw = NULL; /* Keep compiler happy */ - gmx_fatal(FARGS,"Unknown function type %d in do_nonbonded14",ftype); + gmx_fatal(FARGS, "Unknown function type %d in do_nonbonded14", ftype); break; } - - if(fr->efep != efepNO) + + if (fr->efep != efepNO) { /* Lambda factor for state A=1-lambda and B=lambda */ LFC[0] = 1.0 - lambda[efptCOUL]; @@ -548,15 +550,15 @@ do_nonbonded_listed(int ftype,int nbonds, DLF[1] = 1; /* precalculate */ - sigma2_def = pow(fr->sc_sigma6_def,1.0/3.0); - sigma2_min = pow(fr->sc_sigma6_min,1.0/3.0); + sigma2_def = pow(fr->sc_sigma6_def, 1.0/3.0); + sigma2_min = pow(fr->sc_sigma6_min, 1.0/3.0); - for (i=0;i<2;i++) + for (i = 0; i < 2; i++) { - lfac_coul[i] = (fr->sc_power==2 ? (1-LFC[i])*(1-LFC[i]) : (1-LFC[i])); - dlfac_coul[i] = DLF[i]*fr->sc_power/fr->sc_r_power*(fr->sc_power==2 ? (1-LFC[i]) : 1); - lfac_vdw[i] = (fr->sc_power==2 ? (1-LFV[i])*(1-LFV[i]) : (1-LFV[i])); - dlfac_vdw[i] = DLF[i]*fr->sc_power/fr->sc_r_power*(fr->sc_power==2 ? (1-LFV[i]) : 1); + lfac_coul[i] = (fr->sc_power == 2 ? (1-LFC[i])*(1-LFC[i]) : (1-LFC[i])); + dlfac_coul[i] = DLF[i]*fr->sc_power/fr->sc_r_power*(fr->sc_power == 2 ? (1-LFC[i]) : 1); + lfac_vdw[i] = (fr->sc_power == 2 ? (1-LFV[i])*(1-LFV[i]) : (1-LFV[i])); + dlfac_vdw[i] = DLF[i]*fr->sc_power/fr->sc_r_power*(fr->sc_power == 2 ? (1-LFV[i]) : 1); } } else @@ -565,21 +567,22 @@ do_nonbonded_listed(int ftype,int nbonds, } bFreeEnergy = FALSE; - for(i=0; (icENER[ai],md->cENER[aj],md->nenergrp); - + gid = GID(md->cENER[ai], md->cENER[aj], md->nenergrp); + /* Get parameters */ - switch (ftype) { + switch (ftype) + { case F_LJ14: bFreeEnergy = - (fr->efep != efepNO && - ((md->nPerturbed && (md->bPerturbed[ai] || md->bPerturbed[aj])) || - iparams[itype].lj14.c6A != iparams[itype].lj14.c6B || - iparams[itype].lj14.c12A != iparams[itype].lj14.c12B)); + (fr->efep != efepNO && + ((md->nPerturbed && (md->bPerturbed[ai] || md->bPerturbed[aj])) || + iparams[itype].lj14.c6A != iparams[itype].lj14.c6B || + iparams[itype].lj14.c12A != iparams[itype].lj14.c12B)); qq = md->chargeA[ai]*md->chargeA[aj]*fr->epsfac*fr->fudgeQQ; c6 = iparams[itype].lj14.c6A; c12 = iparams[itype].lj14.c12A; @@ -599,7 +602,7 @@ do_nonbonded_listed(int ftype,int nbonds, qq = c6 = c12 = 0; /* Keep compiler happy */ break; } - + /* To save flops in the optimized kernels, c6/c12 have 6.0/12.0 derivative prefactors * included in the general nfbp array now. This means the tables are scaled down by the * same factor, so when we use the original c6/c12 parameters from iparams[] they must @@ -607,25 +610,25 @@ do_nonbonded_listed(int ftype,int nbonds, */ c6 *= 6.0; c12 *= 12.0; - + /* Do we need to apply full periodic boundary conditions? */ - if(fr->bMolPBC==TRUE) + if (fr->bMolPBC == TRUE) { - fshift_index = pbc_dx_aiuc(pbc,x[ai],x[aj],dx); + fshift_index = pbc_dx_aiuc(pbc, x[ai], x[aj], dx); } else { fshift_index = CENTRAL; - rvec_sub(x[ai],x[aj],dx); + rvec_sub(x[ai], x[aj], dx); } r2 = norm2(dx); - if(r2>=fr->tab14.r*fr->tab14.r) + if (r2 >= fr->tab14.r*fr->tab14.r) { - if(warned_rlimit==FALSE) + if (warned_rlimit == FALSE) { - nb_listed_warning_rlimit(x,ai,aj,global_atom_index,sqrt(r2),fr->tab14.r); - warned_rlimit=TRUE; + nb_listed_warning_rlimit(x, ai, aj, global_atom_index, sqrt(r2), fr->tab14.r); + warned_rlimit = TRUE; } continue; } @@ -637,38 +640,36 @@ do_nonbonded_listed(int ftype,int nbonds, c6B = iparams[itype].lj14.c6B*6.0; c12B = iparams[itype].lj14.c12B*12.0; - fscal = nb_free_energy_evaluate_single(r2,fr->sc_r_power,fr->sc_alphacoul,fr->sc_alphavdw, - fr->tab14.scale,fr->tab14.data,qq,c6,c12,qqB,c6B,c12B, - LFC,LFV,DLF,lfac_coul,lfac_vdw,dlfac_coul,dlfac_vdw, - fr->sc_sigma6_def,fr->sc_sigma6_min,sigma2_def,sigma2_min,&velec,&vvdw,dvdl); + fscal = nb_free_energy_evaluate_single(r2, fr->sc_r_power, fr->sc_alphacoul, fr->sc_alphavdw, + fr->tab14.scale, fr->tab14.data, qq, c6, c12, qqB, c6B, c12B, + LFC, LFV, DLF, lfac_coul, lfac_vdw, dlfac_coul, dlfac_vdw, + fr->sc_sigma6_def, fr->sc_sigma6_min, sigma2_def, sigma2_min, &velec, &vvdw, dvdl); } else { /* Evaluate tabulated interaction without free energy */ - fscal = nb_evaluate_single(r2,fr->tab14.scale,fr->tab14.data,qq,c6,c12,&velec,&vvdw); + fscal = nb_evaluate_single(r2, fr->tab14.scale, fr->tab14.data, qq, c6, c12, &velec, &vvdw); } energygrp_elec[gid] += velec; energygrp_vdw[gid] += vvdw; - svmul(fscal,dx,dx); + svmul(fscal, dx, dx); /* Add the forces */ - rvec_inc(f[ai],dx); - rvec_dec(f[aj],dx); + rvec_inc(f[ai], dx); + rvec_dec(f[aj], dx); if (g) { /* Correct the shift forces using the graph */ - ivec_sub(SHIFT_IVEC(g,ai),SHIFT_IVEC(g,aj),dt); + ivec_sub(SHIFT_IVEC(g, ai), SHIFT_IVEC(g, aj), dt); fshift_index = IVEC2IS(dt); } - if(fshift_index!=CENTRAL) + if (fshift_index != CENTRAL) { - rvec_inc(fshift[fshift_index],dx); - rvec_dec(fshift[CENTRAL],dx); + rvec_inc(fshift[fshift_index], dx); + rvec_dec(fshift[CENTRAL], dx); } } return 0.0; } - - diff --git a/src/gromacs/gmxlib/nrama.c b/src/gromacs/gmxlib/nrama.c index dc8307ef9b..51eb50ce72 100644 --- a/src/gromacs/gmxlib/nrama.c +++ b/src/gromacs/gmxlib/nrama.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -51,206 +51,252 @@ static const char *pp_pat[] = { "C", "N", "CA", "C", "N" }; #define NPP (sizeof(pp_pat)/sizeof(pp_pat[0])) -static int d_comp(const void *a,const void *b) +static int d_comp(const void *a, const void *b) { - t_dih *da,*db; + t_dih *da, *db; - da=(t_dih *)a; - db=(t_dih *)b; + da = (t_dih *)a; + db = (t_dih *)b; - if (da->ai[1] < db->ai[1]) - return -1; - else if (da->ai[1] == db->ai[1]) - return (da->ai[2] - db->ai[2]); - else - return 1; + if (da->ai[1] < db->ai[1]) + { + return -1; + } + else if (da->ai[1] == db->ai[1]) + { + return (da->ai[2] - db->ai[2]); + } + else + { + return 1; + } } static void calc_dihs(t_xrama *xr) { - int i,t1,t2,t3; - rvec r_ij,r_kj,r_kl,m,n; - real sign; - t_dih *dd; - gmx_rmpbc_t gpbc=NULL; - - gpbc = gmx_rmpbc_init(xr->idef,xr->ePBC,xr->natoms,xr->box); - gmx_rmpbc(gpbc,xr->natoms,xr->box,xr->x); - gmx_rmpbc_done(gpbc); - - for(i=0; (indih); i++) { - dd=&(xr->dih[i]); - dd->ang=dih_angle(xr->x[dd->ai[0]],xr->x[dd->ai[1]], - xr->x[dd->ai[2]],xr->x[dd->ai[3]], - NULL, - r_ij,r_kj,r_kl,m,n,&sign,&t1,&t2,&t3); - } + int i, t1, t2, t3; + rvec r_ij, r_kj, r_kl, m, n; + real sign; + t_dih *dd; + gmx_rmpbc_t gpbc = NULL; + + gpbc = gmx_rmpbc_init(xr->idef, xr->ePBC, xr->natoms, xr->box); + gmx_rmpbc(gpbc, xr->natoms, xr->box, xr->x); + gmx_rmpbc_done(gpbc); + + for (i = 0; (i < xr->ndih); i++) + { + dd = &(xr->dih[i]); + dd->ang = dih_angle(xr->x[dd->ai[0]], xr->x[dd->ai[1]], + xr->x[dd->ai[2]], xr->x[dd->ai[3]], + NULL, + r_ij, r_kj, r_kl, m, n, &sign, &t1, &t2, &t3); + } } gmx_bool new_data(t_xrama *xr) { - if (!read_next_x(xr->oenv,xr->traj,&xr->t,xr->natoms,xr->x,xr->box)) - return FALSE; + if (!read_next_x(xr->oenv, xr->traj, &xr->t, xr->natoms, xr->x, xr->box)) + { + return FALSE; + } - calc_dihs(xr); + calc_dihs(xr); - return TRUE; + return TRUE; } -static int find_atom(const char *find,char ***names,int start,int nr) +static int find_atom(const char *find, char ***names, int start, int nr) { - int i; + int i; - for(i=start; (idih,xr->ndih+2); - for(i=0; (i<4); i++) - xr->dih[xr->ndih].ai[i]=ff[i]; - for(i=0; (i<4); i++) - xr->dih[xr->ndih+1].ai[i]=ff[i+1]; - xr->ndih+=2; - - srenew(xr->pp,xr->npp+1); - xr->pp[xr->npp].iphi=xr->ndih-2; - xr->pp[xr->npp].ipsi=xr->ndih-1; - xr->pp[xr->npp].bShow=FALSE; - sprintf(buf,"%s-%d",*atoms->resinfo[atoms->atom[ff[1]].resind].name, - atoms->resinfo[atoms->atom[ff[1]].resind].nr); - xr->pp[xr->npp].label=strdup(buf); - xr->npp++; -} - -static void get_dih(t_xrama *xr,t_atoms *atoms) + char buf[12]; + int i; + + srenew(xr->dih, xr->ndih+2); + for (i = 0; (i < 4); i++) + { + xr->dih[xr->ndih].ai[i] = ff[i]; + } + for (i = 0; (i < 4); i++) + { + xr->dih[xr->ndih+1].ai[i] = ff[i+1]; + } + xr->ndih += 2; + + srenew(xr->pp, xr->npp+1); + xr->pp[xr->npp].iphi = xr->ndih-2; + xr->pp[xr->npp].ipsi = xr->ndih-1; + xr->pp[xr->npp].bShow = FALSE; + sprintf(buf, "%s-%d", *atoms->resinfo[atoms->atom[ff[1]].resind].name, + atoms->resinfo[atoms->atom[ff[1]].resind].nr); + xr->pp[xr->npp].label = strdup(buf); + xr->npp++; +} + +static void get_dih(t_xrama *xr, t_atoms *atoms) { - int found,ff[NPP]; - int i; - size_t j; - - for(i=0; (inr); ) { - found=i; - for(j=0; (jatomname,found,atoms->nr)) == -1) - break; - found=ff[j]+1; + int found, ff[NPP]; + int i; + size_t j; + + for (i = 0; (i < atoms->nr); ) + { + found = i; + for (j = 0; (j < NPP); j++) + { + if ((ff[j] = find_atom(pp_pat[j], atoms->atomname, found, atoms->nr)) == -1) + { + break; + } + found = ff[j]+1; + } + if (j != NPP) + { + break; + } + add_xr(xr, ff, atoms); + i = ff[0]+1; } - if (j != NPP) - break; - add_xr(xr,ff,atoms); - i=ff[0]+1; - } - fprintf(stderr,"Found %d phi-psi combinations\n",xr->npp); + fprintf(stderr, "Found %d phi-psi combinations\n", xr->npp); } -static int search_ff(int thisff[NPP],int ndih,int **ff) +static int search_ff(int thisff[NPP], int ndih, int **ff) { - int j,k; - gmx_bool bFound=FALSE; - - for(j=0; (jamin=xr->natoms; - xr->amax=0; - for(i=0; (indih); i++) - for(j=0; (j<4); j++) { - ai=xr->dih[i].ai[j]; - if (ai < xr->amin) - xr->amin = ai; - else if (ai > xr->amax) - xr->amax = ai; + int ai, i, j; + + xr->amin = xr->natoms; + xr->amax = 0; + for (i = 0; (i < xr->ndih); i++) + { + for (j = 0; (j < 4); j++) + { + ai = xr->dih[i].ai[j]; + if (ai < xr->amin) + { + xr->amin = ai; + } + else if (ai > xr->amax) + { + xr->amax = ai; + } + } } } -static void get_dih_props(t_xrama *xr,t_idef *idef,int mult) +static void get_dih_props(t_xrama *xr, t_idef *idef, int mult) { - int i,ft,ftype,nra; - t_iatom *ia; - t_dih *dd,key; - - ia=idef->il[F_PDIHS].iatoms; - for (i=0; (iil[F_PDIHS].nr); ) { - ft=ia[0]; - ftype=idef->functype[ft]; - nra=interaction_function[ftype].nratoms; - - if (ftype != F_PDIHS) - gmx_incons("ftype is not a dihedral"); - - key.ai[1]=ia[2]; - key.ai[2]=ia[3]; - if ((dd = (t_dih *)bsearch(&key,xr->dih,xr->ndih,(size_t)sizeof(key),d_comp)) - != NULL) { - dd->mult=idef->iparams[ft].pdihs.mult; - dd->phi0=idef->iparams[ft].pdihs.phiA; + int i, ft, ftype, nra; + t_iatom *ia; + t_dih *dd, key; + + ia = idef->il[F_PDIHS].iatoms; + for (i = 0; (i < idef->il[F_PDIHS].nr); ) + { + ft = ia[0]; + ftype = idef->functype[ft]; + nra = interaction_function[ftype].nratoms; + + if (ftype != F_PDIHS) + { + gmx_incons("ftype is not a dihedral"); + } + + key.ai[1] = ia[2]; + key.ai[2] = ia[3]; + if ((dd = (t_dih *)bsearch(&key, xr->dih, xr->ndih, (size_t)sizeof(key), d_comp)) + != NULL) + { + dd->mult = idef->iparams[ft].pdihs.mult; + dd->phi0 = idef->iparams[ft].pdihs.phiA; + } + + i += nra+1; + ia += nra+1; } - - i+=nra+1; - ia+=nra+1; - } - /* Fill in defaults for values not in the topology */ - for(i=0; (indih); i++) { - if (xr->dih[i].mult == 0) { - fprintf(stderr, - "Dihedral around %d,%d not found in topology. Using mult=%d\n", - xr->dih[i].ai[1],xr->dih[i].ai[2],mult); - xr->dih[i].mult=mult; - xr->dih[i].phi0=180; + /* Fill in defaults for values not in the topology */ + for (i = 0; (i < xr->ndih); i++) + { + if (xr->dih[i].mult == 0) + { + fprintf(stderr, + "Dihedral around %d,%d not found in topology. Using mult=%d\n", + xr->dih[i].ai[1], xr->dih[i].ai[2], mult); + xr->dih[i].mult = mult; + xr->dih[i].phi0 = 180; + } } - } } -t_topology *init_rama(const output_env_t oenv,const char *infile, - const char *topfile, t_xrama *xr,int mult) +t_topology *init_rama(const output_env_t oenv, const char *infile, + const char *topfile, t_xrama *xr, int mult) { - t_topology *top; - int ePBC; - real t; - - top=read_top(topfile,&xr->ePBC); - - /*get_dih2(xr,top->idef.functype,&(top->idef.bondeds),&(top->atoms));*/ - get_dih(xr,&(top->atoms)); - get_dih_props(xr,&(top->idef),mult); - xr->natoms=read_first_x(oenv,&xr->traj,infile,&t,&(xr->x),xr->box); - xr->idef=&(top->idef); - xr->oenv=oenv; - - min_max(xr); - calc_dihs(xr); - - return top; -} + t_topology *top; + int ePBC; + real t; + + top = read_top(topfile, &xr->ePBC); + /*get_dih2(xr,top->idef.functype,&(top->idef.bondeds),&(top->atoms));*/ + get_dih(xr, &(top->atoms)); + get_dih_props(xr, &(top->idef), mult); + xr->natoms = read_first_x(oenv, &xr->traj, infile, &t, &(xr->x), xr->box); + xr->idef = &(top->idef); + xr->oenv = oenv; + + min_max(xr); + calc_dihs(xr); + + return top; +} diff --git a/src/gromacs/gmxlib/nrjac.c b/src/gromacs/gmxlib/nrjac.c index 57f9d3b9a3..93ade98074 100644 --- a/src/gromacs/gmxlib/nrjac.c +++ b/src/gromacs/gmxlib/nrjac.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -50,143 +50,194 @@ static inline void do_rotate(double **a, int i, int j, int k, int l, double tau, double s) { double g, h; - g = a[i][j]; - h = a[k][l]; + g = a[i][j]; + h = a[k][l]; a[i][j] = g - s * (h + g * tau); a[k][l] = h + s * (g - h * tau); } - -void jacobi(double **a,int n,double d[],double **v,int *nrot) + +void jacobi(double **a, int n, double d[], double **v, int *nrot) { - int j,i; - int iq,ip; - double tresh,theta,tau,t,sm,s,h,g,c,*b,*z; + int j, i; + int iq, ip; + double tresh, theta, tau, t, sm, s, h, g, c, *b, *z; - snew(b,n); - snew(z,n); - for (ip=0; ip 4 && fabs(d[ip])+g == fabs(d[ip]) - && fabs(d[iq])+g == fabs(d[iq])) - a[ip][iq]=0.0; - else if (fabs(a[ip][iq]) > tresh) { - h=d[iq]-d[ip]; - if (fabs(h)+g == fabs(h)) - t=(a[ip][iq])/h; - else { - theta=0.5*h/(a[ip][iq]); - t=1.0/(fabs(theta)+sqrt(1.0+theta*theta)); - if (theta < 0.0) t = -t; - } - c=1.0/sqrt(1+t*t); - s=t*c; - tau=s/(1.0+c); - h=t*a[ip][iq]; - z[ip] -= h; - z[iq] += h; - d[ip] -= h; - d[iq] += h; - a[ip][iq]=0.0; - for (j=0; j 4 && fabs(d[ip])+g == fabs(d[ip]) + && fabs(d[iq])+g == fabs(d[iq])) + { + a[ip][iq] = 0.0; + } + else if (fabs(a[ip][iq]) > tresh) + { + h = d[iq]-d[ip]; + if (fabs(h)+g == fabs(h)) + { + t = (a[ip][iq])/h; + } + else + { + theta = 0.5*h/(a[ip][iq]); + t = 1.0/(fabs(theta)+sqrt(1.0+theta*theta)); + if (theta < 0.0) + { + t = -t; + } + } + c = 1.0/sqrt(1+t*t); + s = t*c; + tau = s/(1.0+c); + h = t*a[ip][iq]; + z[ip] -= h; + z[iq] += h; + d[ip] -= h; + d[iq] += h; + a[ip][iq] = 0.0; + for (j = 0; j < ip; j++) + { + do_rotate(a, j, ip, j, iq, tau, s); + } + for (j = ip+1; j < iq; j++) + { + do_rotate(a, ip, j, j, iq, tau, s); + } + for (j = iq+1; j < n; j++) + { + do_rotate(a, ip, j, iq, j, tau, s); + } + for (j = 0; j < n; j++) + { + do_rotate(v, j, ip, j, iq, tau, s); + } + ++(*nrot); + } + } + } + for (ip = 0; ip < n; ip++) + { + b[ip] += z[ip]; + d[ip] = b[ip]; + z[ip] = 0.0; } - } - } - for (ip=0; ipn[i]=0.0; + for (i = 0; (i < eNRNB); i++) + { + nrnb->n[i] = 0.0; + } } void cp_nrnb(t_nrnb *dest, t_nrnb *src) { - int i; + int i; - for(i=0; (in[i]=src->n[i]; + for (i = 0; (i < eNRNB); i++) + { + dest->n[i] = src->n[i]; + } } void add_nrnb(t_nrnb *dest, t_nrnb *s1, t_nrnb *s2) { - int i; + int i; - for(i=0; (in[i]=s1->n[i]+s2->n[i]; + for (i = 0; (i < eNRNB); i++) + { + dest->n[i] = s1->n[i]+s2->n[i]; + } } void print_nrnb(FILE *out, t_nrnb *nrnb) { - int i; + int i; - for(i=0; (in[i] > 0) - fprintf(out," %-26s %10.0f.\n",nbdata[i].name,nrnb->n[i]); + for (i = 0; (i < eNRNB); i++) + { + if (nrnb->n[i] > 0) + { + fprintf(out, " %-26s %10.0f.\n", nbdata[i].name, nrnb->n[i]); + } + } } -void _inc_nrnb(t_nrnb *nrnb,int enr,int inc,char *file,int line) +void _inc_nrnb(t_nrnb *nrnb, int enr, int inc, char *file, int line) { - nrnb->n[enr]+=inc; + nrnb->n[enr] += inc; #ifdef DEBUG_NRNB - printf("nrnb %15s(%2d) incremented with %8d from file %s line %d\n", - nbdata[enr].name,enr,inc,file,line); + printf("nrnb %15s(%2d) incremented with %8d from file %s line %d\n", + nbdata[enr].name, enr, inc, file, line); #endif } -void print_flop(FILE *out,t_nrnb *nrnb,double *nbfs,double *mflop) +void print_flop(FILE *out, t_nrnb *nrnb, double *nbfs, double *mflop) { - int i; - double mni,frac,tfrac,tflop; - const char *myline = "-----------------------------------------------------------------------------"; - - *nbfs = 0.0; - for(i=0; (in[i]; - else if (strstr(nbdata[i].name,"W3") != NULL) - *nbfs += 3e-6*nrnb->n[i]; - else if (strstr(nbdata[i].name,"W4-W4") != NULL) - *nbfs += 10e-6*nrnb->n[i]; - else if (strstr(nbdata[i].name,"W4") != NULL) - *nbfs += 4e-6*nrnb->n[i]; - else - *nbfs += 1e-6*nrnb->n[i]; - } - tflop=0; - for(i=0; (in[i]*nbdata[i].flop; - - if (tflop == 0) { - fprintf(out,"No MEGA Flopsen this time\n"); - return; - } - if (out) { - fprintf(out,"\n\tM E G A - F L O P S A C C O U N T I N G\n\n"); - } - - if (out) - { - fprintf(out," NB=Group-cutoff nonbonded kernels NxN=N-by-N cluster Verlet kernels\n"); - fprintf(out," RF=Reaction-Field VdW=Van der Waals QSTab=quadratic-spline table\n"); - fprintf(out," W3=SPC/TIP3p W4=TIP4p (single or pairs)\n"); - fprintf(out," V&F=Potential and force V=Potential only F=Force only\n\n"); - - fprintf(out," %-32s %16s %15s %7s\n", - "Computing:","M-Number","M-Flops","% Flops"); - fprintf(out,"%s\n",myline); - } - *mflop=0.0; - tfrac=0.0; - for(i=0; (in[i]; - *mflop += mni*nbdata[i].flop; - frac = 100.0*mni*nbdata[i].flop/tflop; - tfrac += frac; - if (out && mni != 0) - fprintf(out," %-32s %16.6f %15.3f %6.1f\n", - nbdata[i].name,mni,mni*nbdata[i].flop,frac); - } - if (out) { - fprintf(out,"%s\n",myline); - fprintf(out," %-32s %16s %15.3f %6.1f\n", - "Total","",*mflop,tfrac); - fprintf(out,"%s\n\n",myline); - } -} + int i; + double mni, frac, tfrac, tflop; + const char *myline = "-----------------------------------------------------------------------------"; -void print_perf(FILE *out,double nodetime,double realtime,int nprocs, - gmx_large_int_t nsteps,real delta_t, - double nbfs,double mflop, - int omp_nth_pp) -{ - real runtime; + *nbfs = 0.0; + for (i = 0; (i < eNR_NBKERNEL_ALLVSALLGB); i++) + { + if (strstr(nbdata[i].name, "W3-W3") != NULL) + { + *nbfs += 9e-6*nrnb->n[i]; + } + else if (strstr(nbdata[i].name, "W3") != NULL) + { + *nbfs += 3e-6*nrnb->n[i]; + } + else if (strstr(nbdata[i].name, "W4-W4") != NULL) + { + *nbfs += 10e-6*nrnb->n[i]; + } + else if (strstr(nbdata[i].name, "W4") != NULL) + { + *nbfs += 4e-6*nrnb->n[i]; + } + else + { + *nbfs += 1e-6*nrnb->n[i]; + } + } + tflop = 0; + for (i = 0; (i < eNRNB); i++) + { + tflop += 1e-6*nrnb->n[i]*nbdata[i].flop; + } - fprintf(out,"\n"); + if (tflop == 0) + { + fprintf(out, "No MEGA Flopsen this time\n"); + return; + } + if (out) + { + fprintf(out, "\n\tM E G A - F L O P S A C C O U N T I N G\n\n"); + } - if (realtime > 0) - { - fprintf(out,"%12s %12s %12s %10s\n","","Core t (s)","Wall t (s)","(%)"); - fprintf(out,"%12s %12.3f %12.3f %10.1f\n","Time:", - nodetime, realtime, 100.0*nodetime/realtime); - /* only print day-hour-sec format if realtime is more than 30 min */ - if (realtime > 30*60) + if (out) { - fprintf(out,"%12s %12s","",""); - pr_difftime(out,realtime); + fprintf(out, " NB=Group-cutoff nonbonded kernels NxN=N-by-N cluster Verlet kernels\n"); + fprintf(out, " RF=Reaction-Field VdW=Van der Waals QSTab=quadratic-spline table\n"); + fprintf(out, " W3=SPC/TIP3p W4=TIP4p (single or pairs)\n"); + fprintf(out, " V&F=Potential and force V=Potential only F=Force only\n\n"); + + fprintf(out, " %-32s %16s %15s %7s\n", + "Computing:", "M-Number", "M-Flops", "% Flops"); + fprintf(out, "%s\n", myline); } - if (delta_t > 0) + *mflop = 0.0; + tfrac = 0.0; + for (i = 0; (i < eNRNB); i++) { - mflop = mflop/realtime; - runtime = nsteps*delta_t; - - if (getenv("GMX_DETAILED_PERF_STATS") == NULL) - { - fprintf(out,"%12s %12s %12s\n", - "","(ns/day)","(hour/ns)"); - fprintf(out,"%12s %12.3f %12.3f\n","Performance:", - runtime*24*3.6/realtime,1000*realtime/(3600*runtime)); - } - else - { - fprintf(out,"%12s %12s %12s %12s %12s\n", - "","(Mnbf/s)",(mflop > 1000) ? "(GFlops)" : "(MFlops)", - "(ns/day)","(hour/ns)"); - fprintf(out,"%12s %12.3f %12.3f %12.3f %12.3f\n","Performance:", - nbfs/realtime,(mflop > 1000) ? (mflop/1000) : mflop, - runtime*24*3.6/realtime,1000*realtime/(3600*runtime)); - } - } - else + mni = 1e-6*nrnb->n[i]; + *mflop += mni*nbdata[i].flop; + frac = 100.0*mni*nbdata[i].flop/tflop; + tfrac += frac; + if (out && mni != 0) + { + fprintf(out, " %-32s %16.6f %15.3f %6.1f\n", + nbdata[i].name, mni, mni*nbdata[i].flop, frac); + } + } + if (out) { - if (getenv("GMX_DETAILED_PERF_STATS") == NULL) - { - fprintf(out,"%12s %14s\n", - "","(steps/hour)"); - fprintf(out,"%12s %14.1f\n","Performance:", - nsteps*3600.0/realtime); - } - else - { - fprintf(out,"%12s %12s %12s %14s\n", - "","(Mnbf/s)",(mflop > 1000) ? "(GFlops)" : "(MFlops)", - "(steps/hour)"); - fprintf(out,"%12s %12.3f %12.3f %14.1f\n","Performance:", - nbfs/realtime,(mflop > 1000) ? (mflop/1000) : mflop, - nsteps*3600.0/realtime); - } + fprintf(out, "%s\n", myline); + fprintf(out, " %-32s %16s %15.3f %6.1f\n", + "Total", "", *mflop, tfrac); + fprintf(out, "%s\n\n", myline); + } +} + +void print_perf(FILE *out, double nodetime, double realtime, int nprocs, + gmx_large_int_t nsteps, real delta_t, + double nbfs, double mflop, + int omp_nth_pp) +{ + real runtime; + + fprintf(out, "\n"); + + if (realtime > 0) + { + fprintf(out, "%12s %12s %12s %10s\n", "", "Core t (s)", "Wall t (s)", "(%)"); + fprintf(out, "%12s %12.3f %12.3f %10.1f\n", "Time:", + nodetime, realtime, 100.0*nodetime/realtime); + /* only print day-hour-sec format if realtime is more than 30 min */ + if (realtime > 30*60) + { + fprintf(out, "%12s %12s", "", ""); + pr_difftime(out, realtime); + } + if (delta_t > 0) + { + mflop = mflop/realtime; + runtime = nsteps*delta_t; + + if (getenv("GMX_DETAILED_PERF_STATS") == NULL) + { + fprintf(out, "%12s %12s %12s\n", + "", "(ns/day)", "(hour/ns)"); + fprintf(out, "%12s %12.3f %12.3f\n", "Performance:", + runtime*24*3.6/realtime, 1000*realtime/(3600*runtime)); + } + else + { + fprintf(out, "%12s %12s %12s %12s %12s\n", + "", "(Mnbf/s)", (mflop > 1000) ? "(GFlops)" : "(MFlops)", + "(ns/day)", "(hour/ns)"); + fprintf(out, "%12s %12.3f %12.3f %12.3f %12.3f\n", "Performance:", + nbfs/realtime, (mflop > 1000) ? (mflop/1000) : mflop, + runtime*24*3.6/realtime, 1000*realtime/(3600*runtime)); + } + } + else + { + if (getenv("GMX_DETAILED_PERF_STATS") == NULL) + { + fprintf(out, "%12s %14s\n", + "", "(steps/hour)"); + fprintf(out, "%12s %14.1f\n", "Performance:", + nsteps*3600.0/realtime); + } + else + { + fprintf(out, "%12s %12s %12s %14s\n", + "", "(Mnbf/s)", (mflop > 1000) ? "(GFlops)" : "(MFlops)", + "(steps/hour)"); + fprintf(out, "%12s %12.3f %12.3f %14.1f\n", "Performance:", + nbfs/realtime, (mflop > 1000) ? (mflop/1000) : mflop, + nsteps*3600.0/realtime); + } + } } - } } int cost_nrnb(int enr) { - return nbdata[enr].flop; + return nbdata[enr].flop; } const char *nrnb_str(int enr) { - return nbdata[enr].name; + return nbdata[enr].name; } -static const int force_index[]={ - eNR_BONDS, eNR_ANGLES, eNR_PROPER, eNR_IMPROPER, - eNR_RB, eNR_DISRES, eNR_ORIRES, eNR_POSRES, - eNR_FBPOSRES, eNR_NS, +static const int force_index[] = { + eNR_BONDS, eNR_ANGLES, eNR_PROPER, eNR_IMPROPER, + eNR_RB, eNR_DISRES, eNR_ORIRES, eNR_POSRES, + eNR_FBPOSRES, eNR_NS, }; #define NFORCE_INDEX asize(force_index) -static const int constr_index[]={ - eNR_SHAKE, eNR_SHAKE_RIJ, eNR_SETTLE, eNR_UPDATE, eNR_PCOUPL, - eNR_CONSTR_VIR,eNR_CONSTR_V +static const int constr_index[] = { + eNR_SHAKE, eNR_SHAKE_RIJ, eNR_SETTLE, eNR_UPDATE, eNR_PCOUPL, + eNR_CONSTR_VIR, eNR_CONSTR_V }; #define NCONSTR_INDEX asize(constr_index) -static double pr_av(FILE *log,t_commrec *cr, - double fav,double ftot[],const char *title) +static double pr_av(FILE *log, t_commrec *cr, + double fav, double ftot[], const char *title) { - int i,perc; - double dperc,unb; - - unb=0; - if (fav > 0) { - fav /= cr->nnodes - cr->npmenodes; - fprintf(log,"\n %-26s",title); - for(i=0; (innodes); i++) { - dperc=(100.0*ftot[i])/fav; - unb=max(unb,dperc); - perc=dperc; - fprintf(log,"%3d ",perc); - } - if (unb > 0) { - perc=10000.0/unb; - fprintf(log,"%6d%%\n\n",perc); + int i, perc; + double dperc, unb; + + unb = 0; + if (fav > 0) + { + fav /= cr->nnodes - cr->npmenodes; + fprintf(log, "\n %-26s", title); + for (i = 0; (i < cr->nnodes); i++) + { + dperc = (100.0*ftot[i])/fav; + unb = max(unb, dperc); + perc = dperc; + fprintf(log, "%3d ", perc); + } + if (unb > 0) + { + perc = 10000.0/unb; + fprintf(log, "%6d%%\n\n", perc); + } + else + { + fprintf(log, "\n\n"); + } } - else - fprintf(log,"\n\n"); - } - return unb; + return unb; } -void pr_load(FILE *log,t_commrec *cr,t_nrnb nrnb[]) +void pr_load(FILE *log, t_commrec *cr, t_nrnb nrnb[]) { - int i,j,perc; - double dperc,unb,uf,us; - double *ftot,fav; - double *stot,sav; - t_nrnb *av; - - snew(av,1); - snew(ftot,cr->nnodes); - snew(stot,cr->nnodes); - init_nrnb(av); - for(i=0; (innodes); i++) { - add_nrnb(av,av,&(nrnb[i])); - /* Cost due to forces */ - for(j=0; (jn[j]=av->n[j]/(double)(cr->nnodes - cr->npmenodes); - - fprintf(log,"\nDetailed load balancing info in percentage of average\n"); - - fprintf(log," Type NODE:"); - for(i=0; (innodes); i++) - fprintf(log,"%3d ",i); - fprintf(log,"Scaling\n"); - fprintf(log,"---------------------------"); - for(i=0; (innodes); i++) - fprintf(log,"----"); - fprintf(log,"-------\n"); - - for(j=0; (jn[j] > 0) { - fprintf(log," %-26s",nrnb_str(j)); - for(i=0; (innodes); i++) { - dperc=(100.0*nrnb[i].n[j])/av->n[j]; - unb=max(unb,dperc); - perc=dperc; - fprintf(log,"%3d ",perc); - } - if (unb > 0) { - perc=10000.0/unb; - fprintf(log,"%6d%%\n",perc); - } - else - fprintf(log,"\n"); - } - } - fav=sav=0; - for(i=0; (innodes); i++) { - fav+=ftot[i]; - sav+=stot[i]; - } - uf=pr_av(log,cr,fav,ftot,"Total Force"); - us=pr_av(log,cr,sav,stot,"Total Constr."); - - unb=(uf*fav+us*sav)/(fav+sav); - if (unb > 0) { - unb=10000.0/unb; - fprintf(log,"\nTotal Scaling: %.0f%% of max performance\n\n",unb); - } -} + int i, j, perc; + double dperc, unb, uf, us; + double *ftot, fav; + double *stot, sav; + t_nrnb *av; + + snew(av, 1); + snew(ftot, cr->nnodes); + snew(stot, cr->nnodes); + init_nrnb(av); + for (i = 0; (i < cr->nnodes); i++) + { + add_nrnb(av, av, &(nrnb[i])); + /* Cost due to forces */ + for (j = 0; (j < eNR_NBKERNEL_ALLVSALLGB); j++) + { + ftot[i] += nrnb[i].n[j]*cost_nrnb(j); + } + for (j = 0; (j < NFORCE_INDEX); j++) + { + ftot[i] += nrnb[i].n[force_index[j]]*cost_nrnb(force_index[j]); + } + /* Due to shake */ + for (j = 0; (j < NCONSTR_INDEX); j++) + { + stot[i] += nrnb[i].n[constr_index[j]]*cost_nrnb(constr_index[j]); + } + } + for (j = 0; (j < eNRNB); j++) + { + av->n[j] = av->n[j]/(double)(cr->nnodes - cr->npmenodes); + } + + fprintf(log, "\nDetailed load balancing info in percentage of average\n"); + fprintf(log, " Type NODE:"); + for (i = 0; (i < cr->nnodes); i++) + { + fprintf(log, "%3d ", i); + } + fprintf(log, "Scaling\n"); + fprintf(log, "---------------------------"); + for (i = 0; (i < cr->nnodes); i++) + { + fprintf(log, "----"); + } + fprintf(log, "-------\n"); + + for (j = 0; (j < eNRNB); j++) + { + unb = 100.0; + if (av->n[j] > 0) + { + fprintf(log, " %-26s", nrnb_str(j)); + for (i = 0; (i < cr->nnodes); i++) + { + dperc = (100.0*nrnb[i].n[j])/av->n[j]; + unb = max(unb, dperc); + perc = dperc; + fprintf(log, "%3d ", perc); + } + if (unb > 0) + { + perc = 10000.0/unb; + fprintf(log, "%6d%%\n", perc); + } + else + { + fprintf(log, "\n"); + } + } + } + fav = sav = 0; + for (i = 0; (i < cr->nnodes); i++) + { + fav += ftot[i]; + sav += stot[i]; + } + uf = pr_av(log, cr, fav, ftot, "Total Force"); + us = pr_av(log, cr, sav, stot, "Total Constr."); + + unb = (uf*fav+us*sav)/(fav+sav); + if (unb > 0) + { + unb = 10000.0/unb; + fprintf(log, "\nTotal Scaling: %.0f%% of max performance\n\n", unb); + } +} diff --git a/src/gromacs/gmxlib/oenv.cpp b/src/gromacs/gmxlib/oenv.cpp index 9a88904c64..11c2d5c525 100644 --- a/src/gromacs/gmxlib/oenv.cpp +++ b/src/gromacs/gmxlib/oenv.cpp @@ -1,35 +1,35 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -63,14 +63,14 @@ struct output_env gmx::ProgramInfo programInfo; - time_unit_t time_unit; /* the time unit, enum defined in oenv.h */ - gmx_bool view; /* view of file requested */ - xvg_format_t xvg_format; /* xvg output format, enum defined in oenv.h */ - int verbosity; /* The level of verbosity for this program */ - int debug_level; /* the debug level */ + time_unit_t time_unit; /* the time unit, enum defined in oenv.h */ + gmx_bool view; /* view of file requested */ + xvg_format_t xvg_format; /* xvg output format, enum defined in oenv.h */ + int verbosity; /* The level of verbosity for this program */ + int debug_level; /* the debug level */ }; -/* The source code in this file should be thread-safe. +/* The source code in this file should be thread-safe. Please keep it that way. */ /****************************************************************** @@ -81,12 +81,16 @@ struct output_env /* read only time names */ /* These must correspond to the time units type time_unit_t in oenv.h */ -static const real timefactors[] = { 0, 1e3, 1, 1e-3, 1e-6, 1e-9, 1e-12, 0 }; -static const real timeinvfactors[] ={ 0, 1e-3, 1, 1e3, 1e6, 1e9, 1e12, 0 }; -static const char *time_units_str[] = { NULL, "fs", "ps", "ns", "us", - "\\mus", "ms", "s" }; -static const char *time_units_xvgr[] = { NULL, "fs", "ps", "ns", - "ms", "s", NULL }; +static const real timefactors[] = { 0, 1e3, 1, 1e-3, 1e-6, 1e-9, 1e-12, 0 }; +static const real timeinvfactors[] = { 0, 1e-3, 1, 1e3, 1e6, 1e9, 1e12, 0 }; +static const char *time_units_str[] = { + NULL, "fs", "ps", "ns", "us", + "\\mus", "ms", "s" +}; +static const char *time_units_xvgr[] = { + NULL, "fs", "ps", "ns", + "ms", "s", NULL +}; /***** OUTPUT_ENV MEMBER FUNCTIONS ******/ @@ -98,7 +102,7 @@ void output_env_init(output_env_t *oenvp, int argc, char *argv[], try { output_env_t oenv = new output_env(argc, argv); - *oenvp = oenv; + *oenvp = oenv; oenv->time_unit = tmu; oenv->view = view; oenv->xvg_format = xvg_format; @@ -143,10 +147,10 @@ const char *output_env_get_time_label(const output_env_t oenv) { char *label; snew(label, 20); - - sprintf(label,"Time (%s)",time_units_str[oenv->time_unit] ? - time_units_str[oenv->time_unit]: "ps"); - + + sprintf(label, "Time (%s)", time_units_str[oenv->time_unit] ? + time_units_str[oenv->time_unit] : "ps"); + return label; } @@ -154,10 +158,10 @@ const char *output_env_get_xvgr_tlabel(const output_env_t oenv) { char *label; snew(label, 20); - - sprintf(label,"Time (%s)", time_units_xvgr[oenv->time_unit] ? + + sprintf(label, "Time (%s)", time_units_xvgr[oenv->time_unit] ? time_units_xvgr[oenv->time_unit] : "ps"); - + return label; } @@ -178,12 +182,16 @@ real output_env_conv_time(const output_env_t oenv, real time) void output_env_conv_times(const output_env_t oenv, int n, real *time) { - int i; - double fact=timefactors[oenv->time_unit]; - - if (fact!=1.) - for(i=0; itime_unit]; + + if (fact != 1.) + { + for (i = 0; i < n; i++) + { time[i] *= fact; + } + } } gmx_bool output_env_get_view(const output_env_t oenv) diff --git a/src/gromacs/gmxlib/orires.c b/src/gromacs/gmxlib/orires.c index 9fa8a05b48..4ac89a04e1 100644 --- a/src/gromacs/gmxlib/orires.c +++ b/src/gromacs/gmxlib/orires.c @@ -1,12 +1,12 @@ -/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- +/* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- + * * - * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -49,62 +49,62 @@ #include "pbc.h" #include "mtop_util.h" -void init_orires(FILE *fplog,const gmx_mtop_t *mtop, +void init_orires(FILE *fplog, const gmx_mtop_t *mtop, rvec xref[], const t_inputrec *ir, - const gmx_multisim_t *ms,t_oriresdata *od, + const gmx_multisim_t *ms, t_oriresdata *od, t_state *state) { - int i,j,d,ex,nmol,nr,*nr_ex; - double mtot; - rvec com; - gmx_mtop_ilistloop_t iloop; - t_ilist *il; + int i, j, d, ex, nmol, nr, *nr_ex; + double mtot; + rvec com; + gmx_mtop_ilistloop_t iloop; + t_ilist *il; gmx_mtop_atomloop_all_t aloop; - t_atom *atom; + t_atom *atom; od->fc = ir->orires_fc; od->nex = 0; od->S = NULL; - od->M=NULL; - od->eig=NULL; - od->v=NULL; + od->M = NULL; + od->eig = NULL; + od->v = NULL; - od->nr = gmx_mtop_ftype_count(mtop,F_ORIRES); + od->nr = gmx_mtop_ftype_count(mtop, F_ORIRES); if (od->nr == 0) { return; } - + nr_ex = NULL; - + iloop = gmx_mtop_ilistloop_init(mtop); - while (gmx_mtop_ilistloop_next(iloop,&il,&nmol)) + while (gmx_mtop_ilistloop_next(iloop, &il, &nmol)) { - for(i=0; iffparams.iparams[il[F_ORIRES].iatoms[i]].orires.ex; if (ex >= od->nex) { - srenew(nr_ex,ex+1); - for(j=od->nex; jnex; j < ex+1; j++) { nr_ex[j] = 0; - } + } od->nex = ex+1; } nr_ex[ex]++; } } - snew(od->S,od->nex); + snew(od->S, od->nex); /* When not doing time averaging, the instaneous and time averaged data * are indentical and the pointers can point to the same memory. */ - snew(od->Dinsl,od->nr); + snew(od->Dinsl, od->nr); if (ms) { - snew(od->Dins,od->nr); + snew(od->Dins, od->nr); } else { @@ -113,84 +113,85 @@ void init_orires(FILE *fplog,const gmx_mtop_t *mtop, if (ir->orires_tau == 0) { - od->Dtav = od->Dins; - od->edt = 0.0; - od->edt_1= 1.0; + od->Dtav = od->Dins; + od->edt = 0.0; + od->edt_1 = 1.0; } else { - snew(od->Dtav,od->nr); - od->edt = exp(-ir->delta_t/ir->orires_tau); - od->edt_1= 1.0 - od->edt; + snew(od->Dtav, od->nr); + od->edt = exp(-ir->delta_t/ir->orires_tau); + od->edt_1 = 1.0 - od->edt; /* Extend the state with the orires history */ - state->flags |= (1<flags |= (1<hist.orire_initf = 1; - state->flags |= (1<flags |= (1<hist.norire_Dtav = od->nr*5; - snew(state->hist.orire_Dtav,state->hist.norire_Dtav); + snew(state->hist.orire_Dtav, state->hist.norire_Dtav); } - snew(od->oinsl,od->nr); + snew(od->oinsl, od->nr); if (ms) { - snew(od->oins,od->nr); + snew(od->oins, od->nr); } else { od->oins = od->oinsl; } - if (ir->orires_tau == 0) { + if (ir->orires_tau == 0) + { od->otav = od->oins; } else { - snew(od->otav,od->nr); + snew(od->otav, od->nr); } - snew(od->tmp,od->nex); - snew(od->TMP,od->nex); - for(ex=0; exnex; ex++) + snew(od->tmp, od->nex); + snew(od->TMP, od->nex); + for (ex = 0; ex < od->nex; ex++) { - snew(od->TMP[ex],5); - for(i=0; i<5; i++) + snew(od->TMP[ex], 5); + for (i = 0; i < 5; i++) { - snew(od->TMP[ex][i],5); + snew(od->TMP[ex][i], 5); } } - + od->nref = 0; - for(i=0; inatoms; i++) + for (i = 0; i < mtop->natoms; i++) { - if (ggrpnr(&mtop->groups,egcORFIT,i) == 0) + if (ggrpnr(&mtop->groups, egcORFIT, i) == 0) { od->nref++; } } - snew(od->mref,od->nref); - snew(od->xref,od->nref); - snew(od->xtmp,od->nref); - - snew(od->eig,od->nex*12); - + snew(od->mref, od->nref); + snew(od->xref, od->nref); + snew(od->xtmp, od->nref); + + snew(od->eig, od->nex*12); + /* Determine the reference structure on the master node. * Copy it to the other nodes after checking multi compatibility, * so we are sure the subsystems match before copying. */ clear_rvec(com); - mtot = 0.0; - j = 0; + mtot = 0.0; + j = 0; aloop = gmx_mtop_atomloop_all_init(mtop); - while(gmx_mtop_atomloop_all_next(aloop,&i,&atom)) + while (gmx_mtop_atomloop_all_next(aloop, &i, &atom)) { if (mtop->groups.grpnr[egcORFIT] == NULL || mtop->groups.grpnr[egcORFIT][i] == 0) { /* Not correct for free-energy with changing masses */ od->mref[j] = atom->m; - if (ms==NULL || MASTERSIM(ms)) + if (ms == NULL || MASTERSIM(ms)) { - copy_rvec(xref[i],od->xref[j]); - for(d=0; dxref[j]); + for (d = 0; d < DIM; d++) { com[d] += od->mref[j]*xref[i][d]; } @@ -199,103 +200,103 @@ void init_orires(FILE *fplog,const gmx_mtop_t *mtop, j++; } } - svmul(1.0/mtot,com,com); - if (ms==NULL || MASTERSIM(ms)) + svmul(1.0/mtot, com, com); + if (ms == NULL || MASTERSIM(ms)) { - for(j=0; jnref; j++) + for (j = 0; j < od->nref; j++) { - rvec_dec(od->xref[j],com); + rvec_dec(od->xref[j], com); } } - - fprintf(fplog,"Found %d orientation experiments\n",od->nex); - for(i=0; inex; i++) + + fprintf(fplog, "Found %d orientation experiments\n", od->nex); + for (i = 0; i < od->nex; i++) { - fprintf(fplog," experiment %d has %d restraints\n",i+1,nr_ex[i]); + fprintf(fplog, " experiment %d has %d restraints\n", i+1, nr_ex[i]); } - + sfree(nr_ex); - - fprintf(fplog," the fit group consists of %d atoms and has total mass %g\n", - od->nref,mtot); - + + fprintf(fplog, " the fit group consists of %d atoms and has total mass %g\n", + od->nref, mtot); + if (ms) { - fprintf(fplog," the orientation restraints are ensemble averaged over %d systems\n",ms->nsim); - - check_multi_int(fplog,ms,od->nr, + fprintf(fplog, " the orientation restraints are ensemble averaged over %d systems\n", ms->nsim); + + check_multi_int(fplog, ms, od->nr, "the number of orientation restraints", FALSE); - check_multi_int(fplog,ms,od->nref, + check_multi_int(fplog, ms, od->nref, "the number of fit atoms for orientation restraining", FALSE); - check_multi_int(fplog,ms,ir->nsteps,"nsteps",FALSE); + check_multi_int(fplog, ms, ir->nsteps, "nsteps", FALSE); /* Copy the reference coordinates from the master to the other nodes */ - gmx_sum_sim(DIM*od->nref,od->xref[0],ms); + gmx_sum_sim(DIM*od->nref, od->xref[0], ms); } - - please_cite(fplog,"Hess2003"); + + please_cite(fplog, "Hess2003"); } void diagonalize_orires_tensors(t_oriresdata *od) { - int ex,i,j,nrot,ord[DIM],t; - matrix S,TMP; - + int ex, i, j, nrot, ord[DIM], t; + matrix S, TMP; + if (od->M == NULL) { - snew(od->M,DIM); - for(i=0; iM, DIM); + for (i = 0; i < DIM; i++) { - snew(od->M[i],DIM); + snew(od->M[i], DIM); } - snew(od->eig_diag,DIM); - snew(od->v,DIM); - for(i=0; ieig_diag, DIM); + snew(od->v, DIM); + for (i = 0; i < DIM; i++) { - snew(od->v[i],DIM); + snew(od->v[i], DIM); } } - for(ex=0; exnex; ex++) + for (ex = 0; ex < od->nex; ex++) { /* Rotate the S tensor back to the reference frame */ - mmul(od->R,od->S[ex],TMP); - mtmul(TMP,od->R,S); - for(i=0; iR, od->S[ex], TMP); + mtmul(TMP, od->R, S); + for (i = 0; i < DIM; i++) { - for(j=0; jM[i][j] = S[i][j]; } } - - jacobi(od->M,DIM,od->eig_diag,od->v,&nrot); - - for(i=0; iM, DIM, od->eig_diag, od->v, &nrot); + + for (i = 0; i < DIM; i++) { ord[i] = i; } - for(i=0; ieig_diag[ord[j]]) > sqr(od->eig_diag[ord[i]])) { - t = ord[i]; + t = ord[i]; ord[i] = ord[j]; ord[j] = t; } } } - - for(i=0; ieig[ex*12 + i] = od->eig_diag[ord[i]]; } - for(i=0; ieig[ex*12 + 3 + 3*i + j] = od->v[j][ord[i]]; } @@ -303,72 +304,72 @@ void diagonalize_orires_tensors(t_oriresdata *od) } } -void print_orires_log(FILE *log,t_oriresdata *od) +void print_orires_log(FILE *log, t_oriresdata *od) { - int ex,i; - real *eig; - + int ex, i; + real *eig; + diagonalize_orires_tensors(od); - - for(ex=0; exnex; ex++) + + for (ex = 0; ex < od->nex; ex++) { eig = od->eig + ex*12; - fprintf(log," Orientation experiment %d:\n",ex+1); - fprintf(log," order parameter: %g\n",eig[0]); - for(i=0; iorires); if (od->nr == 0) { /* This means that this is not the master node */ - gmx_fatal(FARGS,"Orientation restraints are only supported on the master node, use less processors"); - } - - bTAV = (od->edt != 0); - edt = od->edt; - edt_1= od->edt_1; - S = od->S; - Dinsl= od->Dinsl; - Dins = od->Dins; - Dtav = od->Dtav; - T = od->TMP; - rhs = od->tmp; - nref = od->nref; - mref = od->mref; - xref = od->xref; - xtmp = od->xtmp; - + gmx_fatal(FARGS, "Orientation restraints are only supported on the master node, use less processors"); + } + + bTAV = (od->edt != 0); + edt = od->edt; + edt_1 = od->edt_1; + S = od->S; + Dinsl = od->Dinsl; + Dins = od->Dins; + Dtav = od->Dtav; + T = od->TMP; + rhs = od->tmp; + nref = od->nref; + mref = od->mref; + xref = od->xref; + xtmp = od->xtmp; + if (bTAV) { od->exp_min_t_tau = hist->orire_initf*edt; - + /* Correction factor to correct for the lack of history * at short times. */ @@ -387,17 +388,17 @@ real calc_orires_dev(const gmx_multisim_t *ms, { invn = 1.0; } - + clear_rvec(com); mtot = 0; - j=0; - for(i=0; inr; i++) + j = 0; + for (i = 0; i < md->nr; i++) { if (md->cORF[i] == 0) { - copy_rvec(x[i],xtmp[j]); + copy_rvec(x[i], xtmp[j]); mref[j] = md->massT[i]; - for(d=0; dR); - + calc_fit_R(DIM, nref, mref, xref, xtmp, R); + copy_mat(R, od->R); + d = 0; - for(fa=0; fanr,Dins[0],ms); + gmx_sum_sim(5*od->nr, Dins[0], ms); } - + /* Calculate the order tensor S for each experiment via optimization */ - for(ex=0; exnex; ex++) + for (ex = 0; ex < od->nex; ex++) { - for(i=0; i<5; i++) + for (i = 0; i < 5; i++) { rhs[ex][i] = 0; - for(j=0; j<=i; j++) + for (j = 0; j <= i; j++) { T[ex][i][j] = 0; } } } d = 0; - for(fa=0; faorire_Dtav[d*5+i] + edt_1*Dins[d][i]; } } - + type = forceatoms[fa]; ex = ip[type].orires.ex; weight = ip[type].orires.kfac; /* Calculate the vector rhs and half the matrix T for the 5 equations */ - for(i=0; i<5; i++) { + for (i = 0; i < 5; i++) + { rhs[ex][i] += Dtav[d][i]*ip[type].orires.obs*weight; - for(j=0; j<=i; j++) + for (j = 0; j <= i; j++) { T[ex][i][j] += Dtav[d][i]*Dtav[d][j]*weight; } @@ -498,27 +500,27 @@ real calc_orires_dev(const gmx_multisim_t *ms, d++; } /* Now we have all the data we can calculate S */ - for(ex=0; exnex; ex++) + for (ex = 0; ex < od->nex; ex++) { /* Correct corrfac and copy one half of T to the other half */ - for(i=0; i<5; i++) + for (i = 0; i < 5; i++) { rhs[ex][i] *= corrfac; T[ex][i][i] *= sqr(corrfac); - for(j=0; jotav[d] = two_thr* corrfac*(S[ex][0][0]*Dtav[d][0] + S[ex][0][1]*Dtav[d][1] + S[ex][0][2]*Dtav[d][2] + S[ex][1][1]*Dtav[d][3] + @@ -561,47 +563,47 @@ real calc_orires_dev(const gmx_multisim_t *ms, S[ex][0][2]*Dinsl[d][2] + S[ex][1][1]*Dinsl[d][3] + S[ex][1][2]*Dinsl[d][4]); } - + dev = od->otav[d] - ip[type].orires.obs; - + wsv2 += ip[type].orires.kfac*sqr(dev); sw += ip[type].orires.kfac; - + d++; } od->rmsdev = sqrt(wsv2/sw); - + /* Rotate the S matrices back, so we get the correct grad(tr(S D)) */ - for(ex=0; exnex; ex++) + for (ex = 0; ex < od->nex; ex++) { - tmmul(R,S[ex],TMP); - mmul(TMP,R,S[ex]); + tmmul(R, S[ex], TMP); + mmul(TMP, R, S[ex]); } - + return od->rmsdev; - + /* Approx. 120*nfa/3 flops */ } -real orires(int nfa,const t_iatom forceatoms[],const t_iparams ip[], - const rvec x[],rvec f[],rvec fshift[], - const t_pbc *pbc,const t_graph *g, - real lambda,real *dvdlambda, - const t_mdatoms *md,t_fcdata *fcd, +real orires(int nfa, const t_iatom forceatoms[], const t_iparams ip[], + const rvec x[], rvec f[], rvec fshift[], + const t_pbc *pbc, const t_graph *g, + real lambda, real *dvdlambda, + const t_mdatoms *md, t_fcdata *fcd, int *global_atom_index) { - atom_id ai,aj; - int fa,d,i,type,ex,power,ki=CENTRAL; - ivec dt; - real r2,invr,invr2,fc,smooth_fc,dev,devins,pfac; - rvec r,Sr,fij; - real vtot; + atom_id ai, aj; + int fa, d, i, type, ex, power, ki = CENTRAL; + ivec dt; + real r2, invr, invr2, fc, smooth_fc, dev, devins, pfac; + rvec r, Sr, fij; + real vtot; const t_oriresdata *od; - gmx_bool bTAV; - + gmx_bool bTAV; + vtot = 0; - od = &(fcd->orires); - + od = &(fcd->orires); + if (od->fc != 0) { bTAV = (od->edt != 0); @@ -612,20 +614,20 @@ real orires(int nfa,const t_iatom forceatoms[],const t_iparams ip[], /* Smoothly switch on the restraining when time averaging is used */ smooth_fc *= (1.0 - od->exp_min_t_tau); } - + d = 0; - for(fa=0; faotav[d] - ip[type].orires.obs; - + /* NOTE: * there is no real potential when time averaging is applied */ vtot += 0.5*fc*sqr(dev); - + if (bTAV) { /* Calculate the force as the sqrt of tav times instantaneous */ @@ -657,26 +659,26 @@ real orires(int nfa,const t_iatom forceatoms[],const t_iparams ip[], } } } - + pfac = fc*ip[type].orires.c*invr2; - for(i=0; iS[ex],r,Sr); - for(i=0; iS[ex], r, Sr); + for (i = 0; i < DIM; i++) { fij[i] = - -pfac*dev*(4*Sr[i] - 2*(2+power)*invr2*iprod(Sr,r)*r[i]); + -pfac*dev*(4*Sr[i] - 2*(2+power)*invr2*iprod(Sr, r)*r[i]); } - + if (g) { - ivec_sub(SHIFT_IVEC(g,ai),SHIFT_IVEC(g,aj),dt); - ki=IVEC2IS(dt); + ivec_sub(SHIFT_IVEC(g, ai), SHIFT_IVEC(g, aj), dt); + ki = IVEC2IS(dt); } - - for(i=0; iorires); if (od->edt != 0) { @@ -704,9 +706,9 @@ void update_orires_history(t_fcdata *fcd,history_t *hist) * in calc_orires_dev. */ hist->orire_initf = od->exp_min_t_tau; - for(pair=0; pairnr; pair++) + for (pair = 0; pair < od->nr; pair++) { - for(i=0; i<5; i++) + for (i = 0; i < 5; i++) { hist->orire_Dtav[pair*5+i] = od->Dtav[pair][i]; } diff --git a/src/gromacs/gmxlib/pargs.c b/src/gromacs/gmxlib/pargs.c index d8c0a95624..f4a9ad9eac 100644 --- a/src/gromacs/gmxlib/pargs.c +++ b/src/gromacs/gmxlib/pargs.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -51,344 +51,436 @@ #include "macros.h" #include "wman.h" -/* The source code in this file should be thread-safe. +/* The source code in this file should be thread-safe. Please keep it that way. */ gmx_bool is_hidden(t_pargs *pa) { - return ((strstr(pa->desc,"HIDDEN") != NULL) || - (strstr(pa->desc,"[hidden]") != NULL)); + return ((strstr(pa->desc, "HIDDEN") != NULL) || + (strstr(pa->desc, "[hidden]") != NULL)); } -void get_pargs(int *argc,char *argv[],int nparg,t_pargs pa[],gmx_bool bKeepArgs) +void get_pargs(int *argc, char *argv[], int nparg, t_pargs pa[], gmx_bool bKeepArgs) { - int i,j,k,match; + int i, j, k, match; gmx_bool *bKeep; - char buf[32]; - char *ptr; + char buf[32]; + char *ptr; - snew(bKeep,*argc+1); + snew(bKeep, *argc+1); bKeep[0] = TRUE; bKeep[*argc] = TRUE; - for(i=1; (i<*argc); i++) { + for (i = 1; (i < *argc); i++) + { bKeep[i] = TRUE; - for(j=0; (jtype) { - case etINT: - sprintf(buf,"%-d",*(pa->u.i)); - break; - case etGMX_LARGE_INT: - sprintf(buf,gmx_large_int_pfmt,*(pa->u.is)); - break; - case etTIME: - case etREAL: - r=*(pa->u.r); - sprintf(buf_str,"%-6g",r); - strcpy(buf, buf_str); - break; - case etBOOL: - sprintf(buf,"%-6s",*(pa->u.b) ? "yes" : "no"); - break; - case etSTR: - if (*(pa->u.c)) { - if (strlen(*(pa->u.c)) >= (size_t)sz) - gmx_fatal(FARGS,"Argument too long: \"%d\"\n",*(pa->u.c)); - else - strcpy(buf,*(pa->u.c)); + real r; + char buf_str[1256]; buf_str[0] = '\0'; + + buf[0] = '\0'; + + if (sz < 255) + { + gmx_fatal(FARGS, "Buffer must be at least 255 chars\n"); + } + + switch (pa->type) + { + case etINT: + sprintf(buf, "%-d", *(pa->u.i)); + break; + case etGMX_LARGE_INT: + sprintf(buf, gmx_large_int_pfmt, *(pa->u.is)); + break; + case etTIME: + case etREAL: + r = *(pa->u.r); + sprintf(buf_str, "%-6g", r); + strcpy(buf, buf_str); + break; + case etBOOL: + sprintf(buf, "%-6s", *(pa->u.b) ? "yes" : "no"); + break; + case etSTR: + if (*(pa->u.c)) + { + if (strlen(*(pa->u.c)) >= (size_t)sz) + { + gmx_fatal(FARGS, "Argument too long: \"%d\"\n", *(pa->u.c)); + } + else + { + strcpy(buf, *(pa->u.c)); + } + } + break; + case etENUM: + strcpy(buf, *(pa->u.c)); + break; + case etRVEC: + sprintf(buf, "%g %g %g", (*pa->u.rv)[0], + (*pa->u.rv)[1], + (*pa->u.rv)[2]); + break; } - break; - case etENUM: - strcpy(buf,*(pa->u.c)); - break; - case etRVEC: - sprintf(buf,"%g %g %g",(*pa->u.rv)[0], - (*pa->u.rv)[1], - (*pa->u.rv)[2]); - break; - } - return buf; + return buf; } #define OPTLEN 12 #define TYPELEN 6 #define LONGSTR 1024 -char *pargs_print_line(t_pargs *pa,gmx_bool bLeadingSpace) +char *pargs_print_line(t_pargs *pa, gmx_bool bLeadingSpace) { - char buf[LONGSTR],*buf2,*tmp,*desc; - - snew(buf2,LONGSTR+strlen(pa->desc)); - snew(tmp,LONGSTR+strlen(pa->desc)); - - if (pa->type == etBOOL) - sprintf(buf,"-[no]%s",pa->option+1); - else - strcpy(buf,pa->option); - desc = check_tty(pa->desc); - if (strlen(buf)>((OPTLEN+TYPELEN)-max(strlen(get_arg_desc(pa->type)),4))) { - sprintf(buf2,"%s%s %-6s %-6s %-s\n", - bLeadingSpace ? " " : "",buf, - get_arg_desc(pa->type),pa_val(pa,tmp,LONGSTR-1),desc); - } else if (strlen(buf)>OPTLEN) { - /* so type can be 3 or 4 char's, this fits in the %4s */ - sprintf(buf2,"%s%-14s %-4s %-6s %-s\n", - bLeadingSpace ? " " : "",buf,get_arg_desc(pa->type), - pa_val(pa,tmp,LONGSTR-1),desc); - } else - sprintf(buf2,"%s%-12s %-6s %-6s %-s\n", - bLeadingSpace ? " " : "",buf,get_arg_desc(pa->type), - pa_val(pa,tmp,LONGSTR-1),desc); - sfree(desc); - sfree(tmp); - - tmp = wrap_lines(buf2,78,28,FALSE); - - sfree(buf2); - - return tmp; + char buf[LONGSTR], *buf2, *tmp, *desc; + + snew(buf2, LONGSTR+strlen(pa->desc)); + snew(tmp, LONGSTR+strlen(pa->desc)); + + if (pa->type == etBOOL) + { + sprintf(buf, "-[no]%s", pa->option+1); + } + else + { + strcpy(buf, pa->option); + } + desc = check_tty(pa->desc); + if (strlen(buf) > ((OPTLEN+TYPELEN)-max(strlen(get_arg_desc(pa->type)), 4))) + { + sprintf(buf2, "%s%s %-6s %-6s %-s\n", + bLeadingSpace ? " " : "", buf, + get_arg_desc(pa->type), pa_val(pa, tmp, LONGSTR-1), desc); + } + else if (strlen(buf) > OPTLEN) + { + /* so type can be 3 or 4 char's, this fits in the %4s */ + sprintf(buf2, "%s%-14s %-4s %-6s %-s\n", + bLeadingSpace ? " " : "", buf, get_arg_desc(pa->type), + pa_val(pa, tmp, LONGSTR-1), desc); + } + else + { + sprintf(buf2, "%s%-12s %-6s %-6s %-s\n", + bLeadingSpace ? " " : "", buf, get_arg_desc(pa->type), + pa_val(pa, tmp, LONGSTR-1), desc); + } + sfree(desc); + sfree(tmp); + + tmp = wrap_lines(buf2, 78, 28, FALSE); + + sfree(buf2); + + return tmp; } -void print_pargs(FILE *fp, int npargs,t_pargs pa[],gmx_bool bLeadingSpace) +void print_pargs(FILE *fp, int npargs, t_pargs pa[], gmx_bool bLeadingSpace) { - gmx_bool bShowHidden; - char buf[32],buf2[256],tmp[256]; - char *wdesc; - int i; - - /* Cannot call opt2parg_bSet here, because it crashes when the option - * is not in the list (mdrun) - */ - bShowHidden = FALSE; - for(i=0; (i 0) { - fprintf(fp,"%s%-12s %-6s %-6s %-s\n", - bLeadingSpace ? " " : "","Option","Type","Value","Description"); - fprintf(fp,"%s------------------------------------------------------\n", - bLeadingSpace ? " " : ""); - for(i=0; (i 0) + { + fprintf(fp, "%s%-12s %-6s %-6s %-s\n", + bLeadingSpace ? " " : "", "Option", "Type", "Value", "Description"); + fprintf(fp, "%s------------------------------------------------------\n", + bLeadingSpace ? " " : ""); + for (i = 0; (i < npargs); i++) + { + if (bShowHidden || !is_hidden(&pa[i])) + { + wdesc = pargs_print_line(&pa[i], bLeadingSpace); + fprintf(fp, "%s", wdesc); + sfree(wdesc); + } + } + fprintf(fp, "\n"); } - fprintf(fp,"\n"); - } } -void pr_enums(FILE *fp, int npargs,t_pargs pa[], int shell) +void pr_enums(FILE *fp, int npargs, t_pargs pa[], int shell) { - int i,j; - - switch (shell) { - case eshellCSH: - for (i=0; iePBCDX); - pr_rvecs(fp,0,"box",pbc->box,DIM); - pr_rvecs(fp,0,"fbox_diag",&pbc->fbox_diag,1); - pr_rvecs(fp,0,"hbox_diag",&pbc->hbox_diag,1); - pr_rvecs(fp,0,"mhbox_diag",&pbc->mhbox_diag,1); - rvec_add(pbc->hbox_diag,pbc->mhbox_diag,sum_box); - pr_rvecs(fp,0,"sum of the above two",&sum_box,1); - fprintf(fp,"max_cutoff2 = %g\n",pbc->max_cutoff2); - fprintf(fp,"bLimitDistance = %s\n",EBOOL(pbc->bLimitDistance)); - fprintf(fp,"limit_distance2 = %g\n",pbc->limit_distance2); - fprintf(fp,"ntric_vec = %d\n",pbc->ntric_vec); - if (pbc->ntric_vec > 0) { - pr_ivecs(fp,0,"tric_shift",pbc->tric_shift,pbc->ntric_vec,FALSE); - pr_rvecs(fp,0,"tric_vec",pbc->tric_vec,pbc->ntric_vec); + fprintf(fp, "ePBCDX = %d\n", pbc->ePBCDX); + pr_rvecs(fp, 0, "box", pbc->box, DIM); + pr_rvecs(fp, 0, "fbox_diag", &pbc->fbox_diag, 1); + pr_rvecs(fp, 0, "hbox_diag", &pbc->hbox_diag, 1); + pr_rvecs(fp, 0, "mhbox_diag", &pbc->mhbox_diag, 1); + rvec_add(pbc->hbox_diag, pbc->mhbox_diag, sum_box); + pr_rvecs(fp, 0, "sum of the above two", &sum_box, 1); + fprintf(fp, "max_cutoff2 = %g\n", pbc->max_cutoff2); + fprintf(fp, "bLimitDistance = %s\n", EBOOL(pbc->bLimitDistance)); + fprintf(fp, "limit_distance2 = %g\n", pbc->limit_distance2); + fprintf(fp, "ntric_vec = %d\n", pbc->ntric_vec); + if (pbc->ntric_vec > 0) + { + pr_ivecs(fp, 0, "tric_shift", pbc->tric_shift, pbc->ntric_vec, FALSE); + pr_rvecs(fp, 0, "tric_vec", pbc->tric_vec, pbc->ntric_vec); } } -const char *check_box(int ePBC,matrix box) +const char *check_box(int ePBC, matrix box) { const char *ptr; if (ePBC == -1) + { ePBC = guess_ePBC(box); + } if (ePBC == epbcNONE) + { return NULL; + } - if ((box[XX][YY] != 0) || (box[XX][ZZ] != 0) || (box[YY][ZZ] != 0)) { + if ((box[XX][YY] != 0) || (box[XX][ZZ] != 0) || (box[YY][ZZ] != 0)) + { ptr = "Only triclinic boxes with the first vector parallel to the x-axis and the second vector in the xy-plane are supported."; - } else if (ePBC == epbcSCREW && (box[YY][XX] != 0 || box[ZZ][XX] != 0)) { + } + else if (ePBC == epbcSCREW && (box[YY][XX] != 0 || box[ZZ][XX] != 0)) + { ptr = "The unit cell can not have off-diagonal x-components with screw pbc"; - } else if (fabs(box[YY][XX]) > BOX_MARGIN*0.5*box[XX][XX] || - (ePBC != epbcXY && - (fabs(box[ZZ][XX]) > BOX_MARGIN*0.5*box[XX][XX] || - fabs(box[ZZ][YY]) > BOX_MARGIN*0.5*box[YY][YY]))) { + } + else if (fabs(box[YY][XX]) > BOX_MARGIN*0.5*box[XX][XX] || + (ePBC != epbcXY && + (fabs(box[ZZ][XX]) > BOX_MARGIN*0.5*box[XX][XX] || + fabs(box[ZZ][YY]) > BOX_MARGIN*0.5*box[YY][YY]))) + { ptr = "Triclinic box is too skewed."; - } else { + } + else + { ptr = NULL; } return ptr; } -real max_cutoff2(int ePBC,matrix box) +real max_cutoff2(int ePBC, matrix box) { - real min_hv2,min_ss; + real min_hv2, min_ss; /* Physical limitation of the cut-off * by half the length of the shortest box vector. */ - min_hv2 = min(0.25*norm2(box[XX]),0.25*norm2(box[YY])); + min_hv2 = min(0.25*norm2(box[XX]), 0.25*norm2(box[YY])); if (ePBC != epbcXY) - min_hv2 = min(min_hv2,0.25*norm2(box[ZZ])); + { + min_hv2 = min(min_hv2, 0.25*norm2(box[ZZ])); + } /* Limitation to the smallest diagonal element due to optimizations: * checking only linear combinations of single box-vectors (2 in x) * in the grid search and pbc_dx is a lot faster * than checking all possible combinations. */ - if (ePBC == epbcXY) { - min_ss = min(box[XX][XX],box[YY][YY]); - } else { - min_ss = min(box[XX][XX],min(box[YY][YY]-fabs(box[ZZ][YY]),box[ZZ][ZZ])); + if (ePBC == epbcXY) + { + min_ss = min(box[XX][XX], box[YY][YY]); + } + else + { + min_ss = min(box[XX][XX], min(box[YY][YY]-fabs(box[ZZ][YY]), box[ZZ][ZZ])); } - return min(min_hv2,min_ss*min_ss); + return min(min_hv2, min_ss*min_ss); } /* this one is mostly harmless... */ -static gmx_bool bWarnedGuess=FALSE; +static gmx_bool bWarnedGuess = FALSE; int guess_ePBC(matrix box) { int ePBC; - if (box[XX][XX]>0 && box[YY][YY]>0 && box[ZZ][ZZ]>0) { + if (box[XX][XX] > 0 && box[YY][YY] > 0 && box[ZZ][ZZ] > 0) + { ePBC = epbcXYZ; - } else if (box[XX][XX]>0 && box[YY][YY]>0 && box[ZZ][ZZ]==0) { + } + else if (box[XX][XX] > 0 && box[YY][YY] > 0 && box[ZZ][ZZ] == 0) + { ePBC = epbcXY; - } else if (box[XX][XX]==0 && box[YY][YY]==0 && box[ZZ][ZZ]==0) { + } + else if (box[XX][XX] == 0 && box[YY][YY] == 0 && box[ZZ][ZZ] == 0) + { ePBC = epbcNONE; - } else { - if (!bWarnedGuess) { - fprintf(stderr,"WARNING: Unsupported box diagonal %f %f %f, " + } + else + { + if (!bWarnedGuess) + { + fprintf(stderr, "WARNING: Unsupported box diagonal %f %f %f, " "will not use periodic boundary conditions\n\n", - box[XX][XX],box[YY][YY],box[ZZ][ZZ]); + box[XX][XX], box[YY][YY], box[ZZ][ZZ]); bWarnedGuess = TRUE; } ePBC = epbcNONE; } if (debug) - fprintf(debug,"Guessed pbc = %s from the box matrix\n",epbc_names[ePBC]); + { + fprintf(debug, "Guessed pbc = %s from the box matrix\n", epbc_names[ePBC]); + } return ePBC; } -static int correct_box_elem(FILE *fplog,int step,tensor box,int v,int d) +static int correct_box_elem(FILE *fplog, int step, tensor box, int v, int d) { - int shift,maxshift=10; + int shift, maxshift = 10; shift = 0; /* correct elem d of vector v with vector d */ - while (box[v][d] > BOX_MARGIN_CORRECT*0.5*box[d][d]) { - if (fplog) { - fprintf(fplog,"Step %d: correcting invalid box:\n",step); - pr_rvecs(fplog,0,"old box",box,DIM); + while (box[v][d] > BOX_MARGIN_CORRECT*0.5*box[d][d]) + { + if (fplog) + { + fprintf(fplog, "Step %d: correcting invalid box:\n", step); + pr_rvecs(fplog, 0, "old box", box, DIM); } - rvec_dec(box[v],box[d]); + rvec_dec(box[v], box[d]); shift--; - if (fplog) { - pr_rvecs(fplog,0,"new box",box,DIM); + if (fplog) + { + pr_rvecs(fplog, 0, "new box", box, DIM); } if (shift <= -maxshift) + { gmx_fatal(FARGS, "Box was shifted at least %d times. Please see log-file.", maxshift); - } - while (box[v][d] < -BOX_MARGIN_CORRECT*0.5*box[d][d]) { - if (fplog) { - fprintf(fplog,"Step %d: correcting invalid box:\n",step); - pr_rvecs(fplog,0,"old box",box,DIM); } - rvec_inc(box[v],box[d]); + } + while (box[v][d] < -BOX_MARGIN_CORRECT*0.5*box[d][d]) + { + if (fplog) + { + fprintf(fplog, "Step %d: correcting invalid box:\n", step); + pr_rvecs(fplog, 0, "old box", box, DIM); + } + rvec_inc(box[v], box[d]); shift++; - if (fplog) { - pr_rvecs(fplog,0,"new box",box,DIM); + if (fplog) + { + pr_rvecs(fplog, 0, "new box", box, DIM); } if (shift >= maxshift) + { gmx_fatal(FARGS, "Box was shifted at least %d times. Please see log-file.", maxshift); + } } return shift; } -gmx_bool correct_box(FILE *fplog,int step,tensor box,t_graph *graph) +gmx_bool correct_box(FILE *fplog, int step, tensor box, t_graph *graph) { - int zy,zx,yx,i; + int zy, zx, yx, i; gmx_bool bCorrected; /* check if the box still obeys the restrictions, if not, correct it */ - zy = correct_box_elem(fplog,step,box,ZZ,YY); - zx = correct_box_elem(fplog,step,box,ZZ,XX); - yx = correct_box_elem(fplog,step,box,YY,XX); + zy = correct_box_elem(fplog, step, box, ZZ, YY); + zx = correct_box_elem(fplog, step, box, ZZ, XX); + yx = correct_box_elem(fplog, step, box, YY, XX); bCorrected = (zy || zx || yx); - if (bCorrected && graph) { + if (bCorrected && graph) + { /* correct the graph */ - for(i=graph->at_start; iat_end; i++) { + for (i = graph->at_start; i < graph->at_end; i++) + { graph->ishift[i][YY] -= graph->ishift[i][ZZ]*zy; graph->ishift[i][XX] -= graph->ishift[i][ZZ]*zx; graph->ishift[i][XX] -= graph->ishift[i][YY]*yx; @@ -257,210 +299,293 @@ gmx_bool correct_box(FILE *fplog,int step,tensor box,t_graph *graph) int ndof_com(t_inputrec *ir) { - int n=0; - - switch (ir->ePBC) { - case epbcXYZ: - case epbcNONE: - n = 3; - break; - case epbcXY: - n = (ir->nwall == 0 ? 3 : 2); - break; - case epbcSCREW: - n = 1; - break; - default: - gmx_incons("Unknown pbc in calc_nrdf"); + int n = 0; + + switch (ir->ePBC) + { + case epbcXYZ: + case epbcNONE: + n = 3; + break; + case epbcXY: + n = (ir->nwall == 0 ? 3 : 2); + break; + case epbcSCREW: + n = 1; + break; + default: + gmx_incons("Unknown pbc in calc_nrdf"); } - + return n; } -static void low_set_pbc(t_pbc *pbc,int ePBC,ivec *dd_nc,matrix box) +static void low_set_pbc(t_pbc *pbc, int ePBC, ivec *dd_nc, matrix box) { - int order[5]={0,-1,1,-2,2}; - int ii,jj,kk,i,j,k,d,dd,jc,kc,npbcdim,shift; - ivec bPBC; - real d2old,d2new,d2new_c; - rvec trial,pos; - gmx_bool bXY,bUse; + int order[5] = {0, -1, 1, -2, 2}; + int ii, jj, kk, i, j, k, d, dd, jc, kc, npbcdim, shift; + ivec bPBC; + real d2old, d2new, d2new_c; + rvec trial, pos; + gmx_bool bXY, bUse; const char *ptr; pbc->ndim_ePBC = ePBC2npbcdim(ePBC); - copy_mat(box,pbc->box); + copy_mat(box, pbc->box); pbc->bLimitDistance = FALSE; - pbc->max_cutoff2 = 0; - pbc->dim = -1; + pbc->max_cutoff2 = 0; + pbc->dim = -1; - for(i=0; (ifbox_diag[i] = box[i][i]; pbc->hbox_diag[i] = pbc->fbox_diag[i]*0.5; pbc->mhbox_diag[i] = -pbc->hbox_diag[i]; } - ptr = check_box(ePBC,box); - if (ePBC == epbcNONE) { + ptr = check_box(ePBC, box); + if (ePBC == epbcNONE) + { pbc->ePBCDX = epbcdxNOPBC; - } else if (ptr) { - fprintf(stderr, "Warning: %s\n",ptr); - pr_rvecs(stderr,0," Box",box,DIM); + } + else if (ptr) + { + fprintf(stderr, "Warning: %s\n", ptr); + pr_rvecs(stderr, 0, " Box", box, DIM); fprintf(stderr, " Can not fix pbc.\n"); - pbc->ePBCDX = epbcdxUNSUPPORTED; - pbc->bLimitDistance = TRUE; + pbc->ePBCDX = epbcdxUNSUPPORTED; + pbc->bLimitDistance = TRUE; pbc->limit_distance2 = 0; - } else { - if (ePBC == epbcSCREW && dd_nc) { + } + else + { + if (ePBC == epbcSCREW && dd_nc) + { /* This combinated should never appear here */ gmx_incons("low_set_pbc called with screw pbc and dd_nc != NULL"); } npbcdim = 0; - for(i=0; i 1) || (ePBC == epbcXY && i == ZZ)) { + for (i = 0; i < DIM; i++) + { + if ((dd_nc && (*dd_nc)[i] > 1) || (ePBC == epbcXY && i == ZZ)) + { bPBC[i] = 0; - } else { + } + else + { bPBC[i] = 1; npbcdim++; } } - switch (npbcdim) { - case 1: - /* 1D pbc is not an mdp option and it is therefore only used - * with single shifts. - */ - pbc->ePBCDX = epbcdx1D_RECT; - for(i=0; idim = i; - for(i=0; idim; i++) - if (pbc->box[pbc->dim][i] != 0) - pbc->ePBCDX = epbcdx1D_TRIC; - break; - case 2: - pbc->ePBCDX = epbcdx2D_RECT; - for(i=0; idim = i; - for(i=0; ibox[i][j] != 0) - pbc->ePBCDX = epbcdx2D_TRIC; - break; - case 3: - if (ePBC != epbcSCREW) { - if (TRICLINIC(box)) { - pbc->ePBCDX = epbcdxTRICLINIC; - } else { - pbc->ePBCDX = epbcdxRECTANGULAR; + switch (npbcdim) + { + case 1: + /* 1D pbc is not an mdp option and it is therefore only used + * with single shifts. + */ + pbc->ePBCDX = epbcdx1D_RECT; + for (i = 0; i < DIM; i++) + { + if (bPBC[i]) + { + pbc->dim = i; + } } - } else { - pbc->ePBCDX = (box[ZZ][YY]==0 ? epbcdxSCREW_RECT : epbcdxSCREW_TRIC); - if (pbc->ePBCDX == epbcdxSCREW_TRIC) { - fprintf(stderr, - "Screw pbc is not yet implemented for triclinic boxes.\n" - "Can not fix pbc.\n"); - pbc->ePBCDX = epbcdxUNSUPPORTED; + for (i = 0; i < pbc->dim; i++) + { + if (pbc->box[pbc->dim][i] != 0) + { + pbc->ePBCDX = epbcdx1D_TRIC; + } } - } - break; - default: - gmx_fatal(FARGS,"Incorrect number of pbc dimensions with DD: %d", - npbcdim); + break; + case 2: + pbc->ePBCDX = epbcdx2D_RECT; + for (i = 0; i < DIM; i++) + { + if (!bPBC[i]) + { + pbc->dim = i; + } + } + for (i = 0; i < DIM; i++) + { + if (bPBC[i]) + { + for (j = 0; j < i; j++) + { + if (pbc->box[i][j] != 0) + { + pbc->ePBCDX = epbcdx2D_TRIC; + } + } + } + } + break; + case 3: + if (ePBC != epbcSCREW) + { + if (TRICLINIC(box)) + { + pbc->ePBCDX = epbcdxTRICLINIC; + } + else + { + pbc->ePBCDX = epbcdxRECTANGULAR; + } + } + else + { + pbc->ePBCDX = (box[ZZ][YY] == 0 ? epbcdxSCREW_RECT : epbcdxSCREW_TRIC); + if (pbc->ePBCDX == epbcdxSCREW_TRIC) + { + fprintf(stderr, + "Screw pbc is not yet implemented for triclinic boxes.\n" + "Can not fix pbc.\n"); + pbc->ePBCDX = epbcdxUNSUPPORTED; + } + } + break; + default: + gmx_fatal(FARGS, "Incorrect number of pbc dimensions with DD: %d", + npbcdim); } - pbc->max_cutoff2 = max_cutoff2(ePBC,box); + pbc->max_cutoff2 = max_cutoff2(ePBC, box); if (pbc->ePBCDX == epbcdxTRICLINIC || pbc->ePBCDX == epbcdx2D_TRIC || - pbc->ePBCDX == epbcdxSCREW_TRIC) { - if (debug) { - pr_rvecs(debug,0,"Box",box,DIM); - fprintf(debug,"max cutoff %.3f\n",sqrt(pbc->max_cutoff2)); + pbc->ePBCDX == epbcdxSCREW_TRIC) + { + if (debug) + { + pr_rvecs(debug, 0, "Box", box, DIM); + fprintf(debug, "max cutoff %.3f\n", sqrt(pbc->max_cutoff2)); } pbc->ntric_vec = 0; /* We will only use single shifts, but we will check a few * more shifts to see if there is a limiting distance * above which we can not be sure of the correct distance. */ - for(kk=0; kk<5; kk++) { + for (kk = 0; kk < 5; kk++) + { k = order[kk]; if (!bPBC[ZZ] && k != 0) + { continue; - for(jj=0; jj<5; jj++) { + } + for (jj = 0; jj < 5; jj++) + { j = order[jj]; if (!bPBC[YY] && j != 0) + { continue; - for(ii=0; ii<3; ii++) { + } + for (ii = 0; ii < 3; ii++) + { i = order[ii]; if (!bPBC[XX] && i != 0) + { continue; + } /* A shift is only useful when it is trilinic */ - if (j != 0 || k != 0) { + if (j != 0 || k != 0) + { d2old = 0; d2new = 0; - for(d=0; ddim) { + if (d == pbc->dim) + { trial[d] = 0; - pos[d] = 0; - } else { + pos[d] = 0; + } + else + { if (trial[d] < 0) - pos[d] = min( pbc->hbox_diag[d],-trial[d]); + { + pos[d] = min( pbc->hbox_diag[d], -trial[d]); + } else - pos[d] = max(-pbc->hbox_diag[d],-trial[d]); + { + pos[d] = max(-pbc->hbox_diag[d], -trial[d]); + } } d2old += sqr(pos[d]); d2new += sqr(pos[d] + trial[d]); } - if (BOX_MARGIN*d2new < d2old) { - if (j < -1 || j > 1 || k < -1 || k > 1) { + if (BOX_MARGIN*d2new < d2old) + { + if (j < -1 || j > 1 || k < -1 || k > 1) + { /* Check if there is a single shift vector * that decreases this distance even more. */ jc = 0; kc = 0; if (j < -1 || j > 1) + { jc = j/2; + } if (k < -1 || k > 1) + { kc = k/2; + } d2new_c = 0; - for(d=0; d BOX_MARGIN*d2new) { + for (d = 0; d < DIM; d++) + { + d2new_c += sqr(pos[d] + trial[d] + - jc*box[YY][d] - kc*box[ZZ][d]); + } + if (d2new_c > BOX_MARGIN*d2new) + { /* Reject this shift vector, as there is no a priori limit * to the number of shifts that decrease distances. */ if (!pbc->bLimitDistance || d2new < pbc->limit_distance2) + { pbc->limit_distance2 = d2new; + } pbc->bLimitDistance = TRUE; } - } else { + } + else + { /* Check if shifts with one box vector less do better */ bUse = TRUE; - for(dd=0; ddntric_vec >= MAX_NTRICVEC) { - fprintf(stderr,"\nWARNING: Found more than %d triclinic correction vectors, ignoring some.\n" - " There is probably something wrong with your box.\n",MAX_NTRICVEC); - pr_rvecs(stderr,0," Box",box,DIM); - } else { - copy_rvec(trial,pbc->tric_vec[pbc->ntric_vec]); + if (pbc->ntric_vec >= MAX_NTRICVEC) + { + fprintf(stderr, "\nWARNING: Found more than %d triclinic correction vectors, ignoring some.\n" + " There is probably something wrong with your box.\n", MAX_NTRICVEC); + pr_rvecs(stderr, 0, " Box", box, DIM); + } + else + { + copy_rvec(trial, pbc->tric_vec[pbc->ntric_vec]); pbc->tric_shift[pbc->ntric_vec][XX] = i; pbc->tric_shift[pbc->ntric_vec][YY] = j; pbc->tric_shift[pbc->ntric_vec][ZZ] = k; @@ -468,12 +593,13 @@ static void low_set_pbc(t_pbc *pbc,int ePBC,ivec *dd_nc,matrix box) } } } - if (debug) { - fprintf(debug," tricvec %2d = %2d %2d %2d %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f\n", - pbc->ntric_vec,i,j,k, - sqrt(d2old),sqrt(d2new), - trial[XX],trial[YY],trial[ZZ], - pos[XX],pos[YY],pos[ZZ]); + if (debug) + { + fprintf(debug, " tricvec %2d = %2d %2d %2d %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f %5.2f\n", + pbc->ntric_vec, i, j, k, + sqrt(d2old), sqrt(d2new), + trial[XX], trial[YY], trial[ZZ], + pos[XX], pos[YY], pos[ZZ]); } } } @@ -484,707 +610,926 @@ static void low_set_pbc(t_pbc *pbc,int ePBC,ivec *dd_nc,matrix box) } } -void set_pbc(t_pbc *pbc,int ePBC,matrix box) +void set_pbc(t_pbc *pbc, int ePBC, matrix box) { if (ePBC == -1) + { ePBC = guess_ePBC(box); + } - low_set_pbc(pbc,ePBC,NULL,box); + low_set_pbc(pbc, ePBC, NULL, box); } -t_pbc *set_pbc_dd(t_pbc *pbc,int ePBC, - gmx_domdec_t *dd,gmx_bool bSingleDir,matrix box) +t_pbc *set_pbc_dd(t_pbc *pbc, int ePBC, + gmx_domdec_t *dd, gmx_bool bSingleDir, matrix box) { ivec nc2; - int npbcdim,i; + int npbcdim, i; - if (dd == NULL) { + if (dd == NULL) + { npbcdim = DIM; - } else { - if (ePBC == epbcSCREW && dd->nc[XX] > 1) { + } + else + { + if (ePBC == epbcSCREW && dd->nc[XX] > 1) + { /* The rotation has been taken care of during coordinate communication */ ePBC = epbcXYZ; } npbcdim = 0; - for(i=0; inc[i] <= (bSingleDir ? 1 : 2)) { + for (i = 0; i < DIM; i++) + { + if (dd->nc[i] <= (bSingleDir ? 1 : 2)) + { nc2[i] = 1; if (!(ePBC == epbcXY && i == ZZ)) + { npbcdim++; - } else { + } + } + else + { nc2[i] = dd->nc[i]; } } } if (npbcdim > 0) - low_set_pbc(pbc,ePBC,npbcdim 0 ? pbc : NULL); } -void pbc_dx(const t_pbc *pbc,const rvec x1, const rvec x2, rvec dx) +void pbc_dx(const t_pbc *pbc, const rvec x1, const rvec x2, rvec dx) { - int i,j; - rvec dx_start,trial; - real d2min,d2trial; + int i, j; + rvec dx_start, trial; + real d2min, d2trial; gmx_bool bRot; - rvec_sub(x1,x2,dx); + rvec_sub(x1, x2, dx); - switch (pbc->ePBCDX) { - case epbcdxRECTANGULAR: - for(i=0; i pbc->hbox_diag[i]) { - dx[i] -= pbc->fbox_diag[i]; - } - while (dx[i] <= pbc->mhbox_diag[i]) { - dx[i] += pbc->fbox_diag[i]; - } - } - break; - case epbcdxTRICLINIC: - for(i=DIM-1; i>=0; i--) { - while (dx[i] > pbc->hbox_diag[i]) { - for (j=i; j>=0; j--) - dx[j] -= pbc->box[i][j]; - } - while (dx[i] <= pbc->mhbox_diag[i]) { - for (j=i; j>=0; j--) - dx[j] += pbc->box[i][j]; - } - } - /* dx is the distance in a rectangular box */ - d2min = norm2(dx); - if (d2min > pbc->max_cutoff2) { - copy_rvec(dx,dx_start); - d2min = norm2(dx); - /* Now try all possible shifts, when the distance is within max_cutoff - * it must be the shortest possible distance. - */ - i = 0; - while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) { - rvec_add(dx_start,pbc->tric_vec[i],trial); - d2trial = norm2(trial); - if (d2trial < d2min) { - copy_rvec(trial,dx); - d2min = d2trial; - } - i++; - } - } - break; - case epbcdx2D_RECT: - for(i=0; idim) { - while (dx[i] > pbc->hbox_diag[i]) { + switch (pbc->ePBCDX) + { + case epbcdxRECTANGULAR: + for (i = 0; i < DIM; i++) + { + while (dx[i] > pbc->hbox_diag[i]) + { dx[i] -= pbc->fbox_diag[i]; } - while (dx[i] <= pbc->mhbox_diag[i]) { + while (dx[i] <= pbc->mhbox_diag[i]) + { dx[i] += pbc->fbox_diag[i]; } } - } - break; - case epbcdx2D_TRIC: - d2min = 0; - for(i=DIM-1; i>=0; i--) { - if (i != pbc->dim) { - while (dx[i] > pbc->hbox_diag[i]) { - for (j=i; j>=0; j--) + break; + case epbcdxTRICLINIC: + for (i = DIM-1; i >= 0; i--) + { + while (dx[i] > pbc->hbox_diag[i]) + { + for (j = i; j >= 0; j--) + { dx[j] -= pbc->box[i][j]; + } } - while (dx[i] <= pbc->mhbox_diag[i]) { - for (j=i; j>=0; j--) + while (dx[i] <= pbc->mhbox_diag[i]) + { + for (j = i; j >= 0; j--) + { dx[j] += pbc->box[i][j]; + } } - d2min += dx[i]*dx[i]; } - } - if (d2min > pbc->max_cutoff2) { - copy_rvec(dx,dx_start); + /* dx is the distance in a rectangular box */ d2min = norm2(dx); - /* Now try all possible shifts, when the distance is within max_cutoff - * it must be the shortest possible distance. - */ - i = 0; - while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) { - rvec_add(dx_start,pbc->tric_vec[i],trial); - d2trial = 0; - for(j=0; jdim) { - d2trial += trial[j]*trial[j]; + if (d2min > pbc->max_cutoff2) + { + copy_rvec(dx, dx_start); + d2min = norm2(dx); + /* Now try all possible shifts, when the distance is within max_cutoff + * it must be the shortest possible distance. + */ + i = 0; + while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) + { + rvec_add(dx_start, pbc->tric_vec[i], trial); + d2trial = norm2(trial); + if (d2trial < d2min) + { + copy_rvec(trial, dx); + d2min = d2trial; } + i++; } - if (d2trial < d2min) { - copy_rvec(trial,dx); - d2min = d2trial; + } + break; + case epbcdx2D_RECT: + for (i = 0; i < DIM; i++) + { + if (i != pbc->dim) + { + while (dx[i] > pbc->hbox_diag[i]) + { + dx[i] -= pbc->fbox_diag[i]; + } + while (dx[i] <= pbc->mhbox_diag[i]) + { + dx[i] += pbc->fbox_diag[i]; + } } - i++; } - } - break; - case epbcdxSCREW_RECT: - /* The shift definition requires x first */ - bRot = FALSE; - while (dx[XX] > pbc->hbox_diag[XX]) { - dx[XX] -= pbc->fbox_diag[XX]; - bRot = !bRot; - } - while (dx[XX] <= pbc->mhbox_diag[XX]) { - dx[XX] += pbc->fbox_diag[YY]; - bRot = !bRot; - } - if (bRot) { - /* Rotate around the x-axis in the middle of the box */ - dx[YY] = pbc->box[YY][YY] - x1[YY] - x2[YY]; - dx[ZZ] = pbc->box[ZZ][ZZ] - x1[ZZ] - x2[ZZ]; - } - /* Normal pbc for y and z */ - for(i=YY; i<=ZZ; i++) { - while (dx[i] > pbc->hbox_diag[i]) { - dx[i] -= pbc->fbox_diag[i]; + break; + case epbcdx2D_TRIC: + d2min = 0; + for (i = DIM-1; i >= 0; i--) + { + if (i != pbc->dim) + { + while (dx[i] > pbc->hbox_diag[i]) + { + for (j = i; j >= 0; j--) + { + dx[j] -= pbc->box[i][j]; + } + } + while (dx[i] <= pbc->mhbox_diag[i]) + { + for (j = i; j >= 0; j--) + { + dx[j] += pbc->box[i][j]; + } + } + d2min += dx[i]*dx[i]; + } } - while (dx[i] <= pbc->mhbox_diag[i]) { - dx[i] += pbc->fbox_diag[i]; + if (d2min > pbc->max_cutoff2) + { + copy_rvec(dx, dx_start); + d2min = norm2(dx); + /* Now try all possible shifts, when the distance is within max_cutoff + * it must be the shortest possible distance. + */ + i = 0; + while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) + { + rvec_add(dx_start, pbc->tric_vec[i], trial); + d2trial = 0; + for (j = 0; j < DIM; j++) + { + if (j != pbc->dim) + { + d2trial += trial[j]*trial[j]; + } + } + if (d2trial < d2min) + { + copy_rvec(trial, dx); + d2min = d2trial; + } + i++; + } } - } - break; - case epbcdxNOPBC: - case epbcdxUNSUPPORTED: - break; - default: - gmx_fatal(FARGS,"Internal error in pbc_dx, set_pbc has not been called"); - break; + break; + case epbcdxSCREW_RECT: + /* The shift definition requires x first */ + bRot = FALSE; + while (dx[XX] > pbc->hbox_diag[XX]) + { + dx[XX] -= pbc->fbox_diag[XX]; + bRot = !bRot; + } + while (dx[XX] <= pbc->mhbox_diag[XX]) + { + dx[XX] += pbc->fbox_diag[YY]; + bRot = !bRot; + } + if (bRot) + { + /* Rotate around the x-axis in the middle of the box */ + dx[YY] = pbc->box[YY][YY] - x1[YY] - x2[YY]; + dx[ZZ] = pbc->box[ZZ][ZZ] - x1[ZZ] - x2[ZZ]; + } + /* Normal pbc for y and z */ + for (i = YY; i <= ZZ; i++) + { + while (dx[i] > pbc->hbox_diag[i]) + { + dx[i] -= pbc->fbox_diag[i]; + } + while (dx[i] <= pbc->mhbox_diag[i]) + { + dx[i] += pbc->fbox_diag[i]; + } + } + break; + case epbcdxNOPBC: + case epbcdxUNSUPPORTED: + break; + default: + gmx_fatal(FARGS, "Internal error in pbc_dx, set_pbc has not been called"); + break; } } -int pbc_dx_aiuc(const t_pbc *pbc,const rvec x1, const rvec x2, rvec dx) +int pbc_dx_aiuc(const t_pbc *pbc, const rvec x1, const rvec x2, rvec dx) { - int i,j,is; - rvec dx_start,trial; - real d2min,d2trial; - ivec ishift,ishift_start; + int i, j, is; + rvec dx_start, trial; + real d2min, d2trial; + ivec ishift, ishift_start; - rvec_sub(x1,x2,dx); + rvec_sub(x1, x2, dx); clear_ivec(ishift); - switch (pbc->ePBCDX) { - case epbcdxRECTANGULAR: - for(i=0; i pbc->hbox_diag[i]) { - dx[i] -= pbc->fbox_diag[i]; - ishift[i]--; - } else if (dx[i] <= pbc->mhbox_diag[i]) { - dx[i] += pbc->fbox_diag[i]; - ishift[i]++; - } - } - break; - case epbcdxTRICLINIC: - /* For triclinic boxes the performance difference between - * if/else and two while loops is negligible. - * However, the while version can cause extreme delays - * before a simulation crashes due to large forces which - * can cause unlimited displacements. - * Also allowing multiple shifts would index fshift beyond bounds. - */ - for(i=DIM-1; i>=1; i--) { - if (dx[i] > pbc->hbox_diag[i]) { - for (j=i; j>=0; j--) - dx[j] -= pbc->box[i][j]; - ishift[i]--; - } else if (dx[i] <= pbc->mhbox_diag[i]) { - for (j=i; j>=0; j--) - dx[j] += pbc->box[i][j]; - ishift[i]++; - } - } - /* Allow 2 shifts in x */ - if (dx[XX] > pbc->hbox_diag[XX]) { - dx[XX] -= pbc->fbox_diag[XX]; - ishift[XX]--; - if (dx[XX] > pbc->hbox_diag[XX]) { - dx[XX] -= pbc->fbox_diag[XX]; - ishift[XX]--; - } - } else if (dx[XX] <= pbc->mhbox_diag[XX]) { - dx[XX] += pbc->fbox_diag[XX]; - ishift[XX]++; - if (dx[XX] <= pbc->mhbox_diag[XX]) { - dx[XX] += pbc->fbox_diag[XX]; - ishift[XX]++; - } - } - /* dx is the distance in a rectangular box */ - d2min = norm2(dx); - if (d2min > pbc->max_cutoff2) { - copy_rvec(dx,dx_start); - copy_ivec(ishift,ishift_start); - d2min = norm2(dx); - /* Now try all possible shifts, when the distance is within max_cutoff - * it must be the shortest possible distance. - */ - i = 0; - while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) { - rvec_add(dx_start,pbc->tric_vec[i],trial); - d2trial = norm2(trial); - if (d2trial < d2min) { - copy_rvec(trial,dx); - ivec_add(ishift_start,pbc->tric_shift[i],ishift); - d2min = d2trial; - } - i++; - } - } - break; - case epbcdx2D_RECT: - for(i=0; idim) { - if (dx[i] > pbc->hbox_diag[i]) { - dx[i] -= pbc->fbox_diag[i]; + switch (pbc->ePBCDX) + { + case epbcdxRECTANGULAR: + for (i = 0; i < DIM; i++) + { + if (dx[i] > pbc->hbox_diag[i]) + { + dx[i] -= pbc->fbox_diag[i]; ishift[i]--; - } else if (dx[i] <= pbc->mhbox_diag[i]) { - dx[i] += pbc->fbox_diag[i]; + } + else if (dx[i] <= pbc->mhbox_diag[i]) + { + dx[i] += pbc->fbox_diag[i]; ishift[i]++; } } - } - break; - case epbcdx2D_TRIC: - d2min = 0; - for(i=DIM-1; i>=1; i--) { - if (i != pbc->dim) { - if (dx[i] > pbc->hbox_diag[i]) { - for (j=i; j>=0; j--) + break; + case epbcdxTRICLINIC: + /* For triclinic boxes the performance difference between + * if/else and two while loops is negligible. + * However, the while version can cause extreme delays + * before a simulation crashes due to large forces which + * can cause unlimited displacements. + * Also allowing multiple shifts would index fshift beyond bounds. + */ + for (i = DIM-1; i >= 1; i--) + { + if (dx[i] > pbc->hbox_diag[i]) + { + for (j = i; j >= 0; j--) + { dx[j] -= pbc->box[i][j]; + } ishift[i]--; - } else if (dx[i] <= pbc->mhbox_diag[i]) { - for (j=i; j>=0; j--) + } + else if (dx[i] <= pbc->mhbox_diag[i]) + { + for (j = i; j >= 0; j--) + { dx[j] += pbc->box[i][j]; + } ishift[i]++; } - d2min += dx[i]*dx[i]; } - } - if (pbc->dim != XX) { /* Allow 2 shifts in x */ - if (dx[XX] > pbc->hbox_diag[XX]) { + if (dx[XX] > pbc->hbox_diag[XX]) + { dx[XX] -= pbc->fbox_diag[XX]; ishift[XX]--; - if (dx[XX] > pbc->hbox_diag[XX]) { + if (dx[XX] > pbc->hbox_diag[XX]) + { dx[XX] -= pbc->fbox_diag[XX]; ishift[XX]--; } - } else if (dx[XX] <= pbc->mhbox_diag[XX]) { + } + else if (dx[XX] <= pbc->mhbox_diag[XX]) + { dx[XX] += pbc->fbox_diag[XX]; ishift[XX]++; - if (dx[XX] <= pbc->mhbox_diag[XX]) { + if (dx[XX] <= pbc->mhbox_diag[XX]) + { dx[XX] += pbc->fbox_diag[XX]; ishift[XX]++; } } - d2min += dx[XX]*dx[XX]; - } - if (d2min > pbc->max_cutoff2) { - copy_rvec(dx,dx_start); - copy_ivec(ishift,ishift_start); - /* Now try all possible shifts, when the distance is within max_cutoff - * it must be the shortest possible distance. - */ - i = 0; - while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) { - rvec_add(dx_start,pbc->tric_vec[i],trial); - d2trial = 0; - for(j=0; jdim) { - d2trial += trial[j]*trial[j]; + /* dx is the distance in a rectangular box */ + d2min = norm2(dx); + if (d2min > pbc->max_cutoff2) + { + copy_rvec(dx, dx_start); + copy_ivec(ishift, ishift_start); + d2min = norm2(dx); + /* Now try all possible shifts, when the distance is within max_cutoff + * it must be the shortest possible distance. + */ + i = 0; + while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) + { + rvec_add(dx_start, pbc->tric_vec[i], trial); + d2trial = norm2(trial); + if (d2trial < d2min) + { + copy_rvec(trial, dx); + ivec_add(ishift_start, pbc->tric_shift[i], ishift); + d2min = d2trial; } + i++; } - if (d2trial < d2min) { - copy_rvec(trial,dx); - ivec_add(ishift_start,pbc->tric_shift[i],ishift); - d2min = d2trial; + } + break; + case epbcdx2D_RECT: + for (i = 0; i < DIM; i++) + { + if (i != pbc->dim) + { + if (dx[i] > pbc->hbox_diag[i]) + { + dx[i] -= pbc->fbox_diag[i]; + ishift[i]--; + } + else if (dx[i] <= pbc->mhbox_diag[i]) + { + dx[i] += pbc->fbox_diag[i]; + ishift[i]++; + } } - i++; } - } - break; - case epbcdx1D_RECT: - i = pbc->dim; - if (dx[i] > pbc->hbox_diag[i]) { - dx[i] -= pbc->fbox_diag[i]; - ishift[i]--; - } else if (dx[i] <= pbc->mhbox_diag[i]) { - dx[i] += pbc->fbox_diag[i]; - ishift[i]++; - } - break; - case epbcdx1D_TRIC: - i = pbc->dim; - if (dx[i] > pbc->hbox_diag[i]) { - rvec_dec(dx,pbc->box[i]); - ishift[i]--; - } else if (dx[i] <= pbc->mhbox_diag[i]) { - rvec_inc(dx,pbc->box[i]); - ishift[i]++; - } - break; - case epbcdxSCREW_RECT: - /* The shift definition requires x first */ - if (dx[XX] > pbc->hbox_diag[XX]) { - dx[XX] -= pbc->fbox_diag[XX]; - ishift[XX]--; - } else if (dx[XX] <= pbc->mhbox_diag[XX]) { - dx[XX] += pbc->fbox_diag[XX]; - ishift[XX]++; - } - if (ishift[XX] == 1 || ishift[XX] == -1) { - /* Rotate around the x-axis in the middle of the box */ - dx[YY] = pbc->box[YY][YY] - x1[YY] - x2[YY]; - dx[ZZ] = pbc->box[ZZ][ZZ] - x1[ZZ] - x2[ZZ]; - } - /* Normal pbc for y and z */ - for(i=YY; i<=ZZ; i++) { - if (dx[i] > pbc->hbox_diag[i]) { + break; + case epbcdx2D_TRIC: + d2min = 0; + for (i = DIM-1; i >= 1; i--) + { + if (i != pbc->dim) + { + if (dx[i] > pbc->hbox_diag[i]) + { + for (j = i; j >= 0; j--) + { + dx[j] -= pbc->box[i][j]; + } + ishift[i]--; + } + else if (dx[i] <= pbc->mhbox_diag[i]) + { + for (j = i; j >= 0; j--) + { + dx[j] += pbc->box[i][j]; + } + ishift[i]++; + } + d2min += dx[i]*dx[i]; + } + } + if (pbc->dim != XX) + { + /* Allow 2 shifts in x */ + if (dx[XX] > pbc->hbox_diag[XX]) + { + dx[XX] -= pbc->fbox_diag[XX]; + ishift[XX]--; + if (dx[XX] > pbc->hbox_diag[XX]) + { + dx[XX] -= pbc->fbox_diag[XX]; + ishift[XX]--; + } + } + else if (dx[XX] <= pbc->mhbox_diag[XX]) + { + dx[XX] += pbc->fbox_diag[XX]; + ishift[XX]++; + if (dx[XX] <= pbc->mhbox_diag[XX]) + { + dx[XX] += pbc->fbox_diag[XX]; + ishift[XX]++; + } + } + d2min += dx[XX]*dx[XX]; + } + if (d2min > pbc->max_cutoff2) + { + copy_rvec(dx, dx_start); + copy_ivec(ishift, ishift_start); + /* Now try all possible shifts, when the distance is within max_cutoff + * it must be the shortest possible distance. + */ + i = 0; + while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) + { + rvec_add(dx_start, pbc->tric_vec[i], trial); + d2trial = 0; + for (j = 0; j < DIM; j++) + { + if (j != pbc->dim) + { + d2trial += trial[j]*trial[j]; + } + } + if (d2trial < d2min) + { + copy_rvec(trial, dx); + ivec_add(ishift_start, pbc->tric_shift[i], ishift); + d2min = d2trial; + } + i++; + } + } + break; + case epbcdx1D_RECT: + i = pbc->dim; + if (dx[i] > pbc->hbox_diag[i]) + { dx[i] -= pbc->fbox_diag[i]; ishift[i]--; - } else if (dx[i] <= pbc->mhbox_diag[i]) { + } + else if (dx[i] <= pbc->mhbox_diag[i]) + { dx[i] += pbc->fbox_diag[i]; ishift[i]++; } - } - break; - case epbcdxNOPBC: - case epbcdxUNSUPPORTED: - break; - default: - gmx_fatal(FARGS,"Internal error in pbc_dx_aiuc, set_pbc_dd or set_pbc has not been called"); - break; + break; + case epbcdx1D_TRIC: + i = pbc->dim; + if (dx[i] > pbc->hbox_diag[i]) + { + rvec_dec(dx, pbc->box[i]); + ishift[i]--; + } + else if (dx[i] <= pbc->mhbox_diag[i]) + { + rvec_inc(dx, pbc->box[i]); + ishift[i]++; + } + break; + case epbcdxSCREW_RECT: + /* The shift definition requires x first */ + if (dx[XX] > pbc->hbox_diag[XX]) + { + dx[XX] -= pbc->fbox_diag[XX]; + ishift[XX]--; + } + else if (dx[XX] <= pbc->mhbox_diag[XX]) + { + dx[XX] += pbc->fbox_diag[XX]; + ishift[XX]++; + } + if (ishift[XX] == 1 || ishift[XX] == -1) + { + /* Rotate around the x-axis in the middle of the box */ + dx[YY] = pbc->box[YY][YY] - x1[YY] - x2[YY]; + dx[ZZ] = pbc->box[ZZ][ZZ] - x1[ZZ] - x2[ZZ]; + } + /* Normal pbc for y and z */ + for (i = YY; i <= ZZ; i++) + { + if (dx[i] > pbc->hbox_diag[i]) + { + dx[i] -= pbc->fbox_diag[i]; + ishift[i]--; + } + else if (dx[i] <= pbc->mhbox_diag[i]) + { + dx[i] += pbc->fbox_diag[i]; + ishift[i]++; + } + } + break; + case epbcdxNOPBC: + case epbcdxUNSUPPORTED: + break; + default: + gmx_fatal(FARGS, "Internal error in pbc_dx_aiuc, set_pbc_dd or set_pbc has not been called"); + break; } is = IVEC2IS(ishift); if (debug) { - range_check_mesg(is,0,SHIFTS,"PBC shift vector index range check."); + range_check_mesg(is, 0, SHIFTS, "PBC shift vector index range check."); } - return is; + return is; } -void pbc_dx_d(const t_pbc *pbc,const dvec x1, const dvec x2, dvec dx) +void pbc_dx_d(const t_pbc *pbc, const dvec x1, const dvec x2, dvec dx) { - int i,j; - dvec dx_start,trial; - double d2min,d2trial; + int i, j; + dvec dx_start, trial; + double d2min, d2trial; gmx_bool bRot; - dvec_sub(x1,x2,dx); + dvec_sub(x1, x2, dx); - switch (pbc->ePBCDX) { - case epbcdxRECTANGULAR: - case epbcdx2D_RECT: - for(i=0; idim) { - while (dx[i] > pbc->hbox_diag[i]) { - dx[i] -= pbc->fbox_diag[i]; - } - while (dx[i] <= pbc->mhbox_diag[i]) { - dx[i] += pbc->fbox_diag[i]; + switch (pbc->ePBCDX) + { + case epbcdxRECTANGULAR: + case epbcdx2D_RECT: + for (i = 0; i < DIM; i++) + { + if (i != pbc->dim) + { + while (dx[i] > pbc->hbox_diag[i]) + { + dx[i] -= pbc->fbox_diag[i]; + } + while (dx[i] <= pbc->mhbox_diag[i]) + { + dx[i] += pbc->fbox_diag[i]; + } } } - } - break; - case epbcdxTRICLINIC: - case epbcdx2D_TRIC: - d2min = 0; - for(i=DIM-1; i>=0; i--) { - if (i != pbc->dim) { - while (dx[i] > pbc->hbox_diag[i]) { - for (j=i; j>=0; j--) - dx[j] -= pbc->box[i][j]; - } - while (dx[i] <= pbc->mhbox_diag[i]) { - for (j=i; j>=0; j--) - dx[j] += pbc->box[i][j]; + break; + case epbcdxTRICLINIC: + case epbcdx2D_TRIC: + d2min = 0; + for (i = DIM-1; i >= 0; i--) + { + if (i != pbc->dim) + { + while (dx[i] > pbc->hbox_diag[i]) + { + for (j = i; j >= 0; j--) + { + dx[j] -= pbc->box[i][j]; + } + } + while (dx[i] <= pbc->mhbox_diag[i]) + { + for (j = i; j >= 0; j--) + { + dx[j] += pbc->box[i][j]; + } + } + d2min += dx[i]*dx[i]; } - d2min += dx[i]*dx[i]; } - } - if (d2min > pbc->max_cutoff2) { - copy_dvec(dx,dx_start); - /* Now try all possible shifts, when the distance is within max_cutoff - * it must be the shortest possible distance. - */ - i = 0; - while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) { - for(j=0; jtric_vec[i][j]; - } - d2trial = 0; - for(j=0; jdim) { - d2trial += trial[j]*trial[j]; + if (d2min > pbc->max_cutoff2) + { + copy_dvec(dx, dx_start); + /* Now try all possible shifts, when the distance is within max_cutoff + * it must be the shortest possible distance. + */ + i = 0; + while ((d2min > pbc->max_cutoff2) && (i < pbc->ntric_vec)) + { + for (j = 0; j < DIM; j++) + { + trial[j] = dx_start[j] + pbc->tric_vec[i][j]; } + d2trial = 0; + for (j = 0; j < DIM; j++) + { + if (j != pbc->dim) + { + d2trial += trial[j]*trial[j]; + } + } + if (d2trial < d2min) + { + copy_dvec(trial, dx); + d2min = d2trial; + } + i++; } - if (d2trial < d2min) { - copy_dvec(trial,dx); - d2min = d2trial; - } - i++; } - } - break; - case epbcdxSCREW_RECT: - /* The shift definition requires x first */ - bRot = FALSE; - while (dx[XX] > pbc->hbox_diag[XX]) { - dx[XX] -= pbc->fbox_diag[XX]; - bRot = !bRot; - } - while (dx[XX] <= pbc->mhbox_diag[XX]) { - dx[XX] += pbc->fbox_diag[YY]; - bRot = !bRot; - } - if (bRot) { - /* Rotate around the x-axis in the middle of the box */ - dx[YY] = pbc->box[YY][YY] - x1[YY] - x2[YY]; - dx[ZZ] = pbc->box[ZZ][ZZ] - x1[ZZ] - x2[ZZ]; - } - /* Normal pbc for y and z */ - for(i=YY; i<=ZZ; i++) { - while (dx[i] > pbc->hbox_diag[i]) { - dx[i] -= pbc->fbox_diag[i]; + break; + case epbcdxSCREW_RECT: + /* The shift definition requires x first */ + bRot = FALSE; + while (dx[XX] > pbc->hbox_diag[XX]) + { + dx[XX] -= pbc->fbox_diag[XX]; + bRot = !bRot; } - while (dx[i] <= pbc->mhbox_diag[i]) { - dx[i] += pbc->fbox_diag[i]; + while (dx[XX] <= pbc->mhbox_diag[XX]) + { + dx[XX] += pbc->fbox_diag[YY]; + bRot = !bRot; } - } - break; - case epbcdxNOPBC: - case epbcdxUNSUPPORTED: - break; - default: - gmx_fatal(FARGS,"Internal error in pbc_dx, set_pbc has not been called"); - break; + if (bRot) + { + /* Rotate around the x-axis in the middle of the box */ + dx[YY] = pbc->box[YY][YY] - x1[YY] - x2[YY]; + dx[ZZ] = pbc->box[ZZ][ZZ] - x1[ZZ] - x2[ZZ]; + } + /* Normal pbc for y and z */ + for (i = YY; i <= ZZ; i++) + { + while (dx[i] > pbc->hbox_diag[i]) + { + dx[i] -= pbc->fbox_diag[i]; + } + while (dx[i] <= pbc->mhbox_diag[i]) + { + dx[i] += pbc->fbox_diag[i]; + } + } + break; + case epbcdxNOPBC: + case epbcdxUNSUPPORTED: + break; + default: + gmx_fatal(FARGS, "Internal error in pbc_dx, set_pbc has not been called"); + break; } } -gmx_bool image_rect(ivec xi,ivec xj,ivec box_size,real rlong2,int *shift,real *r2) +gmx_bool image_rect(ivec xi, ivec xj, ivec box_size, real rlong2, int *shift, real *r2) { - int m,t; - int dx,b,b_2; - real dxr,rij2; - - rij2=0.0; - t=0; - for(m=0; (m b_2) - dx-=b; + { + dx -= b; + } else - t+=1; - dxr=dx; - rij2+=dxr*dxr; - if (rij2 >= rlong2) + { + t += 1; + } + dxr = dx; + rij2 += dxr*dxr; + if (rij2 >= rlong2) + { return FALSE; + } } *shift = t; - *r2 = rij2; + *r2 = rij2; return TRUE; } -gmx_bool image_cylindric(ivec xi,ivec xj,ivec box_size,real rlong2, - int *shift,real *r2) +gmx_bool image_cylindric(ivec xi, ivec xj, ivec box_size, real rlong2, + int *shift, real *r2) { - int m,t; - int dx,b,b_2; - real dxr,rij2; - - rij2=0.0; - t=0; - for(m=0; (m b_2) - dx-=b; + { + dx -= b; + } else - t+=1; + { + t += 1; + } - dxr=dx; - rij2+=dxr*dxr; - if (m < ZZ) { - if (rij2 >= rlong2) + dxr = dx; + rij2 += dxr*dxr; + if (m < ZZ) + { + if (rij2 >= rlong2) + { return FALSE; + } } } *shift = t; - *r2 = rij2; + *r2 = rij2; return TRUE; } -void calc_shifts(matrix box,rvec shift_vec[]) +void calc_shifts(matrix box, rvec shift_vec[]) { - int k,l,m,d,n,test; + int k, l, m, d, n, test; - n=0; - for(m = -D_BOX_Z; m <= D_BOX_Z; m++) - for(l = -D_BOX_Y; l <= D_BOX_Y; l++) - for(k = -D_BOX_X; k <= D_BOX_X; k++,n++) { - test = XYZ2IS(k,l,m); + n = 0; + for (m = -D_BOX_Z; m <= D_BOX_Z; m++) + { + for (l = -D_BOX_Y; l <= D_BOX_Y; l++) + { + for (k = -D_BOX_X; k <= D_BOX_X; k++, n++) + { + test = XYZ2IS(k, l, m); if (n != test) + { gmx_incons("inconsistent shift numbering"); - for(d = 0; d < DIM; d++) + } + for (d = 0; d < DIM; d++) + { shift_vec[n][d] = k*box[XX][d] + l*box[YY][d] + m*box[ZZ][d]; + } } + } + } } -void calc_box_center(int ecenter,matrix box,rvec box_center) +void calc_box_center(int ecenter, matrix box, rvec box_center) { - int d,m; + int d, m; clear_rvec(box_center); - switch (ecenter) { - case ecenterTRIC: - for(m=0; (m=0; m--) { + for (m = npbcdim-1; m >= 0; m--) + { while (x[i][m] < 0) { - for(d=0; d<=m; d++) + for (d = 0; d <= m; d++) { x[i][d] += box[m][d]; } } while (x[i][m] >= box[m][m]) { - for(d=0; d<=m; d++) + for (d = 0; d <= m; d++) { x[i][d] -= box[m][d]; } @@ -1250,9 +1596,10 @@ void put_atoms_in_box(int ePBC,matrix box,int natoms,rvec x[]) } else { - for(i=0; i=0; m--) { + for (i = 0; (i < natoms); i++) + { + for (m = DIM-1; m >= 0; m--) + { shift = shift_center[m]; - if (m == 0) { + if (m == 0) + { shift += shm01*x[i][1] + shm02*x[i][2]; - } else if (m == 1) { + } + else if (m == 1) + { shift += shm12*x[i][2]; } while (x[i][m]-shift < 0) - for(d=0; d<=m; d++) + { + for (d = 0; d <= m; d++) + { x[i][d] += box[m][d]; + } + } while (x[i][m]-shift >= box[m][m]) - for(d=0; d<=m; d++) + { + for (d = 0; d <= m; d++) + { x[i][d] -= box[m][d]; + } + } } + } } const char * -put_atoms_in_compact_unitcell(int ePBC,int ecenter,matrix box, - int natoms,rvec x[]) - { +put_atoms_in_compact_unitcell(int ePBC, int ecenter, matrix box, + int natoms, rvec x[]) +{ t_pbc pbc; - rvec box_center,dx; - int i; - - set_pbc(&pbc,ePBC,box); - calc_box_center(ecenter,box,box_center); - for(i=0; i3 && isdigit(name[0])) { - temp=name[0]; - for(i=1; i 3 && isdigit(name[0])) + { + temp = name[0]; + for (i = 1; i < length; i++) + { + name[i-1] = name[i]; + } + name[length-1] = temp; + } } static void xlate_atomname_gmx2pdb(char *name) { - int i,length; - char temp; - - length=strlen(name); - if (length>3 && isdigit(name[length-1])) { - temp=name[length-1]; - for(i=length-1; i>0; --i) - name[i]=name[i-1]; - name[0]=temp; - } + int i, length; + char temp; + + length = strlen(name); + if (length > 3 && isdigit(name[length-1])) + { + temp = name[length-1]; + for (i = length-1; i > 0; --i) + { + name[i] = name[i-1]; + } + name[0] = temp; + } } -void gmx_write_pdb_box(FILE *out,int ePBC,matrix box) +void gmx_write_pdb_box(FILE *out, int ePBC, matrix box) { - real alpha,beta,gamma; - - if (ePBC == -1) - ePBC = guess_ePBC(box); - - if (ePBC == epbcNONE) - return; - - if (norm2(box[YY])*norm2(box[ZZ])!=0) - alpha = RAD2DEG*acos(cos_angle_no_table(box[YY],box[ZZ])); - else - alpha = 90; - if (norm2(box[XX])*norm2(box[ZZ])!=0) - beta = RAD2DEG*acos(cos_angle_no_table(box[XX],box[ZZ])); - else - beta = 90; - if (norm2(box[XX])*norm2(box[YY])!=0) - gamma = RAD2DEG*acos(cos_angle_no_table(box[XX],box[YY])); - else - gamma = 90; - fprintf(out,"REMARK THIS IS A SIMULATION BOX\n"); - if (ePBC != epbcSCREW) { - fprintf(out,"CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f %-11s%4d\n", - 10*norm(box[XX]),10*norm(box[YY]),10*norm(box[ZZ]), - alpha,beta,gamma,"P 1",1); - } else { - /* Double the a-vector length and write the correct space group */ - fprintf(out,"CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f %-11s%4d\n", - 20*norm(box[XX]),10*norm(box[YY]),10*norm(box[ZZ]), - alpha,beta,gamma,"P 21 1 1",1); - - } + real alpha, beta, gamma; + + if (ePBC == -1) + { + ePBC = guess_ePBC(box); + } + + if (ePBC == epbcNONE) + { + return; + } + + if (norm2(box[YY])*norm2(box[ZZ]) != 0) + { + alpha = RAD2DEG*acos(cos_angle_no_table(box[YY], box[ZZ])); + } + else + { + alpha = 90; + } + if (norm2(box[XX])*norm2(box[ZZ]) != 0) + { + beta = RAD2DEG*acos(cos_angle_no_table(box[XX], box[ZZ])); + } + else + { + beta = 90; + } + if (norm2(box[XX])*norm2(box[YY]) != 0) + { + gamma = RAD2DEG*acos(cos_angle_no_table(box[XX], box[YY])); + } + else + { + gamma = 90; + } + fprintf(out, "REMARK THIS IS A SIMULATION BOX\n"); + if (ePBC != epbcSCREW) + { + fprintf(out, "CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f %-11s%4d\n", + 10*norm(box[XX]), 10*norm(box[YY]), 10*norm(box[ZZ]), + alpha, beta, gamma, "P 1", 1); + } + else + { + /* Double the a-vector length and write the correct space group */ + fprintf(out, "CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f %-11s%4d\n", + 20*norm(box[XX]), 10*norm(box[YY]), 10*norm(box[ZZ]), + alpha, beta, gamma, "P 21 1 1", 1); + + } } -static void read_cryst1(char *line,int *ePBC,matrix box) +static void read_cryst1(char *line, int *ePBC, matrix box) { #define SG_SIZE 11 - char sa[12],sb[12],sc[12],sg[SG_SIZE+1],ident; - double fa,fb,fc,alpha,beta,gamma,cosa,cosb,cosg,sing; - int syma,symb,symc; - int ePBC_file; - - sscanf(line,"%*s%s%s%s%lf%lf%lf",sa,sb,sc,&alpha,&beta,&gamma); - - ePBC_file = -1; - if (strlen(line) >= 55) { - strncpy(sg,line+55,SG_SIZE); - sg[SG_SIZE] = '\0'; - ident = ' '; - syma = 0; - symb = 0; - symc = 0; - sscanf(sg,"%c %d %d %d",&ident,&syma,&symb,&symc); - if (ident == 'P' && syma == 1 && symb <= 1 && symc <= 1) { - fc = strtod(sc,NULL)*0.1; - ePBC_file = (fc > 0 ? epbcXYZ : epbcXY); - } - if (ident == 'P' && syma == 21 && symb == 1 && symc == 1) { - ePBC_file = epbcSCREW; - } - } - if (ePBC) { - *ePBC = ePBC_file; - } - - if (box) { - fa = strtod(sa,NULL)*0.1; - fb = strtod(sb,NULL)*0.1; - fc = strtod(sc,NULL)*0.1; - if (ePBC_file == epbcSCREW) { - fa *= 0.5; - } - clear_mat(box); - box[XX][XX] = fa; - if ((alpha!=90.0) || (beta!=90.0) || (gamma!=90.0)) { - if (alpha != 90.0) { - cosa = cos(alpha*DEG2RAD); - } else { - cosa = 0; - } - if (beta != 90.0) { - cosb = cos(beta*DEG2RAD); - } else { - cosb = 0; - } - if (gamma != 90.0) { - cosg = cos(gamma*DEG2RAD); - sing = sin(gamma*DEG2RAD); - } else { - cosg = 0; - sing = 1; - } - box[YY][XX] = fb*cosg; - box[YY][YY] = fb*sing; - box[ZZ][XX] = fc*cosb; - box[ZZ][YY] = fc*(cosa - cosb*cosg)/sing; - box[ZZ][ZZ] = sqrt(fc*fc - - box[ZZ][XX]*box[ZZ][XX] - box[ZZ][YY]*box[ZZ][YY]); - } else { - box[YY][YY] = fb; - box[ZZ][ZZ] = fc; - } - } + char sa[12], sb[12], sc[12], sg[SG_SIZE+1], ident; + double fa, fb, fc, alpha, beta, gamma, cosa, cosb, cosg, sing; + int syma, symb, symc; + int ePBC_file; + + sscanf(line, "%*s%s%s%s%lf%lf%lf", sa, sb, sc, &alpha, &beta, &gamma); + + ePBC_file = -1; + if (strlen(line) >= 55) + { + strncpy(sg, line+55, SG_SIZE); + sg[SG_SIZE] = '\0'; + ident = ' '; + syma = 0; + symb = 0; + symc = 0; + sscanf(sg, "%c %d %d %d", &ident, &syma, &symb, &symc); + if (ident == 'P' && syma == 1 && symb <= 1 && symc <= 1) + { + fc = strtod(sc, NULL)*0.1; + ePBC_file = (fc > 0 ? epbcXYZ : epbcXY); + } + if (ident == 'P' && syma == 21 && symb == 1 && symc == 1) + { + ePBC_file = epbcSCREW; + } + } + if (ePBC) + { + *ePBC = ePBC_file; + } + + if (box) + { + fa = strtod(sa, NULL)*0.1; + fb = strtod(sb, NULL)*0.1; + fc = strtod(sc, NULL)*0.1; + if (ePBC_file == epbcSCREW) + { + fa *= 0.5; + } + clear_mat(box); + box[XX][XX] = fa; + if ((alpha != 90.0) || (beta != 90.0) || (gamma != 90.0)) + { + if (alpha != 90.0) + { + cosa = cos(alpha*DEG2RAD); + } + else + { + cosa = 0; + } + if (beta != 90.0) + { + cosb = cos(beta*DEG2RAD); + } + else + { + cosb = 0; + } + if (gamma != 90.0) + { + cosg = cos(gamma*DEG2RAD); + sing = sin(gamma*DEG2RAD); + } + else + { + cosg = 0; + sing = 1; + } + box[YY][XX] = fb*cosg; + box[YY][YY] = fb*sing; + box[ZZ][XX] = fc*cosb; + box[ZZ][YY] = fc*(cosa - cosb*cosg)/sing; + box[ZZ][ZZ] = sqrt(fc*fc + - box[ZZ][XX]*box[ZZ][XX] - box[ZZ][YY]*box[ZZ][YY]); + } + else + { + box[YY][YY] = fb; + box[ZZ][ZZ] = fc; + } + } } - -void write_pdbfile_indexed(FILE *out,const char *title, - t_atoms *atoms,rvec x[], - int ePBC,matrix box,char chainid, - int model_nr, atom_id nindex, const atom_id index[], - gmx_conect conect, gmx_bool bTerSepChains) + +void write_pdbfile_indexed(FILE *out, const char *title, + t_atoms *atoms, rvec x[], + int ePBC, matrix box, char chainid, + int model_nr, atom_id nindex, const atom_id index[], + gmx_conect conect, gmx_bool bTerSepChains) { - gmx_conect_t *gc = (gmx_conect_t *)conect; - char resnm[6],nm[6],pdbform[128],pukestring[100]; - atom_id i,ii; - int resind,resnr,type; - unsigned char resic,ch; - real occup,bfac; - gmx_bool bOccup; - int nlongname=0; - int chainnum,lastchainnum; - int lastresind,lastchainresind; - gmx_residuetype_t rt; - const char *p_restype; - const char *p_lastrestype; - - gmx_residuetype_init(&rt); - - bromacs(pukestring,99); - fprintf(out,"TITLE %s\n",(title && title[0])?title:pukestring); - if (bWideFormat) { - fprintf(out,"REMARK This file does not adhere to the PDB standard\n"); - fprintf(out,"REMARK As a result of, some programs may not like it\n"); - } - if (box && ( norm2(box[XX]) || norm2(box[YY]) || norm2(box[ZZ]) ) ) { - gmx_write_pdb_box(out,ePBC,box); - } - if (atoms->pdbinfo) { - /* Check whether any occupancies are set, in that case leave it as is, - * otherwise set them all to one - */ - bOccup = TRUE; - for (ii=0; (iipdbinfo[i].occup == 0.0); - } - } - else - bOccup = FALSE; - - fprintf(out,"MODEL %8d\n",model_nr>0 ? model_nr : 1); - - lastchainresind = -1; - lastchainnum = -1; - resind = -1; - p_restype = NULL; - - for (ii=0; iiatom[i].resind; - chainnum = atoms->resinfo[resind].chainnum; - p_lastrestype = p_restype; - gmx_residuetype_get_type(rt,*atoms->resinfo[resind].name,&p_restype); - - /* Add a TER record if we changed chain, and if either the previous or this chain is protein/DNA/RNA. */ - if( bTerSepChains && ii>0 && chainnum != lastchainnum) - { - /* Only add TER if the previous chain contained protein/DNA/RNA. */ - if(gmx_residuetype_is_protein(rt,p_lastrestype) || gmx_residuetype_is_dna(rt,p_lastrestype) || gmx_residuetype_is_rna(rt,p_lastrestype)) - { - fprintf(out,"TER\n"); - } - lastchainnum = chainnum; - lastchainresind = lastresind; - } - - strncpy(resnm,*atoms->resinfo[resind].name,sizeof(resnm)-1); - strncpy(nm,*atoms->atomname[i],sizeof(nm)-1); - /* rename HG12 to 2HG1, etc. */ - xlate_atomname_gmx2pdb(nm); - resnr = atoms->resinfo[resind].nr; - resic = atoms->resinfo[resind].ic; - if (chainid!=' ') - { - ch = chainid; + gmx_conect_t *gc = (gmx_conect_t *)conect; + char resnm[6], nm[6], pdbform[128], pukestring[100]; + atom_id i, ii; + int resind, resnr, type; + unsigned char resic, ch; + real occup, bfac; + gmx_bool bOccup; + int nlongname = 0; + int chainnum, lastchainnum; + int lastresind, lastchainresind; + gmx_residuetype_t rt; + const char *p_restype; + const char *p_lastrestype; + + gmx_residuetype_init(&rt); + + bromacs(pukestring, 99); + fprintf(out, "TITLE %s\n", (title && title[0]) ? title : pukestring); + if (bWideFormat) + { + fprintf(out, "REMARK This file does not adhere to the PDB standard\n"); + fprintf(out, "REMARK As a result of, some programs may not like it\n"); + } + if (box && ( norm2(box[XX]) || norm2(box[YY]) || norm2(box[ZZ]) ) ) + { + gmx_write_pdb_box(out, ePBC, box); + } + if (atoms->pdbinfo) + { + /* Check whether any occupancies are set, in that case leave it as is, + * otherwise set them all to one + */ + bOccup = TRUE; + for (ii = 0; (ii < nindex) && bOccup; ii++) + { + i = index[ii]; + bOccup = bOccup && (atoms->pdbinfo[i].occup == 0.0); + } } else { - ch = atoms->resinfo[resind].chainid; - - if (ch == 0) - { - ch = ' '; - } + bOccup = FALSE; } - if (resnr>=10000) - resnr = resnr % 10000; - if (atoms->pdbinfo) { - type = atoms->pdbinfo[i].type; - occup = bOccup ? 1.0 : atoms->pdbinfo[i].occup; - bfac = atoms->pdbinfo[i].bfac; + + fprintf(out, "MODEL %8d\n", model_nr > 0 ? model_nr : 1); + + lastchainresind = -1; + lastchainnum = -1; + resind = -1; + p_restype = NULL; + + for (ii = 0; ii < nindex; ii++) + { + i = index[ii]; + lastresind = resind; + resind = atoms->atom[i].resind; + chainnum = atoms->resinfo[resind].chainnum; + p_lastrestype = p_restype; + gmx_residuetype_get_type(rt, *atoms->resinfo[resind].name, &p_restype); + + /* Add a TER record if we changed chain, and if either the previous or this chain is protein/DNA/RNA. */ + if (bTerSepChains && ii > 0 && chainnum != lastchainnum) + { + /* Only add TER if the previous chain contained protein/DNA/RNA. */ + if (gmx_residuetype_is_protein(rt, p_lastrestype) || gmx_residuetype_is_dna(rt, p_lastrestype) || gmx_residuetype_is_rna(rt, p_lastrestype)) + { + fprintf(out, "TER\n"); + } + lastchainnum = chainnum; + lastchainresind = lastresind; + } + + strncpy(resnm, *atoms->resinfo[resind].name, sizeof(resnm)-1); + strncpy(nm, *atoms->atomname[i], sizeof(nm)-1); + /* rename HG12 to 2HG1, etc. */ + xlate_atomname_gmx2pdb(nm); + resnr = atoms->resinfo[resind].nr; + resic = atoms->resinfo[resind].ic; + if (chainid != ' ') + { + ch = chainid; + } + else + { + ch = atoms->resinfo[resind].chainid; + + if (ch == 0) + { + ch = ' '; + } + } + if (resnr >= 10000) + { + resnr = resnr % 10000; + } + if (atoms->pdbinfo) + { + type = atoms->pdbinfo[i].type; + occup = bOccup ? 1.0 : atoms->pdbinfo[i].occup; + bfac = atoms->pdbinfo[i].bfac; + } + else + { + type = 0; + occup = 1.0; + bfac = 0.0; + } + if (bWideFormat) + { + strcpy(pdbform, + "%-6s%5u %-4.4s %3.3s %c%4d%c %10.5f%10.5f%10.5f%8.4f%8.4f %2s\n"); + } + else + { + /* Check whether atomname is an element name */ + if ((strlen(nm) < 4) && (gmx_strcasecmp(nm, atoms->atom[i].elem) != 0)) + { + strcpy(pdbform, get_pdbformat()); + } + else + { + strcpy(pdbform, get_pdbformat4()); + if (strlen(nm) > 4) + { + int maxwln = 20; + if (nlongname < maxwln) + { + fprintf(stderr, "WARNING: Writing out atom name (%s) longer than 4 characters to .pdb file\n", nm); + } + else if (nlongname == maxwln) + { + fprintf(stderr, "WARNING: More than %d long atom names, will not write more warnings\n", maxwln); + } + nlongname++; + } + } + strcat(pdbform, "%6.2f%6.2f %2s\n"); + } + fprintf(out, pdbform, pdbtp[type], (i+1)%100000, nm, resnm, ch, resnr, + (resic == '\0') ? ' ' : resic, + 10*x[i][XX], 10*x[i][YY], 10*x[i][ZZ], occup, bfac, atoms->atom[i].elem); + if (atoms->pdbinfo && atoms->pdbinfo[i].bAnisotropic) + { + fprintf(out, "ANISOU%5u %-4.4s%3.3s %c%4d%c %7d%7d%7d%7d%7d%7d\n", + (i+1)%100000, nm, resnm, ch, resnr, + (resic == '\0') ? ' ' : resic, + atoms->pdbinfo[i].uij[0], atoms->pdbinfo[i].uij[1], + atoms->pdbinfo[i].uij[2], atoms->pdbinfo[i].uij[3], + atoms->pdbinfo[i].uij[4], atoms->pdbinfo[i].uij[5]); + } } - else { - type = 0; - occup = 1.0; - bfac = 0.0; + + fprintf(out, "TER\n"); + fprintf(out, "ENDMDL\n"); + + if (NULL != gc) + { + /* Write conect records */ + for (i = 0; (i < gc->nconect); i++) + { + fprintf(out, "CONECT%5d%5d\n", gc->conect[i].ai+1, gc->conect[i].aj+1); + } } - if (bWideFormat) - strcpy(pdbform, - "%-6s%5u %-4.4s %3.3s %c%4d%c %10.5f%10.5f%10.5f%8.4f%8.4f %2s\n"); - else { - /* Check whether atomname is an element name */ - if ((strlen(nm)<4) && (gmx_strcasecmp(nm,atoms->atom[i].elem) != 0)) - strcpy(pdbform,get_pdbformat()); - else { - strcpy(pdbform,get_pdbformat4()); - if (strlen(nm) > 4) { - int maxwln=20; - if (nlongname < maxwln) { - fprintf(stderr,"WARNING: Writing out atom name (%s) longer than 4 characters to .pdb file\n",nm); - } else if (nlongname == maxwln) { - fprintf(stderr,"WARNING: More than %d long atom names, will not write more warnings\n",maxwln); - } - nlongname++; - } - } - strcat(pdbform,"%6.2f%6.2f %2s\n"); - } - fprintf(out,pdbform,pdbtp[type],(i+1)%100000,nm,resnm,ch,resnr, - (resic == '\0') ? ' ' : resic, - 10*x[i][XX],10*x[i][YY],10*x[i][ZZ],occup,bfac,atoms->atom[i].elem); - if (atoms->pdbinfo && atoms->pdbinfo[i].bAnisotropic) { - fprintf(out,"ANISOU%5u %-4.4s%3.3s %c%4d%c %7d%7d%7d%7d%7d%7d\n", - (i+1)%100000,nm,resnm,ch,resnr, - (resic == '\0') ? ' ' : resic, - atoms->pdbinfo[i].uij[0],atoms->pdbinfo[i].uij[1], - atoms->pdbinfo[i].uij[2],atoms->pdbinfo[i].uij[3], - atoms->pdbinfo[i].uij[4],atoms->pdbinfo[i].uij[5]); - } - } - - fprintf(out,"TER\n"); - fprintf(out,"ENDMDL\n"); - - if (NULL != gc) { - /* Write conect records */ - for(i=0; (inconect); i++) { - fprintf(out,"CONECT%5d%5d\n",gc->conect[i].ai+1,gc->conect[i].aj+1); - } - } - - gmx_residuetype_destroy(rt); + + gmx_residuetype_destroy(rt); } -void write_pdbfile(FILE *out,const char *title, t_atoms *atoms,rvec x[], - int ePBC,matrix box,char chainid,int model_nr,gmx_conect conect,gmx_bool bTerSepChains) +void write_pdbfile(FILE *out, const char *title, t_atoms *atoms, rvec x[], + int ePBC, matrix box, char chainid, int model_nr, gmx_conect conect, gmx_bool bTerSepChains) { - atom_id i,*index; - - snew(index,atoms->nr); - for(i=0; inr; i++) - index[i]=i; - write_pdbfile_indexed(out,title,atoms,x,ePBC,box,chainid,model_nr, - atoms->nr,index,conect,bTerSepChains); - sfree(index); + atom_id i, *index; + + snew(index, atoms->nr); + for (i = 0; i < atoms->nr; i++) + { + index[i] = i; + } + write_pdbfile_indexed(out, title, atoms, x, ePBC, box, chainid, model_nr, + atoms->nr, index, conect, bTerSepChains); + sfree(index); } int line2type(char *line) { - int k; - char type[8]; - - for(k=0; (k<6); k++) - type[k]=line[k]; - type[k]='\0'; - - for(k=0; (k=0); i--) - if ((strcmp(anm,*(atoms->atomname[i])) == 0) && - (atomnr == atoms->pdbinfo[i].atomnr)) - break; - if (i < 0) - fprintf(stderr,"Skipping ANISOU record (atom %s %d not found)\n", - anm,atomnr); - else { - if (sscanf(line+29,"%d%d%d%d%d%d", - &atoms->pdbinfo[i].uij[U11],&atoms->pdbinfo[i].uij[U22], - &atoms->pdbinfo[i].uij[U33],&atoms->pdbinfo[i].uij[U12], - &atoms->pdbinfo[i].uij[U13],&atoms->pdbinfo[i].uij[U23]) - == 6) { - atoms->pdbinfo[i].bAnisotropic = TRUE; - } - else { - fprintf(stderr,"Invalid ANISOU record for atom %d\n",i); - atoms->pdbinfo[i].bAnisotropic = FALSE; - } - } + int i, j, k, atomnr; + char nc = '\0'; + char anr[12], anm[12]; + + /* Skip over type */ + j = 6; + for (k = 0; (k < 5); k++, j++) + { + anr[k] = line[j]; + } + anr[k] = nc; + j++; + for (k = 0; (k < 4); k++, j++) + { + anm[k] = line[j]; + } + anm[k] = nc; + j++; + + /* Strip off spaces */ + trim(anm); + + /* Search backwards for number and name only */ + atomnr = strtol(anr, NULL, 10); + for (i = natom-1; (i >= 0); i--) + { + if ((strcmp(anm, *(atoms->atomname[i])) == 0) && + (atomnr == atoms->pdbinfo[i].atomnr)) + { + break; + } + } + if (i < 0) + { + fprintf(stderr, "Skipping ANISOU record (atom %s %d not found)\n", + anm, atomnr); + } + else + { + if (sscanf(line+29, "%d%d%d%d%d%d", + &atoms->pdbinfo[i].uij[U11], &atoms->pdbinfo[i].uij[U22], + &atoms->pdbinfo[i].uij[U33], &atoms->pdbinfo[i].uij[U12], + &atoms->pdbinfo[i].uij[U13], &atoms->pdbinfo[i].uij[U23]) + == 6) + { + atoms->pdbinfo[i].bAnisotropic = TRUE; + } + else + { + fprintf(stderr, "Invalid ANISOU record for atom %d\n", i); + atoms->pdbinfo[i].bAnisotropic = FALSE; + } + } } -void get_pdb_atomnumber(t_atoms *atoms,gmx_atomprop_t aps) +void get_pdb_atomnumber(t_atoms *atoms, gmx_atomprop_t aps) { - int i,atomnumber,len; - size_t k; - char anm[6],anm_copy[6],*ptr; - char nc='\0'; - real eval; - - if (!atoms->pdbinfo) { - gmx_incons("Trying to deduce atomnumbers when no pdb information is present"); - } - for(i=0; (inr); i++) { - strcpy(anm,atoms->pdbinfo[i].atomnm); - strcpy(anm_copy,atoms->pdbinfo[i].atomnm); - len = strlen(anm); - atomnumber = NOTSET; - 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); - else { - anm_copy[1] = nc; - if (gmx_atomprop_query(aps,epropElement,"???",anm_copy,&eval)) - atomnumber = gmx_nint(eval); - } - } - if (atomnumber == NOTSET) { - k=0; - while ((k < strlen(anm)) && (isspace(anm[k]) || isdigit(anm[k]))) - k++; - anm_copy[0] = anm[k]; - anm_copy[1] = nc; - if (gmx_atomprop_query(aps,epropElement,"???",anm_copy,&eval)) - atomnumber = gmx_nint(eval); - } - atoms->atom[i].atomnumber = atomnumber; - ptr = gmx_atomprop_element(aps,atomnumber); - strncpy(atoms->atom[i].elem,ptr==NULL ? "" : ptr,4); - if (debug) - fprintf(debug,"Atomnumber for atom '%s' is %d\n",anm,atomnumber); - } + int i, atomnumber, len; + size_t k; + char anm[6], anm_copy[6], *ptr; + char nc = '\0'; + real eval; + + if (!atoms->pdbinfo) + { + gmx_incons("Trying to deduce atomnumbers when no pdb information is present"); + } + 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] != ' ') && ((len <= 2) || ((len > 2) && !isdigit(anm[2])))) + { + anm_copy[2] = nc; + if (gmx_atomprop_query(aps, epropElement, "???", anm_copy, &eval)) + { + atomnumber = gmx_nint(eval); + } + else + { + anm_copy[1] = nc; + if (gmx_atomprop_query(aps, epropElement, "???", anm_copy, &eval)) + { + atomnumber = gmx_nint(eval); + } + } + } + if (atomnumber == NOTSET) + { + k = 0; + while ((k < strlen(anm)) && (isspace(anm[k]) || isdigit(anm[k]))) + { + k++; + } + anm_copy[0] = anm[k]; + anm_copy[1] = nc; + if (gmx_atomprop_query(aps, epropElement, "???", anm_copy, &eval)) + { + atomnumber = gmx_nint(eval); + } + } + atoms->atom[i].atomnumber = atomnumber; + ptr = gmx_atomprop_element(aps, atomnumber); + strncpy(atoms->atom[i].elem, ptr == NULL ? "" : ptr, 4); + if (debug) + { + fprintf(debug, "Atomnumber for atom '%s' is %d\n", anm, atomnumber); + } + } } static int read_atom(t_symtab *symtab, - char line[],int type,int natom, - t_atoms *atoms,rvec x[],int chainnum,gmx_bool bChange) + char line[], int type, int natom, + t_atoms *atoms, rvec x[], int chainnum, gmx_bool bChange) { - t_atom *atomn; - int j,k; - char nc='\0'; - char anr[12],anm[12],anm_copy[12],altloc,resnm[12],rnr[12]; - char xc[12],yc[12],zc[12],occup[12],bfac[12]; - unsigned char resic; - char chainid; - int resnr,atomnumber; - - if (natom>=atoms->nr) - gmx_fatal(FARGS,"\nFound more atoms (%d) in pdb file than expected (%d)", - natom+1,atoms->nr); - - /* Skip over type */ - j=6; - for(k=0; (k<5); k++,j++) anr[k]=line[j]; - anr[k]=nc; - trim(anr); - j++; - for(k=0; (k<4); k++,j++) anm[k]=line[j]; - anm[k]=nc; - strcpy(anm_copy,anm); - rtrim(anm_copy); - atomnumber = NOTSET; - trim(anm); - altloc=line[j]; - j++; - for(k=0; (k<4); k++,j++) - resnm[k]=line[j]; - resnm[k]=nc; - trim(resnm); - - chainid = line[j]; - j++; - - for(k=0; (k<4); k++,j++) { - rnr[k] = line[j]; - } - rnr[k] = nc; - trim(rnr); - resnr = strtol(rnr, NULL, 10); - resic = line[j]; - j+=4; - - /* X,Y,Z Coordinate */ - for(k=0; (k<8); k++,j++) xc[k]=line[j]; - xc[k]=nc; - for(k=0; (k<8); k++,j++) yc[k]=line[j]; - yc[k]=nc; - for(k=0; (k<8); k++,j++) zc[k]=line[j]; - zc[k]=nc; - - /* Weight */ - for(k=0; (k<6); k++,j++) occup[k]=line[j]; - occup[k]=nc; - - /* B-Factor */ - for(k=0; (k<7); k++,j++) bfac[k]=line[j]; - bfac[k]=nc; - - if (atoms->atom) { - atomn=&(atoms->atom[natom]); - if ((natom==0) || - atoms->resinfo[atoms->atom[natom-1].resind].nr != resnr || - atoms->resinfo[atoms->atom[natom-1].resind].ic != resic || - (strcmp(*atoms->resinfo[atoms->atom[natom-1].resind].name,resnm) != 0)) - { - if (natom == 0) { - atomn->resind = 0; - } else { - atomn->resind = atoms->atom[natom-1].resind + 1; - } - atoms->nres = atomn->resind + 1; - t_atoms_set_resinfo(atoms,natom,symtab,resnm,resnr,resic,chainnum,chainid); + t_atom *atomn; + int j, k; + char nc = '\0'; + char anr[12], anm[12], anm_copy[12], altloc, resnm[12], rnr[12]; + char xc[12], yc[12], zc[12], occup[12], bfac[12]; + unsigned char resic; + char chainid; + int resnr, atomnumber; + + if (natom >= atoms->nr) + { + gmx_fatal(FARGS, "\nFound more atoms (%d) in pdb file than expected (%d)", + natom+1, atoms->nr); } - else + + /* Skip over type */ + j = 6; + for (k = 0; (k < 5); k++, j++) + { + anr[k] = line[j]; + } + anr[k] = nc; + trim(anr); + j++; + for (k = 0; (k < 4); k++, j++) + { + anm[k] = line[j]; + } + anm[k] = nc; + strcpy(anm_copy, anm); + rtrim(anm_copy); + atomnumber = NOTSET; + trim(anm); + altloc = line[j]; + j++; + for (k = 0; (k < 4); k++, j++) + { + resnm[k] = line[j]; + } + resnm[k] = nc; + trim(resnm); + + chainid = line[j]; + j++; + + for (k = 0; (k < 4); k++, j++) { - atomn->resind = atoms->atom[natom-1].resind; - } - if (bChange) { - xlate_atomname_pdb2gmx(anm); - } - atoms->atomname[natom]=put_symtab(symtab,anm); - atomn->m = 0.0; - atomn->q = 0.0; - atomn->atomnumber = atomnumber; - atomn->elem[0] = '\0'; - } - x[natom][XX]=strtod(xc,NULL)*0.1; - x[natom][YY]=strtod(yc,NULL)*0.1; - x[natom][ZZ]=strtod(zc,NULL)*0.1; - if (atoms->pdbinfo) { - atoms->pdbinfo[natom].type=type; - atoms->pdbinfo[natom].atomnr=strtol(anr, NULL, 10); - atoms->pdbinfo[natom].altloc=altloc; - strcpy(atoms->pdbinfo[natom].atomnm,anm_copy); - atoms->pdbinfo[natom].bfac=strtod(bfac,NULL); - atoms->pdbinfo[natom].occup=strtod(occup,NULL); - } - natom++; - - return natom; + rnr[k] = line[j]; + } + rnr[k] = nc; + trim(rnr); + resnr = strtol(rnr, NULL, 10); + resic = line[j]; + j += 4; + + /* X,Y,Z Coordinate */ + for (k = 0; (k < 8); k++, j++) + { + xc[k] = line[j]; + } + xc[k] = nc; + for (k = 0; (k < 8); k++, j++) + { + yc[k] = line[j]; + } + yc[k] = nc; + for (k = 0; (k < 8); k++, j++) + { + zc[k] = line[j]; + } + zc[k] = nc; + + /* Weight */ + for (k = 0; (k < 6); k++, j++) + { + occup[k] = line[j]; + } + occup[k] = nc; + + /* B-Factor */ + for (k = 0; (k < 7); k++, j++) + { + bfac[k] = line[j]; + } + bfac[k] = nc; + + if (atoms->atom) + { + atomn = &(atoms->atom[natom]); + if ((natom == 0) || + atoms->resinfo[atoms->atom[natom-1].resind].nr != resnr || + atoms->resinfo[atoms->atom[natom-1].resind].ic != resic || + (strcmp(*atoms->resinfo[atoms->atom[natom-1].resind].name, resnm) != 0)) + { + if (natom == 0) + { + atomn->resind = 0; + } + else + { + atomn->resind = atoms->atom[natom-1].resind + 1; + } + atoms->nres = atomn->resind + 1; + t_atoms_set_resinfo(atoms, natom, symtab, resnm, resnr, resic, chainnum, chainid); + } + else + { + atomn->resind = atoms->atom[natom-1].resind; + } + if (bChange) + { + xlate_atomname_pdb2gmx(anm); + } + atoms->atomname[natom] = put_symtab(symtab, anm); + atomn->m = 0.0; + atomn->q = 0.0; + atomn->atomnumber = atomnumber; + atomn->elem[0] = '\0'; + } + x[natom][XX] = strtod(xc, NULL)*0.1; + x[natom][YY] = strtod(yc, NULL)*0.1; + x[natom][ZZ] = strtod(zc, NULL)*0.1; + if (atoms->pdbinfo) + { + atoms->pdbinfo[natom].type = type; + atoms->pdbinfo[natom].atomnr = strtol(anr, NULL, 10); + atoms->pdbinfo[natom].altloc = altloc; + strcpy(atoms->pdbinfo[natom].atomnm, anm_copy); + atoms->pdbinfo[natom].bfac = strtod(bfac, NULL); + atoms->pdbinfo[natom].occup = strtod(occup, NULL); + } + natom++; + + return natom; } gmx_bool is_hydrogen(const char *nm) { - char buf[30]; - - strcpy(buf,nm); - trim(buf); - - if (buf[0] == 'H') - return TRUE; - else if ((isdigit(buf[0])) && (buf[1] == 'H')) - return TRUE; - return FALSE; + char buf[30]; + + strcpy(buf, nm); + trim(buf); + + if (buf[0] == 'H') + { + return TRUE; + } + else if ((isdigit(buf[0])) && (buf[1] == 'H')) + { + return TRUE; + } + return FALSE; } gmx_bool is_dummymass(const char *nm) { - char buf[30]; - - strcpy(buf,nm); - trim(buf); - - if ((buf[0] == 'M') && isdigit(buf[strlen(buf)-1])) - return TRUE; - - return FALSE; + char buf[30]; + + strcpy(buf, nm); + trim(buf); + + if ((buf[0] == 'M') && isdigit(buf[strlen(buf)-1])) + { + return TRUE; + } + + return FALSE; } -static void gmx_conect_addline(gmx_conect_t *con,char *line) +static void gmx_conect_addline(gmx_conect_t *con, char *line) { - int n,ai,aj; - char format[32],form2[32]; - - sprintf(form2,"%%*s"); - sprintf(format,"%s%%d",form2); - if (sscanf(line,format,&ai) == 1) { - do { - strcat(form2,"%*s"); - sprintf(format,"%s%%d",form2); - n = sscanf(line,format,&aj); - if (n == 1) { - srenew(con->conect,++con->nconect); - con->conect[con->nconect-1].ai = ai-1; - con->conect[con->nconect-1].aj = aj-1; - } - } while (n == 1); - } + int n, ai, aj; + char format[32], form2[32]; + + sprintf(form2, "%%*s"); + sprintf(format, "%s%%d", form2); + if (sscanf(line, format, &ai) == 1) + { + do + { + strcat(form2, "%*s"); + sprintf(format, "%s%%d", form2); + n = sscanf(line, format, &aj); + if (n == 1) + { + srenew(con->conect, ++con->nconect); + con->conect[con->nconect-1].ai = ai-1; + con->conect[con->nconect-1].aj = aj-1; + } + } + while (n == 1); + } } -void gmx_conect_dump(FILE *fp,gmx_conect conect) +void gmx_conect_dump(FILE *fp, gmx_conect conect) { - gmx_conect_t *gc = (gmx_conect_t *)conect; - int i; - - for(i=0; (inconect); i++) - fprintf(fp,"%6s%5d%5d\n","CONECT", - gc->conect[i].ai+1,gc->conect[i].aj+1); + gmx_conect_t *gc = (gmx_conect_t *)conect; + int i; + + for (i = 0; (i < gc->nconect); i++) + { + fprintf(fp, "%6s%5d%5d\n", "CONECT", + gc->conect[i].ai+1, gc->conect[i].aj+1); + } } gmx_conect gmx_conect_init() { - gmx_conect_t *gc; - - snew(gc,1); - - return (gmx_conect) gc; + gmx_conect_t *gc; + + snew(gc, 1); + + return (gmx_conect) gc; } void gmx_conect_done(gmx_conect conect) { - gmx_conect_t *gc = (gmx_conect_t *)conect; - - sfree(gc->conect); + gmx_conect_t *gc = (gmx_conect_t *)conect; + + sfree(gc->conect); } -gmx_bool gmx_conect_exist(gmx_conect conect,int ai,int aj) +gmx_bool gmx_conect_exist(gmx_conect conect, int ai, int aj) { - gmx_conect_t *gc = (gmx_conect_t *)conect; - int i; - - /* if (!gc->bSorted) - sort_conect(gc);*/ - - for(i=0; (inconect); i++) - if (((gc->conect[i].ai == ai) && - (gc->conect[i].aj == aj)) || - ((gc->conect[i].aj == ai) && - (gc->conect[i].ai == aj))) - return TRUE; - return FALSE; + gmx_conect_t *gc = (gmx_conect_t *)conect; + int i; + + /* if (!gc->bSorted) + sort_conect(gc);*/ + + for (i = 0; (i < gc->nconect); i++) + { + if (((gc->conect[i].ai == ai) && + (gc->conect[i].aj == aj)) || + ((gc->conect[i].aj == ai) && + (gc->conect[i].ai == aj))) + { + return TRUE; + } + } + return FALSE; } -void gmx_conect_add(gmx_conect conect,int ai,int aj) +void gmx_conect_add(gmx_conect conect, int ai, int aj) { - gmx_conect_t *gc = (gmx_conect_t *)conect; - int i; - - /* if (!gc->bSorted) - sort_conect(gc);*/ - - if (!gmx_conect_exist(conect,ai,aj)) { - srenew(gc->conect,++gc->nconect); - gc->conect[gc->nconect-1].ai = ai; - gc->conect[gc->nconect-1].aj = aj; - } + gmx_conect_t *gc = (gmx_conect_t *)conect; + int i; + + /* if (!gc->bSorted) + sort_conect(gc);*/ + + if (!gmx_conect_exist(conect, ai, aj)) + { + srenew(gc->conect, ++gc->nconect); + gc->conect[gc->nconect-1].ai = ai; + gc->conect[gc->nconect-1].aj = aj; + } } -int read_pdbfile(FILE *in,char *title,int *model_nr, - t_atoms *atoms,rvec x[],int *ePBC,matrix box,gmx_bool bChange, - gmx_conect conect) +int read_pdbfile(FILE *in, char *title, int *model_nr, + t_atoms *atoms, rvec x[], int *ePBC, matrix box, gmx_bool bChange, + gmx_conect conect) { gmx_conect_t *gc = (gmx_conect_t *)conect; - t_symtab symtab; - gmx_bool bCOMPND; - gmx_bool bConnWarn = FALSE; - char line[STRLEN+1]; - int line_type; - char *c,*d; - int natom,chainnum,nres_ter_prev=0; - char chidmax=' '; - gmx_bool bStop=FALSE; - - if (ePBC) + t_symtab symtab; + gmx_bool bCOMPND; + gmx_bool bConnWarn = FALSE; + char line[STRLEN+1]; + int line_type; + char *c, *d; + int natom, chainnum, nres_ter_prev = 0; + char chidmax = ' '; + gmx_bool bStop = FALSE; + + if (ePBC) { /* Only assume pbc when there is a CRYST1 entry */ *ePBC = epbcNONE; } - if (box != NULL) + if (box != NULL) { clear_mat(box); } - + open_symtab(&symtab); - bCOMPND=FALSE; - title[0]='\0'; - natom=0; - chainnum=0; - while (!bStop && (fgets2(line,STRLEN,in) != NULL)) + bCOMPND = FALSE; + title[0] = '\0'; + natom = 0; + chainnum = 0; + while (!bStop && (fgets2(line, STRLEN, in) != NULL)) { line_type = line2type(line); - - switch(line_type) + + switch (line_type) { case epdbATOM: case epdbHETATM: - natom = read_atom(&symtab,line,line_type,natom,atoms,x,chainnum,bChange); + natom = read_atom(&symtab, line, line_type, natom, atoms, x, chainnum, bChange); break; - + case epdbANISOU: if (atoms->pdbinfo) { - read_anisou(line,natom,atoms); + read_anisou(line, natom, atoms); } break; - + case epdbCRYST1: - read_cryst1(line,ePBC,box); + read_cryst1(line, ePBC, box); break; - + case epdbTITLE: case epdbHEADER: - if (strlen(line) > 6) + if (strlen(line) > 6) { - c=line+6; + c = line+6; /* skip HEADER or TITLE and spaces */ - while (c[0]!=' ') c++; - while (c[0]==' ') c++; + while (c[0] != ' ') + { + c++; + } + while (c[0] == ' ') + { + c++; + } /* truncate after title */ - d=strstr(c," "); - if (d) + d = strstr(c, " "); + if (d) { - d[0]='\0'; + d[0] = '\0'; } - if (strlen(c)>0) + if (strlen(c) > 0) { - strcpy(title,c); + strcpy(title, c); } } break; - + case epdbCOMPND: - if ((!strstr(line,": ")) || (strstr(line+6,"MOLECULE:"))) + if ((!strstr(line, ": ")) || (strstr(line+6, "MOLECULE:"))) { - if ( !(c=strstr(line+6,"MOLECULE:")) ) + if (!(c = strstr(line+6, "MOLECULE:")) ) { - c=line; + c = line; } /* skip 'MOLECULE:' and spaces */ - while (c[0]!=' ') c++; - while (c[0]==' ') c++; + while (c[0] != ' ') + { + c++; + } + while (c[0] == ' ') + { + c++; + } /* truncate after title */ - d=strstr(c," "); - if (d) + d = strstr(c, " "); + if (d) { - while ( (d[-1]==';') && d>c) d--; - d[0]='\0'; + while ( (d[-1] == ';') && d > c) + { + d--; + } + d[0] = '\0'; } if (strlen(c) > 0) { - if (bCOMPND) + if (bCOMPND) { - strcat(title,"; "); - strcat(title,c); - } + strcat(title, "; "); + strcat(title, c); + } else { - strcpy(title,c); + strcpy(title, c); } } - bCOMPND=TRUE; + bCOMPND = TRUE; } break; - + case epdbTER: chainnum++; break; - + case epdbMODEL: - if(model_nr) + if (model_nr) { - sscanf(line,"%*s%d",model_nr); + sscanf(line, "%*s%d", model_nr); } break; case epdbENDMDL: - bStop=TRUE; + bStop = TRUE; break; case epdbCONECT: - if (gc) + if (gc) { - gmx_conect_addline(gc,line); + gmx_conect_addline(gc, line); } else if (!bConnWarn) { - fprintf(stderr,"WARNING: all CONECT records are ignored\n"); + fprintf(stderr, "WARNING: all CONECT records are ignored\n"); bConnWarn = TRUE; } break; - + default: break; } @@ -835,61 +1004,65 @@ int read_pdbfile(FILE *in,char *title,int *model_nr, return natom; } -void get_pdb_coordnum(FILE *in,int *natoms) +void get_pdb_coordnum(FILE *in, int *natoms) { char line[STRLEN]; - - *natoms=0; - while (fgets2(line,STRLEN,in)) + + *natoms = 0; + while (fgets2(line, STRLEN, in)) { - if ( strncmp(line,"ENDMDL",6) == 0 ) + if (strncmp(line, "ENDMDL", 6) == 0) { break; } - if ((strncmp(line,"ATOM ",6) == 0) || (strncmp(line,"HETATM",6) == 0)) + if ((strncmp(line, "ATOM ", 6) == 0) || (strncmp(line, "HETATM", 6) == 0)) { (*natoms)++; } } } -void read_pdb_conf(const char *infile,char *title, - t_atoms *atoms,rvec x[],int *ePBC,matrix box,gmx_bool bChange, - gmx_conect conect) +void read_pdb_conf(const char *infile, char *title, + t_atoms *atoms, rvec x[], int *ePBC, matrix box, gmx_bool bChange, + gmx_conect conect) { - FILE *in; - - in = gmx_fio_fopen(infile,"r"); - read_pdbfile(in,title,NULL,atoms,x,ePBC,box,bChange,conect); - gmx_fio_fclose(in); + FILE *in; + + in = gmx_fio_fopen(infile, "r"); + read_pdbfile(in, title, NULL, atoms, x, ePBC, box, bChange, conect); + gmx_fio_fclose(in); } gmx_conect gmx_conect_generate(t_topology *top) { - int f,i; - gmx_conect gc; - - /* Fill the conect records */ - gc = gmx_conect_init(); - - for(f=0; (fidef.il[f].nr); i+=interaction_function[f].nratoms+1) { - gmx_conect_add(gc,top->idef.il[f].iatoms[i+1], - top->idef.il[f].iatoms[i+2]); - } - } - return gc; + int f, i; + gmx_conect gc; + + /* Fill the conect records */ + gc = gmx_conect_init(); + + for (f = 0; (f < F_NRE); f++) + { + if (IS_CHEMBOND(f)) + { + for (i = 0; (i < top->idef.il[f].nr); i += interaction_function[f].nratoms+1) + { + gmx_conect_add(gc, top->idef.il[f].iatoms[i+1], + top->idef.il[f].iatoms[i+2]); + } + } + } + return gc; } const char* get_pdbformat() { - static const char *pdbformat ="%-6s%5u %-4.4s%3.3s %c%4d%c %8.3f%8.3f%8.3f"; + static const char *pdbformat = "%-6s%5u %-4.4s%3.3s %c%4d%c %8.3f%8.3f%8.3f"; return pdbformat; } const char* get_pdbformat4() { - static const char *pdbformat4="%-6s%5u %-4.4s %3.3s %c%4d%c %8.3f%8.3f%8.3f"; + static const char *pdbformat4 = "%-6s%5u %-4.4s %3.3s %c%4d%c %8.3f%8.3f%8.3f"; return pdbformat4; } diff --git a/src/gromacs/gmxlib/physics.c b/src/gromacs/gmxlib/physics.c index 790f507288..b1feda4004 100644 --- a/src/gromacs/gmxlib/physics.c +++ b/src/gromacs/gmxlib/physics.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * $Id: molprop_util.c,v 1.51 2009/06/01 06:13:18 spoel Exp $ - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 4.0.99 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,111 +17,117 @@ * 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 - * + * * And Hey: * Groningen Machine for Chemical Simulation */ #include #include "string2.h" #include "physics.h" - -double convert2gmx(double x,int unit) + +double convert2gmx(double x, int unit) { - switch (unit) + switch (unit) { - case eg2cAngstrom: - return x*A2NM; - case eg2cNm: - return x; - case eg2cBohr: - return x*BOHR2NM; - case eg2cKcal_Mole: - return x/CAL2JOULE; - case eg2cHartree: - return x*ONE_4PI_EPS0/BOHR2NM; - case eg2cHartree_e: - return x*ONE_4PI_EPS0/BOHR2NM; - case eg2cAngstrom3: - return x*A2NM*A2NM*A2NM; - case eg2cCoulomb: - return x/E_CHARGE; - case eg2cDebye: - return x*DEBYE2ENM; - case eg2cElectron: - return x; - case eg2cBuckingham: - return x*A2NM*DEBYE2ENM; - default: - fprintf(stderr,"Unknown unit %d, not converting.\n",unit); - } + case eg2cAngstrom: + return x*A2NM; + case eg2cNm: + return x; + case eg2cBohr: + return x*BOHR2NM; + case eg2cKcal_Mole: + return x/CAL2JOULE; + case eg2cHartree: + return x*ONE_4PI_EPS0/BOHR2NM; + case eg2cHartree_e: + return x*ONE_4PI_EPS0/BOHR2NM; + case eg2cAngstrom3: + return x*A2NM*A2NM*A2NM; + case eg2cCoulomb: + return x/E_CHARGE; + case eg2cDebye: + return x*DEBYE2ENM; + case eg2cElectron: + return x; + case eg2cBuckingham: + return x*A2NM*DEBYE2ENM; + default: + fprintf(stderr, "Unknown unit %d, not converting.\n", unit); + } return x; } -double gmx2convert(double x,int unit) +double gmx2convert(double x, int unit) { - switch (unit) + switch (unit) { - case eg2cAngstrom: - return x/A2NM; - case eg2cNm: - return x; - case eg2cBohr: - return x/BOHR2NM; - case eg2cKcal_Mole: - return x*CAL2JOULE; - case eg2cHartree: - return x/(ONE_4PI_EPS0/BOHR2NM); - case eg2cHartree_e: - return x/(ONE_4PI_EPS0/BOHR2NM); - case eg2cAngstrom3: - return x/(A2NM*A2NM*A2NM); - case eg2cCoulomb: - return x*E_CHARGE; - case eg2cDebye: - return x/DEBYE2ENM; - case eg2cElectron: - return x; - case eg2cBuckingham: - return x/(A2NM*DEBYE2ENM); - default: - fprintf(stderr,"Unknown unit %d, not converting.\n",unit); - } + case eg2cAngstrom: + return x/A2NM; + case eg2cNm: + return x; + case eg2cBohr: + return x/BOHR2NM; + case eg2cKcal_Mole: + return x*CAL2JOULE; + case eg2cHartree: + return x/(ONE_4PI_EPS0/BOHR2NM); + case eg2cHartree_e: + return x/(ONE_4PI_EPS0/BOHR2NM); + case eg2cAngstrom3: + return x/(A2NM*A2NM*A2NM); + case eg2cCoulomb: + return x*E_CHARGE; + case eg2cDebye: + return x/DEBYE2ENM; + case eg2cElectron: + return x; + case eg2cBuckingham: + return x/(A2NM*DEBYE2ENM); + default: + fprintf(stderr, "Unknown unit %d, not converting.\n", unit); + } return x; } /* This has to have the same order as the enums. */ static const char *eg2c_names[eg2cNR] = { - "Angstrom", "Nm", "Bohr", "Kcal_Mole", + "Angstrom", "Nm", "Bohr", "Kcal_Mole", "Hartree", "Hartree_e", "Angstrom3", "Coulomb", - "Debye", "Electron", "Buckingham" + "Debye", "Electron", "Buckingham" }; int string2unit(char *string) { int i; - - for(i=0; (i= 0) && (unit < eg2cNR)) + { return eg2c_names[unit]; - + } + return NULL; } diff --git a/src/gromacs/gmxlib/physics_test.c b/src/gromacs/gmxlib/physics_test.c index 323c54e553..0cb4f65f72 100644 --- a/src/gromacs/gmxlib/physics_test.c +++ b/src/gromacs/gmxlib/physics_test.c @@ -1,16 +1,17 @@ #include #include "physics.h" -int main(int argc,char *argv[]) +int main(int argc, char *argv[]) { - int i; - double x,y,z; - - x = 3.25; - for(i=0; (iatom,xcm,FALSE); - for(i=0; iatom,x,trans,prcomp); - if (d) - copy_rvec(prcomp, d); - - /* Check whether this trans matrix mirrors the molecule */ - if (det(trans) < 0) { - for(m=0; (matom, xcm, FALSE); + for (i = 0; i < natoms; i++) + { + rvec_dec(x[i], xcm); + } + principal_comp(isize, index, atoms->atom, x, trans, prcomp); + if (d) + { + copy_rvec(prcomp, d); + } + + /* Check whether this trans matrix mirrors the molecule */ + if (det(trans) < 0) + { + for (m = 0; (m < DIM); m++) + { + trans[ZZ][m] = -trans[ZZ][m]; + } + } + rotate_atoms(natoms, NULL, x, trans); + if (v) + { + rotate_atoms(natoms, NULL, v, trans); + } + for (i = 0; i < natoms; i++) + { + rvec_inc(x[i], xcm); + } +} diff --git a/src/gromacs/gmxlib/rando.c b/src/gromacs/gmxlib/rando.c index 1ac4f5e3f5..3b6d9ed6ac 100644 --- a/src/gromacs/gmxlib/rando.c +++ b/src/gromacs/gmxlib/rando.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -50,46 +50,45 @@ int make_seed(void) { #ifdef GMX_NATIVE_WINDOWS - return (int)_getpid(); + return (int)_getpid(); #else - return (int)getpid(); + return (int)getpid(); #endif } - + real rando(int *ig) - /* generate a random number. */ +/* generate a random number. */ { - int irand; + int irand; - int m = 100000000; - real rm = 100000000.0; /* same number as m, but real format */ - int m1 = 10000; - int mult = 31415821; - - real r; - int irandh,irandl,multh,multl; + int m = 100000000; + real rm = 100000000.0; /* same number as m, but real format */ + int m1 = 10000; + int mult = 31415821; - irand = abs(*ig) % m; - - /* multiply irand by mult, but take into account that overflow - * must be discarded, and do not generate an error. - */ - irandh = irand / m1; - irandl = irand % m1; - multh = mult / m1; - multl = mult % m1; - irand = ((irandh*multl+irandl*multh) % m1) * m1 + irandl*multl; - irand = (irand + 1) % m; + real r; + int irandh, irandl, multh, multl; - /* convert irand to a real random number between 0 and 1. */ - r = (irand / 10); - r = r * 10 / rm; - if ((r <= 0) || (r > 1)) - r = 0.0; - *ig = irand; - - return r; -} + irand = abs(*ig) % m; + /* multiply irand by mult, but take into account that overflow + * must be discarded, and do not generate an error. + */ + irandh = irand / m1; + irandl = irand % m1; + multh = mult / m1; + multl = mult % m1; + irand = ((irandh*multl+irandl*multh) % m1) * m1 + irandl*multl; + irand = (irand + 1) % m; + /* convert irand to a real random number between 0 and 1. */ + r = (irand / 10); + r = r * 10 / rm; + if ((r <= 0) || (r > 1)) + { + r = 0.0; + } + *ig = irand; + return r; +} diff --git a/src/gromacs/gmxlib/random.c b/src/gromacs/gmxlib/random.c index 8cf98e8c84..1002e7d5f7 100644 --- a/src/gromacs/gmxlib/random.c +++ b/src/gromacs/gmxlib/random.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -47,139 +47,159 @@ #include "mtop_util.h" static void low_mspeed(real tempi, - gmx_mtop_t *mtop,rvec v[], gmx_rng_t rng) + gmx_mtop_t *mtop, rvec v[], gmx_rng_t rng) { - int i,m,nrdf; - real boltz,sd; - real ekin,temp,mass,scal; - gmx_mtop_atomloop_all_t aloop; - t_atom *atom; - - boltz=BOLTZ*tempi; - ekin=0.0; - nrdf=0; - aloop = gmx_mtop_atomloop_all_init(mtop); - while (gmx_mtop_atomloop_all_next(aloop,&i,&atom)) { - mass = atom->m; - if (mass > 0) { - sd=sqrt(boltz/mass); - for (m=0; (mm; + if (mass > 0) + { + sd = sqrt(boltz/mass); + for (m = 0; (m < DIM); m++) + { + v[i][m] = sd*gmx_rng_gaussian_real(rng); + ekin += 0.5*mass*v[i][m]*v[i][m]; + } + nrdf += DIM; + } + } + temp = (2.0*ekin)/(nrdf*BOLTZ); + if (temp > 0) + { + scal = sqrt(tempi/temp); + for (i = 0; (i < mtop->natoms); i++) + { + for (m = 0; (m < DIM); m++) + { + v[i][m] *= scal; + } + } + } + fprintf(stderr, "Velocities were taken from a Maxwell distribution at %g K\n", + tempi); + if (debug) + { + fprintf(debug, + "Velocities were taken from a Maxwell distribution\n" + "Initial generated temperature: %12.5e (scaled to: %12.5e)\n", + temp, tempi); } - } - temp=(2.0*ekin)/(nrdf*BOLTZ); - if (temp > 0) { - scal=sqrt(tempi/temp); - for(i=0; (inatoms); i++) - for(m=0; (mmaxreal > 0) { - sfree(b->rbuf); - } - - sfree(b); + if (b->maxreal > 0) + { + sfree(b->rbuf); + } + + sfree(b); } void reset_bin(t_bin *b) { - b->nreal = 0; + b->nreal = 0; } -int add_binr(t_bin *b,int nr,real r[]) +int add_binr(t_bin *b, int nr, real r[]) { #define MULT 4 - int i,rest,index; - double *rbuf; - - if (b->nreal+nr > b->maxreal) { - b->maxreal=b->nreal+nr; - rest=b->maxreal % MULT; - if (rest != 0) - b->maxreal+=MULT-rest; - srenew(b->rbuf,b->maxreal); - } - /* Copy pointer */ - rbuf=b->rbuf+b->nreal; - for(i=0; (inreal; - b->nreal+=nr; - - return index; + int i, rest, index; + double *rbuf; + + if (b->nreal+nr > b->maxreal) + { + b->maxreal = b->nreal+nr; + rest = b->maxreal % MULT; + if (rest != 0) + { + b->maxreal += MULT-rest; + } + srenew(b->rbuf, b->maxreal); + } + /* Copy pointer */ + rbuf = b->rbuf+b->nreal; + for (i = 0; (i < nr); i++) + { + rbuf[i] = r[i]; + } + + index = b->nreal; + b->nreal += nr; + + return index; } -int add_bind(t_bin *b,int nr,double r[]) +int add_bind(t_bin *b, int nr, double r[]) { #define MULT 4 - int i,rest,index; - double *rbuf; - - if (b->nreal+nr > b->maxreal) { - b->maxreal=b->nreal+nr; - rest=b->maxreal % MULT; - if (rest != 0) - b->maxreal+=MULT-rest; - srenew(b->rbuf,b->maxreal); - } - /* Copy pointer */ - rbuf=b->rbuf+b->nreal; - for(i=0; (inreal; - b->nreal+=nr; - - return index; + int i, rest, index; + double *rbuf; + + if (b->nreal+nr > b->maxreal) + { + b->maxreal = b->nreal+nr; + rest = b->maxreal % MULT; + if (rest != 0) + { + b->maxreal += MULT-rest; + } + srenew(b->rbuf, b->maxreal); + } + /* Copy pointer */ + rbuf = b->rbuf+b->nreal; + for (i = 0; (i < nr); i++) + { + rbuf[i] = r[i]; + } + + index = b->nreal; + b->nreal += nr; + + return index; } -void sum_bin(t_bin *b,t_commrec *cr) +void sum_bin(t_bin *b, t_commrec *cr) { - int i; - - for(i=b->nreal; (imaxreal); i++) - b->rbuf[i]=0; - gmx_sumd(b->maxreal,b->rbuf,cr); + int i; + + for (i = b->nreal; (i < b->maxreal); i++) + { + b->rbuf[i] = 0; + } + gmx_sumd(b->maxreal, b->rbuf, cr); } -void extract_binr(t_bin *b,int index,int nr,real r[]) +void extract_binr(t_bin *b, int index, int nr, real r[]) { - int i; - double *rbuf; - - rbuf = b->rbuf+index; - for(i=0; (irbuf+index; + for (i = 0; (i < nr); i++) + { + r[i] = rbuf[i]; + } } -void extract_bind(t_bin *b,int index,int nr,double r[]) +void extract_bind(t_bin *b, int index, int nr, double r[]) { - int i; - double *rbuf; - - rbuf = b->rbuf+index; - for(i=0; (irbuf+index; + for (i = 0; (i < nr); i++) + { + r[i] = rbuf[i]; + } } #ifdef DEBUGRBIN -int main(int argc,char *argv[]) +int main(int argc, char *argv[]) { - t_commrec *cr; - t_bin *rb; - double *r; - rvec *v; - int k,i,ni,mi,n,m; - - cr=init_par(&argc,argv); - n=strtol(argv[1],NULL,10); - m=strtol(argv[2],NULL,10); - fprintf(stdlog,"n=%d\n",n); - rb=mk_bin(); - snew(r,n); - snew(v,m); - - for(k=0; (k < 3); k++) { - fprintf(stdlog,"\nk=%d\n",k); - reset_bin(rb); - - for(i=0; (i 0) { - if (debug) - fprintf(debug,"No = on line %d in file %s, ignored\n",lc,fn); - } - } - else { - for(i=0; (i 0) + { + if (debug) + { + fprintf(debug, "No = on line %d in file %s, ignored\n", lc, fn); + } + } + } + else + { + for (i = 0; (i < j); i++) + { + lbuf[i] = buf[i]; + } + lbuf[i] = '\0'; + trim(lbuf); + if (lbuf[0] == '\0') + { + if (debug) + { + fprintf(debug, "Empty left hand side on line %d in file %s, ignored\n", lc, fn); + } + } + else + { + for (i = j+1, k = 0; (buf[i] != '\0'); i++, k++) + { + rbuf[k] = buf[i]; + } + rbuf[k] = '\0'; + trim(rbuf); + if (rbuf[0] == '\0') + { + if (debug) + { + fprintf(debug, "Empty right hand side on line %d in file %s, ignored\n", lc, fn); + } + } + else + { + /* Now finally something sensible */ + int found_index; + + /* first check whether we hit the 'multiple_entries' option */ + if (gmx_strcasecmp_min(eMultentOpt_names[eMultentOptName], lbuf) == 0) + { + /* we now check whether to allow overrides from here or not */ + if (gmx_strcasecmp_min(eMultentOpt_names[eMultentOptNo], rbuf) == 0) + { + allow_override = FALSE; + } + else if (gmx_strcasecmp_min(eMultentOpt_names[eMultentOptLast], rbuf) == 0) + { + allow_override = TRUE; + } + else + { + sprintf(warn_buf, + "Parameter \"%s\" should either be %s or %s\n", + lbuf, + eMultentOpt_names[eMultentOptNo], + eMultentOpt_names[eMultentOptLast]); + warning_error(wi, warn_buf); + } + } + else + { + /* it is a regular option; check for duplicates */ + found_index = search_einp(nin, inp, lbuf); + + if (found_index == -1) + { + /* add a new item */ + srenew(inp, ++nin); + inp[nin-1].inp_count = 1; + inp[nin-1].count = 0; + inp[nin-1].bObsolete = FALSE; + inp[nin-1].bSet = FALSE; + inp[nin-1].name = strdup(lbuf); + inp[nin-1].value = strdup(rbuf); + } + else + { + if (!allow_override) + { + sprintf(warn_buf, + "Parameter \"%s\" doubly defined (and multiple assignments not allowed)\n", + lbuf); + warning_error(wi, warn_buf); + } + else + { + /* override */ + sfree(inp[found_index].value); + inp[found_index].value = strdup(rbuf); + sprintf(warn_buf, + "Overriding existing parameter \"%s\" with value \"%s\"\n", + lbuf, rbuf); + warning_note(wi, warn_buf); + } + } + } + } + } + } + } + } + while (ptr); + + ffclose(in); + + if (debug) + { + fprintf(debug, "Done reading MDP file, there were %d entries in there\n", + nin); + } - *ninp = nin; + *ninp = nin; - return inp; + return inp; } - - -static int inp_comp(const void *a,const void *b) + + +static int inp_comp(const void *a, const void *b) { - return ((t_inpfile *)a)->count - ((t_inpfile *)b)->count; + return ((t_inpfile *)a)->count - ((t_inpfile *)b)->count; } -static void sort_inp(int ninp,t_inpfile inp[]) +static void sort_inp(int ninp, t_inpfile inp[]) { - int i,mm; - - mm=-1; - for(i=0; (i2 && inp[i].name[1]==';')) - fprintf(out,"%-24s\n",inp[i].name); - else - fprintf(out,"%-24s = %s\n",inp[i].name,inp[i].value ? inp[i].value : ""); - } else if (!inp[i].bObsolete) { - sprintf(warn_buf,"Unknown left-hand '%s' in parameter file\n", - inp[i].name); - if (bHaltOnUnknown) { - warning_error(wi,warn_buf); - } else { - warning(wi,warn_buf); - } + FILE *out; + int i; + char warn_buf[STRLEN]; + + sort_inp(ninp, inp); + out = gmx_fio_fopen(fn, "w"); + nice_header(out, fn); + for (i = 0; (i < ninp); i++) + { + if (inp[i].bSet) + { + if (inp[i].name[0] == ';' || (strlen(inp[i].name) > 2 && inp[i].name[1] == ';')) + { + fprintf(out, "%-24s\n", inp[i].name); + } + else + { + fprintf(out, "%-24s = %s\n", inp[i].name, inp[i].value ? inp[i].value : ""); + } + } + else if (!inp[i].bObsolete) + { + sprintf(warn_buf, "Unknown left-hand '%s' in parameter file\n", + inp[i].name); + if (bHaltOnUnknown) + { + warning_error(wi, warn_buf); + } + else + { + warning(wi, warn_buf); + } + } } - } - gmx_fio_fclose(out); + gmx_fio_fclose(out); - check_warning_error(wi,FARGS); + check_warning_error(wi, FARGS); } -void replace_inp_entry(int ninp,t_inpfile *inp,const char *old_entry,const char *new_entry) +void replace_inp_entry(int ninp, t_inpfile *inp, const char *old_entry, const char *new_entry) { - int i; - - for(i=0; (ingraph; i++) + for (i = 0; i < gpbc->ngraph; i++) { if (natoms == gpbc->graph[i].natoms) { @@ -89,27 +89,27 @@ static t_graph *gmx_rmpbc_get_graph(gmx_rmpbc_t gpbc,int ePBC,int natoms) */ if (natoms > gpbc->natoms_init) { - gmx_fatal(FARGS,"Structure or trajectory file has more atoms (%d) than the topology (%d)",natoms,gpbc->natoms_init); + gmx_fatal(FARGS, "Structure or trajectory file has more atoms (%d) than the topology (%d)", natoms, gpbc->natoms_init); } gpbc->ngraph++; - srenew(gpbc->graph,gpbc->ngraph); - gr = &gpbc->graph[gpbc->ngraph-1]; + srenew(gpbc->graph, gpbc->ngraph); + gr = &gpbc->graph[gpbc->ngraph-1]; gr->natoms = natoms; - gr->gr = mk_graph(NULL,gpbc->idef,0,natoms,FALSE,FALSE); + gr->gr = mk_graph(NULL, gpbc->idef, 0, natoms, FALSE, FALSE); } return gr->gr; } -gmx_rmpbc_t gmx_rmpbc_init(t_idef *idef,int ePBC,int natoms, +gmx_rmpbc_t gmx_rmpbc_init(t_idef *idef, int ePBC, int natoms, matrix box) { gmx_rmpbc_t gpbc; - - snew(gpbc,1); + + snew(gpbc, 1); gpbc->natoms_init = natoms; - + /* This sets pbc when we now it, * otherwise we guess it from the instantaneous box in the trajectory. */ @@ -135,7 +135,7 @@ void gmx_rmpbc_done(gmx_rmpbc_t gpbc) if (NULL != gpbc) { - for(i=0; ingraph; i++) + for (i = 0; i < gpbc->ngraph; i++) { done_graph(gpbc->graph[i].gr); } @@ -147,7 +147,7 @@ void gmx_rmpbc_done(gmx_rmpbc_t gpbc) } } -static int gmx_rmpbc_ePBC(gmx_rmpbc_t gpbc,matrix box) +static int gmx_rmpbc_ePBC(gmx_rmpbc_t gpbc, matrix box) { if (NULL != gpbc && gpbc->ePBC >= 0) { @@ -159,88 +159,87 @@ static int gmx_rmpbc_ePBC(gmx_rmpbc_t gpbc,matrix box) } } -void gmx_rmpbc(gmx_rmpbc_t gpbc,int natoms,matrix box,rvec x[]) +void gmx_rmpbc(gmx_rmpbc_t gpbc, int natoms, matrix box, rvec x[]) { - int ePBC; + int ePBC; t_graph *gr; - - ePBC = gmx_rmpbc_ePBC(gpbc,box); - gr = gmx_rmpbc_get_graph(gpbc,ePBC,natoms); + + ePBC = gmx_rmpbc_ePBC(gpbc, box); + gr = gmx_rmpbc_get_graph(gpbc, ePBC, natoms); if (gr != NULL) { - mk_mshift(stdout,gr,ePBC,box,x); - shift_self(gr,box,x); + mk_mshift(stdout, gr, ePBC, box, x); + shift_self(gr, box, x); } } -void gmx_rmpbc_copy(gmx_rmpbc_t gpbc,int natoms,matrix box,rvec x[],rvec x_s[]) +void gmx_rmpbc_copy(gmx_rmpbc_t gpbc, int natoms, matrix box, rvec x[], rvec x_s[]) { - int ePBC; + int ePBC; t_graph *gr; - int i; + int i; - ePBC = gmx_rmpbc_ePBC(gpbc,box); - gr = gmx_rmpbc_get_graph(gpbc,ePBC,natoms); + ePBC = gmx_rmpbc_ePBC(gpbc, box); + gr = gmx_rmpbc_get_graph(gpbc, ePBC, natoms); if (gr != NULL) { - mk_mshift(stdout,gr,ePBC,box,x); - shift_x(gr,box,x,x_s); + mk_mshift(stdout, gr, ePBC, box, x); + shift_x(gr, box, x, x_s); } else { - for(i=0; ibX && fr->bBox) { - ePBC = gmx_rmpbc_ePBC(gpbc,fr->box); - gr = gmx_rmpbc_get_graph(gpbc,ePBC,fr->natoms); + ePBC = gmx_rmpbc_ePBC(gpbc, fr->box); + gr = gmx_rmpbc_get_graph(gpbc, ePBC, fr->natoms); if (gr != NULL) { - mk_mshift(stdout,gr,ePBC,fr->box,fr->x); - shift_self(gr,fr->box,fr->x); + mk_mshift(stdout, gr, ePBC, fr->box, fr->x); + shift_self(gr, fr->box, fr->x); } } } -void rm_gropbc(t_atoms *atoms,rvec x[],matrix box) +void rm_gropbc(t_atoms *atoms, rvec x[], matrix box) { real dist; - int n,m,d; - + int n, m, d; + /* check periodic boundary */ - for(n=1;(nnr);n++) + for (n = 1; (n < atoms->nr); n++) { - for(m=DIM-1; m>=0; m--) + for (m = DIM-1; m >= 0; m--) { dist = x[n][m]-x[n-1][m]; if (fabs(dist) > 0.9*box[m][m]) { - if ( dist > 0 ) + if (dist > 0) { - for(d=0; d<=m; d++) + for (d = 0; d <= m; d++) { x[n][d] -= box[m][d]; } } else { - for(d=0; d<=m; d++) + for (d = 0; d <= m; d++) { x[n][d] += box[m][d]; } } - } + } } } } - diff --git a/src/gromacs/gmxlib/sfactor.c b/src/gromacs/gmxlib/sfactor.c index cad77484b5..5ec013c64f 100644 --- a/src/gromacs/gmxlib/sfactor.c +++ b/src/gromacs/gmxlib/sfactor.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -61,14 +61,14 @@ typedef struct gmx_structurefactors { - int nratoms; - int *p; /* proton number */ - int *n; /* neutron number */ + int nratoms; + int *p; /* proton number */ + int *n; /* neutron number */ /* Parameters for the Cromer Mann fit */ - real **a; /* parameter a */ - real **b; /* parameter b */ - real *c; /* parameter c */ - char **atomnm; /* atomname */ + real **a; /* parameter a */ + real **b; /* parameter b */ + real *c; /* parameter c */ + char **atomnm; /* atomname */ } gmx_structurefactors; @@ -80,15 +80,15 @@ typedef struct reduced_atom{ typedef struct structure_factor { - int n_angles; - int n_groups; - double lambda; - double energy; - double momentum; - double ref_k; - double **F; - int nSteps; - int total_n_atoms; + int n_angles; + int n_groups; + double lambda; + double energy; + double momentum; + double ref_k; + double **F; + int nSteps; + int total_n_atoms; } structure_factor; @@ -101,22 +101,28 @@ extern int * create_indexed_atom_type (reduced_atom_t * atm, int size) * * the last element is set to 0 */ - int *index_atp, i, i_tmp, j; + int *index_atp, i, i_tmp, j; - reduced_atom *att=(reduced_atom *)atm; + reduced_atom *att = (reduced_atom *)atm; snew (index_atp, 1); - i_tmp = 1; + i_tmp = 1; index_atp[0] = att[0].t; - for (i = 1; i < size; i++) { - for (j = 0; j < i_tmp; j++) - if (att[i].t == index_atp[j]) - break; - if (j == i_tmp) { /* i.e. no indexed atom type is == to atm[i].t */ - i_tmp++; - srenew (index_atp, i_tmp * sizeof (int)); - index_atp[i_tmp - 1] = att[i].t; - } + for (i = 1; i < size; i++) + { + for (j = 0; j < i_tmp; j++) + { + if (att[i].t == index_atp[j]) + { + break; + } + } + if (j == i_tmp) /* i.e. no indexed atom type is == to atm[i].t */ + { + i_tmp++; + srenew (index_atp, i_tmp * sizeof (int)); + index_atp[i_tmp - 1] = att[i].t; + } } i_tmp++; srenew (index_atp, i_tmp * sizeof (int)); @@ -128,39 +134,53 @@ extern int * create_indexed_atom_type (reduced_atom_t * atm, int size) extern t_complex *** rc_tensor_allocation(int x, int y, int z) { - t_complex ***t; - int i,j; - - t = (t_complex ***)calloc(x,sizeof(t_complex**)); - if(!t) exit(fprintf(stderr,"\nallocation error")); - t[0] = (t_complex **)calloc(x*y,sizeof(t_complex*)); - if(!t[0]) exit(fprintf(stderr,"\nallocation error")); - t[0][0] = (t_complex *)calloc(x*y*z,sizeof(t_complex)); - if(!t[0][0]) exit(fprintf(stderr,"\nallocation error")); - - for( j = 1 ; j < y ; j++) - t[0][j] = t[0][j-1] + z; - for( i = 1 ; i < x ; i++) { - t[i] = t[i-1] + y; - t[i][0] = t[i-1][0] + y*z; - for( j = 1 ; j < y ; j++) - t[i][j] = t[i][j-1] + z; - } - return t; + t_complex ***t; + int i, j; + + t = (t_complex ***)calloc(x, sizeof(t_complex**)); + if (!t) + { + exit(fprintf(stderr, "\nallocation error")); + } + t[0] = (t_complex **)calloc(x*y, sizeof(t_complex*)); + if (!t[0]) + { + exit(fprintf(stderr, "\nallocation error")); + } + t[0][0] = (t_complex *)calloc(x*y*z, sizeof(t_complex)); + if (!t[0][0]) + { + exit(fprintf(stderr, "\nallocation error")); + } + + for (j = 1; j < y; j++) + { + t[0][j] = t[0][j-1] + z; + } + for (i = 1; i < x; i++) + { + t[i] = t[i-1] + y; + t[i][0] = t[i-1][0] + y*z; + for (j = 1; j < y; j++) + { + t[i][j] = t[i][j-1] + z; + } + } + return t; } extern void compute_structure_factor (structure_factor_t * sft, matrix box, - reduced_atom_t * red, int isize, real start_q, - real end_q, int group,real **sf_table) + reduced_atom_t * red, int isize, real start_q, + real end_q, int group, real **sf_table) { - structure_factor *sf=(structure_factor *)sft; - reduced_atom *redt=(reduced_atom *)red; + structure_factor *sf = (structure_factor *)sft; + reduced_atom *redt = (reduced_atom *)red; - t_complex ***tmpSF; - rvec k_factor; - real kdotx, asf, kx, ky, kz, krr; - int kr, maxkx, maxky, maxkz, i, j, k, p, *counter; + t_complex ***tmpSF; + rvec k_factor; + real kdotx, asf, kx, ky, kz, krr; + int kr, maxkx, maxky, maxkz, i, j, k, p, *counter; k_factor[XX] = 2 * M_PI / box[XX][XX]; @@ -173,126 +193,147 @@ extern void compute_structure_factor (structure_factor_t * sft, matrix box, snew (counter, sf->n_angles); - tmpSF = rc_tensor_allocation(maxkx,maxky,maxkz); + tmpSF = rc_tensor_allocation(maxkx, maxky, maxkz); /* * The big loop... * compute real and imaginary part of the structure factor for every * (kx,ky,kz)) */ - fprintf(stderr,"\n"); - for (i = 0; i < maxkx; i++) { - fprintf (stderr,"\rdone %3.1f%% ", (double)(100.0*(i+1))/maxkx); - kx = i * k_factor[XX]; - for (j = 0; j < maxky; j++) { - ky = j * k_factor[YY]; - for (k = 0; k < maxkz; k++) - if (i != 0 || j != 0 || k != 0) { - kz = k * k_factor[ZZ]; - krr = sqrt (sqr (kx) + sqr (ky) + sqr (kz)); - if (krr >= start_q && krr <= end_q) { - kr = (int) (krr/sf->ref_k + 0.5); - if (kr < sf->n_angles) { - counter[kr]++; /* will be used for the copmutation - of the average*/ - for (p = 0; p < isize; p++) { - asf = sf_table[redt[p].t][kr]; - - kdotx = kx * redt[p].x[XX] + - ky * redt[p].x[YY] + kz * redt[p].x[ZZ]; - - tmpSF[i][j][k].re += cos (kdotx) * asf; - tmpSF[i][j][k].im += sin (kdotx) * asf; - } - } - } - } - } - } /* end loop on i */ + fprintf(stderr, "\n"); + for (i = 0; i < maxkx; i++) + { + fprintf (stderr, "\rdone %3.1f%% ", (double)(100.0*(i+1))/maxkx); + kx = i * k_factor[XX]; + for (j = 0; j < maxky; j++) + { + ky = j * k_factor[YY]; + for (k = 0; k < maxkz; k++) + { + if (i != 0 || j != 0 || k != 0) + { + kz = k * k_factor[ZZ]; + krr = sqrt (sqr (kx) + sqr (ky) + sqr (kz)); + if (krr >= start_q && krr <= end_q) + { + kr = (int) (krr/sf->ref_k + 0.5); + if (kr < sf->n_angles) + { + counter[kr]++; /* will be used for the copmutation + of the average*/ + for (p = 0; p < isize; p++) + { + asf = sf_table[redt[p].t][kr]; + + kdotx = kx * redt[p].x[XX] + + ky * redt[p].x[YY] + kz * redt[p].x[ZZ]; + + tmpSF[i][j][k].re += cos (kdotx) * asf; + tmpSF[i][j][k].im += sin (kdotx) * asf; + } + } + } + } + } + } + } /* end loop on i */ /* * compute the square modulus of the structure factor, averaging on the surface * kx*kx + ky*ky + kz*kz = krr*krr * note that this is correct only for a (on the macroscopic scale) * isotropic system. */ - for (i = 0; i < maxkx; i++) { - kx = i * k_factor[XX]; for (j = 0; j < maxky; j++) { - ky = j * k_factor[YY]; for (k = 0; k < maxkz; k++) { - kz = k * k_factor[ZZ]; krr = sqrt (sqr (kx) + sqr (ky) - + sqr (kz)); if (krr >= start_q && krr <= end_q) { - kr = (int) (krr / sf->ref_k + 0.5); - if (kr < sf->n_angles && counter[kr] != 0) - sf->F[group][kr] += - (sqr (tmpSF[i][j][k].re) + - sqr (tmpSF[i][j][k].im))/ counter[kr]; - } - } - } - } sfree (counter); free(tmpSF[0][0]); free(tmpSF[0]); free(tmpSF); + for (i = 0; i < maxkx; i++) + { + kx = i * k_factor[XX]; for (j = 0; j < maxky; j++) + { + ky = j * k_factor[YY]; for (k = 0; k < maxkz; k++) + { + kz = k * k_factor[ZZ]; krr = sqrt (sqr (kx) + sqr (ky) + + sqr (kz)); if (krr >= start_q && krr <= end_q) + { + kr = (int) (krr / sf->ref_k + 0.5); + if (kr < sf->n_angles && counter[kr] != 0) + { + sf->F[group][kr] += + (sqr (tmpSF[i][j][k].re) + + sqr (tmpSF[i][j][k].im))/ counter[kr]; + } + } + } + } + } + sfree (counter); free(tmpSF[0][0]); free(tmpSF[0]); free(tmpSF); } -extern gmx_structurefactors_t *gmx_structurefactors_init(const char *datfn) { - - /* Read the database for the structure factor of the different atoms */ +extern gmx_structurefactors_t *gmx_structurefactors_init(const char *datfn) +{ - FILE *fp; - char line[STRLEN]; + /* Read the database for the structure factor of the different atoms */ + + FILE *fp; + char line[STRLEN]; gmx_structurefactors *gsf; - double a1,a2,a3,a4,b1,b2,b3,b4,c; - int p; - int i; - int nralloc=10; - int line_no; - char atomn[32]; - fp=libopen(datfn); + double a1, a2, a3, a4, b1, b2, b3, b4, c; + int p; + int i; + int nralloc = 10; + int line_no; + char atomn[32]; + fp = libopen(datfn); line_no = 0; - snew(gsf,1); - - snew(gsf->atomnm,nralloc); - snew(gsf->a,nralloc); - snew(gsf->b,nralloc); - snew(gsf->c,nralloc); - snew(gsf->p,nralloc); - gsf->n=NULL; - gsf->nratoms=line_no; - while(get_a_line(fp,line,STRLEN)) { - i=line_no; - if (sscanf(line,"%s %d %lf %lf %lf %lf %lf %lf %lf %lf %lf", - atomn,&p,&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4,&c) == 11) { - gsf->atomnm[i]=strdup(atomn); - gsf->p[i]=p; - snew(gsf->a[i],4); - snew(gsf->b[i],4); - gsf->a[i][0]=a1; - gsf->a[i][1]=a2; - gsf->a[i][2]=a3; - gsf->a[i][3]=a4; - gsf->b[i][0]=b1; - gsf->b[i][1]=b2; - gsf->b[i][2]=b3; - gsf->b[i][3]=b4; - gsf->c[i]=c; - line_no++; - gsf->nratoms=line_no; - if (line_no==nralloc){ - nralloc+=10; - srenew(gsf->atomnm,nralloc); - srenew(gsf->a,nralloc); - srenew(gsf->b,nralloc); - srenew(gsf->c,nralloc); - srenew(gsf->p,nralloc); + snew(gsf, 1); + + snew(gsf->atomnm, nralloc); + snew(gsf->a, nralloc); + snew(gsf->b, nralloc); + snew(gsf->c, nralloc); + snew(gsf->p, nralloc); + gsf->n = NULL; + gsf->nratoms = line_no; + while (get_a_line(fp, line, STRLEN)) + { + i = line_no; + if (sscanf(line, "%s %d %lf %lf %lf %lf %lf %lf %lf %lf %lf", + atomn, &p, &a1, &a2, &a3, &a4, &b1, &b2, &b3, &b4, &c) == 11) + { + gsf->atomnm[i] = strdup(atomn); + gsf->p[i] = p; + snew(gsf->a[i], 4); + snew(gsf->b[i], 4); + gsf->a[i][0] = a1; + gsf->a[i][1] = a2; + gsf->a[i][2] = a3; + gsf->a[i][3] = a4; + gsf->b[i][0] = b1; + gsf->b[i][1] = b2; + gsf->b[i][2] = b3; + gsf->b[i][3] = b4; + gsf->c[i] = c; + line_no++; + gsf->nratoms = line_no; + if (line_no == nralloc) + { + nralloc += 10; + srenew(gsf->atomnm, nralloc); + srenew(gsf->a, nralloc); + srenew(gsf->b, nralloc); + srenew(gsf->c, nralloc); + srenew(gsf->p, nralloc); } } - else - fprintf(stderr,"WARNING: Error in file %s at line %d ignored\n", - datfn,line_no); + else + { + fprintf(stderr, "WARNING: Error in file %s at line %d ignored\n", + datfn, line_no); + } } - srenew(gsf->atomnm,gsf->nratoms); - srenew(gsf->a,gsf->nratoms); - srenew(gsf->b,gsf->nratoms); - srenew(gsf->c,gsf->nratoms); - srenew(gsf->p,gsf->nratoms); + srenew(gsf->atomnm, gsf->nratoms); + srenew(gsf->a, gsf->nratoms); + srenew(gsf->b, gsf->nratoms); + srenew(gsf->c, gsf->nratoms); + srenew(gsf->p, gsf->nratoms); fclose(fp); @@ -302,125 +343,144 @@ extern gmx_structurefactors_t *gmx_structurefactors_init(const char *datfn) { extern void rearrange_atoms (reduced_atom_t * positions, t_trxframe *fr, atom_id * index, - int isize, t_topology * top, gmx_bool flag,gmx_structurefactors_t *gsf) + int isize, t_topology * top, gmx_bool flag, gmx_structurefactors_t *gsf) /* given the group's index, return the (continuous) array of atoms */ { - int i; + int i; - reduced_atom *pos=(reduced_atom *)positions; + reduced_atom *pos = (reduced_atom *)positions; - if (flag) + if (flag) + { + for (i = 0; i < isize; i++) + { + pos[i].t = + return_atom_type (*(top->atoms.atomname[index[i]]), gsf); + } + } for (i = 0; i < isize; i++) - pos[i].t = - return_atom_type (*(top->atoms.atomname[index[i]]),gsf); - for (i = 0; i < isize; i++) - copy_rvec (fr->x[index[i]], pos[i].x); + { + copy_rvec (fr->x[index[i]], pos[i].x); + } - positions=(reduced_atom_t *)pos; + positions = (reduced_atom_t *)pos; } -extern int return_atom_type (const char *name,gmx_structurefactors_t *gsf) +extern int return_atom_type (const char *name, gmx_structurefactors_t *gsf) { - typedef struct { - const char *name; - int nh; - } t_united_h; - t_united_h uh[] = { - { "CH1", 1 }, { "CH2", 2 }, { "CH3", 3 }, - { "CS1", 1 }, { "CS2", 2 }, { "CS3", 3 }, - { "CP1", 1 }, { "CP2", 2 }, { "CP3", 3 } - }; - int i,cnt=0; - int *tndx; - int nrc; - int fndx=0; - int NCMT; - - gmx_structurefactors *gsft=(gmx_structurefactors *)gsf; - - NCMT=gsft->nratoms; - - snew(tndx,NCMT); - - for(i=0; (iatomnm[i],strlen(gsft->atomnm[i])) == 0){ - tndx[cnt]=i; - cnt++; + typedef struct { + const char *name; + int nh; + } t_united_h; + t_united_h uh[] = { + { "CH1", 1 }, { "CH2", 2 }, { "CH3", 3 }, + { "CS1", 1 }, { "CS2", 2 }, { "CS3", 3 }, + { "CP1", 1 }, { "CP2", 2 }, { "CP3", 3 } + }; + int i, cnt = 0; + int *tndx; + int nrc; + int fndx = 0; + int NCMT; + + gmx_structurefactors *gsft = (gmx_structurefactors *)gsf; + + NCMT = gsft->nratoms; + + snew(tndx, NCMT); + + for (i = 0; (i < asize(uh)); i++) + { + if (strcmp(name, uh[i].name) == 0) + { + return NCMT-1+uh[i].nh; + } + } + + for (i = 0; (i < NCMT); i++) + { + if (strncmp (name, gsft->atomnm[i], strlen(gsft->atomnm[i])) == 0) + { + tndx[cnt] = i; + cnt++; + } + } + + if (cnt == 0) + { + gmx_fatal(FARGS, "\nError: atom (%s) not in list (%d types checked)!\n", + name, i); } - } - - if (cnt==0) - gmx_fatal(FARGS,"\nError: atom (%s) not in list (%d types checked)!\n", - name,i); - else{ - nrc=0; - for(i=0;iatomnm[tndx[i]])>(size_t)nrc){ - nrc=strlen(gsft->atomnm[tndx[i]]); - fndx=tndx[i]; - } - } - - return fndx; - } - - return 0; + else + { + nrc = 0; + for (i = 0; i < cnt; i++) + { + if (strlen(gsft->atomnm[tndx[i]]) > (size_t)nrc) + { + nrc = strlen(gsft->atomnm[tndx[i]]); + fndx = tndx[i]; + } + } + + return fndx; + } + + return 0; } -extern int gmx_structurefactors_get_sf(gmx_structurefactors_t *gsf, int elem, real a[4], real b[4], real *c){ +extern int gmx_structurefactors_get_sf(gmx_structurefactors_t *gsf, int elem, real a[4], real b[4], real *c) +{ - int success; - int i; - gmx_structurefactors *gsft=(gmx_structurefactors *)gsf; - success=0; + int success; + int i; + gmx_structurefactors *gsft = (gmx_structurefactors *)gsf; + success = 0; - for(i=0;i<4;i++){ - a[i]=gsft->a[elem][i]; - b[i]=gsft->b[elem][i]; - *c=gsft->c[elem]; - } + for (i = 0; i < 4; i++) + { + a[i] = gsft->a[elem][i]; + b[i] = gsft->b[elem][i]; + *c = gsft->c[elem]; + } - success+=1; - return success; + success += 1; + return success; } extern int do_scattering_intensity (const char* fnTPS, const char* fnNDX, - const char* fnXVG, const char *fnTRX, - const char* fnDAT, - real start_q,real end_q, - real energy,int ng,const output_env_t oenv) + const char* fnXVG, const char *fnTRX, + const char* fnDAT, + real start_q, real end_q, + real energy, int ng, const output_env_t oenv) { - int i,*isize,flags = TRX_READ_X,**index_atp; - t_trxstatus *status; - char **grpname,title[STRLEN]; - atom_id **index; - t_topology top; - int ePBC; - t_trxframe fr; - reduced_atom_t **red; - structure_factor *sf; - rvec *xtop; - real **sf_table; - int nsftable; - matrix box; - double r_tmp; + int i, *isize, flags = TRX_READ_X, **index_atp; + t_trxstatus *status; + char **grpname, title[STRLEN]; + atom_id **index; + t_topology top; + int ePBC; + t_trxframe fr; + reduced_atom_t **red; + structure_factor *sf; + rvec *xtop; + real **sf_table; + int nsftable; + matrix box; + double r_tmp; gmx_structurefactors_t *gmx_sf; - real *a,*b,c; - int success; + real *a, *b, c; + int success; - snew(a,4); - snew(b,4); + snew(a, 4); + snew(b, 4); - gmx_sf=gmx_structurefactors_init(fnDAT); + gmx_sf = gmx_structurefactors_init(fnDAT); - success=gmx_structurefactors_get_sf(gmx_sf,0, a, b, &c); + success = gmx_structurefactors_get_sf(gmx_sf, 0, a, b, &c); snew (sf, 1); sf->energy = energy; @@ -435,14 +495,18 @@ extern int do_scattering_intensity (const char* fnTPS, const char* fnNDX, snew (grpname, ng); fprintf (stderr, "\nSelect %d group%s\n", ng, - ng == 1 ? "" : "s"); + ng == 1 ? "" : "s"); if (fnTPS) - get_index (&top.atoms, fnNDX, ng, isize, index, grpname); + { + get_index (&top.atoms, fnNDX, ng, isize, index, grpname); + } else - rd_index (fnNDX, ng, isize, index, grpname); + { + rd_index (fnNDX, ng, isize, index, grpname); + } /* The first time we read data is a little special */ - read_first_frame (oenv,&status, fnTRX, &fr, flags); + read_first_frame (oenv, &status, fnTRX, &fr, flags); sf->total_n_atoms = fr.natoms; @@ -458,31 +522,36 @@ extern int do_scattering_intensity (const char* fnTPS, const char* fnNDX, snew (sf->F, ng); for (i = 0; i < ng; i++) - snew (sf->F[i], sf->n_angles); - for (i = 0; i < ng; i++) { - snew (red[i], isize[i]); - rearrange_atoms (red[i], &fr, index[i], isize[i], &top, TRUE,gmx_sf); - index_atp[i] = create_indexed_atom_type (red[i], isize[i]); + { + snew (sf->F[i], sf->n_angles); + } + for (i = 0; i < ng; i++) + { + snew (red[i], isize[i]); + rearrange_atoms (red[i], &fr, index[i], isize[i], &top, TRUE, gmx_sf); + index_atp[i] = create_indexed_atom_type (red[i], isize[i]); } - sf_table = compute_scattering_factor_table (gmx_sf,(structure_factor_t *)sf,&nsftable); + sf_table = compute_scattering_factor_table (gmx_sf, (structure_factor_t *)sf, &nsftable); /* This is the main loop over frames */ - do { - sf->nSteps++; - for (i = 0; i < ng; i++) { - rearrange_atoms (red[i], &fr, index[i], isize[i], &top,FALSE,gmx_sf); + do + { + sf->nSteps++; + for (i = 0; i < ng; i++) + { + rearrange_atoms (red[i], &fr, index[i], isize[i], &top, FALSE, gmx_sf); - compute_structure_factor ((structure_factor_t *)sf, box, red[i], isize[i], - start_q, end_q, i, sf_table); - } + compute_structure_factor ((structure_factor_t *)sf, box, red[i], isize[i], + start_q, end_q, i, sf_table); + } } - while (read_next_frame (oenv,status, &fr)); + while (read_next_frame (oenv, status, &fr)); - save_data ((structure_factor_t *)sf, fnXVG, ng, start_q, end_q,oenv); + save_data ((structure_factor_t *)sf, fnXVG, ng, start_q, end_q, oenv); sfree(a); @@ -495,23 +564,25 @@ extern int do_scattering_intensity (const char* fnTPS, const char* fnNDX, extern void save_data (structure_factor_t *sft, const char *file, int ngrps, - real start_q, real end_q, const output_env_t oenv) + real start_q, real end_q, const output_env_t oenv) { - FILE *fp; - int i, g = 0; - double *tmp, polarization_factor, A; + FILE *fp; + int i, g = 0; + double *tmp, polarization_factor, A; + + structure_factor *sf = (structure_factor *)sft; - structure_factor *sf=(structure_factor *)sft; - fp = xvgropen (file, "Scattering Intensity", "q (1/nm)", - "Intensity (a.u.)",oenv); + "Intensity (a.u.)", oenv); snew (tmp, ngrps); for (g = 0; g < ngrps; g++) - for (i = 0; i < sf->n_angles; i++) { - + { + for (i = 0; i < sf->n_angles; i++) + { + /* * theta is half the angle between incoming and scattered vectors. * @@ -520,139 +591,154 @@ extern void save_data (structure_factor_t *sft, const char *file, int ngrps, * sin(theta) = q/(2k) := A -> sin^2(theta) = 4*A^2 (1-A^2) -> * -> 0.5*(1+cos^2(2*theta)) = 1 - 2 A^2 (1-A^2) */ - A = (double) (i * sf->ref_k) / (2.0 * sf->momentum); - polarization_factor = 1 - 2.0 * sqr (A) * (1 - sqr (A)); - sf->F[g][i] *= polarization_factor; - } - for (i = 0; i < sf->n_angles; i++) { - if (i * sf->ref_k >= start_q && i * sf->ref_k <= end_q) { - fprintf (fp, "%10.5f ", i * sf->ref_k); - for (g = 0; g < ngrps; g++) - fprintf (fp, " %10.5f ", (sf->F[g][i]) /( sf->total_n_atoms* - sf->nSteps)); - fprintf (fp, "\n"); - } + A = (double) (i * sf->ref_k) / (2.0 * sf->momentum); + polarization_factor = 1 - 2.0 * sqr (A) * (1 - sqr (A)); + sf->F[g][i] *= polarization_factor; + } + } + for (i = 0; i < sf->n_angles; i++) + { + if (i * sf->ref_k >= start_q && i * sf->ref_k <= end_q) + { + fprintf (fp, "%10.5f ", i * sf->ref_k); + for (g = 0; g < ngrps; g++) + { + fprintf (fp, " %10.5f ", (sf->F[g][i]) /( sf->total_n_atoms* + sf->nSteps)); + } + fprintf (fp, "\n"); + } } ffclose (fp); } -extern double CMSF (gmx_structurefactors_t *gsf,int type,int nh,double lambda, double sin_theta) +extern double CMSF (gmx_structurefactors_t *gsf, int type, int nh, double lambda, double sin_theta) /* * return Cromer-Mann fit for the atomic scattering factor: * sin_theta is the sine of half the angle between incoming and scattered * vectors. See g_sq.h for a short description of CM fit. */ { - int i,success; - double tmp = 0.0, k2; - real *a,*b; - real c; - - snew(a,4); - snew(b,4); - - /* - * - * f0[k] = c + [SUM a_i*EXP(-b_i*(k^2)) ] - * i=1,4 - */ - - /* - * united atoms case - * CH2 / CH3 groups - */ - if (nh > 0) { - tmp = (CMSF (gsf,return_atom_type ("C",gsf),0,lambda, sin_theta) + - nh*CMSF (gsf,return_atom_type ("H",gsf),0,lambda, sin_theta)); - } - /* all atom case */ - else { - k2 = (sqr (sin_theta) / sqr (10.0 * lambda)); - success=gmx_structurefactors_get_sf(gsf,type,a,b,&c); - tmp = c; - for (i = 0; (i < 4); i++) - tmp += a[i] * exp (-b[i] * k2); - } - return tmp; + int i, success; + double tmp = 0.0, k2; + real *a, *b; + real c; + + snew(a, 4); + snew(b, 4); + + /* + * + * f0[k] = c + [SUM a_i*EXP(-b_i*(k^2)) ] + * i=1,4 + */ + + /* + * united atoms case + * CH2 / CH3 groups + */ + if (nh > 0) + { + tmp = (CMSF (gsf, return_atom_type ("C", gsf), 0, lambda, sin_theta) + + nh*CMSF (gsf, return_atom_type ("H", gsf), 0, lambda, sin_theta)); + } + /* all atom case */ + else + { + k2 = (sqr (sin_theta) / sqr (10.0 * lambda)); + success = gmx_structurefactors_get_sf(gsf, type, a, b, &c); + tmp = c; + for (i = 0; (i < 4); i++) + { + tmp += a[i] * exp (-b[i] * k2); + } + } + return tmp; } -extern real **gmx_structurefactors_table(gmx_structurefactors_t *gsf,real momentum, real ref_k, real lambda, int n_angles){ - - int NCMT; - int nsftable; - int i,j; - double q,sin_theta; - real **sf_table; - gmx_structurefactors *gsft=(gmx_structurefactors *)gsf; - - NCMT=gsft->nratoms; - nsftable = NCMT+3; +extern real **gmx_structurefactors_table(gmx_structurefactors_t *gsf, real momentum, real ref_k, real lambda, int n_angles) +{ - snew (sf_table,nsftable); - for (i = 0; (i < nsftable); i++) { - snew (sf_table[i], n_angles); - for (j = 0; j < n_angles; j++) { - q = ((double) j * ref_k); - /* theta is half the angle between incoming - and scattered wavevectors. */ - sin_theta = q / (2.0 * momentum); - if (i < NCMT){ - sf_table[i][j] = CMSF (gsf,i,0,lambda, sin_theta); - } - else - sf_table[i][j] = CMSF (gsf,i,i-NCMT+1,lambda, sin_theta); - } + int NCMT; + int nsftable; + int i, j; + double q, sin_theta; + real **sf_table; + gmx_structurefactors *gsft = (gmx_structurefactors *)gsf; + + NCMT = gsft->nratoms; + nsftable = NCMT+3; + + snew (sf_table, nsftable); + for (i = 0; (i < nsftable); i++) + { + snew (sf_table[i], n_angles); + for (j = 0; j < n_angles; j++) + { + q = ((double) j * ref_k); + /* theta is half the angle between incoming + and scattered wavevectors. */ + sin_theta = q / (2.0 * momentum); + if (i < NCMT) + { + sf_table[i][j] = CMSF (gsf, i, 0, lambda, sin_theta); + } + else + { + sf_table[i][j] = CMSF (gsf, i, i-NCMT+1, lambda, sin_theta); + } + } } return sf_table; } -extern void gmx_structurefactors_done(gmx_structurefactors_t *gsf){ +extern void gmx_structurefactors_done(gmx_structurefactors_t *gsf) +{ - int i; - gmx_structurefactors *sf; - sf=(gmx_structurefactors *) gsf; + int i; + gmx_structurefactors *sf; + sf = (gmx_structurefactors *) gsf; - for(i=0;inratoms;i++){ + for (i = 0; i < sf->nratoms; i++) + { sfree(sf->a[i]); - sfree(sf->b[i]); - sfree(sf->atomnm[i]); - } + sfree(sf->b[i]); + sfree(sf->atomnm[i]); + } - sfree(sf->a); - sfree(sf->b); - sfree(sf->atomnm); - sfree(sf->p); - sfree(sf->c); + sfree(sf->a); + sfree(sf->b); + sfree(sf->atomnm); + sfree(sf->p); + sfree(sf->c); - sfree(sf); + sfree(sf); } -extern real **compute_scattering_factor_table (gmx_structurefactors_t *gsf,structure_factor_t *sft,int *nsftable) +extern real **compute_scattering_factor_table (gmx_structurefactors_t *gsf, structure_factor_t *sft, int *nsftable) { /* * this function build up a table of scattering factors for every atom * type and for every scattering angle. */ - - double hc=1239.842; - real ** sf_table; - structure_factor *sf=(structure_factor *)sft; + double hc = 1239.842; + real ** sf_table; + + structure_factor *sf = (structure_factor *)sft; /* \hbar \omega \lambda = hc = 1239.842 eV * nm */ sf->momentum = ((double) (2. * 1000.0 * M_PI * sf->energy) / hc); - sf->lambda = hc / (1000.0 * sf->energy); + sf->lambda = hc / (1000.0 * sf->energy); fprintf (stderr, "\nwavelenght = %f nm\n", sf->lambda); - sf_table=gmx_structurefactors_table(gsf,sf->momentum,sf->ref_k,sf->lambda,sf->n_angles); + sf_table = gmx_structurefactors_table(gsf, sf->momentum, sf->ref_k, sf->lambda, sf->n_angles); return sf_table; } - - diff --git a/src/gromacs/gmxlib/shift_util.c b/src/gromacs/gmxlib/shift_util.c index 9df8e3dc53..9f5aeb2e38 100644 --- a/src/gromacs/gmxlib/shift_util.c +++ b/src/gromacs/gmxlib/shift_util.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -56,63 +56,68 @@ #endif #define p2(x) ((x)*(x)) -#define p3(x) ((x)*(x)*(x)) -#define p4(x) ((x)*(x)*(x)*(x)) +#define p3(x) ((x)*(x)*(x)) +#define p4(x) ((x)*(x)*(x)*(x)) -static real A,A_3,B,B_4,C,c1,c2,c3,c4,c5,c6,One_4pi,FourPi_V,Vol,N0; +static real A, A_3, B, B_4, C, c1, c2, c3, c4, c5, c6, One_4pi, FourPi_V, Vol, N0; #ifdef GMX_THREAD_MPI -static tMPI_Thread_mutex_t shift_mutex=TMPI_THREAD_MUTEX_INITIALIZER; +static tMPI_Thread_mutex_t shift_mutex = TMPI_THREAD_MUTEX_INITIALIZER; #endif -void set_shift_consts(FILE *log,real r1,real rc,rvec box,t_forcerec *fr) +void set_shift_consts(FILE *log, real r1, real rc, rvec box, t_forcerec *fr) { #ifdef GMX_THREAD_MPI - /* at the very least we shouldn't allow multiple threads to set these - simulataneously */ - tMPI_Thread_mutex_lock(&shift_mutex); + /* at the very least we shouldn't allow multiple threads to set these + simulataneously */ + tMPI_Thread_mutex_lock(&shift_mutex); #endif - /* A, B and C are recalculated in tables.c */ - if (r1 < rc) { - A = (2*r1-5*rc)/(p3(rc)*p2(rc-r1)); - B = (4*rc-2*r1)/(p3(rc)*p3(rc-r1)); - /*C = (10*rc*rc-5*rc*r1+r1*r1)/(6*rc*rc); Hermans Eq. not correct */ - } - else - gmx_fatal(FARGS,"r1 (%f) >= rc (%f) in %s, line %d", - r1,rc,__FILE__,__LINE__); + /* A, B and C are recalculated in tables.c */ + if (r1 < rc) + { + A = (2*r1-5*rc)/(p3(rc)*p2(rc-r1)); + B = (4*rc-2*r1)/(p3(rc)*p3(rc-r1)); + /*C = (10*rc*rc-5*rc*r1+r1*r1)/(6*rc*rc); Hermans Eq. not correct */ + } + else + { + gmx_fatal(FARGS, "r1 (%f) >= rc (%f) in %s, line %d", + r1, rc, __FILE__, __LINE__); + } - A_3 = A/3.0; - B_4 = B/4.0; - C = 1/rc-A_3*p3(rc-r1)-B_4*p4(rc-r1); - N0 = 2.0*M_PI*p3(rc)*p3(rc-r1); + A_3 = A/3.0; + B_4 = B/4.0; + C = 1/rc-A_3*p3(rc-r1)-B_4*p4(rc-r1); + N0 = 2.0*M_PI*p3(rc)*p3(rc-r1); - Vol =(box[XX]*box[YY]*box[ZZ]); - FourPi_V=4.0*M_PI/Vol; + Vol = (box[XX]*box[YY]*box[ZZ]); + FourPi_V = 4.0*M_PI/Vol; - if (debug) { - fprintf(debug,"Constants for short-range and fourier stuff:\n" - "r1 = %10.3f, rc = %10.3f\n" - "A = %10.3e, B = %10.3e, C = %10.3e, FourPi_V = %10.3e\n", - r1,rc,A,B,C,FourPi_V); - } + if (debug) + { + fprintf(debug, "Constants for short-range and fourier stuff:\n" + "r1 = %10.3f, rc = %10.3f\n" + "A = %10.3e, B = %10.3e, C = %10.3e, FourPi_V = %10.3e\n", + r1, rc, A, B, C, FourPi_V); + } - /* Constants derived by Mathematica */ - c1 = -40*rc*rc + 50*rc*r1 - 16*r1*r1; - c2 = 60*rc - 30*r1; - c3 = -10*rc*rc*rc + 20*rc*rc*r1 - 13*rc*r1*r1 + 3*r1*r1*r1; - c4 = -20*rc*rc + 40*rc*r1 - 14*r1*r1; - c5 = -c2; - c6 = -5*rc*rc*r1 + 7*rc*r1*r1 - 2*r1*r1*r1; + /* Constants derived by Mathematica */ + c1 = -40*rc*rc + 50*rc*r1 - 16*r1*r1; + c2 = 60*rc - 30*r1; + c3 = -10*rc*rc*rc + 20*rc*rc*r1 - 13*rc*r1*r1 + 3*r1*r1*r1; + c4 = -20*rc*rc + 40*rc*r1 - 14*r1*r1; + c5 = -c2; + c6 = -5*rc*rc*r1 + 7*rc*r1*r1 - 2*r1*r1*r1; - if (debug) { - fprintf(debug,"c1 = %10.3e, c2 = %10.3e, c3 = %10.3e\n" - "c4 = %10.3e, c5 = %10.3e, c6 = %10.3e, N0 = %10.3e\n", - c1,c2,c3,c4,c5,c6,N0); - } - - One_4pi = 1.0/(4.0*M_PI); + if (debug) + { + fprintf(debug, "c1 = %10.3e, c2 = %10.3e, c3 = %10.3e\n" + "c4 = %10.3e, c5 = %10.3e, c6 = %10.3e, N0 = %10.3e\n", + c1, c2, c3, c4, c5, c6, N0); + } + + One_4pi = 1.0/(4.0*M_PI); #ifdef GMX_THREAD_MPI - tMPI_Thread_mutex_unlock(&shift_mutex); + tMPI_Thread_mutex_unlock(&shift_mutex); #endif } diff --git a/src/gromacs/gmxlib/sighandler.c b/src/gromacs/gmxlib/sighandler.c index 95fe435253..b7215c926d 100644 --- a/src/gromacs/gmxlib/sighandler.c +++ b/src/gromacs/gmxlib/sighandler.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROwing Monsters And Cloning Shrimps */ @@ -49,7 +49,7 @@ const char *gmx_stop_cond_name[] = "Abort" }; -/* these do not neccesarily match the stop condition, but are +/* these do not neccesarily match the stop condition, but are referred to in the signal handler. */ const char *gmx_signal_name[] = { @@ -63,33 +63,42 @@ const char *gmx_signal_name[] = "Abort" }; -static volatile sig_atomic_t stop_condition=gmx_stop_cond_none; -static volatile sig_atomic_t last_signal_name=0; +static volatile sig_atomic_t stop_condition = gmx_stop_cond_none; +static volatile sig_atomic_t last_signal_name = 0; -static volatile sig_atomic_t usr_condition=0; +static volatile sig_atomic_t usr_condition = 0; static void signal_handler(int n) { - switch (n) { -/* windows doesn't do SIGINT correctly according to ANSI (yes, signals are in - ANSI C89, and windows spawns a thread specifically to run the INT signal + switch (n) + { +/* windows doesn't do SIGINT correctly according to ANSI (yes, signals are in + ANSI C89, and windows spawns a thread specifically to run the INT signal handler), but that doesn't matter for a simple signal handler like this. */ case SIGTERM: case SIGINT: /* we explicitly set things up to allow this: */ stop_condition++; - if (n==SIGINT) - last_signal_name=1; - if (n==SIGTERM) - last_signal_name=2; + if (n == SIGINT) + { + last_signal_name = 1; + } + if (n == SIGTERM) + { + last_signal_name = 2; + } if (stop_condition == gmx_stop_cond_next) - last_signal_name=3; + { + last_signal_name = 3; + } if (stop_condition >= gmx_stop_cond_abort) + { abort(); + } break; #ifdef HAVE_SIGUSR1 case SIGUSR1: - usr_condition=1; + usr_condition = 1; break; #endif default: @@ -97,16 +106,16 @@ static void signal_handler(int n) } } -static void gmx_signal(int signum) +static void gmx_signal(int signum) { #ifdef HAVE_SIGACTION struct sigaction act; act.sa_handler = signal_handler; sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART; - sigaction(signum,&act,NULL); + sigaction(signum, &act, NULL); #else - signal(signum,signal_handler); + signal(signum, signal_handler); #endif } @@ -116,7 +125,7 @@ void signal_handler_install(void) { if (debug) { - fprintf(debug,"Installing signal handler for SIGTERM\n"); + fprintf(debug, "Installing signal handler for SIGTERM\n"); } gmx_signal(SIGTERM); } @@ -124,7 +133,7 @@ void signal_handler_install(void) { if (debug) { - fprintf(debug,"Installing signal handler for SIGINT\n"); + fprintf(debug, "Installing signal handler for SIGINT\n"); } gmx_signal(SIGINT); } @@ -133,7 +142,7 @@ void signal_handler_install(void) { if (debug) { - fprintf(debug,"Installing signal handler for SIGUSR1\n"); + fprintf(debug, "Installing signal handler for SIGUSR1\n"); } gmx_signal(SIGUSR1); } @@ -149,11 +158,15 @@ void gmx_set_stop_condition(gmx_stop_cond_t recvd_stop_cond) { if (recvd_stop_cond > stop_condition) { - stop_condition=recvd_stop_cond; + stop_condition = recvd_stop_cond; if (stop_condition == gmx_stop_cond_next_ns) - last_signal_name=4; + { + last_signal_name = 4; + } if (stop_condition == gmx_stop_cond_next) - last_signal_name=5; + { + last_signal_name = 5; + } } } @@ -165,12 +178,10 @@ const char *gmx_get_signal_name(void) gmx_bool gmx_got_usr_signal(void) { #ifdef HAVE_SIGUSR1 - gmx_bool ret=(gmx_bool)usr_condition; - usr_condition=0; + gmx_bool ret = (gmx_bool)usr_condition; + usr_condition = 0; return ret; #else return FALSE; #endif } - - diff --git a/src/gromacs/gmxlib/smalloc.c b/src/gromacs/gmxlib/smalloc.c index 8a78196c2c..014dbbdb6c 100644 --- a/src/gromacs/gmxlib/smalloc.c +++ b/src/gromacs/gmxlib/smalloc.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -40,7 +40,7 @@ #ifdef GMX_THREAD_MPI #include "thread_mpi/threads.h" -#endif +#endif #include @@ -54,217 +54,249 @@ #endif #ifdef DEBUG -static void log_action(int bMal,const char *what,const char *file,int line, - int nelem,int size,void *ptr) +static void log_action(int bMal, const char *what, const char *file, int line, + int nelem, int size, void *ptr) { - static int btot=0; - char *NN = "NULL"; - int bytes; - - bytes=size*nelem; - if (!bMal) - bytes=-bytes; - + static int btot = 0; + char *NN = "NULL"; + int bytes; + + bytes = size*nelem; + if (!bMal) + { + bytes = -bytes; + } + #ifdef GMX_THREAD_MPI - tMPI_Thread_mutex_lock(&gmx_logfile_mtx); + tMPI_Thread_mutex_lock(&gmx_logfile_mtx); #endif - /* This total memory count is not correct, since with realloc - * it adds the whole size again, not just the increment. - */ - /* This static variable is protected by the mutex too... */ - btot+=bytes; - - bytes/=1024; - if (debug && (bytes != 0)) { - fprintf(debug,"%s:%d kB (%7d kB) [%s, line %d, nelem %d, size %d]\n", - what ? what : NN,bytes,btot/1024, - file ? file : NN,line,nelem,size); - } - /* Print to stderr for things larger than 1 MB */ - if (bytes >= 1024 || bytes <= -1024) { - char *fname=NULL; - if (file) { - fname = strrchr(file,DIR_SEPARATOR); - if (fname) { - fname++; - } else { - fname = file; - } + /* This total memory count is not correct, since with realloc + * it adds the whole size again, not just the increment. + */ + /* This static variable is protected by the mutex too... */ + btot += bytes; + + bytes /= 1024; + if (debug && (bytes != 0)) + { + fprintf(debug, "%s:%d kB (%7d kB) [%s, line %d, nelem %d, size %d]\n", + what ? what : NN, bytes, btot/1024, + file ? file : NN, line, nelem, size); + } + /* Print to stderr for things larger than 1 MB */ + if (bytes >= 1024 || bytes <= -1024) + { + char *fname = NULL; + if (file) + { + fname = strrchr(file, DIR_SEPARATOR); + if (fname) + { + fname++; + } + else + { + fname = file; + } + } + printf("%s: %.1f MB [%s, line %d, nelem %d, size %d]\n", + what ? what : NN, bytes/1024.0, + file ? fname : NN, line, nelem, size); } - printf("%s: %.1f MB [%s, line %d, nelem %d, size %d]\n", - what ? what : NN,bytes/1024.0, - file ? fname : NN,line,nelem,size); - } #ifdef GMX_THREAD_MPI - tMPI_Thread_mutex_unlock(&gmx_logfile_mtx); + tMPI_Thread_mutex_unlock(&gmx_logfile_mtx); #endif } #endif -static char *gmx_large_int_str(gmx_large_int_t i,char *buf) +static char *gmx_large_int_str(gmx_large_int_t i, char *buf) { - sprintf(buf,gmx_large_int_pfmt,i); + sprintf(buf, gmx_large_int_pfmt, i); - return buf; + return buf; } -void *save_malloc(const char *name,const char *file,int line,size_t size) +void *save_malloc(const char *name, const char *file, int line, size_t size) { - void *p; - - p=NULL; - if (size==0) - p=NULL; - else + void *p; + + p = NULL; + if (size == 0) { - if ((p=malloc(size))==NULL) { - char cbuf[22]; - gmx_fatal(errno,__FILE__,__LINE__, - "Not enough memory. Failed to malloc %s bytes for %s\n" - "(called from file %s, line %d)", - gmx_large_int_str((gmx_large_int_t)size,cbuf), - name,file,line); - } - (void) memset(p,0,size); + p = NULL; + } + else + { + if ((p = malloc(size)) == NULL) + { + char cbuf[22]; + gmx_fatal(errno, __FILE__, __LINE__, + "Not enough memory. Failed to malloc %s bytes for %s\n" + "(called from file %s, line %d)", + gmx_large_int_str((gmx_large_int_t)size, cbuf), + name, file, line); + } + (void) memset(p, 0, size); } #ifdef DEBUG - log_action(1,name,file,line,1,size,p); + log_action(1, name, file, line, 1, size, p); #endif - return p; + return p; } -void *save_calloc(const char *name,const char *file,int line, - size_t nelem,size_t elsize) +void *save_calloc(const char *name, const char *file, int line, + size_t nelem, size_t elsize) { - void *p; - - p=NULL; - if ((nelem==0)||(elsize==0)) - p=NULL; - else + void *p; + + p = NULL; + if ((nelem == 0) || (elsize == 0)) + { + p = NULL; + } + else { #ifdef PRINT_ALLOC_KB - int rank=0; - if (nelem*elsize >= PRINT_ALLOC_KB*1024) { + int rank = 0; + if (nelem*elsize >= PRINT_ALLOC_KB*1024) + { #ifdef GMX_MPI #include - MPI_Comm_rank(MPI_COMM_WORLD,&rank); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); #endif - printf("Allocating %.1f MB for %s (called from file %s, line %d on %d)\n", - nelem*elsize/1048576.0,name,file,line,rank); - } + printf("Allocating %.1f MB for %s (called from file %s, line %d on %d)\n", + nelem*elsize/1048576.0, name, file, line, rank); + } #endif #ifdef GMX_BROKEN_CALLOC - /* emulate calloc(3) with malloc/memset on machines with - a broken calloc, e.g. in -lgmalloc on cray xt3. */ - if ((p=malloc((size_t)nelem*(size_t)elsize))==NULL) - gmx_fatal(errno,__FILE__,__LINE__, - "Not enough memory. Failed to calloc %"gmx_large_int_fmt - " elements of size %"gmx_large_int_fmt - " for %s\n(called from file %s, line %d)", - (gmx_large_int_t)nelem,(gmx_large_int_t)elsize, - name,file,line); - memset(p, 0,(size_t) (nelem * elsize)); + /* emulate calloc(3) with malloc/memset on machines with + a broken calloc, e.g. in -lgmalloc on cray xt3. */ + if ((p = malloc((size_t)nelem*(size_t)elsize)) == NULL) + { + gmx_fatal(errno, __FILE__, __LINE__, + "Not enough memory. Failed to calloc %"gmx_large_int_fmt + " elements of size %"gmx_large_int_fmt + " for %s\n(called from file %s, line %d)", + (gmx_large_int_t)nelem, (gmx_large_int_t)elsize, + name, file, line); + } + memset(p, 0, (size_t) (nelem * elsize)); #else - if ((p=calloc((size_t)nelem,(size_t)elsize))==NULL) - gmx_fatal(errno,__FILE__,__LINE__, - "Not enough memory. Failed to calloc %"gmx_large_int_fmt - " elements of size %"gmx_large_int_fmt - " for %s\n(called from file %s, line %d)", - (gmx_large_int_t)nelem,(gmx_large_int_t)elsize,name,file,line); + if ((p = calloc((size_t)nelem, (size_t)elsize)) == NULL) + { + gmx_fatal(errno, __FILE__, __LINE__, + "Not enough memory. Failed to calloc %"gmx_large_int_fmt + " elements of size %"gmx_large_int_fmt + " for %s\n(called from file %s, line %d)", + (gmx_large_int_t)nelem, (gmx_large_int_t)elsize, name, file, line); + } #endif } #ifdef DEBUG - log_action(1,name,file,line,nelem,elsize,p); + log_action(1, name, file, line, nelem, elsize, p); #endif - return p; + return p; } -void *save_realloc(const char *name,const char *file,int line,void *ptr, - size_t nelem,size_t elsize) +void *save_realloc(const char *name, const char *file, int line, void *ptr, + size_t nelem, size_t elsize) { - void *p; - size_t size = nelem*elsize; - - p=NULL; - if (size==0) + void *p; + size_t size = nelem*elsize; + + p = NULL; + if (size == 0) { - save_free(name, file, line, ptr); + save_free(name, file, line, ptr); } - else + else { #ifdef PRINT_ALLOC_KB - int rank=0; - if (size >= PRINT_ALLOC_KB*1024) { + int rank = 0; + if (size >= PRINT_ALLOC_KB*1024) + { #ifdef GMX_MPI #include - MPI_Comm_rank(MPI_COMM_WORLD,&rank); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); #endif - printf("Reallocating %.1f MB for %s (called from file %s, line %d on %d)\n", - size/1048576.0,name,file,line,rank); - } + printf("Reallocating %.1f MB for %s (called from file %s, line %d on %d)\n", + size/1048576.0, name, file, line, rank); + } #endif - if (ptr==NULL) - p=malloc((size_t)size); - else - p=realloc(ptr,(size_t)size); - if (p == NULL) { - char cbuf[22]; - gmx_fatal(errno,__FILE__,__LINE__, - "Not enough memory. Failed to realloc %s bytes for %s, %s=%x\n" - "(called from file %s, line %d)", - gmx_large_int_str((gmx_large_int_t)size,cbuf), - name,name,ptr,file,line); - } + if (ptr == NULL) + { + p = malloc((size_t)size); + } + else + { + p = realloc(ptr, (size_t)size); + } + if (p == NULL) + { + char cbuf[22]; + gmx_fatal(errno, __FILE__, __LINE__, + "Not enough memory. Failed to realloc %s bytes for %s, %s=%x\n" + "(called from file %s, line %d)", + gmx_large_int_str((gmx_large_int_t)size, cbuf), + name, name, ptr, file, line); + } #ifdef DEBUG - log_action(1,name,file,line,1,size,p); + log_action(1, name, file, line, 1, size, p); #endif } - return p; + return p; } -void save_free(const char *name,const char *file,int line, void *ptr) +void save_free(const char *name, const char *file, int line, void *ptr) { #ifdef DEBUG - log_action(0,name,file,line,0,0,ptr); + log_action(0, name, file, line, 0, 0, ptr); #endif - if (ptr != NULL) - free(ptr); + if (ptr != NULL) + { + free(ptr); + } } size_t maxavail(void) { - char *ptr; - size_t low,high,size; - - low=0; - high=256e6; - while ((high-low) > 4) { - size=(high+low)/2; - if ((ptr=(char *)malloc((size_t)size))==NULL) - high=size; - else { - free(ptr); - low=size; + char *ptr; + size_t low, high, size; + + low = 0; + high = 256e6; + while ((high-low) > 4) + { + size = (high+low)/2; + if ((ptr = (char *)malloc((size_t)size)) == NULL) + { + high = size; + } + else + { + free(ptr); + low = size; + } } - } - return low; + return low; } size_t memavail(void) { - char *ptr; - size_t size; - - size = maxavail(); - if (size != 0) { - if ((ptr=(char *)malloc((size_t)size)) != NULL) { - size += memavail(); - free(ptr); + char *ptr; + size_t size; + + size = maxavail(); + if (size != 0) + { + if ((ptr = (char *)malloc((size_t)size)) != NULL) + { + size += memavail(); + free(ptr); + } } - } - return size; + return size; } /* If we don't have useful routines for allocating aligned memory, @@ -281,24 +313,24 @@ size_t memavail(void) /* Pointers allocated with this routine should only be freed * with save_free_aligned, however this will only matter - * on systems that lack posix_memalign() and memalign() when + * on systems that lack posix_memalign() and memalign() when * freeing memory that needed to be adjusted to achieve * the necessary alignment. */ -void *save_malloc_aligned(const char *name,const char *file,int line, - unsigned nelem,size_t elsize,size_t alignment) +void *save_malloc_aligned(const char *name, const char *file, int line, + unsigned nelem, size_t elsize, size_t alignment) { - void **aligned=NULL; - void *malloced=NULL; + void **aligned = NULL; + void *malloced = NULL; gmx_bool allocate_fail; if (alignment == 0) { - gmx_fatal(errno,__FILE__,__LINE__, - "Cannot allocate aligned memory with alignment of zero!\n(called from file %s, line %d)",file,line); + gmx_fatal(errno, __FILE__, __LINE__, + "Cannot allocate aligned memory with alignment of zero!\n(called from file %s, line %d)", file, line); } - - if (nelem ==0 || elsize == 0) + + if (nelem == 0 || elsize == 0) { aligned = NULL; } @@ -308,40 +340,40 @@ void *save_malloc_aligned(const char *name,const char *file,int line, if (nelem*elsize >= PRINT_ALLOC_KB*1024) { printf("Allocating %.1f MB for %s\n", - nelem*elsize/(PRINT_ALLOC_KB*1024.0),name); + nelem*elsize/(PRINT_ALLOC_KB*1024.0), name); } #endif allocate_fail = FALSE; /* stop compiler warnings */ #ifdef HAVE_POSIX_MEMALIGN - allocate_fail = (0!=posix_memalign(&malloced, alignment, nelem*elsize)); + allocate_fail = (0 != posix_memalign(&malloced, alignment, nelem*elsize)); #elif defined HAVE_MEMALIGN - allocate_fail = ((malloced=memalign(alignment, nelem*elsize)) == NULL); + allocate_fail = ((malloced = memalign(alignment, nelem*elsize)) == NULL); #elif defined HAVE__ALIGNED_MALLOC - allocate_fail = ((malloced=_aligned_malloc(nelem*elsize, alignment)) + allocate_fail = ((malloced = _aligned_malloc(nelem*elsize, alignment)) == NULL); #else allocate_fail = ((malloced = malloc(nelem*elsize+alignment+ - sizeof(void*)))==NULL); + sizeof(void*))) == NULL); #endif if (allocate_fail) { - gmx_fatal(errno,__FILE__,__LINE__, - "Not enough memory. Failed to allocate %u aligned elements of size %u for %s\n(called from file %s, line %d)",nelem,elsize,name,file,line); + gmx_fatal(errno, __FILE__, __LINE__, + "Not enough memory. Failed to allocate %u aligned elements of size %u for %s\n(called from file %s, line %d)", nelem, elsize, name, file, line); } /* we start with the original pointer */ - aligned=(void**)malloced; - + aligned = (void**)malloced; + #ifdef GMX_OWN_MEMALIGN - /* Make the aligned pointer, and save the underlying pointer that - * we're allowed to free(). */ + /* Make the aligned pointer, and save the underlying pointer that + * we're allowed to free(). */ /* we first make space to store that underlying pointer: */ - aligned = aligned + 1; + aligned = aligned + 1; /* then we apply a bit mask */ - aligned = (void *) (((size_t) aligned + alignment - 1) & + aligned = (void *) (((size_t) aligned + alignment - 1) & (~((size_t) (alignment-1)))); - /* and we store the original pointer in the area just before the + /* and we store the original pointer in the area just before the pointer we're going to return */ aligned[-1] = malloced; #endif @@ -349,8 +381,8 @@ void *save_malloc_aligned(const char *name,const char *file,int line, return (void*)aligned; } -void *save_calloc_aligned(const char *name,const char *file,int line, - unsigned nelem,size_t elsize,size_t alignment) +void *save_calloc_aligned(const char *name, const char *file, int line, + unsigned nelem, size_t elsize, size_t alignment) { void *aligned = save_malloc_aligned(name, file, line, nelem, elsize, alignment); if (aligned != NULL) @@ -361,24 +393,23 @@ void *save_calloc_aligned(const char *name,const char *file,int line, } /* This routine can NOT be called with any pointer */ -void save_free_aligned(const char *name,const char *file,int line,void *ptr) +void save_free_aligned(const char *name, const char *file, int line, void *ptr) { - int i, j; - void *free=ptr; + int i, j; + void *free = ptr; if (NULL != ptr) { -#ifdef GMX_OWN_MEMALIGN +#ifdef GMX_OWN_MEMALIGN /* we get the pointer from just before the memaligned pointer */ - free= ((void**)ptr)[-1]; + free = ((void**)ptr)[-1]; #endif #ifndef HAVE__ALIGNED_MALLOC /* (Now) we're allowed to use a normal free() on this pointer. */ - save_free(name,file,line,free); + save_free(name, file, line, free); #else _aligned_free(free); #endif } } - diff --git a/src/gromacs/gmxlib/sortwater.c b/src/gromacs/gmxlib/sortwater.c index a8e1922594..0ff3c2ae53 100644 --- a/src/gromacs/gmxlib/sortwater.c +++ b/src/gromacs/gmxlib/sortwater.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -42,302 +42,378 @@ #include "vec.h" #include "sortwater.h" -static rvec *xptr,box_1; -static int nwat; -static matrix BOX; -static ivec NBOX; +static rvec *xptr, box_1; +static int nwat; +static matrix BOX; +static ivec NBOX; -void randwater(int astart,int nwater,int nwatom,rvec x[],rvec v[],int *seed) +void randwater(int astart, int nwater, int nwatom, rvec x[], rvec v[], int *seed) { - int i,j,wi,wj,*tab; - rvec buf; - - snew(tab,nwater); - for(i=0; (i xptr[bb][XX]) - return 1; - else - return 0; + int aa, bb; + + aa = nwat*(*((int *)a)); + bb = nwat*(*((int *)b)); + if (xptr[aa][XX] < xptr[bb][XX]) + { + return -1; + } + else if (xptr[aa][XX] > xptr[bb][XX]) + { + return 1; + } + else + { + return 0; + } } -static int block_index(rvec x,ivec nbox) +static int block_index(rvec x, ivec nbox) { - ivec ixyz; - int m; - - for(m=0; (m xptr[bb][XX]) - return 1; - else - return 0; - } - else - return aind-bind; + aind = block_index(xptr[aa], NBOX); + bind = block_index(xptr[bb], NBOX); + + if (aind == bind) + { + if (xptr[aa][XX] < xptr[bb][XX]) + { + return -1; + } + else if (xptr[aa][XX] > xptr[bb][XX]) + { + return 1; + } + else + { + return 0; + } + } + else + { + return aind-bind; + } } -static void lo_sortwater(int astart,int nwater,int nwatom,rvec x[],rvec v[], - gmx_bool bBlock) +static void lo_sortwater(int astart, int nwater, int nwatom, rvec x[], rvec v[], + gmx_bool bBlock) { - int i,j,i0,rvi; - int *rvindex; - rvec *tmp; - - /* Sort indices to rvecs */ - snew(rvindex,nwater); - for(i=0; (i 0) { - nbb = add_bb(BB,nbb,bxyz); - } - } - } + ivec *BB, bxyz; + int i, j, m, n, n3, ny, *fx, *fy, nbb; + + n3 = ipow(nnode, 3)*6; + snew(BB, n3); + nbb = 0; + snew(fx, nnode+1); + snew(fy, nnode+1); + factorize(nnode, fx); + for (i = 0; (i <= nnode); i++) + { + for (m = 1; (m <= fx[i]); m++) + { + bxyz[XX] = ipow(i, m); + ny = nnode/bxyz[XX]; + factorize(ny, fy); + for (j = 0; (j <= ny); j++) + { + for (n = 1; (n <= fy[j]); n++) + { + bxyz[YY] = ipow(j, n); + bxyz[ZZ] = ny/bxyz[YY]; + if (bxyz[ZZ] > 0) + { + nbb = add_bb(BB, nbb, bxyz); + } + } + } + } } - } - /* Sort boxes and remove doubles */ - qsort(BB,nbb,sizeof(BB[0]),iv_comp); - j = 0; - for(i=1; (iia,sf->nr+nr); - for(i=0; (iia[sf->nr+i]=ia[i]; - sf->nr+=nr; + srenew(sf->ia, sf->nr+nr); + for (i = 0; (i < nr); i++) + { + sf->ia[sf->nr+i] = ia[i]; + } + sf->nr += nr; } -static int min_nodeid(int nr,atom_id list[],int hid[]) +static int min_nodeid(int nr, atom_id list[], int hid[]) { - int i,nodeid,minnodeid; + int i, nodeid, minnodeid; - if (nr <= 0) - gmx_incons("Invalid node number"); - minnodeid=hid[list[0]]; - for (i=1; (inr; i+=(1+nratoms)) - { - type = ilist->iatoms[i]; - nratoms = interaction_function[ftype].nratoms; - - if (ftype == F_CONSTR) - { - ai = ilist->iatoms[i+1]; - aj = ilist->iatoms[i+2]; - - nodei = hid[ai]; - nodej = hid[aj]; - nodeid = nodei; - - if(ir->eConstrAlg == econtLINCS) - { - node_low_ai = constr_min_nodeid[ai]; - node_low_aj = constr_min_nodeid[aj]; - node_high_ai = constr_max_nodeid[ai]; - node_high_aj = constr_max_nodeid[aj]; - - node_low = min(node_low_ai,node_low_aj); - node_high = max(node_high_ai,node_high_aj); - - if (node_high-nodei > 1 || nodei-node_low > 1 || - node_high-nodej > 1 || nodej-node_low > 1 ) - { - gmx_fatal(FARGS,"Constraint dependencies further away than next-neighbor\n" - "in particle decomposition. Constraint between atoms %d--%d evaluated\n" - "on node %d and %d, but atom %d has connections within %d bonds (lincs_order)\n" - "of node %d, and atom %d has connections within %d bonds of node %d.\n" - "Reduce the # nodes, lincs_order, or\n" - "try domain decomposition.",ai,aj,nodei,nodej,ai,ir->nProjOrder,node_low,aj,ir->nProjOrder,node_high); - } - - if (node_low < nodei || node_low < nodej) - { - right_range[node_low] = max(right_range[node_low],aj); - } - if (node_high > nodei || node_high > nodej) - { - left_range[node_high] = min(left_range[node_high],ai); - } - } - else - { - /* Shake */ - if (hid[ilist->iatoms[i+2]] != nodei) - gmx_fatal(FARGS,"Shake block crossing node boundaries\n" - "constraint between atoms (%d,%d) (try LINCS instead!)", - ilist->iatoms[i+1]+1,ilist->iatoms[i+2]+1); - } - } - else if (ftype == F_SETTLE) - { - /* Only the first particle is stored for settles ... */ - ai=ilist->iatoms[i+1]; - nodeid=hid[ai]; - if (nodeid != hid[ilist->iatoms[i+2]] || - nodeid != hid[ilist->iatoms[i+3]]) - gmx_fatal(FARGS,"Settle block crossing node boundaries\n" - "constraint between atoms %d, %d, %d)", - ai,ilist->iatoms[i+2],ilist->iatoms[i+3]); - } - else if(interaction_function[ftype].flags & IF_VSITE) - { - /* Virtual sites are special, since we need to pre-communicate - * their coordinates to construct vsites before then main - * coordinate communication. - * Vsites can have constructing atoms both larger and smaller than themselves. - * To minimize communication and book-keeping, each vsite is constructed on - * the home node of the atomnr of the vsite. - * Since the vsite coordinates too have to be communicated to the next node, - * we need to - * - * 1. Pre-communicate coordinates of constructing atoms - * 2. Construct the vsite - * 3. Perform main coordinate communication - * - * Note that this has change from gromacs 4.0 and earlier, where the vsite - * was constructed on the home node of the lowest index of any of the constructing - * atoms and the vsite itself. - */ - - if (ftype==F_VSITE2) - nvsite_constr=2; - else if(ftype==F_VSITE4FD || ftype==F_VSITE4FDN) - nvsite_constr=4; - else - nvsite_constr=3; - - /* Vsites are constructed on the home node of the actual site to save communication - * and simplify the book-keeping. - */ - nodeid=hid[ilist->iatoms[i+1]]; - - for(k=2;kiatoms[i+k]]<(nodeid-1) || - hid[ilist->iatoms[i+k]]>(nodeid+1)) - gmx_fatal(FARGS,"Virtual site %d and its constructing" - " atoms are not on the same or adjacent\n" - " nodes. This is necessary to avoid a lot\n" - " of extra communication. The easiest way" - " to ensure this is to place virtual sites\n" - " close to the constructing atoms.\n" - " Sorry, but you will have to rework your topology!\n", - ilist->iatoms[i+1]); - } - } - else - { - nodeid=min_nodeid(nratoms,&ilist->iatoms[i+1],hid); - } - - if (ftype == F_CONSTR && ir->eConstrAlg == econtLINCS) - { - push_sf(&(sf[nodeid]),nratoms+1,&(ilist->iatoms[i])); - - if(node_lowiatoms[i])); - nextra+=nratoms+1; - } - if(node_high>nodeid) - { - push_sf(&(sf[node_high]),nratoms+1,&(ilist->iatoms[i])); - nextra+=nratoms+1; - } - } - else - { - push_sf(&(sf[nodeid]),nratoms+1,&(ilist->iatoms[i])); - } - } - - if(nextra>0) - { - ilist->nr += nextra; - srenew(ilist->iatoms,ilist->nr); - } - - tnr=0; - for(nodeid=0; (nodeidiatoms[tnr++]=sf[nodeid].ia[i]; - - multinr[nodeid]=(nodeid==0) ? 0 : multinr[nodeid-1]; - multinr[nodeid]+=sf[nodeid].nr; - } - - if (tnr != ilist->nr) - gmx_incons("Splitting forces over processors"); - - done_sf(nnodes,sf); + int i, j, k, type, nodeid, nratoms, tnr; + int nvsite_constr; + t_iatom ai, aj; + int node_low_ai, node_low_aj, node_high_ai, node_high_aj; + int node_low, node_high; + int nodei, nodej; + t_sf *sf; + int nextra; + + sf = init_sf(nnodes); + + node_high = node_low = 0; + nextra = 0; + + /* Walk along all the bonded forces, find the appropriate node + * to calc it on, and add it to that nodes list. + */ + for (i = 0; i < ilist->nr; i += (1+nratoms)) + { + type = ilist->iatoms[i]; + nratoms = interaction_function[ftype].nratoms; + + if (ftype == F_CONSTR) + { + ai = ilist->iatoms[i+1]; + aj = ilist->iatoms[i+2]; + + nodei = hid[ai]; + nodej = hid[aj]; + nodeid = nodei; + + if (ir->eConstrAlg == econtLINCS) + { + node_low_ai = constr_min_nodeid[ai]; + node_low_aj = constr_min_nodeid[aj]; + node_high_ai = constr_max_nodeid[ai]; + node_high_aj = constr_max_nodeid[aj]; + + node_low = min(node_low_ai, node_low_aj); + node_high = max(node_high_ai, node_high_aj); + + if (node_high-nodei > 1 || nodei-node_low > 1 || + node_high-nodej > 1 || nodej-node_low > 1) + { + gmx_fatal(FARGS, "Constraint dependencies further away than next-neighbor\n" + "in particle decomposition. Constraint between atoms %d--%d evaluated\n" + "on node %d and %d, but atom %d has connections within %d bonds (lincs_order)\n" + "of node %d, and atom %d has connections within %d bonds of node %d.\n" + "Reduce the # nodes, lincs_order, or\n" + "try domain decomposition.", ai, aj, nodei, nodej, ai, ir->nProjOrder, node_low, aj, ir->nProjOrder, node_high); + } + + if (node_low < nodei || node_low < nodej) + { + right_range[node_low] = max(right_range[node_low], aj); + } + if (node_high > nodei || node_high > nodej) + { + left_range[node_high] = min(left_range[node_high], ai); + } + } + else + { + /* Shake */ + if (hid[ilist->iatoms[i+2]] != nodei) + { + gmx_fatal(FARGS, "Shake block crossing node boundaries\n" + "constraint between atoms (%d,%d) (try LINCS instead!)", + ilist->iatoms[i+1]+1, ilist->iatoms[i+2]+1); + } + } + } + else if (ftype == F_SETTLE) + { + /* Only the first particle is stored for settles ... */ + ai = ilist->iatoms[i+1]; + nodeid = hid[ai]; + if (nodeid != hid[ilist->iatoms[i+2]] || + nodeid != hid[ilist->iatoms[i+3]]) + { + gmx_fatal(FARGS, "Settle block crossing node boundaries\n" + "constraint between atoms %d, %d, %d)", + ai, ilist->iatoms[i+2], ilist->iatoms[i+3]); + } + } + else if (interaction_function[ftype].flags & IF_VSITE) + { + /* Virtual sites are special, since we need to pre-communicate + * their coordinates to construct vsites before then main + * coordinate communication. + * Vsites can have constructing atoms both larger and smaller than themselves. + * To minimize communication and book-keeping, each vsite is constructed on + * the home node of the atomnr of the vsite. + * Since the vsite coordinates too have to be communicated to the next node, + * we need to + * + * 1. Pre-communicate coordinates of constructing atoms + * 2. Construct the vsite + * 3. Perform main coordinate communication + * + * Note that this has change from gromacs 4.0 and earlier, where the vsite + * was constructed on the home node of the lowest index of any of the constructing + * atoms and the vsite itself. + */ + + if (ftype == F_VSITE2) + { + nvsite_constr = 2; + } + else if (ftype == F_VSITE4FD || ftype == F_VSITE4FDN) + { + nvsite_constr = 4; + } + else + { + nvsite_constr = 3; + } + + /* Vsites are constructed on the home node of the actual site to save communication + * and simplify the book-keeping. + */ + nodeid = hid[ilist->iatoms[i+1]]; + + for (k = 2; k < nvsite_constr+2; k++) + { + if (hid[ilist->iatoms[i+k]] < (nodeid-1) || + hid[ilist->iatoms[i+k]] > (nodeid+1)) + { + gmx_fatal(FARGS, "Virtual site %d and its constructing" + " atoms are not on the same or adjacent\n" + " nodes. This is necessary to avoid a lot\n" + " of extra communication. The easiest way" + " to ensure this is to place virtual sites\n" + " close to the constructing atoms.\n" + " Sorry, but you will have to rework your topology!\n", + ilist->iatoms[i+1]); + } + } + } + else + { + nodeid = min_nodeid(nratoms, &ilist->iatoms[i+1], hid); + } + + if (ftype == F_CONSTR && ir->eConstrAlg == econtLINCS) + { + push_sf(&(sf[nodeid]), nratoms+1, &(ilist->iatoms[i])); + + if (node_low < nodeid) + { + push_sf(&(sf[node_low]), nratoms+1, &(ilist->iatoms[i])); + nextra += nratoms+1; + } + if (node_high > nodeid) + { + push_sf(&(sf[node_high]), nratoms+1, &(ilist->iatoms[i])); + nextra += nratoms+1; + } + } + else + { + push_sf(&(sf[nodeid]), nratoms+1, &(ilist->iatoms[i])); + } + } + + if (nextra > 0) + { + ilist->nr += nextra; + srenew(ilist->iatoms, ilist->nr); + } + + tnr = 0; + for (nodeid = 0; (nodeid < nnodes); nodeid++) + { + for (i = 0; (i < sf[nodeid].nr); i++) + { + ilist->iatoms[tnr++] = sf[nodeid].ia[i]; + } + + multinr[nodeid] = (nodeid == 0) ? 0 : multinr[nodeid-1]; + multinr[nodeid] += sf[nodeid].nr; + } + + if (tnr != ilist->nr) + { + gmx_incons("Splitting forces over processors"); + } + + done_sf(nnodes, sf); } -static int *home_index(int nnodes,t_block *cgs,int *multinr) +static int *home_index(int nnodes, t_block *cgs, int *multinr) { - /* This routine determines the node id for each particle */ - int *hid; - int nodeid,j0,j1,j,k; - - snew(hid,cgs->index[cgs->nr]); - /* Initiate to -1 to make it possible to check afterwards, - * all hid's should be set in the loop below - */ - for(k=0; (kindex[cgs->nr]); k++) - hid[k]=-1; - - /* loop over nodes */ - for(nodeid=0; (nodeidindex[j]; (kindex[j+1]); k++) { - hid[k]=nodeid; - } - } - } - /* Now verify that all hid's are not -1 */ - for(k=0; (kindex[cgs->nr]); k++) - if (hid[k] == -1) - gmx_fatal(FARGS,"hid[%d] = -1, cgs->nr = %d, natoms = %d", - k,cgs->nr,cgs->index[cgs->nr]); - - return hid; + /* This routine determines the node id for each particle */ + int *hid; + int nodeid, j0, j1, j, k; + + snew(hid, cgs->index[cgs->nr]); + /* Initiate to -1 to make it possible to check afterwards, + * all hid's should be set in the loop below + */ + for (k = 0; (k < cgs->index[cgs->nr]); k++) + { + hid[k] = -1; + } + + /* loop over nodes */ + for (nodeid = 0; (nodeid < nnodes); nodeid++) + { + j0 = (nodeid == 0) ? 0 : multinr[nodeid-1]; + j1 = multinr[nodeid]; + + /* j0 and j1 are the boundariesin the index array */ + for (j = j0; (j < j1); j++) + { + for (k = cgs->index[j]; (k < cgs->index[j+1]); k++) + { + hid[k] = nodeid; + } + } + } + /* Now verify that all hid's are not -1 */ + for (k = 0; (k < cgs->index[cgs->nr]); k++) + { + if (hid[k] == -1) + { + gmx_fatal(FARGS, "hid[%d] = -1, cgs->nr = %d, natoms = %d", + k, cgs->nr, cgs->index[cgs->nr]); + } + } + + return hid; } typedef struct { - int atom,ic,is; + int atom, ic, is; } t_border; -void set_bor(t_border *b,int atom,int ic,int is) +void set_bor(t_border *b, int atom, int ic, int is) { - if (debug) - fprintf(debug,"border @ atom %5d [ ic = %5d, is = %5d ]\n",atom,ic,is); - b->atom = atom; - b->ic = ic; - b->is = is; + if (debug) + { + fprintf(debug, "border @ atom %5d [ ic = %5d, is = %5d ]\n", atom, ic, is); + } + b->atom = atom; + b->ic = ic; + b->is = is; } -static gmx_bool is_bor(atom_id ai[],int i) +static gmx_bool is_bor(atom_id ai[], int i) { - return ((ai[i] != ai[i-1]) || ((ai[i] == NO_ATID) && (ai[i-1] == NO_ATID))); + return ((ai[i] != ai[i-1]) || ((ai[i] == NO_ATID) && (ai[i-1] == NO_ATID))); } -static t_border *mk_border(FILE *fp,int natom,atom_id *invcgs, - atom_id *invshk,int *nb) +static t_border *mk_border(FILE *fp, int natom, atom_id *invcgs, + atom_id *invshk, int *nb) { - t_border *bor; - atom_id *sbor,*cbor; - int i,j,is,ic,ns,nc,nbor; - - if (debug) { - for(i=0; (i sbor[is]) { - if (is == ns) { - set_bor(&(bor[nbor]),cbor[ic],ic,is); - nbor++; - if (ic < nc) ic++; - } - else if (is < ns) - is++; - } - else if (ic < nc) - ic++; - else - is++;/*gmx_fatal(FARGS,"Can't happen is=%d, ic=%d (%s, %d)", - is,ic,__FILE__,__LINE__);*/ - } - if (fp) - fprintf(fp,"There are %d total borders\n",nbor); - - if (debug) { - fprintf(debug,"There are %d actual bor entries\n",nbor); - for(i=0; (i sbor[is]) + { + if (is == ns) + { + set_bor(&(bor[nbor]), cbor[ic], ic, is); + nbor++; + if (ic < nc) + { + ic++; + } + } + else if (is < ns) + { + is++; + } + } + else if (ic < nc) + { + ic++; + } + else + { + is++; /*gmx_fatal(FARGS,"Can't happen is=%d, ic=%d (%s, %d)", + is,ic,__FILE__,__LINE__);*/ + } + } + if (fp) + { + fprintf(fp, "There are %d total borders\n", nbor); + } + + if (debug) + { + fprintf(debug, "There are %d actual bor entries\n", nbor); + for (i = 0; (i < nbor); i++) + { + fprintf(debug, "bor[%5d] = atom: %d ic: %d is: %d\n", i, + bor[i].atom, bor[i].ic, bor[i].is); + } + } + + *nb = nbor; + + return bor; } -static void split_blocks(FILE *fp,t_inputrec *ir, int nnodes, - t_block *cgs,t_blocka *sblock,real capacity[], - int *multinr_cgs) +static void split_blocks(FILE *fp, t_inputrec *ir, int nnodes, + t_block *cgs, t_blocka *sblock, real capacity[], + int *multinr_cgs) { - int natoms,*maxatom; - int i,ii,ai,b0,b1; - int nodeid,last_shk,nbor; - t_border *border; - double tload,tcap; - - gmx_bool bSHK; - atom_id *shknum,*cgsnum; - - natoms = cgs->index[cgs->nr]; - - if (NULL != debug) { - pr_block(debug,0,"cgs",cgs,TRUE); - pr_blocka(debug,0,"sblock",sblock,TRUE); - fflush(debug); - } - - cgsnum = make_invblock(cgs,natoms+1); - shknum = make_invblocka(sblock,natoms+1); - border = mk_border(fp,natoms,cgsnum,shknum,&nbor); - - snew(maxatom,nnodes); - tload = capacity[0]*natoms; - tcap = 1.0; - nodeid = 0; - /* Start at bor is 1, to force the first block on the first processor */ - for(i=0; (inr; - /* Store atom number, see above */ - maxatom[nodeid] = natoms; - nodeid++; - } - if (nodeid != nnodes) { - gmx_fatal(FARGS,"nodeid = %d, nnodes = %d, file %s, line %d", - nodeid,nnodes,__FILE__,__LINE__); - } - - for(i=nnodes-1; (i>0); i--) - maxatom[i]-=maxatom[i-1]; - - if (fp) { - fprintf(fp,"Division over nodes in atoms:\n"); - for(i=0; (iindex[cgs->nr]; + + if (NULL != debug) + { + pr_block(debug, 0, "cgs", cgs, TRUE); + pr_blocka(debug, 0, "sblock", sblock, TRUE); + fflush(debug); + } + + cgsnum = make_invblock(cgs, natoms+1); + shknum = make_invblocka(sblock, natoms+1); + border = mk_border(fp, natoms, cgsnum, shknum, &nbor); + + snew(maxatom, nnodes); + tload = capacity[0]*natoms; + tcap = 1.0; + nodeid = 0; + /* Start at bor is 1, to force the first block on the first processor */ + for (i = 0; (i < nbor) && (tload < natoms); i++) + { + if (i < (nbor-1)) + { + b1 = border[i+1].atom; + } + else + { + b1 = natoms; + } + + b0 = border[i].atom; + + if ((fabs(b0-tload) < fabs(b1-tload))) + { + /* New nodeid time */ + multinr_cgs[nodeid] = border[i].ic; + maxatom[nodeid] = b0; + tcap -= capacity[nodeid]; + nodeid++; + + /* Recompute target load */ + tload = b0 + (natoms-b0)*capacity[nodeid]/tcap; + + if (debug) + { + printf("tload: %g tcap: %g nodeid: %d\n", tload, tcap, nodeid); + } + } + } + /* Now the last one... */ + while (nodeid < nnodes) + { + multinr_cgs[nodeid] = cgs->nr; + /* Store atom number, see above */ + maxatom[nodeid] = natoms; + nodeid++; + } + if (nodeid != nnodes) + { + gmx_fatal(FARGS, "nodeid = %d, nnodes = %d, file %s, line %d", + nodeid, nnodes, __FILE__, __LINE__); + } + + for (i = nnodes-1; (i > 0); i--) + { + maxatom[i] -= maxatom[i-1]; + } + + if (fp) + { + fprintf(fp, "Division over nodes in atoms:\n"); + for (i = 0; (i < nnodes); i++) + { + fprintf(fp, " %7d", maxatom[i]); + } + fprintf(fp, "\n"); + } + + sfree(maxatom); + sfree(shknum); + sfree(cgsnum); + sfree(border); } typedef struct { - int atom,sid; + int atom, sid; } t_sid; -static int sid_comp(const void *a,const void *b) +static int sid_comp(const void *a, const void *b) { - t_sid *sa,*sb; - int dd; - - sa=(t_sid *)a; - sb=(t_sid *)b; - - dd=sa->sid-sb->sid; - if (dd == 0) - return (sa->atom-sb->atom); - else - return dd; + t_sid *sa, *sb; + int dd; + + sa = (t_sid *)a; + sb = (t_sid *)b; + + dd = sa->sid-sb->sid; + if (dd == 0) + { + return (sa->atom-sb->atom); + } + else + { + return dd; + } } -static int mk_grey(int nnodes,egCol egc[],t_graph *g,int *AtomI, - int maxsid,t_sid sid[]) +static int mk_grey(int nnodes, egCol egc[], t_graph *g, int *AtomI, + int maxsid, t_sid sid[]) { - int j,ng,ai,aj,g0; - - ng=0; - ai=*AtomI; - - g0=g->at_start; - /* Loop over all the bonds */ - for(j=0; (jnedge[ai]); j++) { - aj=g->edge[ai][j]-g0; - /* If there is a white one, make it gray and set pbc */ - if (egc[aj] == egcolWhite) { - if (aj < *AtomI) - *AtomI = aj; - egc[aj] = egcolGrey; - - /* Check whether this one has been set before... */ - range_check(aj+g0,0,maxsid); - range_check(ai+g0,0,maxsid); - if (sid[aj+g0].sid != -1) - gmx_fatal(FARGS,"sid[%d]=%d, sid[%d]=%d, file %s, line %d", - ai,sid[ai+g0].sid,aj,sid[aj+g0].sid,__FILE__,__LINE__); - else { - sid[aj+g0].sid = sid[ai+g0].sid; - sid[aj+g0].atom = aj+g0; - } - ng++; - } - } - return ng; + int j, ng, ai, aj, g0; + + ng = 0; + ai = *AtomI; + + g0 = g->at_start; + /* Loop over all the bonds */ + for (j = 0; (j < g->nedge[ai]); j++) + { + aj = g->edge[ai][j]-g0; + /* If there is a white one, make it gray and set pbc */ + if (egc[aj] == egcolWhite) + { + if (aj < *AtomI) + { + *AtomI = aj; + } + egc[aj] = egcolGrey; + + /* Check whether this one has been set before... */ + range_check(aj+g0, 0, maxsid); + range_check(ai+g0, 0, maxsid); + if (sid[aj+g0].sid != -1) + { + gmx_fatal(FARGS, "sid[%d]=%d, sid[%d]=%d, file %s, line %d", + ai, sid[ai+g0].sid, aj, sid[aj+g0].sid, __FILE__, __LINE__); + } + else + { + sid[aj+g0].sid = sid[ai+g0].sid; + sid[aj+g0].atom = aj+g0; + } + ng++; + } + } + return ng; } -static int first_colour(int fC,egCol Col,t_graph *g,egCol egc[]) +static int first_colour(int fC, egCol Col, t_graph *g, egCol egc[]) /* Return the first node with colour Col starting at fC. * return -1 if none found. */ { - int i; - - for(i=fC; (innodes); i++) - if ((g->nedge[i] > 0) && (egc[i]==Col)) - return i; - - return -1; + int i; + + for (i = fC; (i < g->nnodes); i++) + { + if ((g->nedge[i] > 0) && (egc[i] == Col)) + { + return i; + } + } + + return -1; } -static int mk_sblocks(FILE *fp,t_graph *g,int maxsid,t_sid sid[]) +static int mk_sblocks(FILE *fp, t_graph *g, int maxsid, t_sid sid[]) { - int ng,nnodes; - int nW,nG,nB; /* Number of Grey, Black, White */ - int fW,fG; /* First of each category */ - egCol *egc=NULL; /* The colour of each node */ - int g0,nblock; - - if (!g->nbound) - return 0; - - nblock=0; - - nnodes=g->nnodes; - snew(egc,nnodes); - - g0=g->at_start; - nW=g->nbound; - nG=0; - nB=0; - - fW=0; - - /* We even have a loop invariant: - * nW+nG+nB == g->nbound - */ - - if (fp) - fprintf(fp,"Walking down the molecule graph to make constraint-blocks\n"); - - while (nW > 0) { - /* Find the first white, this will allways be a larger - * number than before, because no nodes are made white - * in the loop + int ng, nnodes; + int nW, nG, nB; /* Number of Grey, Black, White */ + int fW, fG; /* First of each category */ + egCol *egc = NULL; /* The colour of each node */ + int g0, nblock; + + if (!g->nbound) + { + return 0; + } + + nblock = 0; + + nnodes = g->nnodes; + snew(egc, nnodes); + + g0 = g->at_start; + nW = g->nbound; + nG = 0; + nB = 0; + + fW = 0; + + /* We even have a loop invariant: + * nW+nG+nB == g->nbound */ - if ((fW=first_colour(fW,egcolWhite,g,egc)) == -1) - gmx_fatal(FARGS,"No WHITE nodes found while nW=%d\n",nW); - - /* Make the first white node grey, and set the block number */ - egc[fW] = egcolGrey; - range_check(fW+g0,0,maxsid); - sid[fW+g0].sid = nblock++; - nG++; - nW--; - - /* Initial value for the first grey */ - fG=fW; + + if (fp) + { + fprintf(fp, "Walking down the molecule graph to make constraint-blocks\n"); + } + + while (nW > 0) + { + /* Find the first white, this will allways be a larger + * number than before, because no nodes are made white + * in the loop + */ + if ((fW = first_colour(fW, egcolWhite, g, egc)) == -1) + { + gmx_fatal(FARGS, "No WHITE nodes found while nW=%d\n", nW); + } + + /* Make the first white node grey, and set the block number */ + egc[fW] = egcolGrey; + range_check(fW+g0, 0, maxsid); + sid[fW+g0].sid = nblock++; + nG++; + nW--; + + /* Initial value for the first grey */ + fG = fW; + + if (debug) + { + fprintf(debug, "Starting G loop (nW=%d, nG=%d, nB=%d, total %d)\n", + nW, nG, nB, nW+nG+nB); + } + + while (nG > 0) + { + if ((fG = first_colour(fG, egcolGrey, g, egc)) == -1) + { + gmx_fatal(FARGS, "No GREY nodes found while nG=%d\n", nG); + } + + /* Make the first grey node black */ + egc[fG] = egcolBlack; + nB++; + nG--; + + /* Make all the neighbours of this black node grey + * and set their block number + */ + ng = mk_grey(nnodes, egc, g, &fG, maxsid, sid); + /* ng is the number of white nodes made grey */ + nG += ng; + nW -= ng; + } + } + sfree(egc); if (debug) - fprintf(debug,"Starting G loop (nW=%d, nG=%d, nB=%d, total %d)\n", - nW,nG,nB,nW+nG+nB); - - while (nG > 0) { - if ((fG=first_colour(fG,egcolGrey,g,egc)) == -1) - gmx_fatal(FARGS,"No GREY nodes found while nG=%d\n",nG); - - /* Make the first grey node black */ - egc[fG]=egcolBlack; - nB++; - nG--; - - /* Make all the neighbours of this black node grey - * and set their block number - */ - ng=mk_grey(nnodes,egc,g,&fG,maxsid,sid); - /* ng is the number of white nodes made grey */ - nG+=ng; - nW-=ng; - } - } - sfree(egc); - - if (debug) - fprintf(debug,"Found %d shake blocks\n",nblock); - - return nblock; + { + fprintf(debug, "Found %d shake blocks\n", nblock); + } + + return nblock; } typedef struct { - int first,last,sid; + int first, last, sid; } t_merge_sid; static int ms_comp(const void *a, const void *b) { - t_merge_sid *ma = (t_merge_sid *)a; - t_merge_sid *mb = (t_merge_sid *)b; - int d; - - d = ma->first-mb->first; - if (d == 0) - return ma->last-mb->last; - else - return d; + t_merge_sid *ma = (t_merge_sid *)a; + t_merge_sid *mb = (t_merge_sid *)b; + int d; + + d = ma->first-mb->first; + if (d == 0) + { + return ma->last-mb->last; + } + else + { + return d; + } } -static int merge_sid(int i0,int at_start,int at_end,int nsid,t_sid sid[], - t_blocka *sblock) +static int merge_sid(int i0, int at_start, int at_end, int nsid, t_sid sid[], + t_blocka *sblock) { - int i,j,k,n,isid,ndel; - t_merge_sid *ms; - int nChanged; - - /* We try to remdy the following problem: - * Atom: 1 2 3 4 5 6 7 8 9 10 - * Sid: 0 -1 1 0 -1 1 1 1 1 1 - */ - - /* Determine first and last atom in each shake ID */ - snew(ms,nsid); - - for(k=0; (k= 0) { - ms[isid].first = min(ms[isid].first,sid[i].atom); - ms[isid].last = max(ms[isid].last,sid[i].atom); - } - } - qsort(ms,nsid,sizeof(ms[0]),ms_comp); - - /* Now merge the overlapping ones */ - ndel = 0; - for(k=0; (knr = nsid; - sblock->nalloc_index = sblock->nr+1; - snew(sblock->index,sblock->nalloc_index); - sblock->nra = at_end - at_start; - sblock->nalloc_a = sblock->nra; - snew(sblock->a,sblock->nalloc_a); - sblock->index[0] = 0; - for(k=n=0; (kindex[k+1] = sblock->index[k] + ms[k].last - ms[k].first+1; - for(j=ms[k].first; (j<=ms[k].last); j++) { - range_check(n,0,sblock->nra); - sblock->a[n++] = j; - range_check(j,0,at_end); - if (sid[j].sid == -1) - sid[j].sid = k; - else - fprintf(stderr,"Double sids (%d, %d) for atom %d\n",sid[j].sid,k,j); - } - } - assert(k == nsid); - /* Removed 2007-09-04 - sblock->index[k+1] = natoms; - for(k=0; (ka[n++] = k; - assert(n == natoms); - */ - sblock->nra = n; - assert(sblock->index[k] == sblock->nra); - sfree(ms); - - return nsid; + int i, j, k, n, isid, ndel; + t_merge_sid *ms; + int nChanged; + + /* We try to remdy the following problem: + * Atom: 1 2 3 4 5 6 7 8 9 10 + * Sid: 0 -1 1 0 -1 1 1 1 1 1 + */ + + /* Determine first and last atom in each shake ID */ + snew(ms, nsid); + + for (k = 0; (k < nsid); k++) + { + ms[k].first = at_end+1; + ms[k].last = -1; + ms[k].sid = k; + } + for (i = at_start; (i < at_end); i++) + { + isid = sid[i].sid; + range_check(isid, -1, nsid); + if (isid >= 0) + { + ms[isid].first = min(ms[isid].first, sid[i].atom); + ms[isid].last = max(ms[isid].last, sid[i].atom); + } + } + qsort(ms, nsid, sizeof(ms[0]), ms_comp); + + /* Now merge the overlapping ones */ + ndel = 0; + for (k = 0; (k < nsid); ) + { + for (j = k+1; (j < nsid); ) + { + if (ms[j].first <= ms[k].last) + { + ms[k].last = max(ms[k].last, ms[j].last); + ms[k].first = min(ms[k].first, ms[j].first); + ms[j].sid = -1; + ndel++; + j++; + } + else + { + k = j; + j = k+1; + } + } + if (j == nsid) + { + k++; + } + } + for (k = 0; (k < nsid); k++) + { + while ((k < nsid-1) && (ms[k].sid == -1)) + { + for (j = k+1; (j < nsid); j++) + { + memcpy(&(ms[j-1]), &(ms[j]), sizeof(ms[0])); + } + nsid--; + } + } + + for (k = at_start; (k < at_end); k++) + { + sid[k].atom = k; + sid[k].sid = -1; + } + sblock->nr = nsid; + sblock->nalloc_index = sblock->nr+1; + snew(sblock->index, sblock->nalloc_index); + sblock->nra = at_end - at_start; + sblock->nalloc_a = sblock->nra; + snew(sblock->a, sblock->nalloc_a); + sblock->index[0] = 0; + for (k = n = 0; (k < nsid); k++) + { + sblock->index[k+1] = sblock->index[k] + ms[k].last - ms[k].first+1; + for (j = ms[k].first; (j <= ms[k].last); j++) + { + range_check(n, 0, sblock->nra); + sblock->a[n++] = j; + range_check(j, 0, at_end); + if (sid[j].sid == -1) + { + sid[j].sid = k; + } + else + { + fprintf(stderr, "Double sids (%d, %d) for atom %d\n", sid[j].sid, k, j); + } + } + } + assert(k == nsid); + /* Removed 2007-09-04 + sblock->index[k+1] = natoms; + for(k=0; (ka[n++] = k; + assert(n == natoms); + */ + sblock->nra = n; + assert(sblock->index[k] == sblock->nra); + sfree(ms); + + return nsid; } -void gen_sblocks(FILE *fp,int at_start,int at_end, - t_idef *idef,t_blocka *sblock, - gmx_bool bSettle) +void gen_sblocks(FILE *fp, int at_start, int at_end, + t_idef *idef, t_blocka *sblock, + gmx_bool bSettle) { - t_graph *g; - int i,i0,j,k,istart,n; - t_sid *sid; - int isid,nsid; - - g=mk_graph(NULL,idef,at_start,at_end,TRUE,bSettle); - if (debug) - p_graph(debug,"Graaf Dracula",g); - snew(sid,at_end); - for(i=at_start; (i -1) - break; - - /* Now we have the sids that have to be shaken. We'll check the min and - * max atom numbers and this determines the shake block. DvdS 2007-07-19. - * For the purpose of making boundaries all atoms in between need to be - * part of the shake block too. There may be cases where blocks overlap - * and they will have to be merged. - */ - nsid = merge_sid(i0,at_start,at_end,nsid,sid,sblock); - /* Now sort the shake blocks again... */ - /*qsort(sid,natoms,(size_t)sizeof(sid[0]),sid_comp);*/ - - /* Fill the sblock struct */ - /* sblock->nr = nsid; - sblock->nra = natoms; - srenew(sblock->a,sblock->nra); - srenew(sblock->index,sblock->nr+1); - - i = i0; - isid = sid[i].sid; - n = k = 0; - sblock->index[n++]=k; - while (i < natoms) { - istart = sid[i].atom; - while ((i -1) + { + break; + } + } + + /* Now we have the sids that have to be shaken. We'll check the min and + * max atom numbers and this determines the shake block. DvdS 2007-07-19. + * For the purpose of making boundaries all atoms in between need to be + * part of the shake block too. There may be cases where blocks overlap + * and they will have to be merged. + */ + nsid = merge_sid(i0, at_start, at_end, nsid, sid, sblock); + /* Now sort the shake blocks again... */ + /*qsort(sid,natoms,(size_t)sizeof(sid[0]),sid_comp);*/ + + /* Fill the sblock struct */ + /* sblock->nr = nsid; + sblock->nra = natoms; + srenew(sblock->a,sblock->nra); + srenew(sblock->index,sblock->nr+1); + + i = i0; + isid = sid[i].sid; + n = k = 0; + sblock->index[n++]=k; + while (i < natoms) { + istart = sid[i].atom; + while ((ia[k]=j; - sblock->index[n] = k; - if (i < natoms-1) - n++; - if (n > nsid) - gmx_fatal(FARGS,"Death Horror: nsid = %d, n= %d",nsid,n); - i++; - isid = sid[i].sid; - } - */ - sfree(sid); - /* Due to unknown reason this free generates a problem sometimes */ - done_graph(g); - sfree(g); - if (debug) - fprintf(debug,"Done gen_sblocks\n"); + /* for(j=istart; (j<=sid[i].atom); j++,k++) + sblock->a[k]=j; + sblock->index[n] = k; + if (i < natoms-1) + n++; + if (n > nsid) + gmx_fatal(FARGS,"Death Horror: nsid = %d, n= %d",nsid,n); + i++; + isid = sid[i].sid; + } + */ + sfree(sid); + /* Due to unknown reason this free generates a problem sometimes */ + done_graph(g); + sfree(g); + if (debug) + { + fprintf(debug, "Done gen_sblocks\n"); + } } static t_blocka block2blocka(t_block *block) { - t_blocka blocka; - int i; - - blocka.nr = block->nr; - blocka.nalloc_index = blocka.nr + 1; - snew(blocka.index,blocka.nalloc_index); - for(i=0; i<=block->nr; i++) - blocka.index[i] = block->index[i]; - blocka.nra = block->index[block->nr]; - blocka.nalloc_a = blocka.nra; - snew(blocka.a,blocka.nalloc_a); - for(i=0; inr; + blocka.nalloc_index = blocka.nr + 1; + snew(blocka.index, blocka.nalloc_index); + for (i = 0; i <= block->nr; i++) + { + blocka.index[i] = block->index[i]; + } + blocka.nra = block->index[block->nr]; + blocka.nalloc_a = blocka.nra; + snew(blocka.a, blocka.nalloc_a); + for (i = 0; i < blocka.nra; i++) + { + blocka.a[i] = i; + } + + return blocka; } typedef struct { - int nconstr; - int index[10]; + int nconstr; + int index[10]; } pd_constraintlist_t; - + static void find_constraint_range_recursive(pd_constraintlist_t * constraintlist, - int thisatom, - int depth, - int * min_atomid, - int * max_atomid) + int thisatom, + int depth, + int * min_atomid, + int * max_atomid) { - int i,j; - int nconstr; - - for(i=0;i*max_atomid) ? j : *max_atomid; - - if(depth>0) - { - find_constraint_range_recursive(constraintlist,j,depth-1,min_atomid,max_atomid); - } - } + int i, j; + int nconstr; + + for (i = 0; i < constraintlist[thisatom].nconstr; i++) + { + j = constraintlist[thisatom].index[i]; + + *min_atomid = (j < *min_atomid) ? j : *min_atomid; + *max_atomid = (j > *max_atomid) ? j : *max_atomid; + + if (depth > 0) + { + find_constraint_range_recursive(constraintlist, j, depth-1, min_atomid, max_atomid); + } + } } static void pd_determine_constraints_range(t_inputrec * ir, - int natoms, - t_ilist * ilist, - int hid[], - int * min_nodeid, - int * max_nodeid) + int natoms, + t_ilist * ilist, + int hid[], + int * min_nodeid, + int * max_nodeid) { - int i,j,k; - int nratoms; - int depth; - int ai,aj; - int min_atomid,max_atomid; - pd_constraintlist_t *constraintlist; - - nratoms = interaction_function[F_CONSTR].nratoms; - depth = ir->nProjOrder; - - snew(constraintlist,natoms); - - /* Make a list of all the connections */ - for(i=0;inr;i+=nratoms+1) - { - ai=ilist->iatoms[i+1]; - aj=ilist->iatoms[i+2]; - constraintlist[ai].index[constraintlist[ai].nconstr++]=aj; - constraintlist[aj].index[constraintlist[aj].nconstr++]=ai; - } - - for(i=0;inProjOrder; + + snew(constraintlist, natoms); + + /* Make a list of all the connections */ + for (i = 0; i < ilist->nr; i += nratoms+1) + { + ai = ilist->iatoms[i+1]; + aj = ilist->iatoms[i+2]; + constraintlist[ai].index[constraintlist[ai].nconstr++] = aj; + constraintlist[aj].index[constraintlist[aj].nconstr++] = ai; + } + + for (i = 0; i < natoms; i++) + { + min_atomid = i; + max_atomid = i; + + find_constraint_range_recursive(constraintlist, i, depth, &min_atomid, &max_atomid); + + min_nodeid[i] = hid[min_atomid]; + max_nodeid[i] = hid[max_atomid]; + } + sfree(constraintlist); } -void split_top(FILE *fp,int nnodes,gmx_localtop_t *top,t_inputrec *ir,t_block *mols, - real *capacity,int *multinr_cgs,int **multinr_nre, int *left_range, int * right_range) +void split_top(FILE *fp, int nnodes, gmx_localtop_t *top, t_inputrec *ir, t_block *mols, + real *capacity, int *multinr_cgs, int **multinr_nre, int *left_range, int * right_range) { - int natoms,i,j,k,mj,atom,maxatom,sstart,send,bstart,nodeid; - t_blocka sblock; - int *homeind; - int ftype,nvsite_constr,nra,nrd; - t_iatom *ia; - int minhome,ihome,minidx; - int *constr_min_nodeid; - int *constr_max_nodeid; - - if (nnodes <= 1) - return; - - natoms = mols->index[mols->nr]; - - if (fp) - fprintf(fp,"splitting topology...\n"); - + int natoms, i, j, k, mj, atom, maxatom, sstart, send, bstart, nodeid; + t_blocka sblock; + int *homeind; + int ftype, nvsite_constr, nra, nrd; + t_iatom *ia; + int minhome, ihome, minidx; + int *constr_min_nodeid; + int *constr_max_nodeid; + + if (nnodes <= 1) + { + return; + } + + natoms = mols->index[mols->nr]; + + if (fp) + { + fprintf(fp, "splitting topology...\n"); + } + /*#define MOL_BORDER*/ /*Removed the above to allow splitting molecules with h-bond constraints - over processors. The results in DP are the same. */ - init_blocka(&sblock); - if(ir->eConstrAlg != econtLINCS) - { + over processors. The results in DP are the same. */ + init_blocka(&sblock); + if (ir->eConstrAlg != econtLINCS) + { #ifndef MOL_BORDER - /* Make a special shake block that includes settles */ - gen_sblocks(fp,0,natoms,&top->idef,&sblock,TRUE); + /* Make a special shake block that includes settles */ + gen_sblocks(fp, 0, natoms, &top->idef, &sblock, TRUE); #else - sblock = block2blocka(mols); -#endif - } - - split_blocks(fp,ir,nnodes,&top->cgs,&sblock,capacity,multinr_cgs); - - homeind=home_index(nnodes,&top->cgs,multinr_cgs); - - snew(constr_min_nodeid,natoms); - snew(constr_max_nodeid,natoms); - - if(top->idef.il[F_CONSTR].nr>0) - { - pd_determine_constraints_range(ir,natoms,&top->idef.il[F_CONSTR],homeind,constr_min_nodeid,constr_max_nodeid); - } - else - { - /* Not 100% necessary, but it is a bad habit to have uninitialized arrays around... */ - for(i=0;icgs.index[multinr_cgs[i-1]]; - right_range[i-1] = left_range[i]-1; - } - right_range[nnodes-1] = top->cgs.index[multinr_cgs[nnodes-1]]-1; - - for(j=0; (jidef.il[j],multinr_nre[j],constr_min_nodeid,constr_max_nodeid, - left_range,right_range); - - sfree(constr_min_nodeid); - sfree(constr_max_nodeid); - - sfree(homeind); - done_blocka(&sblock); -} + sblock = block2blocka(mols); +#endif + } + + split_blocks(fp, ir, nnodes, &top->cgs, &sblock, capacity, multinr_cgs); + homeind = home_index(nnodes, &top->cgs, multinr_cgs); + + snew(constr_min_nodeid, natoms); + snew(constr_max_nodeid, natoms); + + if (top->idef.il[F_CONSTR].nr > 0) + { + pd_determine_constraints_range(ir, natoms, &top->idef.il[F_CONSTR], homeind, constr_min_nodeid, constr_max_nodeid); + } + else + { + /* Not 100% necessary, but it is a bad habit to have uninitialized arrays around... */ + for (i = 0; i < natoms; i++) + { + constr_min_nodeid[i] = constr_max_nodeid[i] = homeind[i]; + } + } + + /* Default limits (no communication) for PD constraints */ + left_range[0] = 0; + for (i = 1; i < nnodes; i++) + { + left_range[i] = top->cgs.index[multinr_cgs[i-1]]; + right_range[i-1] = left_range[i]-1; + } + right_range[nnodes-1] = top->cgs.index[multinr_cgs[nnodes-1]]-1; + + for (j = 0; (j < F_NRE); j++) + { + split_force2(ir, nnodes, homeind, j, &top->idef.il[j], multinr_nre[j], constr_min_nodeid, constr_max_nodeid, + left_range, right_range); + } + + sfree(constr_min_nodeid); + sfree(constr_max_nodeid); + + sfree(homeind); + done_blocka(&sblock); +} diff --git a/src/gromacs/gmxlib/statistics/gmx_statistics.c b/src/gromacs/gmxlib/statistics/gmx_statistics.c index d6b22400d4..be25ede6af 100644 --- a/src/gromacs/gmxlib/statistics/gmx_statistics.c +++ b/src/gromacs/gmxlib/statistics/gmx_statistics.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- */ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * Green Red Orange Magenta Azure Cyan Skyblue */ @@ -49,35 +49,35 @@ static int gmx_dnint(double x) } typedef struct gmx_stats { - double aa,a,b,sigma_aa,sigma_a,sigma_b,aver,sigma_aver,error; - double rmsd,Rdata,Rfit,Rfitaa,chi2,chi2aa; - double *x,*y,*dx,*dy; - int computed; - int np,np_c,nalloc; + double aa, a, b, sigma_aa, sigma_a, sigma_b, aver, sigma_aver, error; + double rmsd, Rdata, Rfit, Rfitaa, chi2, chi2aa; + double *x, *y, *dx, *dy; + int computed; + int np, np_c, nalloc; } gmx_stats; gmx_stats_t gmx_stats_init() { gmx_stats *stats; - - snew(stats,1); - + + snew(stats, 1); + return (gmx_stats_t) stats; } int gmx_stats_get_npoints(gmx_stats_t gstats, int *N) { gmx_stats *stats = (gmx_stats *) gstats; - + *N = stats->np; - + return estatsOK; } int gmx_stats_done(gmx_stats_t gstats) { gmx_stats *stats = (gmx_stats *) gstats; - + sfree(stats->x); stats->x = NULL; sfree(stats->y); @@ -86,27 +86,31 @@ int gmx_stats_done(gmx_stats_t gstats) stats->dx = NULL; sfree(stats->dy); stats->dy = NULL; - + return estatsOK; } -int gmx_stats_add_point(gmx_stats_t gstats,double x,double y, - double dx,double dy) +int gmx_stats_add_point(gmx_stats_t gstats, double x, double y, + double dx, double dy) { gmx_stats *stats = (gmx_stats *) gstats; - int i; - - if (stats->np+1 >= stats->nalloc) + int i; + + if (stats->np+1 >= stats->nalloc) { - if (stats->nalloc == 0) + if (stats->nalloc == 0) + { stats->nalloc = 1024; + } else + { stats->nalloc *= 2; - srenew(stats->x,stats->nalloc); - srenew(stats->y,stats->nalloc); - srenew(stats->dx,stats->nalloc); - srenew(stats->dy,stats->nalloc); - for(i=stats->np; (inalloc); i++) + } + srenew(stats->x, stats->nalloc); + srenew(stats->y, stats->nalloc); + srenew(stats->dx, stats->nalloc); + srenew(stats->dy, stats->nalloc); + for (i = stats->np; (i < stats->nalloc); i++) { stats->x[i] = 0; stats->y[i] = 0; @@ -120,52 +124,66 @@ int gmx_stats_add_point(gmx_stats_t gstats,double x,double y, stats->dy[stats->np] = dy; stats->np++; stats->computed = 0; - + return estatsOK; } -int gmx_stats_get_point(gmx_stats_t gstats,real *x,real *y, - real *dx,real *dy,real level) +int gmx_stats_get_point(gmx_stats_t gstats, real *x, real *y, + real *dx, real *dy, real level) { gmx_stats *stats = (gmx_stats *) gstats; - int ok,outlier; - real rmsd,r; - - if ((ok = gmx_stats_get_rmsd(gstats,&rmsd)) != estatsOK) + int ok, outlier; + real rmsd, r; + + if ((ok = gmx_stats_get_rmsd(gstats, &rmsd)) != estatsOK) { return ok; } outlier = 0; while ((outlier == 0) && (stats->np_c < stats->np)) { - r = fabs(stats->x[stats->np_c] - stats->y[stats->np_c]); + r = fabs(stats->x[stats->np_c] - stats->y[stats->np_c]); outlier = (r > rmsd*level); if (outlier) { - if (NULL != x) *x = stats->x[stats->np_c]; - if (NULL != y) *y = stats->y[stats->np_c]; - if (NULL != dx) *dx = stats->dx[stats->np_c]; - if (NULL != dy) *dy = stats->dy[stats->np_c]; + if (NULL != x) + { + *x = stats->x[stats->np_c]; + } + if (NULL != y) + { + *y = stats->y[stats->np_c]; + } + if (NULL != dx) + { + *dx = stats->dx[stats->np_c]; + } + if (NULL != dy) + { + *dy = stats->dy[stats->np_c]; + } } stats->np_c++; - - if (outlier) + + if (outlier) + { return estatsOK; + } } - + stats->np_c = 0; - + return estatsNO_POINTS; } -int gmx_stats_add_points(gmx_stats_t gstats,int n,real *x,real *y, - real *dx,real *dy) +int gmx_stats_add_points(gmx_stats_t gstats, int n, real *x, real *y, + real *dx, real *dy) { - int i,ok; - - for(i=0; (inp; - if (stats->computed == 0) + if (stats->computed == 0) { if (N < 1) { return estatsNO_POINTS; } - - xx = xx_nw = 0; - yy = yy_nw = 0; - yx = yx_nw = 0; - sx = sx_nw = 0; - sy = sy_nw = 0; + + xx = xx_nw = 0; + yy = yy_nw = 0; + yx = yx_nw = 0; + sx = sx_nw = 0; + sy = sy_nw = 0; wtot = 0; d2 = 0; - for(i=0; (ix[i]-stats->y[i]); if ((stats->dy[i]) && (weight == elsqWEIGHT_Y)) @@ -208,25 +226,25 @@ static int gmx_stats_compute(gmx_stats *stats,int weight) { w = 1; } - + wtot += w; - + xx += w*dsqr(stats->x[i]); xx_nw += dsqr(stats->x[i]); - + yy += w*dsqr(stats->y[i]); yy_nw += dsqr(stats->y[i]); - + yx += w*stats->y[i]*stats->x[i]; yx_nw += stats->y[i]*stats->x[i]; - + sx += w*stats->x[i]; sx_nw += stats->x[i]; - + sy += w*stats->y[i]; sy_nw += stats->y[i]; } - + /* Compute average, sigma and error */ stats->aver = sy_nw/N; stats->sigma_aver = sqrt(yy_nw/N - dsqr(sy_nw/N)); @@ -234,18 +252,18 @@ static int gmx_stats_compute(gmx_stats *stats,int weight) /* Compute RMSD between x and y */ stats->rmsd = sqrt(d2/N); - + /* Correlation coefficient for data */ - yx_nw /= N; - xx_nw /= N; - yy_nw /= N; - sx_nw /= N; - sy_nw /= N; - ssxx = N*(xx_nw - dsqr(sx_nw)); - ssyy = N*(yy_nw - dsqr(sy_nw)); - ssxy = N*(yx_nw - (sx_nw*sy_nw)); + yx_nw /= N; + xx_nw /= N; + yy_nw /= N; + sx_nw /= N; + sy_nw /= N; + ssxx = N*(xx_nw - dsqr(sx_nw)); + ssyy = N*(yy_nw - dsqr(sy_nw)); + ssxy = N*(yx_nw - (sx_nw*sy_nw)); stats->Rdata = sqrt(dsqr(ssxy)/(ssxx*ssyy)); - + /* Compute straight line through datapoints, either with intercept zero (result in aa) or with intercept variable (results in a and b) */ @@ -253,16 +271,16 @@ static int gmx_stats_compute(gmx_stats *stats,int weight) xx = xx/wtot; sx = sx/wtot; sy = sy/wtot; - - stats->aa = (yx/xx); + + stats->aa = (yx/xx); stats->a = (yx-sx*sy)/(xx-sx*sx); stats->b = (sy)-(stats->a)*(sx); - + /* Compute chi2, deviation from a line y = ax+b. Also compute chi2aa which returns the deviation from a line y = ax. */ chi2 = 0; chi2aa = 0; - for(i=0; (idy[i] > 0) { @@ -275,19 +293,19 @@ static int gmx_stats_compute(gmx_stats *stats,int weight) chi2aa += dsqr((stats->y[i]-(stats->aa*stats->x[i]))/dy); chi2 += dsqr((stats->y[i]-(stats->a*stats->x[i]+stats->b))/dy); } - if (N > 2) + if (N > 2) { stats->chi2 = sqrt(chi2/(N-2)); stats->chi2aa = sqrt(chi2aa/(N-2)); - + /* Look up equations! */ - dx2 = (xx-sx*sx); - dy2 = (yy-sy*sy); + dx2 = (xx-sx*sx); + dy2 = (yy-sy*sy); stats->sigma_a = sqrt(stats->chi2/((N-2)*dx2)); stats->sigma_b = stats->sigma_a*sqrt(xx); stats->Rfit = fabs(ssxy)/sqrt(ssxx*ssyy); - /*stats->a*sqrt(dx2/dy2);*/ - stats->Rfitaa = stats->aa*sqrt(dx2/dy2); + /*stats->a*sqrt(dx2/dy2);*/ + stats->Rfitaa = stats->aa*sqrt(dx2/dy2); } else { @@ -297,197 +315,219 @@ static int gmx_stats_compute(gmx_stats *stats,int weight) stats->sigma_b = 0; stats->Rfit = 0; stats->Rfitaa = 0; - } + } stats->computed = 1; } - + return estatsOK; } -int gmx_stats_get_ab(gmx_stats_t gstats,int weight, - real *a,real *b,real *da,real *db, - real *chi2,real *Rfit) +int gmx_stats_get_ab(gmx_stats_t gstats, int weight, + real *a, real *b, real *da, real *db, + real *chi2, real *Rfit) { gmx_stats *stats = (gmx_stats *) gstats; - int ok; - - if ((ok = gmx_stats_compute(stats,weight)) != estatsOK) + int ok; + + if ((ok = gmx_stats_compute(stats, weight)) != estatsOK) + { return ok; + } if (NULL != a) { *a = stats->a; } - if (NULL != b) + if (NULL != b) { *b = stats->b; } - if (NULL != da) + if (NULL != da) { *da = stats->sigma_a; } - if (NULL != db) + if (NULL != db) { *db = stats->sigma_b; } - if (NULL != chi2) + if (NULL != chi2) { *chi2 = stats->chi2; } - if (NULL != Rfit) + if (NULL != Rfit) { *Rfit = stats->Rfit; } - + return estatsOK; } -int gmx_stats_get_a(gmx_stats_t gstats,int weight,real *a,real *da, - real *chi2,real *Rfit) +int gmx_stats_get_a(gmx_stats_t gstats, int weight, real *a, real *da, + real *chi2, real *Rfit) { gmx_stats *stats = (gmx_stats *) gstats; - int ok; - - if ((ok = gmx_stats_compute(stats,weight)) != estatsOK) + int ok; + + if ((ok = gmx_stats_compute(stats, weight)) != estatsOK) + { return ok; - if (NULL != a) *a = stats->aa; - if (NULL != da) *da = stats->sigma_aa; - if (NULL != chi2) *chi2 = stats->chi2aa; - if (NULL != Rfit) *Rfit = stats->Rfitaa; - + } + if (NULL != a) + { + *a = stats->aa; + } + if (NULL != da) + { + *da = stats->sigma_aa; + } + if (NULL != chi2) + { + *chi2 = stats->chi2aa; + } + if (NULL != Rfit) + { + *Rfit = stats->Rfitaa; + } + return estatsOK; } -int gmx_stats_get_average(gmx_stats_t gstats,real *aver) +int gmx_stats_get_average(gmx_stats_t gstats, real *aver) { gmx_stats *stats = (gmx_stats *) gstats; - int ok; - - if ((ok = gmx_stats_compute(stats,elsqWEIGHT_NONE)) != estatsOK) + int ok; + + if ((ok = gmx_stats_compute(stats, elsqWEIGHT_NONE)) != estatsOK) { return ok; } - + *aver = stats->aver; - + return estatsOK; } -int gmx_stats_get_ase(gmx_stats_t gstats,real *aver,real *sigma,real *error) +int gmx_stats_get_ase(gmx_stats_t gstats, real *aver, real *sigma, real *error) { gmx_stats *stats = (gmx_stats *) gstats; - int ok; - - if ((ok = gmx_stats_compute(stats,elsqWEIGHT_NONE)) != estatsOK) + int ok; + + if ((ok = gmx_stats_compute(stats, elsqWEIGHT_NONE)) != estatsOK) { return ok; } - + if (NULL != aver) { *aver = stats->aver; } - if (NULL != sigma) + if (NULL != sigma) { *sigma = stats->sigma_aver; } - if (NULL != error) + if (NULL != error) { *error = stats->error; } - + return estatsOK; } -int gmx_stats_get_sigma(gmx_stats_t gstats,real *sigma) +int gmx_stats_get_sigma(gmx_stats_t gstats, real *sigma) { gmx_stats *stats = (gmx_stats *) gstats; - int ok; - - if ((ok = gmx_stats_compute(stats,elsqWEIGHT_NONE)) != estatsOK) + int ok; + + if ((ok = gmx_stats_compute(stats, elsqWEIGHT_NONE)) != estatsOK) + { return ok; + } *sigma = stats->sigma_aver; - + return estatsOK; } -int gmx_stats_get_error(gmx_stats_t gstats,real *error) +int gmx_stats_get_error(gmx_stats_t gstats, real *error) { gmx_stats *stats = (gmx_stats *) gstats; - int ok; - - if ((ok = gmx_stats_compute(stats,elsqWEIGHT_NONE)) != estatsOK) + int ok; + + if ((ok = gmx_stats_compute(stats, elsqWEIGHT_NONE)) != estatsOK) + { return ok; + } *error = stats->error; - + return estatsOK; } -int gmx_stats_get_corr_coeff(gmx_stats_t gstats,real *R) +int gmx_stats_get_corr_coeff(gmx_stats_t gstats, real *R) { gmx_stats *stats = (gmx_stats *) gstats; - int ok; - - if ((ok = gmx_stats_compute(stats,elsqWEIGHT_NONE)) != estatsOK) + int ok; + + if ((ok = gmx_stats_compute(stats, elsqWEIGHT_NONE)) != estatsOK) + { return ok; + } *R = stats->Rdata; - + return estatsOK; } -int gmx_stats_get_rmsd(gmx_stats_t gstats,real *rmsd) +int gmx_stats_get_rmsd(gmx_stats_t gstats, real *rmsd) { gmx_stats *stats = (gmx_stats *) gstats; - int ok; - - if ((ok = gmx_stats_compute(stats,elsqWEIGHT_NONE)) != estatsOK) + int ok; + + if ((ok = gmx_stats_compute(stats, elsqWEIGHT_NONE)) != estatsOK) { return ok; } - + *rmsd = stats->rmsd; - + return estatsOK; } -int gmx_stats_dump_xy(gmx_stats_t gstats,FILE *fp) +int gmx_stats_dump_xy(gmx_stats_t gstats, FILE *fp) { gmx_stats *stats = (gmx_stats *) gstats; - int i,ok; - - for(i=0; (inp); i++) + int i, ok; + + for (i = 0; (i < stats->np); i++) { - fprintf(fp,"%12g %12g %12g %12g\n",stats->x[i],stats->y[i], - stats->dx[i],stats->dy[i]); + fprintf(fp, "%12g %12g %12g %12g\n", stats->x[i], stats->y[i], + stats->dx[i], stats->dy[i]); } - + return estatsOK; } -int gmx_stats_remove_outliers(gmx_stats_t gstats,double level) +int gmx_stats_remove_outliers(gmx_stats_t gstats, double level) { gmx_stats *stats = (gmx_stats *) gstats; - int i,iter=1,done=0,ok; - real rmsd,r; - - while ((stats->np >= 10) && !done) + int i, iter = 1, done = 0, ok; + real rmsd, r; + + while ((stats->np >= 10) && !done) { - if ((ok = gmx_stats_get_rmsd(gstats,&rmsd)) != estatsOK) + if ((ok = gmx_stats_get_rmsd(gstats, &rmsd)) != estatsOK) { return ok; } done = 1; - for(i=0; (inp); ) + for (i = 0; (i < stats->np); ) { r = fabs(stats->x[i]-stats->y[i]); - if (r > level*rmsd) + if (r > level*rmsd) { - fprintf(stderr,"Removing outlier, iter = %d, rmsd = %g, x = %g, y = %g\n", - iter,rmsd,stats->x[i],stats->y[i]); - if (i < stats->np-1) + fprintf(stderr, "Removing outlier, iter = %d, rmsd = %g, x = %g, y = %g\n", + iter, rmsd, stats->x[i], stats->y[i]); + if (i < stats->np-1) { stats->x[i] = stats->x[stats->np-1]; stats->y[i] = stats->y[stats->np-1]; @@ -497,24 +537,24 @@ int gmx_stats_remove_outliers(gmx_stats_t gstats,double level) stats->np--; done = 0; } - else + else { i++; } } iter++; } - + return estatsOK; } -int gmx_stats_make_histogram(gmx_stats_t gstats,real binwidth,int *nb, - int ehisto,int normalized,real **x,real **y) +int gmx_stats_make_histogram(gmx_stats_t gstats, real binwidth, int *nb, + int ehisto, int normalized, real **x, real **y) { gmx_stats *stats = (gmx_stats *) gstats; - int i,ok,index=0,nbins=*nb,*nindex; - double minx,maxx,maxy,miny,delta,dd,minh; - + int i, ok, index = 0, nbins = *nb, *nindex; + double minx, maxx, maxy, miny, delta, dd, minh; + if (((binwidth <= 0) && (nbins <= 0)) || ((binwidth > 0) && (nbins > 0))) { @@ -526,7 +566,7 @@ int gmx_stats_make_histogram(gmx_stats_t gstats,real binwidth,int *nb, } minx = maxx = stats->x[0]; miny = maxy = stats->y[0]; - for(i=1; (inp); i++) + for (i = 1; (i < stats->np); i++) { miny = (stats->y[i] < miny) ? stats->y[i] : miny; maxy = (stats->y[i] > maxy) ? stats->y[i] : maxy; @@ -536,16 +576,18 @@ int gmx_stats_make_histogram(gmx_stats_t gstats,real binwidth,int *nb, if (ehisto == ehistoX) { delta = maxx-minx; - minh = minx; + minh = minx; } else if (ehisto == ehistoY) { delta = maxy-miny; - minh = miny; + minh = miny; } else + { return estatsINVALID_INPUT; - + } + if (binwidth == 0) { binwidth = (delta)/nbins; @@ -554,9 +596,9 @@ int gmx_stats_make_histogram(gmx_stats_t gstats,real binwidth,int *nb, { nbins = gmx_dnint((delta)/binwidth + 0.5); } - snew(*x,nbins); - snew(nindex,nbins); - for(i=0; (inp); } - - snew(*y,nbins); - for(i=0; (inp); i++) + + snew(*y, nbins); + for (i = 0; (i < stats->np); i++) { if (ehisto == ehistoY) + { index = (stats->y[i]-miny)/binwidth; - else if (ehisto == ehistoX) + } + else if (ehisto == ehistoX) + { index = (stats->x[i]-minx)/binwidth; - if (index<0) - { - index = 0; - } - if (index>nbins-1) - { - index = nbins-1; - } + } + if (index < 0) + { + index = 0; + } + if (index > nbins-1) + { + index = nbins-1; + } (*y)[index] += dd; nindex[index]++; } if (*nb == 0) + { *nb = nbins; - for(i=0; (i 0) + { (*y)[i] /= nindex[i]; - + } + } + sfree(nindex); - + return estatsOK; } -static const char *stats_error[estatsNR] = +static const char *stats_error[estatsNR] = { "All well in STATS land", "No points", @@ -619,120 +671,120 @@ const char *gmx_stats_message(int estats) return stats_error[estatsERROR]; } } - + /* Old convenience functions, should be merged with the core statistics above. */ int lsq_y_ax(int n, real x[], real y[], real *a) { gmx_stats_t lsq = gmx_stats_init(); - int ok; - real da,chi2,Rfit; - - gmx_stats_add_points(lsq,n,x,y,0,0); - if ((ok = gmx_stats_get_a(lsq,elsqWEIGHT_NONE,a,&da,&chi2,&Rfit)) != estatsOK) + int ok; + real da, chi2, Rfit; + + gmx_stats_add_points(lsq, n, x, y, 0, 0); + if ((ok = gmx_stats_get_a(lsq, elsqWEIGHT_NONE, a, &da, &chi2, &Rfit)) != estatsOK) { return ok; } - + /* int i; double xx,yx; - + yx=xx=0.0; for (i=0; i 2) - return sqrt(chi2/(n-2)); - else - return 0; - */ + double x,y,yx,xx,yy,sx,sy,chi2; + + yx=xx=yy=sx=sy=0.0; + for (i=0; i 2) + return sqrt(chi2/(n-2)); + else + return 0; + */ } -int lsq_y_ax_b(int n, real x[], real y[], real *a, real *b,real *r,real *chi2) +int lsq_y_ax_b(int n, real x[], real y[], real *a, real *b, real *r, real *chi2) { - return low_lsq_y_ax_b(n,x,NULL,y,a,b,r,chi2); + return low_lsq_y_ax_b(n, x, NULL, y, a, b, r, chi2); } int lsq_y_ax_b_xdouble(int n, double x[], real y[], real *a, real *b, - real *r,real *chi2) + real *r, real *chi2) { - return low_lsq_y_ax_b(n,NULL,x,y,a,b,r,chi2); + return low_lsq_y_ax_b(n, NULL, x, y, a, b, r, chi2); } int lsq_y_ax_b_error(int n, real x[], real y[], real dy[], real *a, real *b, real *da, real *db, - real *r,real *chi2) + real *r, real *chi2) { gmx_stats_t lsq; - int i,ok; - + int i, ok; + lsq = gmx_stats_init(); - for(i=0; (i 2) - *chi2 = sqrt(*chi2/(n-2)); - else - *chi2 = 0; - */ + double sxy,sxx,syy,sx,sy,w,s_2,dx2,dy2,mins; + + sxy=sxx=syy=sx=sy=w=0.0; + mins = dy[0]; + for(i=1; (i 2) + * chi2 = sqrt(*chi2/(n-2)); + else + * chi2 = 0; + */ } - - diff --git a/src/gromacs/gmxlib/statistics/gmx_statistics_test.c b/src/gromacs/gmxlib/statistics/gmx_statistics_test.c index 6497be8918..0f7bbe0214 100644 --- a/src/gromacs/gmxlib/statistics/gmx_statistics_test.c +++ b/src/gromacs/gmxlib/statistics/gmx_statistics_test.c @@ -1,34 +1,34 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 4.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-2008, 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 - * + * * And Hey: * Groningen Machine for Chemical Simulation */ @@ -45,112 +45,147 @@ static void horizontal() { - gmx_rng_t rng; - gmx_stats_t straight; - int i,ok,n=1000; - real y,a,b,da,db,aver,sigma,error,chi2,R,*xh,*yh; - FILE *fp; - - rng = gmx_rng_init(13); - straight = gmx_stats_init(); - for(i=0; (itype = type; h->flags = 0; - + h->bsize = 0; h->blockfp = NULL; h->invbw = 0; @@ -284,7 +284,7 @@ gmx_histogram_create_range(gmx_histogram_t **hp, e_histogram_t type, { start -= binw; } - end += binw; + end += binw; nbins = (int)((end - start) / binw + 0.5); } /* Create the histogram */ @@ -592,7 +592,7 @@ gmx_histogram_get_value(gmx_histogram_t *h, real pos, double *value, double *err if (pos < h->start || pos > h->end) { - v = e = 0; + v = e = 0; } else { @@ -632,7 +632,7 @@ gmx_histogram_get_bin_value(gmx_histogram_t *h, int bin, double *value, double * if (bin < 0 || bin >= h->nbins) { - v = e = 0; + v = e = 0; } else { @@ -928,7 +928,7 @@ gmx_histogram_resample_dblbw(gmx_histogram_t **destp, gmx_histogram_t *src, ve = sqr(src->histerr[j]) + sqr(src->histerr[j+1]); j += 2; } - ve = sqrt(ve); + ve = sqrt(ve); dest->hist[i] = v; dest->histerr[i] = ve; } @@ -1014,7 +1014,7 @@ void gmx_histogram_scale_vec(gmx_histogram_t *h, real norm[]) { int i; - + for (i = 0; i < h->nbins; ++i) { h->hist[i] *= norm[i]; @@ -1130,7 +1130,7 @@ gmx_histogram_write_array(FILE *fp, int n, gmx_histogram_t *h[], */ void gmx_histogram_write_cum_array(FILE *fp, int n, gmx_histogram_t *h[], - gmx_bool bValue, gmx_bool bErrors) + gmx_bool bValue, gmx_bool bErrors) { int i, j, nbins; double *sum; diff --git a/src/gromacs/gmxlib/statutil.cpp b/src/gromacs/gmxlib/statutil.cpp index 52e22190ff..16c47bcc5f 100644 --- a/src/gromacs/gmxlib/statutil.cpp +++ b/src/gromacs/gmxlib/statutil.cpp @@ -1,35 +1,35 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -69,7 +69,7 @@ #include #endif -/* The source code in this file should be thread-safe. +/* The source code in this file should be thread-safe. Please keep it that way. */ /****************************************************************** @@ -125,47 +125,60 @@ void set_program_name(const char *argvzero) gmx_bool bRmod_fd(double a, double b, double c, gmx_bool bDouble) { - int iq; + int iq; double tol; - + tol = 2*(bDouble ? GMX_DOUBLE_EPS : GMX_FLOAT_EPS); - + iq = static_cast((a - b + tol*a)/c); - + if (std::fabs(a - b - c*iq) <= tol*std::fabs(a)) + { return TRUE; + } else + { return FALSE; + } } -int check_times2(real t,real t0,real tp, real tpp, gmx_bool bDouble) +int check_times2(real t, real t0, real tp, real tpp, gmx_bool bDouble) { int r; - + #ifndef GMX_DOUBLE /* since t is float, we can not use double precision for bRmod */ bDouble = FALSE; #endif - - r=-1; + + r = -1; if ((!bTimeSet(TBEGIN) || (t >= rTimeValue(TBEGIN))) && - (!bTimeSet(TEND) || (t <= rTimeValue(TEND)))) { - if (bTimeSet(TDELTA) && !bRmod_fd(t,t0,rTimeValue(TDELTA),bDouble)) + (!bTimeSet(TEND) || (t <= rTimeValue(TEND)))) + { + if (bTimeSet(TDELTA) && !bRmod_fd(t, t0, rTimeValue(TDELTA), bDouble)) + { r = -1; + } else + { r = 0; + } } else if (bTimeSet(TEND) && (t >= rTimeValue(TEND))) + { r = 1; - if (debug) - fprintf(debug,"t=%g, t0=%g, b=%g, e=%g, dt=%g: r=%d\n", - t,t0,rTimeValue(TBEGIN),rTimeValue(TEND),rTimeValue(TDELTA),r); + } + if (debug) + { + fprintf(debug, "t=%g, t0=%g, b=%g, e=%g, dt=%g: r=%d\n", + t, t0, rTimeValue(TBEGIN), rTimeValue(TEND), rTimeValue(TDELTA), r); + } return r; } int check_times(real t) { - return check_times2(t,t,t,t,FALSE); + return check_times2(t, t, t, t, FALSE); } @@ -173,7 +186,7 @@ int check_times(real t) static void set_default_time_unit(const char *time_list[], gmx_bool bCanTime) { - int i=0; + int i = 0; const char *select = NULL; if (bCanTime) @@ -182,22 +195,22 @@ static void set_default_time_unit(const char *time_list[], gmx_bool bCanTime) if (select != NULL) { i = 1; - while(time_list[i] && strcmp(time_list[i], select) != 0) + while (time_list[i] && strcmp(time_list[i], select) != 0) { i++; } } } - if (!bCanTime || select == NULL || - time_list[i]==NULL || strcmp(time_list[i], select) != 0) + if (!bCanTime || select == NULL || + time_list[i] == NULL || strcmp(time_list[i], select) != 0) { /* Set it to the default: ps */ i = 1; - while(time_list[i] && strcmp(time_list[i], "ps") != 0) + while (time_list[i] && strcmp(time_list[i], "ps") != 0) { i++; } - + } time_list[0] = time_list[i]; } @@ -205,7 +218,7 @@ static void set_default_time_unit(const char *time_list[], gmx_bool bCanTime) static void set_default_xvg_format(const char *xvg_list[]) { - int i; + int i; const char *select; select = getenv("GMX_VIEW_XVG"); @@ -235,16 +248,18 @@ static void set_default_xvg_format(const char *xvg_list[]) /***** T O P O L O G Y S T U F F ******/ -t_topology *read_top(const char *fn,int *ePBC) +t_topology *read_top(const char *fn, int *ePBC) { - int epbc,natoms; + int epbc, natoms; t_topology *top; - - snew(top,1); - epbc = read_tpx_top(fn,NULL,NULL,&natoms,NULL,NULL,NULL,top); + + snew(top, 1); + epbc = read_tpx_top(fn, NULL, NULL, &natoms, NULL, NULL, NULL, top); if (ePBC) + { *ePBC = epbc; - + } + return top; } @@ -254,13 +269,13 @@ t_topology *read_top(const char *fn,int *ePBC) * *************************************************************/ -static void usage(const char *type,const char *arg) +static void usage(const char *type, const char *arg) { GMX_ASSERT(arg != NULL, "NULL command-line argument should not occur"); - gmx_fatal(FARGS,"Expected %s argument for option %s\n",type,arg); + gmx_fatal(FARGS, "Expected %s argument for option %s\n", type, arg); } -int iscan(int argc,char *argv[],int *i) +int iscan(int argc, char *argv[], int *i) { const char *const arg = argv[*i]; if (argc <= (*i)+1) @@ -268,8 +283,8 @@ int iscan(int argc,char *argv[],int *i) usage("an integer", arg); } const char *const value = argv[++(*i)]; - char *endptr; - int var = std::strtol(value, &endptr, 10); + char *endptr; + int var = std::strtol(value, &endptr, 10); if (*value == '\0' || *endptr != '\0') { usage("an integer", arg); @@ -277,7 +292,7 @@ int iscan(int argc,char *argv[],int *i) return var; } -gmx_large_int_t istepscan(int argc,char *argv[],int *i) +gmx_large_int_t istepscan(int argc, char *argv[], int *i) { const char *const arg = argv[*i]; if (argc <= (*i)+1) @@ -285,8 +300,8 @@ gmx_large_int_t istepscan(int argc,char *argv[],int *i) usage("an integer", arg); } const char *const value = argv[++(*i)]; - char *endptr; - gmx_large_int_t var = str_to_large_int_t(value, &endptr); + char *endptr; + gmx_large_int_t var = str_to_large_int_t(value, &endptr); if (*value == '\0' || *endptr != '\0') { usage("an integer", arg); @@ -294,7 +309,7 @@ gmx_large_int_t istepscan(int argc,char *argv[],int *i) return var; } -double dscan(int argc,char *argv[],int *i) +double dscan(int argc, char *argv[], int *i) { const char *const arg = argv[*i]; if (argc <= (*i)+1) @@ -302,8 +317,8 @@ double dscan(int argc,char *argv[],int *i) usage("a real", arg); } const char *const value = argv[++(*i)]; - char *endptr; - double var = std::strtod(value, &endptr); + char *endptr; + double var = std::strtod(value, &endptr); if (*value == '\0' || *endptr != '\0') { usage("a real", arg); @@ -311,134 +326,168 @@ double dscan(int argc,char *argv[],int *i) return var; } -char *sscan(int argc,char *argv[],int *i) +char *sscan(int argc, char *argv[], int *i) { - if (argc > (*i)+1) + if (argc > (*i)+1) { - if ( (argv[(*i)+1][0]=='-') && (argc > (*i)+2) && - (argv[(*i)+2][0]!='-') ) + if ( (argv[(*i)+1][0] == '-') && (argc > (*i)+2) && + (argv[(*i)+2][0] != '-') ) { - fprintf(stderr,"Possible missing string argument for option %s\n\n", + fprintf(stderr, "Possible missing string argument for option %s\n\n", argv[*i]); } - } + } else - usage("a string",argv[*i]); - + { + usage("a string", argv[*i]); + } + return argv[++(*i)]; } int nenum(const char *const enumc[]) { int i; - - i=1; + + i = 1; /* we *can* compare pointers directly here! */ - while(enumc[i] && enumc[0]!=enumc[i]) + while (enumc[i] && enumc[0] != enumc[i]) + { i++; - + } + return i; } static void pdesc(char *desc) { - char *ptr,*nptr; - - ptr=desc; + char *ptr, *nptr; + + ptr = desc; if ((int)strlen(ptr) < 70) - fprintf(stderr,"\t%s\n",ptr); - else { - for(nptr=ptr+70; (nptr != ptr) && (!std::isspace(*nptr)); nptr--) + { + fprintf(stderr, "\t%s\n", ptr); + } + else + { + for (nptr = ptr+70; (nptr != ptr) && (!std::isspace(*nptr)); nptr--) + { ; + } if (nptr == ptr) - fprintf(stderr,"\t%s\n",ptr); - else { - *nptr='\0'; + { + fprintf(stderr, "\t%s\n", ptr); + } + else + { + *nptr = '\0'; nptr++; - fprintf(stderr,"\t%s\n",ptr); + fprintf(stderr, "\t%s\n", ptr); pdesc(nptr); } } } -static FILE *man_file(const output_env_t oenv,const char *mantp) +static FILE *man_file(const output_env_t oenv, const char *mantp) { - FILE *fp; - char buf[256]; + FILE *fp; + char buf[256]; const char *pr = output_env_get_short_program_name(oenv); - - if (strcmp(mantp,"ascii") != 0) - sprintf(buf,"%s.%s",pr,mantp); + + if (strcmp(mantp, "ascii") != 0) + { + sprintf(buf, "%s.%s", pr, mantp); + } else - sprintf(buf,"%s.txt",pr); - fp = gmx_fio_fopen(buf,"w"); - + { + sprintf(buf, "%s.txt", pr); + } + fp = gmx_fio_fopen(buf, "w"); + return fp; } -static int add_parg(int npargs,t_pargs *pa,t_pargs *pa_add) +static int add_parg(int npargs, t_pargs *pa, t_pargs *pa_add) { - memcpy(&(pa[npargs]),pa_add,sizeof(*pa_add)); - + memcpy(&(pa[npargs]), pa_add, sizeof(*pa_add)); + return npargs+1; } static char *mk_desc(t_pargs *pa, const char *time_unit_str) { - char *newdesc=NULL,*ndesc=NULL,*nptr=NULL; - const char*ptr=NULL; - int len,k; - + char *newdesc = NULL, *ndesc = NULL, *nptr = NULL; + const char*ptr = NULL; + int len, k; + /* First compute length for description */ len = strlen(pa->desc)+1; - if ((ptr = strstr(pa->desc,"HIDDEN")) != NULL) + if ((ptr = strstr(pa->desc, "HIDDEN")) != NULL) + { len += 4; - if (pa->type == etENUM) { + } + if (pa->type == etENUM) + { len += 10; - for(k=1; (pa->u.c[k] != NULL); k++) { + for (k = 1; (pa->u.c[k] != NULL); k++) + { len += strlen(pa->u.c[k])+12; } } - snew(newdesc,len); - + snew(newdesc, len); + /* add label for hidden options */ - if (is_hidden(pa)) - sprintf(newdesc,"[hidden] %s",ptr+6); + if (is_hidden(pa)) + { + sprintf(newdesc, "[hidden] %s", ptr+6); + } else - strcpy(newdesc,pa->desc); - + { + strcpy(newdesc, pa->desc); + } + /* change '%t' into time_unit */ #define TUNITLABEL "%t" #define NTUNIT strlen(TUNITLABEL) if (pa->type == etTIME) - while( (nptr=strstr(newdesc,TUNITLABEL)) != NULL ) { - nptr[0]='\0'; - nptr+=NTUNIT; - len+=strlen(time_unit_str)-NTUNIT; - snew(ndesc,len); - strcpy(ndesc,newdesc); - strcat(ndesc,time_unit_str); - strcat(ndesc,nptr); + { + while ( (nptr = strstr(newdesc, TUNITLABEL)) != NULL) + { + nptr[0] = '\0'; + nptr += NTUNIT; + len += strlen(time_unit_str)-NTUNIT; + snew(ndesc, len); + strcpy(ndesc, newdesc); + strcat(ndesc, time_unit_str); + strcat(ndesc, nptr); sfree(newdesc); - newdesc=ndesc; - ndesc=NULL; + newdesc = ndesc; + ndesc = NULL; } + } #undef TUNITLABEL #undef NTUNIT - + /* Add extra comment for enumerateds */ - if (pa->type == etENUM) { - strcat(newdesc,": "); - for(k=1; (pa->u.c[k] != NULL); k++) { - strcat(newdesc,"[TT]"); - strcat(newdesc,pa->u.c[k]); - strcat(newdesc,"[tt]"); + if (pa->type == etENUM) + { + strcat(newdesc, ": "); + for (k = 1; (pa->u.c[k] != NULL); k++) + { + strcat(newdesc, "[TT]"); + strcat(newdesc, pa->u.c[k]); + strcat(newdesc, "[tt]"); /* Print a comma everywhere but at the last one */ - if (pa->u.c[k+1] != NULL) { + if (pa->u.c[k+1] != NULL) + { if (pa->u.c[k+2] == NULL) - strcat(newdesc," or "); + { + strcat(newdesc, " or "); + } else - strcat(newdesc,", "); + { + strcat(newdesc, ", "); + } } } } @@ -446,227 +495,286 @@ static char *mk_desc(t_pargs *pa, const char *time_unit_str) } -void parse_common_args(int *argc,char *argv[],unsigned long Flags, - int nfile,t_filenm fnm[],int npargs,t_pargs *pa, - int ndesc,const char **desc, - int nbugs,const char **bugs, +void parse_common_args(int *argc, char *argv[], unsigned long Flags, + int nfile, t_filenm fnm[], int npargs, t_pargs *pa, + int ndesc, const char **desc, + int nbugs, const char **bugs, output_env_t *oenv) { - gmx_bool bHelp=FALSE,bHidden=FALSE,bQuiet=FALSE,bVersion=FALSE; - const char *manstr[] = { NULL, "no", "html", "tex", "nroff", "ascii", - "completion", "py", "xml", "wiki", NULL }; + gmx_bool bHelp = FALSE, bHidden = FALSE, bQuiet = FALSE, bVersion = FALSE; + const char *manstr[] = { + NULL, "no", "html", "tex", "nroff", "ascii", + "completion", "py", "xml", "wiki", NULL + }; /* This array should match the order of the enum in oenv.h */ const char *xvg_format[] = { NULL, "xmgrace", "xmgr", "none", NULL }; /* This array should match the order of the enum in oenv.h */ - const char *time_units[] = { NULL, "fs", "ps", "ns", "us", "ms", "s", - NULL }; - int nicelevel=0,debug_level=0,verbose_level=0; - char *deffnm=NULL; - real tbegin=0,tend=0,tdelta=0; - gmx_bool bView=FALSE; - - t_pargs *all_pa=NULL; - + const char *time_units[] = { + NULL, "fs", "ps", "ns", "us", "ms", "s", + NULL + }; + int nicelevel = 0, debug_level = 0, verbose_level = 0; + char *deffnm = NULL; + real tbegin = 0, tend = 0, tdelta = 0; + gmx_bool bView = FALSE; + + t_pargs *all_pa = NULL; + #ifdef __sgi - int npri=0; - t_pargs npri_pa = { "-npri", FALSE, etINT, {&npri}, - "HIDDEN Set non blocking priority (try 128)" }; + int npri = 0; + t_pargs npri_pa = { + "-npri", FALSE, etINT, {&npri}, + "HIDDEN Set non blocking priority (try 128)" + }; #endif - t_pargs nice_pa = { "-nice", FALSE, etINT, {&nicelevel}, - "Set the nicelevel" }; - t_pargs deffnm_pa = { "-deffnm", FALSE, etSTR, {&deffnm}, - "Set the default filename for all file options" }; - t_pargs begin_pa = { "-b", FALSE, etTIME, {&tbegin}, - "First frame (%t) to read from trajectory" }; - t_pargs end_pa = { "-e", FALSE, etTIME, {&tend}, - "Last frame (%t) to read from trajectory" }; - t_pargs dt_pa = { "-dt", FALSE, etTIME, {&tdelta}, - "Only use frame when t MOD dt = first time (%t)" }; - t_pargs view_pa = { "-w", FALSE, etBOOL, {&bView}, - "View output [TT].xvg[tt], [TT].xpm[tt], [TT].eps[tt] and [TT].pdb[tt] files" }; - t_pargs xvg_pa = { "-xvg", FALSE, etENUM, {xvg_format}, - "xvg plot formatting" }; - t_pargs time_pa = { "-tu", FALSE, etENUM, {time_units}, - "Time unit" }; + t_pargs nice_pa = { + "-nice", FALSE, etINT, {&nicelevel}, + "Set the nicelevel" + }; + t_pargs deffnm_pa = { + "-deffnm", FALSE, etSTR, {&deffnm}, + "Set the default filename for all file options" + }; + t_pargs begin_pa = { + "-b", FALSE, etTIME, {&tbegin}, + "First frame (%t) to read from trajectory" + }; + t_pargs end_pa = { + "-e", FALSE, etTIME, {&tend}, + "Last frame (%t) to read from trajectory" + }; + t_pargs dt_pa = { + "-dt", FALSE, etTIME, {&tdelta}, + "Only use frame when t MOD dt = first time (%t)" + }; + t_pargs view_pa = { + "-w", FALSE, etBOOL, {&bView}, + "View output [TT].xvg[tt], [TT].xpm[tt], [TT].eps[tt] and [TT].pdb[tt] files" + }; + t_pargs xvg_pa = { + "-xvg", FALSE, etENUM, {xvg_format}, + "xvg plot formatting" + }; + t_pargs time_pa = { + "-tu", FALSE, etENUM, {time_units}, + "Time unit" + }; /* Maximum number of extra arguments */ #define EXTRA_PA 16 - - t_pargs pca_pa[] = { - { "-h", FALSE, etBOOL, {&bHelp}, - "Print help info and quit" }, - { "-version", FALSE, etBOOL, {&bVersion}, - "Print version info and quit" }, - { "-verb", FALSE, etINT, {&verbose_level}, - "HIDDENLevel of verbosity for this program" }, - { "-hidden", FALSE, etBOOL, {&bHidden}, - "HIDDENPrint hidden options" }, - { "-quiet",FALSE, etBOOL, {&bQuiet}, - "HIDDENDo not print help info" }, - { "-man", FALSE, etENUM, {manstr}, - "HIDDENWrite manual and quit" }, - { "-debug",FALSE, etINT, {&debug_level}, - "HIDDENWrite file with debug information, 1: short, 2: also x and f" }, + + t_pargs pca_pa[] = { + { "-h", FALSE, etBOOL, {&bHelp}, + "Print help info and quit" }, + { "-version", FALSE, etBOOL, {&bVersion}, + "Print version info and quit" }, + { "-verb", FALSE, etINT, {&verbose_level}, + "HIDDENLevel of verbosity for this program" }, + { "-hidden", FALSE, etBOOL, {&bHidden}, + "HIDDENPrint hidden options" }, + { "-quiet", FALSE, etBOOL, {&bQuiet}, + "HIDDENDo not print help info" }, + { "-man", FALSE, etENUM, {manstr}, + "HIDDENWrite manual and quit" }, + { "-debug", FALSE, etINT, {&debug_level}, + "HIDDENWrite file with debug information, 1: short, 2: also x and f" }, }; #define NPCA_PA asize(pca_pa) - FILE *fp; - gmx_bool bPrint,bExit,bXvgr; - int i,j,k,npall,max_pa; - -#define FF(arg) ((Flags & arg)==arg) + FILE *fp; + gmx_bool bPrint, bExit, bXvgr; + int i, j, k, npall, max_pa; + +#define FF(arg) ((Flags & arg) == arg) /* Check for double arguments */ - for (i=1; (i<*argc); i++) + for (i = 1; (i < *argc); i++) { if (argv[i] && (strlen(argv[i]) > 1) && (!std::isdigit(argv[i][1]))) { - for (j=i+1; (j<*argc); j++) + for (j = i+1; (j < *argc); j++) { - if ( (argv[i][0]=='-') && (argv[j][0]=='-') && - (strcmp(argv[i],argv[j])==0) ) + if ( (argv[i][0] == '-') && (argv[j][0] == '-') && + (strcmp(argv[i], argv[j]) == 0) ) { if (FF(PCA_NOEXIT_ON_ARGS)) - fprintf(stderr,"Double command line argument %s\n", + { + fprintf(stderr, "Double command line argument %s\n", argv[i]); + } else - gmx_fatal(FARGS,"Double command line argument %s\n", + { + gmx_fatal(FARGS, "Double command line argument %s\n", argv[i]); + } } } } } debug_gmx(); gmx::ProgramInfo::init(*argc, argv); - - /* Handle the flags argument, which is a bit field + + /* Handle the flags argument, which is a bit field * The FF macro returns whether or not the bit is set */ bPrint = !FF(PCA_SILENT); - + /* Check ALL the flags ... */ max_pa = NPCA_PA + EXTRA_PA + npargs+1; - snew(all_pa,max_pa); - - for(i=npall=0; (i(NPCA_PA)); i++) - npall = add_parg(npall,all_pa,&(pca_pa[i])); - + snew(all_pa, max_pa); + + for (i = npall = 0; (i < static_cast(NPCA_PA)); i++) + { + npall = add_parg(npall, all_pa, &(pca_pa[i])); + } + #ifdef __sgi const char *envstr = getenv("GMXNPRIALL"); if (envstr) - npri=strtol(envstr,NULL,10); - if (FF(PCA_BE_NICE)) { + { + npri = strtol(envstr, NULL, 10); + } + if (FF(PCA_BE_NICE)) + { envstr = getenv("GMXNPRI"); if (envstr) - npri=strtol(envstr,NULL,10); + { + npri = strtol(envstr, NULL, 10); + } } - npall = add_parg(npall,all_pa,&npri_pa); + npall = add_parg(npall, all_pa, &npri_pa); #endif - - if (FF(PCA_BE_NICE)) - nicelevel=19; - npall = add_parg(npall,all_pa,&nice_pa); - - if (FF(PCA_CAN_SET_DEFFNM)) - npall = add_parg(npall,all_pa,&deffnm_pa); - if (FF(PCA_CAN_BEGIN)) - npall = add_parg(npall,all_pa,&begin_pa); + + if (FF(PCA_BE_NICE)) + { + nicelevel = 19; + } + npall = add_parg(npall, all_pa, &nice_pa); + + if (FF(PCA_CAN_SET_DEFFNM)) + { + npall = add_parg(npall, all_pa, &deffnm_pa); + } + if (FF(PCA_CAN_BEGIN)) + { + npall = add_parg(npall, all_pa, &begin_pa); + } if (FF(PCA_CAN_END)) - npall = add_parg(npall,all_pa,&end_pa); + { + npall = add_parg(npall, all_pa, &end_pa); + } if (FF(PCA_CAN_DT)) { - npall = add_parg(npall,all_pa,&dt_pa); + npall = add_parg(npall, all_pa, &dt_pa); } - if (FF(PCA_TIME_UNIT)) { - npall = add_parg(npall,all_pa,&time_pa); - } - if (FF(PCA_CAN_VIEW)) - npall = add_parg(npall,all_pa,&view_pa); - + if (FF(PCA_TIME_UNIT)) + { + npall = add_parg(npall, all_pa, &time_pa); + } + if (FF(PCA_CAN_VIEW)) + { + npall = add_parg(npall, all_pa, &view_pa); + } + bXvgr = FALSE; - for(i=0; (i 0) { + if (debug_level > 0) + { char buf[256]; - + if (gmx_mpi_initialized()) - sprintf(buf,"%s%d.debug",output_env_get_short_program_name(*oenv), + { + sprintf(buf, "%s%d.debug", output_env_get_short_program_name(*oenv), gmx_node_rank()); + } else - sprintf(buf,"%s.debug",output_env_get_short_program_name(*oenv)); - - init_debug(debug_level,buf); - fprintf(stderr,"Opening debug file %s (src code file %s, line %d)\n", - buf,__FILE__,__LINE__); + { + sprintf(buf, "%s.debug", output_env_get_short_program_name(*oenv)); + } + + init_debug(debug_level, buf); + fprintf(stderr, "Opening debug file %s (src code file %s, line %d)\n", + buf, __FILE__, __LINE__); } - + /* Now copy the results back... */ - for(i=0,k=npall-npargs; (i= 0)) { + + for (i = 0; i < npall; i++) + { + if ((all_pa[i].type == etTIME) && (*all_pa[i].u.r >= 0)) + { *all_pa[i].u.r *= output_env_get_time_invfactor(*oenv); } } - + /* Extract Time info from arguments */ - if (FF(PCA_CAN_BEGIN) && opt2parg_bSet("-b",npall,all_pa)) - setTimeValue(TBEGIN,opt2parg_real("-b",npall,all_pa)); - - if (FF(PCA_CAN_END) && opt2parg_bSet("-e",npall,all_pa)) - setTimeValue(TEND,opt2parg_real("-e",npall,all_pa)); - - if (FF(PCA_CAN_DT) && opt2parg_bSet("-dt",npall,all_pa)) - setTimeValue(TDELTA,opt2parg_real("-dt",npall,all_pa)); - + if (FF(PCA_CAN_BEGIN) && opt2parg_bSet("-b", npall, all_pa)) + { + setTimeValue(TBEGIN, opt2parg_real("-b", npall, all_pa)); + } + + if (FF(PCA_CAN_END) && opt2parg_bSet("-e", npall, all_pa)) + { + setTimeValue(TEND, opt2parg_real("-e", npall, all_pa)); + } + + if (FF(PCA_CAN_DT) && opt2parg_bSet("-dt", npall, all_pa)) + { + setTimeValue(TDELTA, opt2parg_real("-dt", npall, all_pa)); + } + /* clear memory */ for (i = 0; i < npall; ++i) + { sfree((void *)all_pa[i].desc); + } sfree(all_pa); - - if (!FF(PCA_NOEXIT_ON_ARGS)) { - if (*argc > 1) { + + if (!FF(PCA_NOEXIT_ON_ARGS)) + { + if (*argc > 1) + { gmx_cmd(argv[1]); } - } + } if (bExit) { gmx_finalize_par(); @@ -752,4 +880,3 @@ void parse_common_args(int *argc,char *argv[],unsigned long Flags, } #undef FF } - diff --git a/src/gromacs/gmxlib/strdb.c b/src/gromacs/gmxlib/strdb.c index 91a9ef713e..9012f0ec39 100644 --- a/src/gromacs/gmxlib/strdb.c +++ b/src/gromacs/gmxlib/strdb.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -44,165 +44,189 @@ #include "gmx_fatal.h" #include "strdb.h" -gmx_bool get_a_line(FILE *fp,char line[],int n) +gmx_bool get_a_line(FILE *fp, char line[], int n) { - char *line0; - char *dum; - - snew(line0,n+1); - - do { - if (!fgets(line0,n+1,fp)) { - sfree(line0); - return FALSE; + char *line0; + char *dum; + + snew(line0, n+1); + + do + { + if (!fgets(line0, n+1, fp)) + { + sfree(line0); + return FALSE; + } + dum = strchr(line0, '\n'); + if (dum) + { + dum[0] = '\0'; + } + else if (strlen(line0) == n) + { + fprintf(stderr, "Warning: line length exceeds buffer length (%d), data might be corrupted\n", n); + line0[n-1] = '\0'; + } + else + { + fprintf(stderr, "Warning: file does not end with a newline, last line:\n%s\n", + line0); + } + dum = strchr(line0, ';'); + if (dum) + { + dum[0] = '\0'; + } + strncpy(line, line0, n); + dum = line0; + ltrim(dum); } - dum=strchr(line0,'\n'); - if (dum) - dum[0]='\0'; - else if (strlen(line0)==n) { - fprintf(stderr,"Warning: line length exceeds buffer length (%d), data might be corrupted\n",n); - line0[n-1] ='\0'; - } else - fprintf(stderr,"Warning: file does not end with a newline, last line:\n%s\n", - line0); - dum=strchr(line0,';'); - if (dum) - dum[0]='\0'; - strncpy(line,line0,n); - dum=line0; - ltrim(dum); - } while (dum[0] == '\0'); - - sfree(line0); - return TRUE; + while (dum[0] == '\0'); + + sfree(line0); + return TRUE; } -gmx_bool get_header(char line[],char *header) +gmx_bool get_header(char line[], char *header) { - char temp[STRLEN],*dum; - - strcpy(temp,line); - dum=strchr(temp,'['); - if (dum==NULL) - return FALSE; - dum[0]=' '; - dum=strchr(temp,']'); - if (dum==NULL) { - gmx_fatal(FARGS,"header is not terminated on line:\n'%s'\n",line); - return FALSE; - } - dum[0]='\0'; - if (sscanf(temp,"%s%*s",header) != 1) - return FALSE; - - return TRUE; + char temp[STRLEN], *dum; + + strcpy(temp, line); + dum = strchr(temp, '['); + if (dum == NULL) + { + return FALSE; + } + dum[0] = ' '; + dum = strchr(temp, ']'); + if (dum == NULL) + { + gmx_fatal(FARGS, "header is not terminated on line:\n'%s'\n", line); + return FALSE; + } + dum[0] = '\0'; + if (sscanf(temp, "%s%*s", header) != 1) + { + return FALSE; + } + + return TRUE; } -int get_strings(const char *db,char ***strings) +int get_strings(const char *db, char ***strings) { - FILE *in; - char **ptr; - char buf[256]; - int i,nstr; - - in=libopen(db); - - if (fscanf(in,"%d",&nstr) != 1) { - gmx_warning("File %s is empty",db); - ffclose(in); - return 0; - } - snew(ptr,nstr); - for(i=0; (i=maxi) { - maxi+=50; - srenew(ptr,maxi); + FILE *in; + char **ptr = NULL; + char buf[STRLEN]; + int i, nstr, maxi; + + in = libopen(db); + + i = maxi = 0; + while (fgets2(buf, STRLEN-1, in)) + { + if (i >= maxi) + { + maxi += 50; + srenew(ptr, maxi); + } + ptr[i] = strdup(buf); + i++; } - ptr[i] = strdup(buf); - i++; - } - nstr=i; - ffclose(in); - srenew(ptr,nstr); - *strings=ptr; - - return nstr; -} + nstr = i; + ffclose(in); + srenew(ptr, nstr); + *strings = ptr; + return nstr; +} diff --git a/src/gromacs/gmxlib/string2.c b/src/gromacs/gmxlib/string2.c index 36caebca45..5022212289 100644 --- a/src/gromacs/gmxlib/string2.c +++ b/src/gromacs/gmxlib/string2.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -72,109 +72,133 @@ int continuing(char *s) { - int sl; - assert(s); - - rtrim(s); - sl = strlen(s); - if ((sl > 0) && (s[sl-1] == CONTINUE)) { - s[sl-1] = 0; - return TRUE; - } - else - return FALSE; + int sl; + assert(s); + + rtrim(s); + sl = strlen(s); + if ((sl > 0) && (s[sl-1] == CONTINUE)) + { + s[sl-1] = 0; + return TRUE; + } + else + { + return FALSE; + } } char *fgets2(char *line, int n, FILE *stream) { - char *c; - if (fgets(line,n,stream) == NULL) { - return NULL; - } - if ((c=strchr(line,'\n')) != NULL) { - *c = '\0'; - } else { - /* A line not ending in a newline can only occur at the end of a file, - * or because of n being too small. - * Since both cases occur very infrequently, we can check for EOF. - */ - if (!gmx_eof(stream)) { - gmx_fatal(FARGS,"An input file contains a line longer than %d characters, while the buffer passed to fgets2 has size %d. The line starts with: '%20.20s'",n,n,line); + char *c; + if (fgets(line, n, stream) == NULL) + { + return NULL; + } + if ((c = strchr(line, '\n')) != NULL) + { + *c = '\0'; + } + else + { + /* A line not ending in a newline can only occur at the end of a file, + * or because of n being too small. + * Since both cases occur very infrequently, we can check for EOF. + */ + if (!gmx_eof(stream)) + { + gmx_fatal(FARGS, "An input file contains a line longer than %d characters, while the buffer passed to fgets2 has size %d. The line starts with: '%20.20s'", n, n, line); + } + } + if ((c = strchr(line, '\r')) != NULL) + { + *c = '\0'; } - } - if ((c=strchr(line,'\r')) != NULL) { - *c = '\0'; - } - return line; + return line; } void strip_comment (char *line) { - char *c; + char *c; - if (!line) - return; + if (!line) + { + return; + } - /* search for a comment mark and replace it by a zero */ - if ((c = strchr(line,COMMENTSIGN)) != NULL) - (*c) = 0; + /* search for a comment mark and replace it by a zero */ + if ((c = strchr(line, COMMENTSIGN)) != NULL) + { + (*c) = 0; + } } void upstring (char *str) { - int i; + int i; - for (i=0; (i < (int)strlen(str)); i++) - str[i] = toupper(str[i]); + for (i = 0; (i < (int)strlen(str)); i++) + { + str[i] = toupper(str[i]); + } } void ltrim (char *str) { - char *tr; - int i,c; + char *tr; + int i, c; - if (NULL == str) - return; + if (NULL == str) + { + return; + } - c = 0; - while (('\0' != str[c]) && isspace(str[c])) - c++; - if (c > 0) + c = 0; + while (('\0' != str[c]) && isspace(str[c])) { - for(i=c; ('\0' != str[i]); i++) - str[i-c] = str[i]; - str[i-c] = '\0'; + c++; + } + if (c > 0) + { + for (i = c; ('\0' != str[i]); i++) + { + str[i-c] = str[i]; + } + str[i-c] = '\0'; } } void rtrim (char *str) { - int nul; + int nul; - if (NULL == str) - return; + if (NULL == str) + { + return; + } - nul = strlen(str)-1; - while ((nul > 0) && ((str[nul] == ' ') || (str[nul] == '\t')) ) { - str[nul] = '\0'; - nul--; - } + nul = strlen(str)-1; + while ((nul > 0) && ((str[nul] == ' ') || (str[nul] == '\t')) ) + { + str[nul] = '\0'; + nul--; + } } void trim (char *str) { - ltrim (str); - rtrim (str); + ltrim (str); + rtrim (str); } char * -gmx_ctime_r(const time_t *clock,char *buf, int n) +gmx_ctime_r(const time_t *clock, char *buf, int n) { char tmpbuf[STRLEN]; - + #ifdef GMX_NATIVE_WINDOWS /* Windows */ ctime_s( tmpbuf, STRLEN, clock ); @@ -182,74 +206,77 @@ gmx_ctime_r(const time_t *clock,char *buf, int n) /*Solaris*/ ctime_r(clock, tmpbuf, n); #else - ctime_r(clock,tmpbuf); + ctime_r(clock, tmpbuf); #endif - strncpy(buf,tmpbuf,n-1); - buf[n-1]='\0'; - + strncpy(buf, tmpbuf, n-1); + buf[n-1] = '\0'; + return buf; } - -void nice_header (FILE *out,const char *fn) + +void nice_header (FILE *out, const char *fn) { - const char *unk = "onbekend"; - time_t clock; - const char *user=unk; - int gh; + const char *unk = "onbekend"; + time_t clock; + const char *user = unk; + int gh; #ifdef HAVE_PWD_H - uid_t uid; + uid_t uid; #else - int uid; + int uid; #endif - char buf[256]=""; - char timebuf[STRLEN]; + char buf[256] = ""; + char timebuf[STRLEN]; #ifdef HAVE_PWD_H - struct passwd *pw; + struct passwd *pw; #endif - /* Print a nice header above the file */ - time(&clock); - fprintf (out,"%c\n",COMMENTSIGN); - fprintf (out,"%c\tFile '%s' was generated\n",COMMENTSIGN,fn ? fn : unk); - + /* Print a nice header above the file */ + time(&clock); + fprintf (out, "%c\n", COMMENTSIGN); + fprintf (out, "%c\tFile '%s' was generated\n", COMMENTSIGN, fn ? fn : unk); + #ifdef HAVE_PWD_H - uid = getuid(); - pw = getpwuid(uid); - gh = gethostname(buf,255); - user= pw->pw_name; + uid = getuid(); + pw = getpwuid(uid); + gh = gethostname(buf, 255); + user = pw->pw_name; #else - uid = 0; - gh = -1; + uid = 0; + gh = -1; #endif - - gmx_ctime_r(&clock,timebuf,STRLEN); - fprintf (out,"%c\tBy user: %s (%d)\n",COMMENTSIGN, - user ? user : unk,(int) uid); - fprintf(out,"%c\tOn host: %s\n",COMMENTSIGN,(gh == 0) ? buf : unk); - - fprintf (out,"%c\tAt date: %s",COMMENTSIGN,timebuf); - fprintf (out,"%c\n",COMMENTSIGN); + + gmx_ctime_r(&clock, timebuf, STRLEN); + fprintf (out, "%c\tBy user: %s (%d)\n", COMMENTSIGN, + user ? user : unk, (int) uid); + fprintf(out, "%c\tOn host: %s\n", COMMENTSIGN, (gh == 0) ? buf : unk); + + fprintf (out, "%c\tAt date: %s", COMMENTSIGN, timebuf); + fprintf (out, "%c\n", COMMENTSIGN); } int gmx_strcasecmp_min(const char *str1, const char *str2) { - char ch1,ch2; + char ch1, ch2; do { do { - ch1=toupper(*(str1++)); + ch1 = toupper(*(str1++)); } - while ((ch1=='-') || (ch1=='_')); + while ((ch1 == '-') || (ch1 == '_')); do { - ch2=toupper(*(str2++)); + ch2 = toupper(*(str2++)); } - while ((ch2=='-') || (ch2=='_')); + while ((ch2 == '-') || (ch2 == '_')); - if (ch1!=ch2) return (ch1-ch2); + if (ch1 != ch2) + { + return (ch1-ch2); + } } while (ch1); return 0; @@ -257,70 +284,81 @@ int gmx_strcasecmp_min(const char *str1, const char *str2) int gmx_strncasecmp_min(const char *str1, const char *str2, int n) { - char ch1,ch2; + char ch1, ch2; char *stri1, *stri2; - stri1=(char *)str1; - stri2=(char *)str2; + stri1 = (char *)str1; + stri2 = (char *)str2; do { do { - ch1=toupper(*(str1++)); + ch1 = toupper(*(str1++)); } - while ((ch1=='-') || (ch1=='_')); + while ((ch1 == '-') || (ch1 == '_')); do { - ch2=toupper(*(str2++)); + ch2 = toupper(*(str2++)); } - while ((ch2=='-') || (ch2=='_')); + while ((ch2 == '-') || (ch2 == '_')); - if (ch1!=ch2) return (ch1-ch2); + if (ch1 != ch2) + { + return (ch1-ch2); + } } - while (ch1 && (str1-stri1 n) + if (len > n) { len = n; } @@ -344,7 +382,7 @@ gmx_strndup(const char *src, int n) * Do NOT use any other value unless you really know what you are doing. */ const unsigned int -gmx_string_hash_init = 5381; + gmx_string_hash_init = 5381; unsigned int @@ -354,7 +392,10 @@ gmx_string_hash_func(const char *s, unsigned int hash_init) while ((c = toupper(*s++)) != '\0') { - if(isalnum(c)) hash_init = ((hash_init << 5) + hash_init) ^ c; /* (hash * 33) xor c */ + if (isalnum(c)) + { + hash_init = ((hash_init << 5) + hash_init) ^ c; /* (hash * 33) xor c */ + } } return hash_init; } @@ -424,206 +465,239 @@ gmx_wcmatch(const char *pattern, const char *str) return (*str == 0) ? 0 : GMX_NO_WCMATCH; } -char *wrap_lines(const char *buf,int line_width, int indent,gmx_bool bIndentFirst) +char *wrap_lines(const char *buf, int line_width, int indent, gmx_bool bIndentFirst) { - char *b2; - int i,i0,i2,j,b2len,lspace=0,l2space=0; - gmx_bool bFirst,bFitsOnLine; - - /* characters are copied from buf to b2 with possible spaces changed - * into newlines and extra space added for indentation. - * i indexes buf (source buffer) and i2 indexes b2 (destination buffer) - * i0 points to the beginning of the current line (in buf, source) - * lspace and l2space point to the last space on the current line - * bFirst is set to prevent indentation of first line - * bFitsOnLine says if the first space occurred before line_width, if - * that is not the case, we have a word longer than line_width which - * will also not fit on the next line, so we might as well keep it on - * the current line (where it also won't fit, but looks better) - */ - - b2=NULL; - b2len=strlen(buf)+1+indent; - snew(b2,b2len); - i0=i2=0; - if (bIndentFirst) - for(i2=0; (i2= indent) ) { - /* start a new line */ - b2[l2space] = '\n'; - /* and add indentation */ - if (indent) { - if (bFirst) { - line_width-=indent; - bFirst=FALSE; - } - b2len+=indent; - srenew(b2, b2len); - for(j=0; (j= indent) ) + { + /* start a new line */ + b2[l2space] = '\n'; + /* and add indentation */ + if (indent) + { + if (bFirst) + { + line_width -= indent; + bFirst = FALSE; + } + b2len += indent; + srenew(b2, b2len); + for (j = 0; (j < indent); j++) + { + b2[i2++] = ' '; + } + /* no extra spaces after indent; */ + while (buf[i0] == ' ') + { + i0++; + } + } + } + } + } + while (buf[i]); + b2[i2] = '\0'; + + return b2; } -char **split(char sep,const char *str) +char **split(char sep, const char *str) { - char **ptr = NULL; - int n,nn,nptr = 0; - - if (str == NULL) - return NULL; - nn = strlen(str); - for(n=0; (n(size_t)(maxlen-1)) - gmx_fatal(FARGS,"String '%s' (%d) is longer than buffer (%d).\n", - s, strlen(s), maxlen-1); - - for (; (*s)&&((*s)==' '); s++); - for (len=strlen(s); (len>0); len--) if (s[len-1]!=' ') break; - if (len>=BUFSIZE) len=BUFSIZE-1; - for (i=0; i (size_t)(maxlen-1)) + { + gmx_fatal(FARGS, "String '%s' (%d) is longer than buffer (%d).\n", + s, strlen(s), maxlen-1); + } + + for (; (*s) && ((*s) == ' '); s++) + { + ; + } + for (len = strlen(s); (len > 0); len--) + { + if (s[len-1] != ' ') + { + break; + } + } + if (len >= BUFSIZE) + { + len = BUFSIZE-1; + } + for (i = 0; i < len; i++) + { + out[i] = *(s++); + } + out[i] = 0; + return out; } -int lookup_symtab(t_symtab *symtab,char **name) +int lookup_symtab(t_symtab *symtab, char **name) { - int base,index; - t_symbuf *symbuf; - - base=0; - index=0; - symbuf=symtab->symbuf; - while (symbuf!=NULL) { - index=name-symbuf->buf; - if ( ( index >= 0 ) && ( index < symbuf->bufsize ) ) - return index+base; - else { - base+=symbuf->bufsize; - symbuf=symbuf->next; + int base, index; + t_symbuf *symbuf; + + base = 0; + index = 0; + symbuf = symtab->symbuf; + while (symbuf != NULL) + { + index = name-symbuf->buf; + if ( ( index >= 0 ) && ( index < symbuf->bufsize ) ) + { + return index+base; + } + else + { + base += symbuf->bufsize; + symbuf = symbuf->next; + } } - } - gmx_fatal(FARGS,"symtab lookup \"%s\" not found",*name); - return -1; + gmx_fatal(FARGS, "symtab lookup \"%s\" not found", *name); + return -1; } -char **get_symtab_handle(t_symtab *symtab,int name) +char **get_symtab_handle(t_symtab *symtab, int name) { - t_symbuf *symbuf; - - symbuf=symtab->symbuf; - while (symbuf!=NULL) { - if (namebufsize) - return &(symbuf->buf[name]); - else { - name-=symbuf->bufsize; - symbuf=symbuf->next; + t_symbuf *symbuf; + + symbuf = symtab->symbuf; + while (symbuf != NULL) + { + if (name < symbuf->bufsize) + { + return &(symbuf->buf[name]); + } + else + { + name -= symbuf->bufsize; + symbuf = symbuf->next; + } } - } - gmx_fatal(FARGS,"symtab get_symtab_handle %d not found",name); - return NULL; + gmx_fatal(FARGS, "symtab get_symtab_handle %d not found", name); + return NULL; } static t_symbuf *new_symbuf(void) { - t_symbuf *symbuf; + t_symbuf *symbuf; - snew(symbuf,1); - symbuf->bufsize=TABLESIZE; - snew(symbuf->buf,symbuf->bufsize); - symbuf->next=NULL; + snew(symbuf, 1); + symbuf->bufsize = TABLESIZE; + snew(symbuf->buf, symbuf->bufsize); + symbuf->next = NULL; - return symbuf; + return symbuf; } -static char **enter_buf(t_symtab *symtab,char *name) +static char **enter_buf(t_symtab *symtab, char *name) { - int i; - t_symbuf *symbuf; - gmx_bool bCont; - - if (symtab->symbuf == NULL) - symtab->symbuf=new_symbuf(); - - symbuf=symtab->symbuf; - do { - for(i=0; (i < symbuf->bufsize); i++) { - if (symbuf->buf[i]==NULL) { - symtab->nr++; - symbuf->buf[i]=strdup(name); - return &(symbuf->buf[i]); - } else if (strcmp(symbuf->buf[i],name)==0) - return &(symbuf->buf[i]); + int i; + t_symbuf *symbuf; + gmx_bool bCont; + + if (symtab->symbuf == NULL) + { + symtab->symbuf = new_symbuf(); } - if (symbuf->next != NULL) { - symbuf=symbuf->next; - bCont = TRUE; + + symbuf = symtab->symbuf; + do + { + for (i = 0; (i < symbuf->bufsize); i++) + { + if (symbuf->buf[i] == NULL) + { + symtab->nr++; + symbuf->buf[i] = strdup(name); + return &(symbuf->buf[i]); + } + else if (strcmp(symbuf->buf[i], name) == 0) + { + return &(symbuf->buf[i]); + } + } + if (symbuf->next != NULL) + { + symbuf = symbuf->next; + bCont = TRUE; + } + else + { + bCont = FALSE; + } } - else - bCont = FALSE; - } while (bCont); + while (bCont); - symbuf->next=new_symbuf(); - symbuf=symbuf->next; + symbuf->next = new_symbuf(); + symbuf = symbuf->next; - symtab->nr++; - symbuf->buf[0]=strdup(name); - return &(symbuf->buf[0]); + symtab->nr++; + symbuf->buf[0] = strdup(name); + return &(symbuf->buf[0]); } -char **put_symtab(t_symtab *symtab,const char *name) +char **put_symtab(t_symtab *symtab, const char *name) { - char buf[1024]; - - return enter_buf(symtab,trim_string(name,buf,1023)); + char buf[1024]; + + return enter_buf(symtab, trim_string(name, buf, 1023)); } void open_symtab(t_symtab *symtab) { - symtab->nr=0; - symtab->symbuf=NULL; + symtab->nr = 0; + symtab->symbuf = NULL; } void close_symtab(t_symtab *symtab) @@ -175,64 +212,74 @@ void close_symtab(t_symtab *symtab) void done_symtab(t_symtab *symtab) { - int i; - t_symbuf *symbuf,*freeptr; - - close_symtab(symtab); - symbuf=symtab->symbuf; - while (symbuf!=NULL) { - for (i=0; (i < symbuf->bufsize) && (i < symtab->nr); i++) - sfree(symbuf->buf[i]); - symtab->nr-=i; - sfree(symbuf->buf); - freeptr=symbuf; - symbuf=symbuf->next; - sfree(freeptr); - } - symtab->symbuf=NULL; - if (symtab->nr != 0) - gmx_incons("Freeing symbol table (symtab) structure"); + int i; + t_symbuf *symbuf, *freeptr; + + close_symtab(symtab); + symbuf = symtab->symbuf; + while (symbuf != NULL) + { + for (i = 0; (i < symbuf->bufsize) && (i < symtab->nr); i++) + { + sfree(symbuf->buf[i]); + } + symtab->nr -= i; + sfree(symbuf->buf); + freeptr = symbuf; + symbuf = symbuf->next; + sfree(freeptr); + } + symtab->symbuf = NULL; + if (symtab->nr != 0) + { + gmx_incons("Freeing symbol table (symtab) structure"); + } } void free_symtab(t_symtab *symtab) { - t_symbuf *symbuf,*freeptr; - - close_symtab(symtab); - symbuf=symtab->symbuf; - while (symbuf!=NULL) { - symtab->nr-=min(symbuf->bufsize,symtab->nr); - freeptr=symbuf; - symbuf=symbuf->next; - sfree(freeptr); - } - symtab->symbuf=NULL; - if (symtab->nr != 0) - gmx_incons("Freeing symbol table (symtab) structure"); + t_symbuf *symbuf, *freeptr; + + close_symtab(symtab); + symbuf = symtab->symbuf; + while (symbuf != NULL) + { + symtab->nr -= min(symbuf->bufsize, symtab->nr); + freeptr = symbuf; + symbuf = symbuf->next; + sfree(freeptr); + } + symtab->symbuf = NULL; + if (symtab->nr != 0) + { + gmx_incons("Freeing symbol table (symtab) structure"); + } } -void pr_symtab(FILE *fp,int indent,const char *title,t_symtab *symtab) +void pr_symtab(FILE *fp, int indent, const char *title, t_symtab *symtab) { - int i,j,nr; - t_symbuf *symbuf; - - if (available(fp,symtab,indent,title)) + int i, j, nr; + t_symbuf *symbuf; + + if (available(fp, symtab, indent, title)) { - indent=pr_title_n(fp,indent,title,symtab->nr); - i=0; - nr=symtab->nr; - symbuf=symtab->symbuf; - while (symbuf!=NULL) + indent = pr_title_n(fp, indent, title, symtab->nr); + i = 0; + nr = symtab->nr; + symbuf = symtab->symbuf; + while (symbuf != NULL) { - for (j=0; (j < symbuf->bufsize) && (j < nr); j++) + for (j = 0; (j < symbuf->bufsize) && (j < nr); j++) { - pr_indent(fp,indent); - (void) fprintf(fp,"%s[%d]=\"%s\"\n",title,i++,symbuf->buf[j]); + pr_indent(fp, indent); + (void) fprintf(fp, "%s[%d]=\"%s\"\n", title, i++, symbuf->buf[j]); } - nr-=j; - symbuf=symbuf->next; + nr -= j; + symbuf = symbuf->next; + } + if (nr != 0) + { + gmx_incons("Printing symbol table (symtab) structure"); } - if (nr != 0) - gmx_incons("Printing symbol table (symtab) structure"); } } diff --git a/src/gromacs/gmxlib/tcontrol.c b/src/gromacs/gmxlib/tcontrol.c index c807bddea3..7befe045ed 100644 --- a/src/gromacs/gmxlib/tcontrol.c +++ b/src/gromacs/gmxlib/tcontrol.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -44,23 +44,23 @@ #include "thread_mpi.h" #endif -/* The source code in this file should be thread-safe. +/* The source code in this file should be thread-safe. Please keep it that way. */ /* Globals for trajectory input */ typedef struct { - real t; - gmx_bool bSet; + real t; + gmx_bool bSet; } t_timecontrol; static t_timecontrol timecontrol[TNR] = { - { 0, FALSE }, - { 0, FALSE }, - { 0, FALSE } + { 0, FALSE }, + { 0, FALSE }, + { 0, FALSE } }; #ifdef GMX_THREAD_MPI -static tMPI_Thread_mutex_t tc_mutex=TMPI_THREAD_MUTEX_INITIALIZER; +static tMPI_Thread_mutex_t tc_mutex = TMPI_THREAD_MUTEX_INITIALIZER; #endif gmx_bool bTimeSet(int tcontrol) @@ -70,15 +70,15 @@ gmx_bool bTimeSet(int tcontrol) #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&tc_mutex); #endif - range_check(tcontrol,0,TNR); - ret=timecontrol[tcontrol].bSet; + range_check(tcontrol, 0, TNR); + ret = timecontrol[tcontrol].bSet; #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&tc_mutex); #endif return ret; } - + real rTimeValue(int tcontrol) { real ret; @@ -86,25 +86,23 @@ real rTimeValue(int tcontrol) #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&tc_mutex); #endif - range_check(tcontrol,0,TNR); - ret=timecontrol[tcontrol].t; + range_check(tcontrol, 0, TNR); + ret = timecontrol[tcontrol].t; #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&tc_mutex); #endif return ret; } - -void setTimeValue(int tcontrol,real value) + +void setTimeValue(int tcontrol, real value) { #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&tc_mutex); #endif - range_check(tcontrol,0,TNR); - timecontrol[tcontrol].t = value; + range_check(tcontrol, 0, TNR); + timecontrol[tcontrol].t = value; timecontrol[tcontrol].bSet = TRUE; #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&tc_mutex); #endif } - - diff --git a/src/gromacs/gmxlib/thread_mpi/alltoall.c b/src/gromacs/gmxlib/thread_mpi/alltoall.c index e350f72158..0ddf15dd07 100644 --- a/src/gromacs/gmxlib/thread_mpi/alltoall.c +++ b/src/gromacs/gmxlib/thread_mpi/alltoall.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -63,18 +63,18 @@ int tMPI_Alltoall(void* sendbuf, int sendcount, tMPI_Datatype sendtype, void* recvbuf, int recvcount, tMPI_Datatype recvtype, tMPI_Comm comm) { - int synct; - struct coll_env *cev; - int myrank; - int ret=TMPI_SUCCESS; - int i; - size_t sendsize=sendtype->size*sendcount; - size_t recvsize=recvtype->size*recvcount; - int n_remaining; - struct tmpi_thread *cur=tMPI_Get_current(); + int synct; + struct coll_env *cev; + int myrank; + int ret = TMPI_SUCCESS; + int i; + size_t sendsize = sendtype->size*sendcount; + size_t recvsize = recvtype->size*recvcount; + int n_remaining; + struct tmpi_thread *cur = tMPI_Get_current(); #ifdef TMPI_PROFILE - tMPI_Profile_count_start(cur); + tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Alltoall(%p, %d, %p, %p, %d, %p, %p)", @@ -91,30 +91,32 @@ int tMPI_Alltoall(void* sendbuf, int sendcount, tMPI_Datatype sendtype, return tMPI_Error(comm, TMPI_ERR_BUF); } - myrank=tMPI_Comm_seek_rank(comm, cur); + myrank = tMPI_Comm_seek_rank(comm, cur); /* we increase our counter, and determine which coll_env we get */ - cev=tMPI_Get_cev(comm, myrank, &synct); + cev = tMPI_Get_cev(comm, myrank, &synct); /* post our pointers */ /* we set up multiple posts, so no Post_multi */ - cev->met[myrank].tag=TMPI_ALLTOALL_TAG; - cev->met[myrank].datatype=sendtype; + cev->met[myrank].tag = TMPI_ALLTOALL_TAG; + cev->met[myrank].datatype = sendtype; tMPI_Atomic_set( &(cev->met[myrank].n_remaining), cev->N-1 ); - for(i=0;igrp.N;i++) - { - cev->met[myrank].bufsize[i]=sendsize; - cev->met[myrank].buf[i]=(char*)sendbuf+sendsize*i; - cev->met[myrank].read_data[i]=FALSE; + for (i = 0; i < comm->grp.N; i++) + { + cev->met[myrank].bufsize[i] = sendsize; + cev->met[myrank].buf[i] = (char*)sendbuf+sendsize*i; + cev->met[myrank].read_data[i] = FALSE; } tMPI_Atomic_memory_barrier_rel(); tMPI_Atomic_set(&(cev->met[myrank].current_sync), synct); /* post availability */ - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { - if (i!=myrank) + if (i != myrank) + { tMPI_Event_signal( &(cev->met[i].recv_ev) ); + } } /* we don't do the copy buffer thing here because it's pointless: @@ -124,32 +126,34 @@ int tMPI_Alltoall(void* sendbuf, int sendcount, tMPI_Datatype sendtype, /* do root transfer */ tMPI_Coll_root_xfer(comm, sendtype, recvtype, sendsize, recvsize, - (char*)sendbuf+sendsize*myrank, + (char*)sendbuf+sendsize*myrank, (char*)recvbuf+recvsize*myrank, &ret); - cev->met[myrank].read_data[myrank]=TRUE; + cev->met[myrank].read_data[myrank] = TRUE; /* and poll data availability */ - n_remaining=cev->N-1; - while(n_remaining>0) + n_remaining = cev->N-1; + while (n_remaining > 0) { #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_start(cur); #endif - tMPI_Event_wait( &(cev->met[myrank]).recv_ev ) ; + tMPI_Event_wait( &(cev->met[myrank]).recv_ev ); #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_stop(cur, TMPIWAIT_Coll_recv); #endif - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { - if ((! cev->met[myrank].read_data[i]) && - (tMPI_Atomic_get(&(cev->met[i].current_sync))==synct)) + if ((!cev->met[myrank].read_data[i]) && + (tMPI_Atomic_get(&(cev->met[i].current_sync)) == synct)) { - tMPI_Event_process( &(cev->met[myrank]).recv_ev, 1) ; + tMPI_Event_process( &(cev->met[myrank]).recv_ev, 1); tMPI_Mult_recv(comm, cev, i, myrank, TMPI_ALLTOALL_TAG, - recvtype, recvsize, (char*)recvbuf+recvsize*i, + recvtype, recvsize, (char*)recvbuf+recvsize*i, &ret); - if (ret!=TMPI_SUCCESS) + if (ret != TMPI_SUCCESS) + { return ret; - cev->met[myrank].read_data[i]=TRUE; + } + cev->met[myrank].read_data[i] = TRUE; n_remaining--; } } @@ -160,29 +164,29 @@ int tMPI_Alltoall(void* sendbuf, int sendcount, tMPI_Datatype sendtype, tMPI_Wait_for_others(cev, myrank); #ifdef TMPI_PROFILE - tMPI_Profile_count_stop(cur, TMPIFN_Alltoall); + tMPI_Profile_count_stop(cur, TMPIFN_Alltoall); #endif return ret; } int tMPI_Alltoallv(void* sendbuf, int *sendcounts, int *sdispls, - tMPI_Datatype sendtype, - void* recvbuf, int *recvcounts, int *rdispls, - tMPI_Datatype recvtype, - tMPI_Comm comm) + tMPI_Datatype sendtype, + void* recvbuf, int *recvcounts, int *rdispls, + tMPI_Datatype recvtype, + tMPI_Comm comm) { - int synct; - struct coll_env *cev; - int myrank; - int ret=TMPI_SUCCESS; - int i; - int n_remaining; - struct tmpi_thread *cur=tMPI_Get_current(); + int synct; + struct coll_env *cev; + int myrank; + int ret = TMPI_SUCCESS; + int i; + int n_remaining; + struct tmpi_thread *cur = tMPI_Get_current(); #ifdef TMPI_PROFILE - tMPI_Profile_count_start(cur); + tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Alltoallv(%p, %p, %p, %p, %p, %p, %p, %p, %p, %p)", @@ -199,30 +203,32 @@ int tMPI_Alltoallv(void* sendbuf, int *sendcounts, int *sdispls, return tMPI_Error(comm, TMPI_ERR_BUF); } - myrank=tMPI_Comm_seek_rank(comm, cur); + myrank = tMPI_Comm_seek_rank(comm, cur); /* we increase our counter, and determine which coll_env we get */ - cev=tMPI_Get_cev(comm, myrank, &synct); + cev = tMPI_Get_cev(comm, myrank, &synct); /* post our pointers */ /* we set up multiple posts, so no Post_multi */ - cev->met[myrank].tag=TMPI_ALLTOALLV_TAG; - cev->met[myrank].datatype=sendtype; + cev->met[myrank].tag = TMPI_ALLTOALLV_TAG; + cev->met[myrank].datatype = sendtype; tMPI_Atomic_set( &(cev->met[myrank].n_remaining), cev->N-1 ); - for(i=0;igrp.N;i++) - { - cev->met[myrank].bufsize[i]=sendtype->size*sendcounts[i]; - cev->met[myrank].buf[i]=(char*)sendbuf+sendtype->size*sdispls[i]; - cev->met[myrank].read_data[i]=FALSE; + for (i = 0; i < comm->grp.N; i++) + { + cev->met[myrank].bufsize[i] = sendtype->size*sendcounts[i]; + cev->met[myrank].buf[i] = (char*)sendbuf+sendtype->size*sdispls[i]; + cev->met[myrank].read_data[i] = FALSE; } tMPI_Atomic_memory_barrier_rel(); tMPI_Atomic_set(&(cev->met[myrank].current_sync), synct); /* post availability */ - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { - if (i!=myrank) + if (i != myrank) + { tMPI_Event_signal( &(cev->met[i].recv_ev) ); + } } /* we don't do the copy buffer thing here because it's pointless: @@ -231,35 +237,37 @@ int tMPI_Alltoallv(void* sendbuf, int *sendcounts, int *sdispls, /* do root transfer */ tMPI_Coll_root_xfer(comm, sendtype, recvtype, - sendtype->size*sendcounts[myrank], - recvtype->size*recvcounts[myrank], - (char*)sendbuf+sendtype->size*sdispls[myrank], + sendtype->size*sendcounts[myrank], + recvtype->size*recvcounts[myrank], + (char*)sendbuf+sendtype->size*sdispls[myrank], (char*)recvbuf+recvtype->size*rdispls[myrank], &ret); - cev->met[myrank].read_data[myrank]=TRUE; + cev->met[myrank].read_data[myrank] = TRUE; /* and poll data availability */ - n_remaining=cev->N-1; - while(n_remaining>0) + n_remaining = cev->N-1; + while (n_remaining > 0) { #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_start(cur); #endif - tMPI_Event_wait( &(cev->met[myrank]).recv_ev ) ; + tMPI_Event_wait( &(cev->met[myrank]).recv_ev ); #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_stop(cur, TMPIWAIT_Coll_recv); #endif - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { - if ((! cev->met[myrank].read_data[i]) && - (tMPI_Atomic_get(&(cev->met[i].current_sync))==synct) ) + if ((!cev->met[myrank].read_data[i]) && + (tMPI_Atomic_get(&(cev->met[i].current_sync)) == synct) ) { - tMPI_Event_process( &(cev->met[myrank]).recv_ev, 1) ; + tMPI_Event_process( &(cev->met[myrank]).recv_ev, 1); tMPI_Mult_recv(comm, cev, i, myrank, TMPI_ALLTOALLV_TAG, recvtype, recvtype->size*recvcounts[i], (char*)recvbuf+recvtype->size*rdispls[i], &ret); - if (ret!=TMPI_SUCCESS) + if (ret != TMPI_SUCCESS) + { return ret; - cev->met[myrank].read_data[i]=TRUE; + } + cev->met[myrank].read_data[i] = TRUE; n_remaining--; } } @@ -269,9 +277,7 @@ int tMPI_Alltoallv(void* sendbuf, int *sendcounts, int *sdispls, tMPI_Wait_for_others(cev, myrank); #ifdef TMPI_PROFILE - tMPI_Profile_count_stop(cur, TMPIFN_Alltoallv); + tMPI_Profile_count_stop(cur, TMPIFN_Alltoallv); #endif return ret; } - - diff --git a/src/gromacs/gmxlib/thread_mpi/barrier.c b/src/gromacs/gmxlib/thread_mpi/barrier.c index 4940716edc..42ef5213d0 100644 --- a/src/gromacs/gmxlib/thread_mpi/barrier.c +++ b/src/gromacs/gmxlib/thread_mpi/barrier.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -60,8 +60,8 @@ files. void tMPI_Barrier_init(tMPI_Barrier_t *barrier, int count) { barrier->threshold = count; - tMPI_Atomic_set(&(barrier->cycle), 0); - tMPI_Atomic_set(&(barrier->count),count); + tMPI_Atomic_set(&(barrier->cycle), 0); + tMPI_Atomic_set(&(barrier->count), count); TMPI_YIELD_WAIT_DATA_INIT(barrier); } @@ -71,10 +71,10 @@ int tMPI_Barrier_wait(tMPI_Barrier_t *barrier) int cycle; int status; - /* We don't need to lock or use atomic ops here, since the cycle index + /* We don't need to lock or use atomic ops here, since the cycle index * cannot change until after the last thread has performed the check - * further down. Further, they cannot reach this point in the next - * barrier iteration until all of them have been released, and that + * further down. Further, they cannot reach this point in the next + * barrier iteration until all of them have been released, and that * happens after the cycle value has been updated. * * No synchronization == fast synchronization. @@ -84,11 +84,11 @@ int tMPI_Barrier_wait(tMPI_Barrier_t *barrier) /* Decrement the count atomically and check if it is zero. * This will only be true for the last thread calling us. */ - if( tMPI_Atomic_add_return( &(barrier->count), -1 ) <= 0) + if (tMPI_Atomic_add_return( &(barrier->count), -1 ) <= 0) { tMPI_Atomic_memory_barrier(); tMPI_Atomic_set(&(barrier->count), barrier->threshold); - tMPI_Atomic_add_return(&(barrier->cycle), 1) ; + tMPI_Atomic_add_return(&(barrier->cycle), 1); status = -1; } @@ -104,12 +104,10 @@ int tMPI_Barrier_wait(tMPI_Barrier_t *barrier) /*tMPI_Atomic_memory_barrier();*/ TMPI_YIELD_WAIT(barrier); } - while( tMPI_Atomic_get( &(barrier->cycle) ) == cycle ); + while (tMPI_Atomic_get( &(barrier->cycle) ) == cycle); tMPI_Atomic_memory_barrier(); status = 0; } return status; } - - diff --git a/src/gromacs/gmxlib/thread_mpi/bcast.c b/src/gromacs/gmxlib/thread_mpi/bcast.c index 2ec09096d5..bd8acd3a67 100644 --- a/src/gromacs/gmxlib/thread_mpi/bcast.c +++ b/src/gromacs/gmxlib/thread_mpi/bcast.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" #endif @@ -61,17 +61,17 @@ files. int tMPI_Bcast(void* buffer, int count, tMPI_Datatype datatype, int root, tMPI_Comm comm) { - int synct; - struct coll_env *cev; - int myrank; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); + int synct; + struct coll_env *cev; + int myrank; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); #ifdef TMPI_PROFILE - tMPI_Profile_count_start(cur); + tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Bcast(%p, %d, %p, %d, %p)", buffer, count, datatype, + tMPI_Trace_print("tMPI_Bcast(%p, %d, %p, %d, %p)", buffer, count, datatype, root, comm); #endif @@ -79,34 +79,29 @@ int tMPI_Bcast(void* buffer, int count, tMPI_Datatype datatype, int root, { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - myrank=tMPI_Comm_seek_rank(comm, cur); + myrank = tMPI_Comm_seek_rank(comm, cur); /* we increase our counter, and determine which coll_env we get */ - cev=tMPI_Get_cev(comm, myrank, &synct); + cev = tMPI_Get_cev(comm, myrank, &synct); - if (myrank==root) + if (myrank == root) { /* first set up the data */ - tMPI_Post_multi(cev, myrank, 0, TMPI_BCAST_TAG, datatype, + tMPI_Post_multi(cev, myrank, 0, TMPI_BCAST_TAG, datatype, count*datatype->size, buffer, comm->grp.N-1, synct, -1); /* and wait until everybody is done copying */ tMPI_Wait_for_others(cev, myrank); } else { - size_t bufsize=count*datatype->size; + size_t bufsize = count*datatype->size; /* wait until root becomes available */ tMPI_Wait_for_data(cur, cev, myrank); - tMPI_Mult_recv(comm, cev, root, 0, TMPI_BCAST_TAG, datatype, bufsize, + tMPI_Mult_recv(comm, cev, root, 0, TMPI_BCAST_TAG, datatype, bufsize, buffer, &ret); } #ifdef TMPI_PROFILE - tMPI_Profile_count_stop(cur, TMPIFN_Bcast); + tMPI_Profile_count_stop(cur, TMPIFN_Bcast); #endif return ret; } - - - - - diff --git a/src/gromacs/gmxlib/thread_mpi/collective.c b/src/gromacs/gmxlib/thread_mpi/collective.c index 3cbf07e6aa..069db3f1d8 100644 --- a/src/gromacs/gmxlib/thread_mpi/collective.c +++ b/src/gromacs/gmxlib/thread_mpi/collective.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -65,8 +65,8 @@ files. /* initialize a copy buffer */ void tMPI_Copy_buffer_init(struct copy_buffer *cb, size_t size) { - cb->buf=tMPI_Malloc(size); - cb->size=size; + cb->buf = tMPI_Malloc(size); + cb->size = size; } /* destroy a copy buffer */ @@ -80,18 +80,22 @@ void tMPI_Copy_buffer_list_init(struct copy_buffer_list *cbl, int Nbufs, { int i; - cbl->size=size; - cbl->cb_alloc=(struct copy_buffer*) - tMPI_Malloc(sizeof(struct copy_buffer)*Nbufs); - cbl->cb=cbl->cb_alloc; /* the first one */ + cbl->size = size; + cbl->cb_alloc = (struct copy_buffer*) + tMPI_Malloc(sizeof(struct copy_buffer)*Nbufs); + cbl->cb = cbl->cb_alloc; /* the first one */ cbl->Nbufs = Nbufs; - for(i=0;icb_alloc[i]), size ); - if (icb_alloc[i].next=&(cbl->cb_alloc[i+1]); + if (i < Nbufs-1) + { + cbl->cb_alloc[i].next = &(cbl->cb_alloc[i+1]); + } else - cbl->cb_alloc[i].next=NULL; + { + cbl->cb_alloc[i].next = NULL; + } } } @@ -99,7 +103,7 @@ void tMPI_Copy_buffer_list_destroy(struct copy_buffer_list *cbl) { int i; - for(i=0;iNbufs;i++) + for (i = 0; i < cbl->Nbufs; i++) { tMPI_Copy_buffer_destroy( &(cbl->cb_alloc[i]) ); } @@ -108,22 +112,22 @@ void tMPI_Copy_buffer_list_destroy(struct copy_buffer_list *cbl) struct copy_buffer *tMPI_Copy_buffer_list_get(struct copy_buffer_list *cbl) { - struct copy_buffer *ret=cbl->cb; + struct copy_buffer *ret = cbl->cb; if (!ret) { - fprintf(stderr,"out of copy buffers!!"); + fprintf(stderr, "out of copy buffers!!"); exit(1); } - cbl->cb=ret->next; + cbl->cb = ret->next; return ret; } -void tMPI_Copy_buffer_list_return(struct copy_buffer_list *cbl, - struct copy_buffer *cb) +void tMPI_Copy_buffer_list_return(struct copy_buffer_list *cbl, + struct copy_buffer *cb) { - cb->next=cbl->cb; - cbl->cb=cb; + cb->next = cbl->cb; + cbl->cb = cb; } #endif @@ -138,13 +142,13 @@ void tMPI_Coll_envt_init(struct coll_env_thread *met, int N) { tMPI_Atomic_set(&(met->current_sync), 0); tMPI_Atomic_set(&(met->n_remaining), 0); - met->buf=(void**)tMPI_Malloc(sizeof(void*)*N); - met->bufsize=(size_t*)tMPI_Malloc(sizeof(size_t)*N); - met->read_data=(tmpi_bool*)tMPI_Malloc(sizeof(tmpi_bool)*N); + met->buf = (void**)tMPI_Malloc(sizeof(void*)*N); + met->bufsize = (size_t*)tMPI_Malloc(sizeof(size_t)*N); + met->read_data = (tmpi_bool*)tMPI_Malloc(sizeof(tmpi_bool)*N); #ifdef USE_COLLECTIVE_COPY_BUFFER - met->cpbuf=(tMPI_Atomic_ptr_t*)tMPI_Malloc(sizeof(tMPI_Atomic_ptr_t)*N); - met->cb=NULL; - met->using_cb=FALSE; + met->cpbuf = (tMPI_Atomic_ptr_t*)tMPI_Malloc(sizeof(tMPI_Atomic_ptr_t)*N); + met->cb = NULL; + met->using_cb = FALSE; #endif tMPI_Event_init( &(met->send_ev) ); tMPI_Event_init( &(met->recv_ev) ); @@ -166,12 +170,12 @@ void tMPI_Coll_env_init(struct coll_env *cev, int N) { int i; - cev->met=(struct coll_env_thread*)tMPI_Malloc( - sizeof(struct coll_env_thread)*N); - cev->N=N; + cev->met = (struct coll_env_thread*)tMPI_Malloc( + sizeof(struct coll_env_thread)*N); + cev->N = N; tMPI_Atomic_set(&(cev->coll.current_sync), 0); tMPI_Atomic_set(&(cev->coll.n_remaining), 0); - for(i=0;imet[i]), N); } @@ -180,7 +184,7 @@ void tMPI_Coll_env_init(struct coll_env *cev, int N) void tMPI_Coll_env_destroy(struct coll_env *cev) { int i; - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { tMPI_Coll_envt_destroy(&(cev->met[i])); } @@ -192,12 +196,12 @@ void tMPI_Coll_sync_init(struct coll_sync *csync, int N) { int i; - csync->synct=0; - csync->syncs=0; - csync->N=N; + csync->synct = 0; + csync->syncs = 0; + csync->N = N; - csync->events=(tMPI_Event*)tMPI_Malloc(sizeof(tMPI_Event)*N); - for(i=0;ievents = (tMPI_Event*)tMPI_Malloc(sizeof(tMPI_Event)*N); + for (i = 0; i < N; i++) { tMPI_Event_init( &(csync->events[i]) ); } @@ -207,10 +211,10 @@ void tMPI_Coll_sync_destroy(struct coll_sync *csync) { int i; - csync->synct=0; - csync->syncs=0; + csync->synct = 0; + csync->syncs = 0; - for(i=0;iN;i++) + for (i = 0; i < csync->N; i++) { tMPI_Event_destroy( &(csync->events[i]) ); } @@ -225,33 +229,33 @@ void tMPI_Coll_sync_destroy(struct coll_sync *csync) /* get a pointer the next coll_env once it's ready. */ struct coll_env *tMPI_Get_cev(tMPI_Comm comm, int myrank, int *counter) { - struct coll_sync *csync=&(comm->csync[myrank]); - struct coll_env *cev; + struct coll_sync *csync = &(comm->csync[myrank]); + struct coll_env *cev; #ifdef USE_COLLECTIVE_COPY_BUFFER - int N; + int N; #endif /* we increase our counter, and determine which coll_env we get */ csync->synct++; - *counter=csync->synct; - cev=&(comm->cev[csync->synct % N_COLL_ENV]); + *counter = csync->synct; + cev = &(comm->cev[csync->synct % N_COLL_ENV]); #ifdef USE_COLLECTIVE_COPY_BUFFER if (cev->met[myrank].using_cb) { - N=tMPI_Event_wait( &(cev->met[myrank].send_ev)); + N = tMPI_Event_wait( &(cev->met[myrank].send_ev)); tMPI_Event_process( &(cev->met[myrank].send_ev), 1); } #endif #ifdef USE_COLLECTIVE_COPY_BUFFER /* clean up old copy_buffer pointers */ - if (cev->met[myrank].cb) + if (cev->met[myrank].cb) { tMPI_Copy_buffer_list_return(&(tMPI_Get_current()->cbl_multi), cev->met[myrank].cb); - cev->met[myrank].cb=NULL; - cev->met[myrank].using_cb=FALSE; + cev->met[myrank].cb = NULL; + cev->met[myrank].using_cb = FALSE; } #endif @@ -263,51 +267,51 @@ struct coll_env *tMPI_Get_cev(tMPI_Comm comm, int myrank, int *counter) void tMPI_Mult_recv(tMPI_Comm comm, struct coll_env *cev, int rank, - int index, int expected_tag, tMPI_Datatype recvtype, + int index, int expected_tag, tMPI_Datatype recvtype, size_t recvsize, void *recvbuf, int *ret) { - size_t sendsize=cev->met[rank].bufsize[index]; + size_t sendsize = cev->met[rank].bufsize[index]; /* check tags, types */ - if ((cev->met[rank].datatype != recvtype ) || + if ((cev->met[rank].datatype != recvtype ) || (cev->met[rank].tag != expected_tag)) { - *ret=tMPI_Error(comm, TMPI_ERR_MULTI_MISMATCH); + *ret = tMPI_Error(comm, TMPI_ERR_MULTI_MISMATCH); } - + if (sendsize) /* we allow NULL ptrs if there's nothing to xmit */ { - void *srcbuf; + void *srcbuf; #ifdef USE_COLLECTIVE_COPY_BUFFER - tmpi_bool decrease_ctr=FALSE; + tmpi_bool decrease_ctr = FALSE; #endif - if ( sendsize > recvsize ) + if (sendsize > recvsize) { - *ret=tMPI_Error(comm, TMPI_ERR_XFER_BUFSIZE); + *ret = tMPI_Error(comm, TMPI_ERR_XFER_BUFSIZE); return; } - if ( cev->met[rank].buf == recvbuf ) + if (cev->met[rank].buf == recvbuf) { - *ret=tMPI_Error(TMPI_COMM_WORLD,TMPI_ERR_XFER_BUF_OVERLAP); + *ret = tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_XFER_BUF_OVERLAP); return; } /* get source buffer */ #ifdef USE_COLLECTIVE_COPY_BUFFER - if ( !(cev->met[rank].using_cb)) + if (!(cev->met[rank].using_cb)) #endif { - srcbuf=cev->met[rank].buf[index]; + srcbuf = cev->met[rank].buf[index]; } #ifdef USE_COLLECTIVE_COPY_BUFFER else { - srcbuf=tMPI_Atomic_ptr_get(&(cev->met[rank].cpbuf[index])); + srcbuf = tMPI_Atomic_ptr_get(&(cev->met[rank].cpbuf[index])); tMPI_Atomic_memory_barrier_acq(); - if(!srcbuf) - { /* there was (as of yet) no copied buffer */ + if (!srcbuf) + { /* there was (as of yet) no copied buffer */ void *try_again_srcbuf; /* we need to try checking the pointer again after we increase the read counter, signaling that one more thread @@ -315,31 +319,33 @@ void tMPI_Mult_recv(tMPI_Comm comm, struct coll_env *cev, int rank, tMPI_Atomic_add_return(&(cev->met[rank].buf_readcount), 1); /* a full memory barrier */ tMPI_Atomic_memory_barrier(); - try_again_srcbuf=tMPI_Atomic_ptr_get( - &(cev->met[rank].cpbuf[index])); + try_again_srcbuf = tMPI_Atomic_ptr_get( + &(cev->met[rank].cpbuf[index])); if (!try_again_srcbuf) { /* apparently the copied buffer is not ready yet. We just use the real source buffer. We have already indicated we're reading from the regular buf. */ - srcbuf=cev->met[rank].buf[index]; - decrease_ctr=TRUE; + srcbuf = cev->met[rank].buf[index]; + decrease_ctr = TRUE; } else { - /* We tried again, and this time there was a copied buffer. + /* We tried again, and this time there was a copied buffer. We use that, and indicate that we're not reading from the regular buf. This case should be pretty rare. */ - tMPI_Atomic_add_return(&(cev->met[rank].buf_readcount),-1); + tMPI_Atomic_add_return(&(cev->met[rank].buf_readcount), -1); tMPI_Atomic_memory_barrier_acq(); - srcbuf=try_again_srcbuf; + srcbuf = try_again_srcbuf; } } #ifdef TMPI_PROFILE if (srcbuf) + { tMPI_Profile_count_buffered_coll_xfer(tMPI_Get_current()); + } #endif } #endif @@ -359,10 +365,10 @@ void tMPI_Mult_recv(tMPI_Comm comm, struct coll_env *cev, int rank, #endif } /* signal one thread ready */ - { + { int reta; tMPI_Atomic_memory_barrier_rel(); - reta=tMPI_Atomic_add_return( &(cev->met[rank].n_remaining), -1); + reta = tMPI_Atomic_add_return( &(cev->met[rank].n_remaining), -1); if (reta <= 0) { tMPI_Event_signal( &(cev->met[rank].send_ev) ); @@ -370,41 +376,41 @@ void tMPI_Mult_recv(tMPI_Comm comm, struct coll_env *cev, int rank, } } -void tMPI_Coll_root_xfer(tMPI_Comm comm, tMPI_Datatype sendtype, - tMPI_Datatype recvtype, - size_t sendsize, size_t recvsize, +void tMPI_Coll_root_xfer(tMPI_Comm comm, tMPI_Datatype sendtype, + tMPI_Datatype recvtype, + size_t sendsize, size_t recvsize, void* sendbuf, void* recvbuf, int *ret) { /* do root transfer */ if (recvsize < sendsize) { - *ret=tMPI_Error(comm, TMPI_ERR_XFER_BUFSIZE); + *ret = tMPI_Error(comm, TMPI_ERR_XFER_BUFSIZE); return; } if (recvtype != sendtype) { - *ret=tMPI_Error(comm, TMPI_ERR_MULTI_MISMATCH); + *ret = tMPI_Error(comm, TMPI_ERR_MULTI_MISMATCH); return; } - if ( sendbuf == recvbuf ) + if (sendbuf == recvbuf) { - *ret=tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_XFER_BUF_OVERLAP); + *ret = tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_XFER_BUF_OVERLAP); return; } memcpy(recvbuf, sendbuf, sendsize); } -void tMPI_Post_multi(struct coll_env *cev, int myrank, int index, - int tag, tMPI_Datatype datatype, size_t bufsize, +void tMPI_Post_multi(struct coll_env *cev, int myrank, int index, + int tag, tMPI_Datatype datatype, size_t bufsize, void *buf, int n_remaining, int synct, int dest) { int i; #ifdef USE_COLLECTIVE_COPY_BUFFER /* decide based on the number of waiting threads */ - tmpi_bool using_cb=(bufsize < (size_t)(n_remaining*COPY_BUFFER_SIZE)); + tmpi_bool using_cb = (bufsize < (size_t)(n_remaining*COPY_BUFFER_SIZE)); - cev->met[myrank].using_cb=using_cb; + cev->met[myrank].using_cb = using_cb; if (using_cb) { /* we set it to NULL initially */ @@ -414,21 +420,23 @@ void tMPI_Post_multi(struct coll_env *cev, int myrank, int index, tMPI_Atomic_set(&(cev->met[myrank].buf_readcount), 0); } #endif - cev->met[myrank].tag=tag; - cev->met[myrank].datatype=datatype; - cev->met[myrank].buf[index]=buf; - cev->met[myrank].bufsize[index]=bufsize; + cev->met[myrank].tag = tag; + cev->met[myrank].datatype = datatype; + cev->met[myrank].buf[index] = buf; + cev->met[myrank].bufsize[index] = bufsize; tMPI_Atomic_set(&(cev->met[myrank].n_remaining), n_remaining); tMPI_Atomic_memory_barrier_rel(); tMPI_Atomic_set(&(cev->met[myrank].current_sync), synct); /* publish availability. */ - if (dest<0) + if (dest < 0) { - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { if (i != myrank) + { tMPI_Event_signal( &(cev->met[i].recv_ev) ); + } } } else @@ -437,13 +445,13 @@ void tMPI_Post_multi(struct coll_env *cev, int myrank, int index, } #ifdef USE_COLLECTIVE_COPY_BUFFER - /* becase we've published availability, we can start copying -- + /* becase we've published availability, we can start copying -- possibly in parallel with the receiver */ if (using_cb) { - struct tmpi_thread *cur=tMPI_Get_current(); - /* copy the buffer locally. First allocate */ - cev->met[myrank].cb=tMPI_Copy_buffer_list_get( &(cur->cbl_multi) ); + struct tmpi_thread *cur = tMPI_Get_current(); + /* copy the buffer locally. First allocate */ + cev->met[myrank].cb = tMPI_Copy_buffer_list_get( &(cur->cbl_multi) ); if (cev->met[myrank].cb->size < bufsize) { fprintf(stderr, "ERROR: cb size too small\n"); @@ -455,7 +463,7 @@ void tMPI_Post_multi(struct coll_env *cev, int myrank, int index, /* post the new buf */ tMPI_Atomic_memory_barrier_rel(); /*cev->met[myrank].cpbuf[index]=cev->met[myrank].cb->buf;*/ - tMPI_Atomic_ptr_set(&(cev->met[myrank].cpbuf[index]), + tMPI_Atomic_ptr_set(&(cev->met[myrank].cpbuf[index]), cev->met[myrank].cb->buf); } #endif @@ -464,13 +472,13 @@ void tMPI_Post_multi(struct coll_env *cev, int myrank, int index, void tMPI_Wait_for_others(struct coll_env *cev, int myrank) { -#if defined(TMPI_PROFILE) - struct tmpi_thread *cur=tMPI_Get_current(); +#if defined(TMPI_PROFILE) + struct tmpi_thread *cur = tMPI_Get_current(); tMPI_Profile_wait_start(cur); #endif #ifdef USE_COLLECTIVE_COPY_BUFFER - if (! (cev->met[myrank].using_cb) ) + if (!(cev->met[myrank].using_cb) ) #endif { /* wait until everybody else is done copying the buffer */ @@ -480,41 +488,41 @@ void tMPI_Wait_for_others(struct coll_env *cev, int myrank) #ifdef USE_COLLECTIVE_COPY_BUFFER else { - /* wait until everybody else is done copying the original buffer. + /* wait until everybody else is done copying the original buffer. We use atomic add-return because we want to be sure of coherency. - This wait is bound to be very short (otherwise it wouldn't + This wait is bound to be very short (otherwise it wouldn't be double-buffering) so we always spin here. */ /*tMPI_Atomic_memory_barrier_rel();*/ #if 0 while (!tMPI_Atomic_cas( &(cev->met[rank].buf_readcount), 0, - -100000)) + -100000)) #endif #if 0 - while (tMPI_Atomic_add_return( &(cev->met[myrank].buf_readcount), 0) + while (tMPI_Atomic_add_return( &(cev->met[myrank].buf_readcount), 0) != 0) #endif #if 1 - while (tMPI_Atomic_get( &(cev->met[rank].buf_readcount) )>0) + while (tMPI_Atomic_get( &(cev->met[rank].buf_readcount) ) > 0) #endif { } tMPI_Atomic_memory_barrier_acq(); } #endif -#if defined(TMPI_PROFILE) +#if defined(TMPI_PROFILE) tMPI_Profile_wait_stop(cur, TMPIWAIT_Coll_send); #endif } -void tMPI_Wait_for_data(struct tmpi_thread *cur, struct coll_env *cev, +void tMPI_Wait_for_data(struct tmpi_thread *cur, struct coll_env *cev, int myrank) { -#if defined(TMPI_PROFILE) +#if defined(TMPI_PROFILE) tMPI_Profile_wait_start(cur); #endif tMPI_Event_wait( &(cev->met[myrank].recv_ev)); tMPI_Event_process( &(cev->met[myrank].recv_ev), 1); -#if defined(TMPI_PROFILE) +#if defined(TMPI_PROFILE) tMPI_Profile_wait_stop(cur, TMPIWAIT_Coll_recv); #endif } @@ -524,10 +532,10 @@ void tMPI_Wait_for_data(struct tmpi_thread *cur, struct coll_env *cev, -int tMPI_Barrier(tMPI_Comm comm) +int tMPI_Barrier(tMPI_Comm comm) { #ifdef TMPI_PROFILE - struct tmpi_thread *cur=tMPI_Get_current(); + struct tmpi_thread *cur = tMPI_Get_current(); tMPI_Profile_count_start(cur); #endif @@ -540,14 +548,14 @@ int tMPI_Barrier(tMPI_Comm comm) return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - if (comm->grp.N>1) + if (comm->grp.N > 1) { -#if defined(TMPI_PROFILE) +#if defined(TMPI_PROFILE) tMPI_Profile_wait_start(cur); #endif tMPI_Barrier_wait( &(comm->barrier) ); -#if defined(TMPI_PROFILE) +#if defined(TMPI_PROFILE) tMPI_Profile_wait_stop(cur, TMPIWAIT_Barrier); #endif } @@ -557,7 +565,3 @@ int tMPI_Barrier(tMPI_Comm comm) #endif return TMPI_SUCCESS; } - - - - diff --git a/src/gromacs/gmxlib/thread_mpi/collective.h b/src/gromacs/gmxlib/thread_mpi/collective.h index 337cdafa8b..1aadef84bc 100644 --- a/src/gromacs/gmxlib/thread_mpi/collective.h +++ b/src/gromacs/gmxlib/thread_mpi/collective.h @@ -1,45 +1,45 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ /* get a pointer the next coll_env once it's ready */ struct coll_env *tMPI_Get_cev(tMPI_Comm comm, int myrank, int *synct); -/* post the availability of data in a cev. +/* post the availability of data in a cev. cev = the collective comm environment myrank = my rank index = the buffer index @@ -48,12 +48,12 @@ struct coll_env *tMPI_Get_cev(tMPI_Comm comm, int myrank, int *synct); busize = the buffer size buf = the buffer to xfer n_remaining = the number of remaining threads that need to transfer - synct = the multicast sync number + synct = the multicast sync number dest = -1 for all theads, or a specific rank number. - */ -void tMPI_Post_multi(struct coll_env *cev, int myrank, int index, - int tag, tMPI_Datatype datatype, - size_t bufsize, void *buf, int n_remaining, + */ +void tMPI_Post_multi(struct coll_env *cev, int myrank, int index, + int tag, tMPI_Datatype datatype, + size_t bufsize, void *buf, int n_remaining, int synct, int dest); /* transfer data from cev->met[rank] to recvbuf */ @@ -62,17 +62,14 @@ void tMPI_Mult_recv(tMPI_Comm comm, struct coll_env *cev, int rank, size_t recvsize, void *recvbuf, int *ret); /* do a root transfer (from root send buffer to root recv buffer) */ -void tMPI_Coll_root_xfer(tMPI_Comm comm, - tMPI_Datatype sendtype, tMPI_Datatype recvtype, - size_t sendsize, size_t recvsize, +void tMPI_Coll_root_xfer(tMPI_Comm comm, + tMPI_Datatype sendtype, tMPI_Datatype recvtype, + size_t sendsize, size_t recvsize, void* sendbuf, void* recvbuf, int *ret); /* wait for other processes to copy data from my cev */ void tMPI_Wait_for_others(struct coll_env *cev, int myrank); /* wait for data to become available from a specific rank */ -void tMPI_Wait_for_data(struct tmpi_thread *cur, struct coll_env *cev, +void tMPI_Wait_for_data(struct tmpi_thread *cur, struct coll_env *cev, int myrank); /*int rank, int myrank, int synct);*/ - - - diff --git a/src/gromacs/gmxlib/thread_mpi/comm.c b/src/gromacs/gmxlib/thread_mpi/comm.c index c2e0046a86..98c84e9758 100644 --- a/src/gromacs/gmxlib/thread_mpi/comm.c +++ b/src/gromacs/gmxlib/thread_mpi/comm.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -75,7 +75,9 @@ int tMPI_Comm_N(tMPI_Comm comm) tMPI_Trace_print("tMPI_Comm_N(%p)", comm); #endif if (!comm) + { return 0; + } return comm->grp.N; } @@ -98,48 +100,48 @@ int tMPI_Comm_rank(tMPI_Comm comm, int *rank) int tMPI_Comm_compare(tMPI_Comm comm1, tMPI_Comm comm2, int *result) { - int i,j; + int i, j; #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Comm_compare(%p, %p, %p)", comm1, comm2, result); #endif if (comm1 == comm2) { - *result=TMPI_IDENT; + *result = TMPI_IDENT; return TMPI_SUCCESS; } if ( (!comm1) || (!comm2) ) { - *result=TMPI_UNEQUAL; + *result = TMPI_UNEQUAL; return TMPI_SUCCESS; } if (comm1->grp.N != comm2->grp.N) { - *result=TMPI_UNEQUAL; + *result = TMPI_UNEQUAL; return TMPI_SUCCESS; } - *result=TMPI_CONGRUENT; + *result = TMPI_CONGRUENT; /* we assume that there are two identical comm members within a comm */ - for(i=0;igrp.N;i++) + for (i = 0; i < comm1->grp.N; i++) { if (comm1->grp.peers[i] != comm2->grp.peers[i]) { - tmpi_bool found=FALSE; + tmpi_bool found = FALSE; - *result=TMPI_SIMILAR; - for(j=0;jgrp.N;j++) + *result = TMPI_SIMILAR; + for (j = 0; j < comm2->grp.N; j++) { if (comm1->grp.peers[i] == comm2->grp.peers[j]) { - found=TRUE; + found = TRUE; break; } } if (!found) { - *result=TMPI_UNEQUAL; + *result = TMPI_UNEQUAL; return TMPI_SUCCESS; } } @@ -151,21 +153,21 @@ int tMPI_Comm_compare(tMPI_Comm comm1, tMPI_Comm comm2, int *result) tMPI_Comm tMPI_Comm_alloc(tMPI_Comm parent, int N) { struct tmpi_comm_ *ret; - int i; + int i; - ret=(struct tmpi_comm_*)tMPI_Malloc(sizeof(struct tmpi_comm_)); - ret->grp.peers=(struct tmpi_thread**)tMPI_Malloc( - sizeof(struct tmpi_thread*)*Nthreads); - ret->grp.N=N; + ret = (struct tmpi_comm_*)tMPI_Malloc(sizeof(struct tmpi_comm_)); + ret->grp.peers = (struct tmpi_thread**)tMPI_Malloc( + sizeof(struct tmpi_thread*)*Nthreads); + ret->grp.N = N; tMPI_Thread_mutex_init( &(ret->comm_create_lock) ); tMPI_Thread_cond_init( &(ret->comm_create_prep) ); tMPI_Thread_cond_init( &(ret->comm_create_finish) ); - ret->split = NULL; + ret->split = NULL; ret->new_comm = NULL; /* we have no topology to start out with */ - ret->cart=NULL; + ret->cart = NULL; /*ret->graph=NULL;*/ /* we start counting at 0 */ @@ -177,79 +179,84 @@ tMPI_Comm tMPI_Comm_alloc(tMPI_Comm parent, int N) /* the reduce barriers */ { /* First calculate the number of reduce barriers */ - int Niter=0; /* the iteration number */ - int Nred=N; /* the number of reduce barriers for this iteration */ - while(Nred>1) { - /* Nred is now Nred/2 + a rest term because solitary + int Niter = 0; /* the iteration number */ + int Nred = N; /* the number of reduce barriers for this iteration */ + while (Nred > 1) + { + /* Nred is now Nred/2 + a rest term because solitary process at the end of the list must still be accounter for */ - Nred = Nred/2 + Nred%2; - Niter+=1; - } + Nred = Nred/2 + Nred%2; + Niter += 1; + } - ret->N_reduce_iter=Niter; + ret->N_reduce_iter = Niter; /* allocate the list */ - ret->reduce_barrier=(tMPI_Barrier_t**) - tMPI_Malloc(sizeof(tMPI_Barrier_t*)*(Niter+1)); - ret->N_reduce=(int*)tMPI_Malloc(sizeof(int)*(Niter+1)); + ret->reduce_barrier = (tMPI_Barrier_t**) + tMPI_Malloc(sizeof(tMPI_Barrier_t*)*(Niter+1)); + ret->N_reduce = (int*)tMPI_Malloc(sizeof(int)*(Niter+1)); /* we re-set Nred to N */ - Nred=N; - for(i=0;iN_reduce[i] = Nred; /* allocate the sub-list */ - ret->reduce_barrier[i]=(tMPI_Barrier_t*) - tMPI_Malloc(sizeof(tMPI_Barrier_t)*(Nred)); - for(j=0;jreduce_barrier[i] = (tMPI_Barrier_t*) + tMPI_Malloc(sizeof(tMPI_Barrier_t)*(Nred)); + for (j = 0; j < Nred; j++) { - tMPI_Barrier_init(&(ret->reduce_barrier[i][j]),2); + tMPI_Barrier_init(&(ret->reduce_barrier[i][j]), 2); } } } /* the reduce buffers */ - ret->reduce_sendbuf=(tMPI_Atomic_ptr_t*) - tMPI_Malloc(sizeof(tMPI_Atomic_ptr_t)*Nthreads); - ret->reduce_recvbuf=(tMPI_Atomic_ptr_t*) - tMPI_Malloc(sizeof(tMPI_Atomic_ptr_t)*Nthreads); + ret->reduce_sendbuf = (tMPI_Atomic_ptr_t*) + tMPI_Malloc(sizeof(tMPI_Atomic_ptr_t)*Nthreads); + ret->reduce_recvbuf = (tMPI_Atomic_ptr_t*) + tMPI_Malloc(sizeof(tMPI_Atomic_ptr_t)*Nthreads); if (parent) { - ret->erh=parent->erh; + ret->erh = parent->erh; } else { - ret->erh=TMPI_ERRORS_ARE_FATAL; + ret->erh = TMPI_ERRORS_ARE_FATAL; } /* coll_env objects */ - ret->cev=(struct coll_env*)tMPI_Malloc(sizeof(struct coll_env)*N_COLL_ENV); - for(i=0;icev = (struct coll_env*)tMPI_Malloc(sizeof(struct coll_env)*N_COLL_ENV); + for (i = 0; i < N_COLL_ENV; i++) + { tMPI_Coll_env_init( &(ret->cev[i]), N); + } /* multi_sync objects */ - ret->csync=(struct coll_sync*)tMPI_Malloc(sizeof(struct coll_sync)*N); - for(i=0;icsync = (struct coll_sync*)tMPI_Malloc(sizeof(struct coll_sync)*N); + for (i = 0; i < N; i++) + { tMPI_Coll_sync_init( &(ret->csync[i]), N); + } - tMPI_Thread_mutex_lock( &(tmpi_global->comm_link_lock) ); + tMPI_Thread_mutex_lock( &(tmpi_global->comm_link_lock) ); /* we insert ourselves in the circular list, after TMPI_COMM_WORLD */ if (TMPI_COMM_WORLD) { - ret->next=TMPI_COMM_WORLD; - ret->prev=TMPI_COMM_WORLD->prev; + ret->next = TMPI_COMM_WORLD; + ret->prev = TMPI_COMM_WORLD->prev; TMPI_COMM_WORLD->prev->next = ret; - TMPI_COMM_WORLD->prev = ret; + TMPI_COMM_WORLD->prev = ret; } else { - ret->prev=ret->next=ret; + ret->prev = ret->next = ret; } - tMPI_Thread_mutex_unlock( &(tmpi_global->comm_link_lock) ); + tMPI_Thread_mutex_unlock( &(tmpi_global->comm_link_lock) ); return ret; } @@ -258,15 +265,21 @@ void tMPI_Comm_destroy(tMPI_Comm comm, tmpi_bool do_link_lock) int i; free(comm->grp.peers); - for(i=0;iN_reduce_iter;i++) + for (i = 0; i < comm->N_reduce_iter; i++) + { free(comm->reduce_barrier[i]); + } free(comm->reduce_barrier); free(comm->N_reduce); - for(i=0;icev[i]) ); - for(i=0;igrp.N;i++) + } + for (i = 0; i < comm->grp.N; i++) + { tMPI_Coll_sync_destroy( &(comm->csync[i]) ); + } free(comm->cev); free(comm->csync); @@ -277,7 +290,7 @@ void tMPI_Comm_destroy(tMPI_Comm comm, tmpi_bool do_link_lock) free((void*)comm->reduce_sendbuf); free((void*)comm->reduce_recvbuf); - if ( comm->cart ) + if (comm->cart) { tMPI_Cart_destroy( comm->cart ); free(comm->cart); @@ -285,18 +298,22 @@ void tMPI_Comm_destroy(tMPI_Comm comm, tmpi_bool do_link_lock) /* remove ourselves from the circular list */ if (do_link_lock) - tMPI_Thread_mutex_lock( &(tmpi_global->comm_link_lock) ); + { + tMPI_Thread_mutex_lock( &(tmpi_global->comm_link_lock) ); + } if (comm->next) { - comm->next->prev=comm->prev; + comm->next->prev = comm->prev; } if (comm->prev) { - comm->prev->next=comm->next; + comm->prev->next = comm->next; } free(comm); if (do_link_lock) - tMPI_Thread_mutex_unlock( &(tmpi_global->comm_link_lock) ); + { + tMPI_Thread_mutex_unlock( &(tmpi_global->comm_link_lock) ); + } } int tMPI_Comm_free(tMPI_Comm *comm) @@ -307,8 +324,10 @@ int tMPI_Comm_free(tMPI_Comm *comm) tMPI_Trace_print("tMPI_Comm_free(%p)", comm); #endif #ifndef TMPI_STRICT - if (! *comm) + if (!*comm) + { return TMPI_SUCCESS; + } if ((*comm)->grp.N > 1) { @@ -324,19 +343,21 @@ int tMPI_Comm_free(tMPI_Comm *comm) tMPI_Comm_destroy(*comm, TRUE); } #else - /* This is correct if programs actually treat Comm_free as a collective + /* This is correct if programs actually treat Comm_free as a collective call */ - if (! *comm) + if (!*comm) + { return TMPI_SUCCESS; + } - size=(*comm)->grp.N; + size = (*comm)->grp.N; /* we add 1 to the destroy counter and actually deallocate if the counter reaches N. */ - sum=tMPI_Atomic_add_return( &((*comm)->destroy_counter), 1); - /* this is a collective call on a shared data structure, so only + sum = tMPI_Atomic_add_return( &((*comm)->destroy_counter), 1); + /* this is a collective call on a shared data structure, so only one process (the last one in this case) should do anything */ - if (sum==size) + if (sum == size) { tMPI_Comm_destroy(*comm, TRUE); } @@ -351,66 +372,68 @@ int tMPI_Comm_dup(tMPI_Comm comm, tMPI_Comm *newcomm) #endif /* we just call Comm_split because it already contains all the neccesary synchronization constructs. */ - return tMPI_Comm_split(comm, 0, tMPI_Comm_seek_rank(comm, - tMPI_Get_current()), newcomm); + return tMPI_Comm_split(comm, 0, tMPI_Comm_seek_rank(comm, + tMPI_Get_current()), newcomm); } int tMPI_Comm_create(tMPI_Comm comm, tMPI_Group group, tMPI_Comm *newcomm) { - int color=TMPI_UNDEFINED; - int key=tMPI_Comm_seek_rank(comm, tMPI_Get_current()); + int color = TMPI_UNDEFINED; + int key = tMPI_Comm_seek_rank(comm, tMPI_Get_current()); #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Comm_create(%p, %p, %p)", comm, group, newcomm); #endif if (tMPI_In_group(group)) { - color=1; + color = 1; } /* the MPI specs specifically say that this is equivalent */ return tMPI_Comm_split(comm, color, key, newcomm); } -static void tMPI_Split_colors(int N, const int *color, const int *key, - int *Ngroups, int *grp_N, int *grp_color, +static void tMPI_Split_colors(int N, const int *color, const int *key, + int *Ngroups, int *grp_N, int *grp_color, int *group) { - int i,j; + int i, j; tmpi_bool found; /* reset groups */ - for(i=0;i0 && ( key[group[N*j + k-1]]>key[i]) ) + while (k > 0 && ( key[group[N*j + k-1]] > key[i]) ) { /* shift up */ - group[N*j + k]=group[N*j + k-1]; + group[N*j + k] = group[N*j + k-1]; k--; } - group[N*j+k]=i; + group[N*j+k] = i; grp_N[j]++; - found=TRUE; + found = TRUE; } } if (!found) { /* not found. just add a new color */ - grp_N[(*Ngroups)]=1; - grp_color[(*Ngroups)]=color[i]; - group[N*(*Ngroups) + 0]=i; + grp_N[(*Ngroups)] = 1; + grp_color[(*Ngroups)] = color[i]; + group[N*(*Ngroups) + 0] = i; (*Ngroups)++; } } @@ -421,127 +444,133 @@ static void tMPI_Split_colors(int N, const int *color, const int *key, comms use this*/ int tMPI_Comm_split(tMPI_Comm comm, int color, int key, tMPI_Comm *newcomm) { - int i,j; - int N=tMPI_Comm_N(comm); + int i, j; + int N = tMPI_Comm_N(comm); volatile tMPI_Comm *newcomm_list; - volatile int colors[MAX_PREALLOC_THREADS]; /* array with the colors - of each thread */ - volatile int keys[MAX_PREALLOC_THREADS]; /* same for keys (only one of - the threads actually suplies - these arrays to the comm - structure) */ - tmpi_bool i_am_first=FALSE; - int myrank=tMPI_Comm_seek_rank(comm, tMPI_Get_current()); + volatile int colors[MAX_PREALLOC_THREADS]; /* array with the colors + of each thread */ + volatile int keys[MAX_PREALLOC_THREADS]; /* same for keys (only one of + the threads actually suplies + these arrays to the comm + structure) */ + tmpi_bool i_am_first = FALSE; + int myrank = tMPI_Comm_seek_rank(comm, tMPI_Get_current()); struct tmpi_split *spl; #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Comm_split(%p, %d, %d, %p)", comm, color, key, + tMPI_Trace_print("tMPI_Comm_split(%p, %d, %d, %p)", comm, color, key, newcomm); #endif if (!comm) { - *newcomm=NULL; + *newcomm = NULL; return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - tMPI_Thread_mutex_lock(&(comm->comm_create_lock)); + tMPI_Thread_mutex_lock(&(comm->comm_create_lock)); /* first get the colors */ if (!comm->new_comm) { /* i am apparently first */ - comm->split=(struct tmpi_split*)tMPI_Malloc(sizeof(struct tmpi_split)); - comm->new_comm=(tMPI_Comm*)tMPI_Malloc(N*sizeof(tMPI_Comm)); - if (N<=MAX_PREALLOC_THREADS) + comm->split = (struct tmpi_split*)tMPI_Malloc(sizeof(struct tmpi_split)); + comm->new_comm = (tMPI_Comm*)tMPI_Malloc(N*sizeof(tMPI_Comm)); + if (N <= MAX_PREALLOC_THREADS) { - comm->split->colors=colors; - comm->split->keys=keys; + comm->split->colors = colors; + comm->split->keys = keys; } else { - comm->split->colors=(int*)tMPI_Malloc(N*sizeof(int)); - comm->split->keys=(int*)tMPI_Malloc(N*sizeof(int)); + comm->split->colors = (int*)tMPI_Malloc(N*sizeof(int)); + comm->split->keys = (int*)tMPI_Malloc(N*sizeof(int)); } - comm->split->Ncol_init=tMPI_Comm_N(comm); - comm->split->can_finish=FALSE; - i_am_first=TRUE; + comm->split->Ncol_init = tMPI_Comm_N(comm); + comm->split->can_finish = FALSE; + i_am_first = TRUE; /* the main communicator contains a list the size of grp.N */ } - newcomm_list=comm->new_comm; /* we copy it to the local stacks because - we can later erase comm->new_comm safely */ - spl=comm->split; /* we do the same for spl */ + newcomm_list = comm->new_comm; /* we copy it to the local stacks because + we can later erase comm->new_comm safely */ + spl = comm->split; /* we do the same for spl */ spl->colors[myrank] = color; - spl->keys[myrank] = key; + spl->keys[myrank] = key; spl->Ncol_init--; if (spl->Ncol_init == 0) + { tMPI_Thread_cond_signal(&(comm->comm_create_prep)); + } if (!i_am_first) { - /* all other threads can just wait until the creator thread is + /* all other threads can just wait until the creator thread is finished */ - while(! spl->can_finish ) + while (!spl->can_finish) { - tMPI_Thread_cond_wait(&(comm->comm_create_finish) , + tMPI_Thread_cond_wait(&(comm->comm_create_finish), &(comm->comm_create_lock) ); } } else { - int Ncomms=0; - int comm_color_[MAX_PREALLOC_THREADS]; - int comm_N_[MAX_PREALLOC_THREADS]; - int *comm_color=comm_color_; /* there can't be more comms than N*/ - int *comm_N=comm_N_; /* the number of procs in a group */ + int Ncomms = 0; + int comm_color_[MAX_PREALLOC_THREADS]; + int comm_N_[MAX_PREALLOC_THREADS]; + int *comm_color = comm_color_; /* there can't be more comms than N*/ + int *comm_N = comm_N_; /* the number of procs in a group */ - int *comm_groups; /* the groups */ - tMPI_Comm *comms; /* the communicators */ + int *comm_groups; /* the groups */ + tMPI_Comm *comms; /* the communicators */ /* wait for the colors to be done */ /*if (N>1)*/ - while(spl->Ncol_init > 0) + while (spl->Ncol_init > 0) { - tMPI_Thread_cond_wait(&(comm->comm_create_prep), + tMPI_Thread_cond_wait(&(comm->comm_create_prep), &(comm->comm_create_lock)); } /* reset the state so that a new comm creating function can run */ - spl->Ncol_destroy=N; - comm->new_comm=0; - comm->split=0; + spl->Ncol_destroy = N; + comm->new_comm = 0; + comm->split = 0; - comm_groups=(int*)tMPI_Malloc(N*N*sizeof(int)); - if (N>MAX_PREALLOC_THREADS) + comm_groups = (int*)tMPI_Malloc(N*N*sizeof(int)); + if (N > MAX_PREALLOC_THREADS) { - comm_color=(int*)tMPI_Malloc(N*sizeof(int)); - comm_N=(int*)tMPI_Malloc(N*sizeof(int)); + comm_color = (int*)tMPI_Malloc(N*sizeof(int)); + comm_N = (int*)tMPI_Malloc(N*sizeof(int)); } /* count colors, allocate and split up communicators */ - tMPI_Split_colors(N, (int*)spl->colors, - (int*)spl->keys, - &Ncomms, - comm_N, comm_color, comm_groups); + tMPI_Split_colors(N, (int*)spl->colors, + (int*)spl->keys, + &Ncomms, + comm_N, comm_color, comm_groups); /* allocate a bunch of communicators */ - comms=(tMPI_Comm*)tMPI_Malloc(Ncomms*sizeof(tMPI_Comm)); - for(i=0;igrp.N=comm_N[i]; - for(j=0;jgrp.peers[j]= + comms[i]->grp.N = comm_N[i]; + for (j = 0; j < comm_N[i]; j++) + { + comms[i]->grp.peers[j] = comm->grp.peers[comm_groups[i*comm->grp.N + j]]; + } } /* and put them into the newcomm_list */ - for(i=0;icolors[i] == comm_color[j]) { @@ -553,23 +582,29 @@ int tMPI_Comm_split(tMPI_Comm comm, int color, int key, tMPI_Comm *newcomm) #ifdef TMPI_DEBUG /* output */ - for(i=0;igrp.N*i + j]); + i, comm_color[i], comm_N[i]); + for (j = 0; j < comm_N[i]; j++) + { + printf(" %d ", comm_groups[comm->grp.N*i + j]); + } printf(" rank: "); - for(j=0;jkeys[comm_groups[N*i + j]]); + for (j = 0; j < comm_N[i]; j++) + { + printf(" %d ", spl->keys[comm_groups[N*i + j]]); + } printf(" color: "); - for(j=0;jcolors[comm_groups[N*i + j]]); + for (j = 0; j < comm_N[i]; j++) + { + printf(" %d ", spl->colors[comm_groups[N*i + j]]); + } printf("\n"); } #endif - if (N>MAX_PREALLOC_THREADS) + if (N > MAX_PREALLOC_THREADS) { free((int*)spl->colors); free((int*)spl->keys); @@ -578,17 +613,17 @@ int tMPI_Comm_split(tMPI_Comm comm, int color, int key, tMPI_Comm *newcomm) } free(comm_groups); free(comms); - spl->can_finish=TRUE; + spl->can_finish = TRUE; /* tell the waiting threads that there's a comm ready */ tMPI_Thread_cond_broadcast(&(comm->comm_create_finish)); } /* here the individual threads get their comm object */ - *newcomm=newcomm_list[myrank]; + *newcomm = newcomm_list[myrank]; /* free when we have assigned them all, so we can reuse the object*/ spl->Ncol_destroy--; - if (spl->Ncol_destroy==0) + if (spl->Ncol_destroy == 0) { free((void*)newcomm_list); free(spl); @@ -596,22 +631,23 @@ int tMPI_Comm_split(tMPI_Comm comm, int color, int key, tMPI_Comm *newcomm) tMPI_Thread_mutex_unlock(&(comm->comm_create_lock)); - return TMPI_SUCCESS; + return TMPI_SUCCESS; } int tMPI_Comm_seek_rank(tMPI_Comm comm, struct tmpi_thread *th) { int i; if (!comm) + { return -1; + } - for(i=0;igrp.N;i++) + for (i = 0; i < comm->grp.N; i++) { if (comm->grp.peers[i] == th) + { return i; + } } return -1; } - - - diff --git a/src/gromacs/gmxlib/thread_mpi/errhandler.c b/src/gromacs/gmxlib/thread_mpi/errhandler.c index 3e97bb7fd9..fe8d444c70 100644 --- a/src/gromacs/gmxlib/thread_mpi/errhandler.c +++ b/src/gromacs/gmxlib/thread_mpi/errhandler.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -51,7 +51,7 @@ files. #include #include #include -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) #include #endif @@ -66,8 +66,8 @@ struct tmpi_errhandler_ tmpi_errors_are_fatal = { 0, tmpi_errors_are_fatal_fn }; struct tmpi_errhandler_ tmpi_errors_return = { 0, tmpi_errors_return_fn }; -tMPI_Errhandler TMPI_ERRORS_ARE_FATAL=&tmpi_errors_are_fatal; -tMPI_Errhandler TMPI_ERRORS_RETURN=&tmpi_errors_return; +tMPI_Errhandler TMPI_ERRORS_ARE_FATAL = &tmpi_errors_are_fatal; +tMPI_Errhandler TMPI_ERRORS_RETURN = &tmpi_errors_return; @@ -106,7 +106,7 @@ int tMPI_Error(tMPI_Comm comm, int tmpi_errno) { if (comm) { - comm->erh->err=tmpi_errno; + comm->erh->err = tmpi_errno; comm->erh->fn(&comm, &tmpi_errno); } else @@ -120,20 +120,22 @@ int tMPI_Error(tMPI_Comm comm, int tmpi_errno) int tMPI_Error_string(int errorcode, char *strn, size_t *resultlen) { - if (errorcode<0 || errorcode>=N_TMPI_ERR) - errorcode=TMPI_ERR_UNKNOWN; + if (errorcode < 0 || errorcode >= N_TMPI_ERR) + { + errorcode = TMPI_ERR_UNKNOWN; + } -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) strncpy(strn, tmpi_errmsg[errorcode], TMPI_MAX_ERROR_STRING); #else strncpy_s(strn, TMPI_MAX_ERROR_STRING, tmpi_errmsg[errorcode], TMPI_MAX_ERROR_STRING); #endif - *resultlen=strlen(strn); + *resultlen = strlen(strn); return TMPI_SUCCESS; } -int tMPI_Create_errhandler(tMPI_Errhandler_fn *function, - tMPI_Errhandler *errhandler) +int tMPI_Create_errhandler(tMPI_Errhandler_fn *function, + tMPI_Errhandler *errhandler) { #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Create_errhandler(%p, %p)", function, errhandler); @@ -141,15 +143,15 @@ int tMPI_Create_errhandler(tMPI_Errhandler_fn *function, /* we don't use a special malloc here because this is the error handler creation function. */ - *errhandler=(tMPI_Errhandler)malloc(sizeof(struct tmpi_errhandler_)); + *errhandler = (tMPI_Errhandler)malloc(sizeof(struct tmpi_errhandler_)); if (!*errhandler) { - fprintf(stderr, "tMPI fatal error (%s), bailing out\n", + fprintf(stderr, "tMPI fatal error (%s), bailing out\n", tmpi_errmsg[TMPI_ERR_MALLOC]); abort(); } - (*errhandler)->err=0; - (*errhandler)->fn=*function; + (*errhandler)->err = 0; + (*errhandler)->fn = *function; return TMPI_SUCCESS; } @@ -180,13 +182,13 @@ int tMPI_Comm_get_errhandler(tMPI_Comm comm, tMPI_Errhandler *errhandler) tMPI_Trace_print("tMPI_Comm_get_errhandler(%p, %p)", comm, errhandler); #endif - *errhandler=comm->erh; + *errhandler = comm->erh; return TMPI_SUCCESS; } void tmpi_errors_are_fatal_fn(tMPI_Comm *comm, int *err) { - char errstr[TMPI_MAX_ERROR_STRING]; + char errstr[TMPI_MAX_ERROR_STRING]; size_t len; tMPI_Error_string(*err, errstr, &len); @@ -204,7 +206,7 @@ void tmpi_errors_are_fatal_fn(tMPI_Comm *comm, int *err) void tmpi_errors_return_fn(tMPI_Comm *comm, int *err) { - char errstr[TMPI_MAX_ERROR_STRING]; + char errstr[TMPI_MAX_ERROR_STRING]; size_t len; tMPI_Error_string(*err, errstr, &len); @@ -218,4 +220,3 @@ void tmpi_errors_return_fn(tMPI_Comm *comm, int *err) } return; } - diff --git a/src/gromacs/gmxlib/thread_mpi/event.c b/src/gromacs/gmxlib/thread_mpi/event.c index dbb8e8a08a..7d7bb1ef07 100644 --- a/src/gromacs/gmxlib/thread_mpi/event.c +++ b/src/gromacs/gmxlib/thread_mpi/event.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -53,28 +53,26 @@ files. void tMPI_Event_init(tMPI_Event *ev) { tMPI_Atomic_set(&(ev->sync), 0); - ev->last_sync=0; + ev->last_sync = 0; } void tMPI_Event_destroy(tMPI_Event *ev) { tMPI_Atomic_set(&(ev->sync), 0); - ev->last_sync=0; + ev->last_sync = 0; } -int tMPI_Event_wait(tMPI_Event *ev) +int tMPI_Event_wait(tMPI_Event *ev) { int ret; - /* for most OSes yielding waits result in much better performance - (by an order of magnitude) than using the OS-provided wait functions + /* for most OSes yielding waits result in much better performance + (by an order of magnitude) than using the OS-provided wait functions such as pthread_cond_wait(). That's why we do a busy-wait loop here.*/ - while( (tMPI_Atomic_get(&(ev->sync)) - (ev->last_sync)) <= 0 ) - { + while ( (tMPI_Atomic_get(&(ev->sync)) - (ev->last_sync)) <= 0) + { TMPI_YIELD_WAIT(ev); } - tMPI_Atomic_memory_barrier_acq(); - ret=tMPI_Atomic_get(&(ev->sync)) - (ev->last_sync); + tMPI_Atomic_memory_barrier_acq(); + ret = tMPI_Atomic_get(&(ev->sync)) - (ev->last_sync); return ret; } - - diff --git a/src/gromacs/gmxlib/thread_mpi/gather.c b/src/gromacs/gmxlib/thread_mpi/gather.c index b049d224aa..a43f2db53d 100644 --- a/src/gromacs/gmxlib/thread_mpi/gather.c +++ b/src/gromacs/gmxlib/thread_mpi/gather.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -59,21 +59,21 @@ files. int tMPI_Gather(void* sendbuf, int sendcount, tMPI_Datatype sendtype, - void* recvbuf, int recvcount, tMPI_Datatype recvtype, + void* recvbuf, int recvcount, tMPI_Datatype recvtype, int root, tMPI_Comm comm) { - int synct; - struct coll_env *cev; - int myrank; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); + int synct; + struct coll_env *cev; + int myrank; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); #ifdef TMPI_PROFILE - tMPI_Profile_count_start(cur); + tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Gather(%p, %d, %p, %p, %d, %p, %d, %p)", - sendbuf, sendcount, sendtype, + sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm); #endif @@ -81,53 +81,57 @@ int tMPI_Gather(void* sendbuf, int sendcount, tMPI_Datatype sendtype, { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - myrank=tMPI_Comm_seek_rank(comm, cur); + myrank = tMPI_Comm_seek_rank(comm, cur); /* we increase our counter, and determine which coll_env we get */ - cev=tMPI_Get_cev(comm, myrank, &synct); + cev = tMPI_Get_cev(comm, myrank, &synct); - if (myrank==root) + if (myrank == root) { int i; - int n_remaining=comm->grp.N-1; + int n_remaining = comm->grp.N-1; /* do root transfer */ - if (sendbuf!=TMPI_IN_PLACE) + if (sendbuf != TMPI_IN_PLACE) { tMPI_Coll_root_xfer(comm, sendtype, recvtype, - sendtype->size*sendcount, - recvtype->size*recvcount, - sendbuf, + sendtype->size*sendcount, + recvtype->size*recvcount, + sendbuf, (char*)recvbuf+myrank*recvcount*recvtype->size, &ret); } - for(i=0;igrp.N;i++) - cev->met[myrank].read_data[i]=FALSE; - cev->met[myrank].read_data[myrank]=TRUE; + for (i = 0; i < comm->grp.N; i++) + { + cev->met[myrank].read_data[i] = FALSE; + } + cev->met[myrank].read_data[myrank] = TRUE; /* wait for data availability as long as there are xfers to be done */ - while(n_remaining>0) + while (n_remaining > 0) { #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_start(cur); #endif - tMPI_Event_wait( &(cev->met[myrank]).recv_ev ) ; + tMPI_Event_wait( &(cev->met[myrank]).recv_ev ); #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_stop(cur, TMPIWAIT_Coll_recv); #endif /* now check all of them */ - for(i=0;igrp.N;i++) + for (i = 0; i < comm->grp.N; i++) { - if ( !cev->met[myrank].read_data[i] && - (tMPI_Atomic_get(&(cev->met[i].current_sync))== synct)) + if (!cev->met[myrank].read_data[i] && + (tMPI_Atomic_get(&(cev->met[i].current_sync)) == synct)) { - tMPI_Mult_recv(comm, cev, i, 0, TMPI_GATHER_TAG, recvtype, + tMPI_Mult_recv(comm, cev, i, 0, TMPI_GATHER_TAG, recvtype, recvcount*recvtype->size, (char*)recvbuf+i*recvcount*recvtype->size, &ret); - tMPI_Event_process( &(cev->met[myrank]).recv_ev, 1) ; - if (ret!=TMPI_SUCCESS) + tMPI_Event_process( &(cev->met[myrank]).recv_ev, 1); + if (ret != TMPI_SUCCESS) + { return ret; - cev->met[myrank].read_data[i]=TRUE; + } + cev->met[myrank].read_data[i] = TRUE; n_remaining--; } } @@ -141,13 +145,13 @@ int tMPI_Gather(void* sendbuf, int sendcount, tMPI_Datatype sendtype, } /* first set up the data just to root. */ - tMPI_Post_multi(cev, myrank, 0, TMPI_GATHER_TAG, sendtype, + tMPI_Post_multi(cev, myrank, 0, TMPI_GATHER_TAG, sendtype, sendcount*sendtype->size, sendbuf, 1, synct, root); /* and wait until root is done copying */ tMPI_Wait_for_others(cev, myrank); } #ifdef TMPI_PROFILE - tMPI_Profile_count_stop(cur,TMPIFN_Gather); + tMPI_Profile_count_stop(cur, TMPIFN_Gather); #endif return ret; } @@ -161,14 +165,14 @@ int tMPI_Gatherv(void* sendbuf, int sendcount, tMPI_Datatype sendtype, void* recvbuf, int *recvcounts, int *displs, tMPI_Datatype recvtype, int root, tMPI_Comm comm) { - int synct; - struct coll_env *cev; - int myrank; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); + int synct; + struct coll_env *cev; + int myrank; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); #ifdef TMPI_PROFILE - tMPI_Profile_count_start(cur); + tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Gatherv(%p, %d, %p, %p, %p, %p, %p, %d, %p)", @@ -180,52 +184,56 @@ int tMPI_Gatherv(void* sendbuf, int sendcount, tMPI_Datatype sendtype, { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - myrank=tMPI_Comm_seek_rank(comm, cur); + myrank = tMPI_Comm_seek_rank(comm, cur); /* we increase our counter, and determine which coll_env we get */ - cev=tMPI_Get_cev(comm, myrank, &synct); + cev = tMPI_Get_cev(comm, myrank, &synct); - if (myrank==root) + if (myrank == root) { int i; - int n_remaining=comm->grp.N-1; + int n_remaining = comm->grp.N-1; /* do root transfer */ - if (sendbuf!=TMPI_IN_PLACE) + if (sendbuf != TMPI_IN_PLACE) { tMPI_Coll_root_xfer(comm, sendtype, recvtype, - sendtype->size*sendcount, - recvtype->size*recvcounts[myrank], - sendbuf, - (char*)recvbuf+displs[myrank]*recvtype->size, + sendtype->size*sendcount, + recvtype->size*recvcounts[myrank], + sendbuf, + (char*)recvbuf+displs[myrank]*recvtype->size, &ret); } - for(i=0;igrp.N;i++) - cev->met[myrank].read_data[i]=FALSE; - cev->met[myrank].read_data[myrank]=TRUE; + for (i = 0; i < comm->grp.N; i++) + { + cev->met[myrank].read_data[i] = FALSE; + } + cev->met[myrank].read_data[myrank] = TRUE; /* wait for data availability as long as there are xfers to be done */ - while(n_remaining>0) - { + while (n_remaining > 0) + { #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_start(cur); #endif - tMPI_Event_wait( &(cev->met[myrank]).recv_ev ) ; + tMPI_Event_wait( &(cev->met[myrank]).recv_ev ); #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_stop(cur, TMPIWAIT_Coll_recv); #endif - for(i=0;igrp.N;i++) + for (i = 0; i < comm->grp.N; i++) { - if ( !cev->met[myrank].read_data[i] && - (tMPI_Atomic_get(&(cev->met[i].current_sync))==synct) ) + if (!cev->met[myrank].read_data[i] && + (tMPI_Atomic_get(&(cev->met[i].current_sync)) == synct) ) { - tMPI_Event_process( &(cev->met[myrank]).recv_ev, 1) ; + tMPI_Event_process( &(cev->met[myrank]).recv_ev, 1); tMPI_Mult_recv(comm, cev, i, 0, TMPI_GATHERV_TAG, recvtype, recvcounts[i]*recvtype->size, (char*)recvbuf+displs[i]*recvtype->size, &ret); - if (ret!=TMPI_SUCCESS) + if (ret != TMPI_SUCCESS) + { return ret; - cev->met[myrank].read_data[i]=TRUE; + } + cev->met[myrank].read_data[i] = TRUE; n_remaining--; } } @@ -239,18 +247,14 @@ int tMPI_Gatherv(void* sendbuf, int sendcount, tMPI_Datatype sendtype, } /* first set up the data just to root. */ - tMPI_Post_multi(cev, myrank, 0, TMPI_GATHERV_TAG, sendtype, + tMPI_Post_multi(cev, myrank, 0, TMPI_GATHERV_TAG, sendtype, sendcount*sendtype->size, sendbuf, 1, synct, root); /* and wait until root is done copying */ tMPI_Wait_for_others(cev, myrank); } #ifdef TMPI_PROFILE - tMPI_Profile_count_stop(cur, TMPIFN_Gatherv); + tMPI_Profile_count_stop(cur, TMPIFN_Gatherv); #endif return ret; } - - - - diff --git a/src/gromacs/gmxlib/thread_mpi/group.c b/src/gromacs/gmxlib/thread_mpi/group.c index b60d6d46b0..6820c32fa2 100644 --- a/src/gromacs/gmxlib/thread_mpi/group.c +++ b/src/gromacs/gmxlib/thread_mpi/group.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -62,14 +62,16 @@ files. tmpi_bool tMPI_In_group(tMPI_Group group) { - int i; + int i; struct tmpi_thread *cur; - cur=tMPI_Get_current(); - for(i=0;iN;i++) + cur = tMPI_Get_current(); + for (i = 0; i < group->N; i++) { if (group->peers[i] == cur) + { return TRUE; + } } return FALSE; } @@ -81,30 +83,36 @@ int tMPI_Group_size(tMPI_Group group, int *size) #endif if (group) + { *size = group->N; + } else + { *size = 0; + } return TMPI_SUCCESS; } int tMPI_Group_rank(tMPI_Group group, int *rank) -{ - int i; +{ + int i; struct tmpi_thread *cur; #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Group_rank(%p, %p)", group, rank); #endif if (!group) + { return TMPI_UNDEFINED; + } /* search for my id in the list of peers */ - cur=tMPI_Get_current(); - for(i=0;iN;i++) + cur = tMPI_Get_current(); + for (i = 0; i < group->N; i++) { if (group->peers[i] == cur) { - *rank=i; + *rank = i; return TMPI_SUCCESS; } } @@ -117,12 +125,12 @@ tMPI_Group tMPI_Group_alloc(void) { struct tmpi_group_ *ret; - ret=(struct tmpi_group_*)tMPI_Malloc(sizeof(struct tmpi_group_)); - ret->peers=(struct tmpi_thread**)tMPI_Malloc( - sizeof(struct tmpi_thread*)*Nthreads); - ret->N=0; + ret = (struct tmpi_group_*)tMPI_Malloc(sizeof(struct tmpi_group_)); + ret->peers = (struct tmpi_thread**)tMPI_Malloc( + sizeof(struct tmpi_thread*)*Nthreads); + ret->N = 0; #if 0 - ret->Nrefs=1; + ret->Nrefs = 1; #endif return ret; @@ -143,26 +151,26 @@ int tMPI_Group_free(tMPI_Group *group) int tMPI_Comm_group(tMPI_Comm comm, tMPI_Group *group) { - int i; - struct tmpi_group_ *ret=tMPI_Group_alloc(); + int i; + struct tmpi_group_ *ret = tMPI_Group_alloc(); #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Comm_group(%p, %p)", comm, group); #endif - ret->N=comm->grp.N; - for(i=0;igrp.N;i++) + ret->N = comm->grp.N; + for (i = 0; i < comm->grp.N; i++) { - ret->peers[i]=comm->grp.peers[i]; + ret->peers[i] = comm->grp.peers[i]; } - *group=ret; + *group = ret; #if 0 if (comm) { - *group=&(comm->grp); + *group = &(comm->grp); } else { - *group=NULL; + *group = NULL; } #endif @@ -172,27 +180,24 @@ int tMPI_Comm_group(tMPI_Comm comm, tMPI_Group *group) int tMPI_Group_incl(tMPI_Group group, int n, int *ranks, tMPI_Group *newgroup) { - int i; + int i; tMPI_Group ng; #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Group_incl(%p, %d, %p, %p, %p)", group, n, ranks, - newgroup); + tMPI_Trace_print("tMPI_Group_incl(%p, %d, %p, %p, %p)", group, n, ranks, + newgroup); #endif /* just allocate and copy */ - ng=tMPI_Group_alloc(); - ng->N=n; - for(i=0;iN = n; + for (i = 0; i < n; i++) { if (ranks[i] < 0 || !group || ranks[i] >= group->N) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_GROUP_RANK); } - ng->peers[i]=group->peers[ranks[i]]; + ng->peers[i] = group->peers[ranks[i]]; } - *newgroup=ng; + *newgroup = ng; return TMPI_SUCCESS; } - - - diff --git a/src/gromacs/gmxlib/thread_mpi/impl.h b/src/gromacs/gmxlib/thread_mpi/impl.h index 43a8ac1e52..17b4b46661 100644 --- a/src/gromacs/gmxlib/thread_mpi/impl.h +++ b/src/gromacs/gmxlib/thread_mpi/impl.h @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ /* this is the header file for the implementation side of the thread_mpi @@ -70,10 +70,10 @@ files. /************************************************************************** - - BASIC DEFINITIONS - -**************************************************************************/ + + BASIC DEFINITIONS + + **************************************************************************/ typedef int tmpi_bool; @@ -84,31 +84,31 @@ typedef int tmpi_bool; #ifdef USE_COLLECTIVE_COPY_BUFFER /************************************************************************** - - PRE-ALLOCATED COMMUNICATION BUFFERS - -**************************************************************************/ + + PRE-ALLOCATED COMMUNICATION BUFFERS + + **************************************************************************/ -/* 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 +/* 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 */ + void *buf; /* the actual buffer */ struct copy_buffer *next; /* pointer to next free buffer in buffer_list */ - size_t size; /* allocated size of buffer */ + size_t size; /* allocated size of buffer */ }; /* a list of copy_buffers of a specific size. */ struct copy_buffer_list { - struct copy_buffer *cb; /* pointer to the first copy_buffer */ - size_t size; /* allocated size of buffers in this list */ + struct copy_buffer *cb; /* pointer to the first copy_buffer */ + size_t size; /* allocated size of buffers in this list */ struct copy_buffer *cb_alloc; /* list as allocated */ - int Nbufs; /* number of allocated buffers */ + int Nbufs; /* number of allocated buffers */ }; #endif @@ -125,32 +125,32 @@ struct copy_buffer_list /************************************************************************** - - POINT-TO-POINT COMMUNICATION DATA STRUCTURES - -**************************************************************************/ -/* the message envelopes (as described in the MPI standard). + POINT-TO-POINT COMMUNICATION DATA STRUCTURES + + **************************************************************************/ + +/* the message envelopes (as described in the MPI standard). These fully describes the message, and make each message unique (enough). - Transmitting data works by having the sender put a pointer to an envelope - onto the receiver's new envelope list corresponding to the originating - thread. + Transmitting data works by having the sender put a pointer to an envelope + onto the receiver's new envelope list corresponding to the originating + thread. The sender then waits until the receiver finishes the transmission, while - matching all incoming new envelopes against its own list of receive + matching all incoming new envelopes against its own list of receive envelopes. The receiver either directly matches its receiving envelope against all previously un-matched sending envelopes, or, if no suitable envelope - is found, it puts the receive envelope on a receive list. - Once waiting for completion, the receiver matches against all incoming + is found, it puts the receive envelope on a receive list. + Once waiting for completion, the receiver matches against all incoming new envelopes. */ /* the state of an individual point-to-point transmission */ enum envelope_state { env_unmatched = 0, /* the envelope has not had a match yet */ - env_copying = 1, /* busy copying (only used for send envelope + env_copying = 1, /* busy copying (only used for send envelope by receiver if using_cpbuf is true, but cb was still NULL). */ env_cb_available = 2, /* the copy buffer is available. Set by @@ -163,21 +163,21 @@ enum envelope_state or in tmpi_thread->evl for receive envelopes */ struct envelope { - int tag; /* the tag */ - tMPI_Comm comm; /* this is a structure shared across threads, so we - can test easily whether two threads are talking - about the same comm. */ + int tag; /* the tag */ + tMPI_Comm comm; /* this is a structure shared across threads, so we + can test easily whether two threads are talking + about the same comm. */ struct tmpi_thread *src, *dest; /* these are pretty obvious */ - void *buf; /* buffer to be sent */ - size_t bufsize; /* the size of the data to be transmitted */ - tMPI_Datatype datatype; /* the data type */ + void *buf; /* buffer to be sent */ + size_t bufsize; /* the size of the data to be transmitted */ + tMPI_Datatype datatype; /* the data type */ - tmpi_bool nonblock; /* whether the receiver is non-blocking */ + tmpi_bool nonblock; /* whether the receiver is non-blocking */ - /* state, values from enum_envelope_state . - (there's a few busy-waits relying on this flag). + /* state, values from enum_envelope_state . + (there's a few busy-waits relying on this flag). status=env_unmatched is the initial state.*/ tMPI_Atomic_t state; @@ -188,13 +188,13 @@ struct envelope /*tMPI_Status *status;*/ /* prev and next envelopes in the send/recv_envelope_list linked list */ - struct envelope *prev,*next; + struct envelope *prev, *next; - tmpi_bool send; /* whether this is a send envelope (if TRUE), or a receive - envelope (if FALSE) */ + tmpi_bool send; /* whether this is a send envelope (if TRUE), or a receive + envelope (if FALSE) */ #ifdef USE_SEND_RECV_COPY_BUFFER - tmpi_bool using_cb; /* whether a copy buffer is (going to be) used */ - void* cb;/* the allocated copy buffer pointer */ + tmpi_bool using_cb; /* whether a copy buffer is (going to be) used */ + void * cb; /* the allocated copy buffer pointer */ #endif /* the next and previous envelopes in the request list */ struct envelope *prev_req, *next_req; @@ -208,74 +208,74 @@ struct envelope /* singly linked lists of free send & receive envelopes belonging to a thread. */ -struct free_envelope_list +struct free_envelope_list { - struct envelope *head_recv; /* the first element in the linked list */ - struct envelope *recv_alloc_head; /* the allocated recv list */ + struct envelope *head_recv; /* the first element in the linked list */ + struct envelope *recv_alloc_head; /* the allocated recv list */ }; /* collection of send envelopes to a specific thread */ struct send_envelope_list { - struct envelope *head_free; /* singly linked list with free send - envelopes. A single-thread LIFO.*/ + struct envelope *head_free; /* singly linked list with free send + envelopes. A single-thread LIFO.*/ #ifdef TMPI_LOCK_FREE_LISTS - tMPI_Atomic_ptr_t head_new; /* singly linked list with the new send - envelopes (i.e. those that are put there by - the sending thread, but not yet checked by - the receiving thread). This is a lock-free - shared detachable list.*/ - tMPI_Atomic_ptr_t head_rts; /* singly linked list with free send - envelopes returned by the other thread. - This is a lock-free shared LIFO.*/ + tMPI_Atomic_ptr_t head_new; /* singly linked list with the new send + envelopes (i.e. those that are put there by + the sending thread, but not yet checked by + the receiving thread). This is a lock-free + shared detachable list.*/ + tMPI_Atomic_ptr_t head_rts; /* singly linked list with free send + envelopes returned by the other thread. + This is a lock-free shared LIFO.*/ #else - struct envelope *head_new; /* singly linked list with the new send - envelopes (i.e. those that are put there by - the sending thread, but not yet checked by - the receiving thread). */ - struct envelope *head_rts; /* singly linked list with free send envelopes */ - tMPI_Spinlock_t lock_new; /* this locks head_new */ - tMPI_Spinlock_t lock_rts; /* this locks head_rts */ + struct envelope *head_new; /* singly linked list with the new send + envelopes (i.e. those that are put there by + the sending thread, but not yet checked by + the receiving thread). */ + struct envelope *head_rts; /* singly linked list with free send envelopes */ + tMPI_Spinlock_t lock_new; /* this locks head_new */ + tMPI_Spinlock_t lock_rts; /* this locks head_rts */ #endif - struct envelope *head_old; /* the old send envelopes, in a circular doubly - linked list. These have been checked by the - receiving thread against the existing - recv_envelope_list. */ + struct envelope *head_old; /* the old send envelopes, in a circular doubly + linked list. These have been checked by the + receiving thread against the existing + recv_envelope_list. */ - struct envelope *alloc_head; /* the allocated send list */ - size_t Nalloc; /* number of allocted sends */ + struct envelope *alloc_head; /* the allocated send list */ + size_t Nalloc; /* number of allocted sends */ }; struct recv_envelope_list { - struct envelope *head; /* first envelope in this list */ - struct envelope dummy; /* the dummy element for the list */ + struct envelope *head; /* first envelope in this list */ + struct envelope dummy; /* the dummy element for the list */ }; /* the request object for asynchronious operations. */ struct tmpi_req_ { - tmpi_bool finished; /* whether it's finished */ - struct envelope *ev; /* the envelope */ - - struct tmpi_thread *source; /* the message source (for receives) */ - tMPI_Comm comm; /* the comm */ - int tag; /* the tag */ - int error; /* error code */ - size_t transferred; /* the number of transferred bytes */ - tmpi_bool cancelled; /* whether the transmission was canceled */ - - struct tmpi_req_ *next,*prev; /* next,prev request in linked list, - used in the req_list, but also in - tMPI_Test_mult(). */ + tmpi_bool finished; /* whether it's finished */ + struct envelope *ev; /* the envelope */ + + struct tmpi_thread *source; /* the message source (for receives) */ + tMPI_Comm comm; /* the comm */ + int tag; /* the tag */ + int error; /* error code */ + size_t transferred; /* the number of transferred bytes */ + tmpi_bool cancelled; /* whether the transmission was canceled */ + + struct tmpi_req_ *next, *prev; /* next,prev request in linked list, + used in the req_list, but also in + tMPI_Test_mult(). */ }; /* pre-allocated request object list */ struct req_list { - struct tmpi_req_ *head; /* pre-allocated singly linked list of requests. - (i.e. reqs->prev is undefined). */ + struct tmpi_req_ *head; /* pre-allocated singly linked list of requests. + (i.e. reqs->prev is undefined). */ struct tmpi_req_ *alloc_head; /* the allocated block */ }; @@ -296,9 +296,9 @@ struct req_list /************************************************************************** - MULTICAST COMMUNICATION DATA STRUCTURES + MULTICAST COMMUNICATION DATA STRUCTURES -**************************************************************************/ + **************************************************************************/ /* these are data structures meant for keeping track of multicast operations (tMPI_Bcast, tMPI_Gather, etc.). Because these operations are all collective @@ -323,25 +323,25 @@ struct coll_env_thread communication */ tMPI_Atomic_t n_remaining; /* remaining threads count for each thread */ - int tag; /* collective communication type */ - tMPI_Datatype datatype; /* datatype */ + int tag; /* collective communication type */ + tMPI_Datatype datatype; /* datatype */ - void **buf; /* array of send/recv buffer values */ - size_t *bufsize; /* array of number of bytes to send/recv */ + void **buf; /* array of send/recv buffer values */ + size_t *bufsize; /* array of number of bytes to send/recv */ #ifdef USE_COLLECTIVE_COPY_BUFFER - tmpi_bool using_cb; /* whether a copy buffer is (going to be) used */ + tmpi_bool using_cb; /* whether a copy buffer is (going to be) used */ tMPI_Atomic_t buf_readcount; /* Number of threads reading from buf - while using_cpbuf is true, but cpbuf + while using_cpbuf is true, but cpbuf is still NULL. */ - tMPI_Atomic_ptr_t *cpbuf; /* copy_buffer pointers. */ - struct copy_buffer *cb; /* the copy buffer cpbuf points to */ + tMPI_Atomic_ptr_t *cpbuf; /* copy_buffer pointers. */ + struct copy_buffer *cb; /* the copy buffer cpbuf points to */ #endif - tMPI_Event send_ev; /* event associated with being the sending thread. - Triggered when last receiving thread is ready, - and the coll_env_thread is ready for re-use. */ - tMPI_Event recv_ev; /* event associated with being a receiving thread. */ + tMPI_Event send_ev; /* event associated with being the sending thread. + Triggered when last receiving thread is ready, + and the coll_env_thread is ready for re-use. */ + tMPI_Event recv_ev; /* event associated with being a receiving thread. */ tmpi_bool *read_data; /* whether we read data from a specific thread. */ }; @@ -355,28 +355,28 @@ struct coll_env_coll communication */ tMPI_Atomic_t n_remaining; /* remaining threads count */ - void *res; /* result data for once calls. */ + void *res; /* result data for once calls. */ }; -/* the collective communication envelope. There's a few of these per +/* the collective communication envelope. There's a few of these per comm, and each one stands for one collective communication call. */ struct coll_env { struct coll_env_thread *met; /* thread-specific collective envelope data.*/ - struct coll_env_coll coll; - int N; + struct coll_env_coll coll; + int N; }; -/* multicast synchronization data structure. There's one of these for +/* multicast synchronization data structure. There's one of these for each thread in each tMPI_Comm structure */ struct coll_sync { - int synct; /* sync counter for coll_env_thread. */ - int syncs; /* sync counter for coll_env_coll. */ + int synct; /* sync counter for coll_env_thread. */ + int syncs; /* sync counter for coll_env_coll. */ tMPI_Event *events; /* One event for each other thread */ - int N; /* the number of threads */ + int N; /* the number of threads */ }; @@ -391,11 +391,11 @@ struct coll_sync /************************************************************************** - THREAD DATA STRUCTURES + THREAD DATA STRUCTURES -**************************************************************************/ + **************************************************************************/ -/* information about a running thread. This structure is put in a +/* information about a running thread. This structure is put in a globally available array; the envelope exchange, etc. are all done through the elements of this array.*/ struct tmpi_thread @@ -405,23 +405,23 @@ struct tmpi_thread /* p2p communication structures: */ /* the receive envelopes posted for other threads to check */ - struct recv_envelope_list evr; + struct recv_envelope_list evr; /* the send envelopes posted by other threadas */ struct send_envelope_list *evs; /* free send and receive envelopes */ - struct free_envelope_list envelopes; + struct free_envelope_list envelopes; /* number of finished send envelopes */ - tMPI_Atomic_t ev_outgoing_received; - /* the p2p communication events (incoming envelopes + finished send + tMPI_Atomic_t ev_outgoing_received; + /* the p2p communication events (incoming envelopes + finished send envelopes generate events) */ - tMPI_Event p2p_event; + tMPI_Event p2p_event; TMPI_YIELD_WAIT_DATA /* data associated with waiting */ - struct req_list rql; /* list of pre-allocated requests */ + struct req_list rql; /* list of pre-allocated requests */ /* collective communication structures: */ #ifdef USE_COLLECTIVE_COPY_BUFFER /* copy buffer list for multicast communications */ - struct copy_buffer_list cbl_multi; + struct copy_buffer_list cbl_multi; #endif /* miscellaneous data: */ @@ -431,18 +431,18 @@ struct tmpi_thread /* the per-thread profile structure that keeps call counts & wait times. */ struct tmpi_profile profile; #endif - /* The start function (or NULL, if a main()-style start function is to + /* The start function (or NULL, if a main()-style start function is to be called) */ - void (*start_fn)(void*); + void (*start_fn)(void*); /* The main()-style start function */ - int (*start_fn_main)(int, char**); + int (*start_fn_main)(int, char**); /* the argument to the start function, if it's not main()*/ - void *start_arg; + void *start_arg; - /* we copy these for each thread (providing these to main() is not - required by the MPI standard, but it's convenient). Note that we copy, - because some programs (like Gromacs) like to manipulate these. */ - int argc; + /* we copy these for each thread (providing these to main() is not + required by the MPI standard, but it's convenient). Note that we copy, + because some programs (like Gromacs) like to manipulate these. */ + int argc; char **argv; }; @@ -453,15 +453,15 @@ struct tmpi_thread /************************************************************************** - ERROR HANDLER DATA STRUCTURES + ERROR HANDLER DATA STRUCTURES -**************************************************************************/ + **************************************************************************/ /* the error handler */ struct tmpi_errhandler_ { - int err; + int err; tMPI_Errhandler_fn fn; }; @@ -475,17 +475,17 @@ void tmpi_errors_return_fn(tMPI_Comm *comm, int *err); /************************************************************************** - GLOBAL DATA STRUCTURE + GLOBAL DATA STRUCTURE -**************************************************************************/ + **************************************************************************/ /* global MPI information */ struct tmpi_global { /* list of pointers to all user-defined types */ struct tmpi_datatype_ **usertypes; - int N_usertypes; - int Nalloc_usertypes; + int N_usertypes; + int Nalloc_usertypes; /* spinlock/mutex for manipulating tmpi_user_types */ tMPI_Spinlock_t datatype_lock; @@ -499,7 +499,7 @@ struct tmpi_global /* the timer for tMPI_Wtime() */ tMPI_Thread_mutex_t timer_mutex; -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) /* the time at initialization. */ struct timeval timer_init; #else @@ -524,17 +524,17 @@ struct tmpi_global /************************************************************************** - COMMUNICATOR DATA STRUCTURES + COMMUNICATOR DATA STRUCTURES -**************************************************************************/ + **************************************************************************/ struct tmpi_group_ { - int N; /* the number of threads */ + int N; /* the number of threads */ struct tmpi_thread **peers; /* the list of peers to communicate with */ #if 0 - int Nrefs; /* the number of references to this structure */ + int Nrefs; /* the number of references to this structure */ #endif }; @@ -555,26 +555,26 @@ struct tmpi_comm_ and so on. (until N/x reaches 1) This is to facilitate tree-based algorithms for tMPI_Reduce, etc. */ tMPI_Barrier_t **reduce_barrier; - int *N_reduce; /* the number of barriers in each iteration */ - int N_reduce_iter; /* the number of iterations */ + int *N_reduce; /* the number of barriers in each iteration */ + int N_reduce_iter; /* the number of iterations */ - struct coll_env *cev; /* list of multicast envelope objecs */ + struct coll_env *cev; /* list of multicast envelope objecs */ struct coll_sync *csync; /* list of multicast sync objecs */ /* lists of globally shared send/receive buffers for tMPI_Reduce. */ - tMPI_Atomic_ptr_t *reduce_sendbuf, *reduce_recvbuf; - - /* mutex for communication object creation. Traditional mutexes are - better here because communicator creation should not be done in - time-critical sections of code. */ + tMPI_Atomic_ptr_t *reduce_sendbuf, *reduce_recvbuf; + + /* mutex for communication object creation. Traditional mutexes are + better here because communicator creation should not be done in + time-critical sections of code. */ tMPI_Thread_mutex_t comm_create_lock; - tMPI_Thread_cond_t comm_create_prep; - tMPI_Thread_cond_t comm_create_finish; + tMPI_Thread_cond_t comm_create_prep; + tMPI_Thread_cond_t comm_create_finish; - tMPI_Comm *new_comm; /* newly created communicators */ + tMPI_Comm *new_comm; /* newly created communicators */ - /* the split structure is shared among the comm threads and is + /* the split structure is shared among the comm threads and is allocated & deallocated during tMPI_Comm_split */ struct tmpi_split *split; @@ -584,10 +584,10 @@ struct tmpi_comm_ tMPI_Errhandler erh; - /* links for a global circular list of all comms that starts at - TMPI_COMM_WORLD. Used to de-allocate the comm structures after + /* links for a global circular list of all comms that starts at + TMPI_COMM_WORLD. Used to de-allocate the comm structures after tMPI_Finalize(). */ - struct tmpi_comm_ *next,*prev; + struct tmpi_comm_ *next, *prev; /* A counter that counts up to N before the comm is freed. */ tMPI_Atomic_t destroy_counter; @@ -597,19 +597,19 @@ struct tmpi_comm_ /* specific for tMPI_Split: */ struct tmpi_split -{ - volatile int Ncol_init; - volatile int Ncol_destroy; +{ + volatile int Ncol_init; + volatile int Ncol_destroy; volatile tmpi_bool can_finish; - volatile int *colors; - volatile int *keys; + volatile int *colors; + volatile int *keys; }; /* cartesian topology */ struct cart_topol { - int ndims; /* number of dimensions */ - int *dims; /* procs per coordinate */ + int ndims; /* number of dimensions */ + int *dims; /* procs per coordinate */ int *periods; /* whether the grid is periodic, per dimension */ }; @@ -626,9 +626,9 @@ struct tmpi_graph_topol_ /************************************************************************** - DATA TYPE DATA STRUCTURES + DATA TYPE DATA STRUCTURES -**************************************************************************/ + **************************************************************************/ /* tMPI_Reduce Op functions */ typedef void (*tMPI_Op_fn)(void*, void*, void*, int); @@ -637,17 +637,17 @@ typedef void (*tMPI_Op_fn)(void*, void*, void*, int); struct tmpi_datatype_component { struct tmpi_datatype_ *type; - unsigned int count; + unsigned int count; }; /* we don't support datatypes with holes (yet) */ struct tmpi_datatype_ { - size_t size; /* full extent of type. */ - tMPI_Op_fn *op_functions; /* array of op functions for this datatype */ - int N_comp; /* number of components */ - struct tmpi_datatype_component *comps; /* the components */ - tmpi_bool committed; /* whether the data type is committed */ + size_t size; /* full extent of type. */ + tMPI_Op_fn *op_functions; /* array of op functions for this datatype */ + int N_comp; /* number of components */ + struct tmpi_datatype_component *comps; /* the components */ + tmpi_bool committed; /* whether the data type is committed */ }; /* just as a shorthand: */ typedef struct tmpi_datatype_ tmpi_dt; @@ -661,15 +661,15 @@ typedef struct tmpi_datatype_ tmpi_dt; /************************************************************************** - GLOBAL VARIABLES + GLOBAL VARIABLES -**************************************************************************/ + **************************************************************************/ /* the threads themselves (tmpi_comm only contains lists of pointers to this structure */ extern struct tmpi_thread *threads; -extern int Nthreads; +extern int Nthreads; /* thread info */ extern tMPI_Thread_key_t id_key; /* the key to get the thread id */ @@ -686,9 +686,9 @@ extern struct tmpi_global *tmpi_global; /************************************************************************** - FUNCTION PROTOTYPES & MACROS + FUNCTION PROTOTYPES & MACROS -**************************************************************************/ + **************************************************************************/ #ifdef TMPI_TRACE void tMPI_Trace_print(const char *fmt, ...); @@ -809,7 +809,7 @@ void tMPI_Copy_buffer_list_destroy(struct copy_buffer_list *cbl); struct copy_buffer *tMPI_Copy_buffer_list_get(struct copy_buffer_list *cbl); /* return a copy buffer to a list */ void tMPI_Copy_buffer_list_return(struct copy_buffer_list *cbl, - struct copy_buffer *cb); + struct copy_buffer *cb); /* initialize a copy buffer */ void tMPI_Copy_buffer_init(struct copy_buffer *cb, size_t size); void tMPI_Copy_buffer_destroy(struct copy_buffer *cb); @@ -824,9 +824,3 @@ int tMPI_Reduce_run_op(void *dest, void *src_a, void *src_b, /* and we need this prototype */ int main(int argc, char **argv); - - - - - - diff --git a/src/gromacs/gmxlib/thread_mpi/list.c b/src/gromacs/gmxlib/thread_mpi/list.c index 24634d0301..5c3d605a23 100644 --- a/src/gromacs/gmxlib/thread_mpi/list.c +++ b/src/gromacs/gmxlib/thread_mpi/list.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -74,23 +74,28 @@ void tMPI_Stack_push(tMPI_Stack *st, tMPI_Stack_element *el) tMPI_Stack_element *head; do { - head=(tMPI_Stack_element*)tMPI_Atomic_ptr_get( &(st->head) ); - el->next=head; + head = (tMPI_Stack_element*)tMPI_Atomic_ptr_get( &(st->head) ); + el->next = head; } while (!tMPI_Atomic_ptr_cas(&(st->head), head, el)); } tMPI_Stack_element *tMPI_Stack_pop(tMPI_Stack *st) { - tMPI_Stack_element *head,*next; + tMPI_Stack_element *head, *next; do { - head=(tMPI_Stack_element*)tMPI_Atomic_ptr_get( &(st->head) ); + head = (tMPI_Stack_element*)tMPI_Atomic_ptr_get( &(st->head) ); if (head) - next=head->next; + { + next = head->next; + } else - next=NULL; - } while (!tMPI_Atomic_ptr_cas(&(st->head), head, next)); + { + next = NULL; + } + } + while (!tMPI_Atomic_ptr_cas(&(st->head), head, next)); return head; } @@ -100,8 +105,9 @@ tMPI_Stack_element *tMPI_Stack_detach(tMPI_Stack *st) tMPI_Stack_element *head; do { - head=(tMPI_Stack_element*)tMPI_Atomic_ptr_get( &(st->head) ); - } while (!tMPI_Atomic_ptr_cas(&(st->head), head, NULL)); + head = (tMPI_Stack_element*)tMPI_Atomic_ptr_get( &(st->head) ); + } + while (!tMPI_Atomic_ptr_cas(&(st->head), head, NULL)); return head; } @@ -130,7 +136,7 @@ void tMPI_Queue_enqueue(tMPI_Queue *q, tMPI_Queue_element *qe) do { - } while (!tMPI_Atomic_ptr_cas(&(q->head), head, next)); + } + while (!tMPI_Atomic_ptr_cas(&(q->head), head, next)); } #endif - diff --git a/src/gromacs/gmxlib/thread_mpi/lock.c b/src/gromacs/gmxlib/thread_mpi/lock.c index e1e027223b..3fd19bd670 100644 --- a/src/gromacs/gmxlib/thread_mpi/lock.c +++ b/src/gromacs/gmxlib/thread_mpi/lock.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -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); } diff --git a/src/gromacs/gmxlib/thread_mpi/numa_malloc.c b/src/gromacs/gmxlib/thread_mpi/numa_malloc.c index f419b14381..5fc6206c6a 100644 --- a/src/gromacs/gmxlib/thread_mpi/numa_malloc.c +++ b/src/gromacs/gmxlib/thread_mpi/numa_malloc.c @@ -56,30 +56,30 @@ int tMPI_Free_numa(void *ptr) /* Windows NUMA memory allocation support. - NUMA support is implemented to maximize the chance that memory access - patterns remain Local to the NUMA node. This avoids penalties accessing + NUMA support is implemented to maximize the chance that memory access + patterns remain Local to the NUMA node. This avoids penalties accessing "remote" memory. - An important assumption here is that code paths which allocate and - reallocate heap blocks are likely to be accessing that allocated memory + An important assumption here is that code paths which allocate and + reallocate heap blocks are likely to be accessing that allocated memory on the same NUMA node. - Testing has shown the above criteria to be met, yielding gains of > 15% + Testing has shown the above criteria to be met, yielding gains of > 15% when on Windows with NUMA hardware. The high level approach is: - 1. Use a separate heap per NUMA node. This reduces heap contention, steers - allocations to the local NUMA node, and avoids re-use of freed heap + 1. Use a separate heap per NUMA node. This reduces heap contention, steers + allocations to the local NUMA node, and avoids re-use of freed heap blocks across (remote) NUMA nodes. - 2. Allocate each heap locally to each NUMA node, such that heap control + 2. Allocate each heap locally to each NUMA node, such that heap control structures are on the NUMA node accessing the heap. - 3. During realloc operations, transfer the new block to the local NUMA - node, if appropriate. This is a rare case when thread affinity and - access patterns are correct. - 4. Use GetProcAddress() to obtain function pointers to functions that are - operating system version dependent, to allow maximum binary - compatibility. + 3. During realloc operations, transfer the new block to the local NUMA + node, if appropriate. This is a rare case when thread affinity and + access patterns are correct. + 4. Use GetProcAddress() to obtain function pointers to functions that are + operating system version dependent, to allow maximum binary + compatibility. - Scott Field (sfield@microsoft.com) Jan-2011 - */ + Scott Field (sfield@microsoft.com) Jan-2011 + */ //#define _WIN32_WINNT 0x0601 #include @@ -87,18 +87,18 @@ int tMPI_Free_numa(void *ptr) /* - __declspec(align()) may not be supported by all compilers, so define the + __declspec(align()) may not be supported by all compilers, so define the size of the structure manually to force alignment note that HeapAlloc() already returns aligned blocks. - typedef __declspec(align(32)) struct ... -*/ + typedef __declspec(align(32)) struct ... + */ typedef struct { - DWORD dwMagic; + DWORD dwMagic; HANDLE hHeap; /* 8 */ size_t cbAllocationSize; /* 8 */ - ULONG ProcessorNumber; /* processor number at time of allocation + ULONG ProcessorNumber; /* processor number at time of allocation (development/testing) */ - USHORT NodeNumber; /* NUMA node number at time of allocation + USHORT NodeNumber; /* NUMA node number at time of allocation (development/testing) */ } HEAPHEADER, *PHEAPHEADER; @@ -110,7 +110,7 @@ typedef struct { C_ASSERT(sizeof(HEAPHEADER) <= HEAPHEADER_SIZE); #endif -/* function prototypes and variables to support obtaining function +/* function prototypes and variables to support obtaining function addresses dynamically -- supports down-level operating systems */ typedef BOOL (WINAPI *func_GetNumaHighestNodeNumber_t)( PULONG HighestNodeNumber ); @@ -125,35 +125,35 @@ func_GetCurrentProcessorNumberEx_t smalloc_GetCurrentProcessorNumberEx; #define NUMA_STATUS_NOT_NUMA (1) #define NUMA_STATUS_NUMA (2) -DWORD g_dwTlsHeap; /* TLS slot used for preferred heap handle */ -HANDLE *g_hHeap; /* array of heap handles */ -ULONG g_ulNumaStatus; /* 0 = unknown, 1 = not NUMA, 2 = NUMA */ +DWORD g_dwTlsHeap; /* TLS slot used for preferred heap handle */ +HANDLE *g_hHeap; /* array of heap handles */ +ULONG g_ulNumaStatus; /* 0 = unknown, 1 = not NUMA, 2 = NUMA */ VOID InitNumaHeapSupport( - VOID - ) + VOID + ) { - HMODULE hModKernel32; /* module handle to kernel32.dll -- we already + HMODULE hModKernel32; /* module handle to kernel32.dll -- we already reference it, so it's already loaded */ - ULONG ulNumaHighestNodeNumber; + ULONG ulNumaHighestNodeNumber; - /* grab the addresses for the NUMA functions. + /* grab the addresses for the NUMA functions. It's fine if there is a race condition reaching this routine */ hModKernel32 = GetModuleHandleA("kernel32.dll"); - if(hModKernel32 == NULL) + if (hModKernel32 == NULL) { g_ulNumaStatus = NUMA_STATUS_NOT_NUMA; return; } - smalloc_GetNumaHighestNodeNumber = (func_GetNumaHighestNodeNumber_t)GetProcAddress( hModKernel32, "GetNumaHighestNodeNumber" ); + smalloc_GetNumaHighestNodeNumber = (func_GetNumaHighestNodeNumber_t)GetProcAddress( hModKernel32, "GetNumaHighestNodeNumber" ); smalloc_GetCurrentProcessorNumberEx = (func_GetCurrentProcessorNumberEx_t)GetProcAddress( hModKernel32, "GetCurrentProcessorNumberEx" ); - smalloc_GetNumaProcessorNodeEx = (func_GetNumaProcessorNodeEx_t)GetProcAddress( hModKernel32, "GetNumaProcessorNodeEx" ); + smalloc_GetNumaProcessorNodeEx = (func_GetNumaProcessorNodeEx_t)GetProcAddress( hModKernel32, "GetNumaProcessorNodeEx" ); - if( (smalloc_GetNumaHighestNodeNumber == NULL) || - (smalloc_GetCurrentProcessorNumberEx == NULL) || - (smalloc_GetNumaProcessorNodeEx == NULL) ) + if ( (smalloc_GetNumaHighestNodeNumber == NULL) || + (smalloc_GetCurrentProcessorNumberEx == NULL) || + (smalloc_GetNumaProcessorNodeEx == NULL) ) { g_ulNumaStatus = NUMA_STATUS_NOT_NUMA; return; @@ -161,7 +161,7 @@ InitNumaHeapSupport( /* determine how many NUMA nodes are present */ - if(!smalloc_GetNumaHighestNodeNumber(&ulNumaHighestNodeNumber) || + if (!smalloc_GetNumaHighestNodeNumber(&ulNumaHighestNodeNumber) || (ulNumaHighestNodeNumber == 0) ) { g_ulNumaStatus = NUMA_STATUS_NOT_NUMA; @@ -171,26 +171,26 @@ InitNumaHeapSupport( /* handle deferred creation of TLS slot. note: this could be moved to one-time init path. failures here result in assuming the system is not NUMA. - */ + */ - if( g_dwTlsHeap == 0 ) + if (g_dwTlsHeap == 0) { DWORD dwTlsHeap = TlsAlloc(); DWORD dwPriorValue; - if( dwTlsHeap == TLS_OUT_OF_INDEXES ) + if (dwTlsHeap == TLS_OUT_OF_INDEXES) { g_ulNumaStatus = NUMA_STATUS_NOT_NUMA; return; } dwPriorValue = (DWORD)InterlockedCompareExchange( - (LONG volatile *)&g_dwTlsHeap, - (LONG) dwTlsHeap, - 0 - ); - - if( dwPriorValue != 0 ) + (LONG volatile *)&g_dwTlsHeap, + (LONG) dwTlsHeap, + 0 + ); + + if (dwPriorValue != 0) { TlsFree( dwTlsHeap ); } @@ -198,9 +198,9 @@ InitNumaHeapSupport( /* handle deferred creation of heap handle array. note: this could be moved to one-time init path. - */ + */ - if( g_hHeap == NULL ) + if (g_hHeap == NULL) { HANDLE *hHeapNew; HANDLE *hPriorValue; @@ -212,19 +212,19 @@ InitNumaHeapSupport( sizeof(HANDLE) * (ulNumaHighestNodeNumber+1) ); - if( hHeapNew == NULL ) + if (hHeapNew == NULL) { g_ulNumaStatus = NUMA_STATUS_NOT_NUMA; return; } hPriorValue = (HANDLE *)InterlockedCompareExchange( - (LONG volatile *)&g_hHeap, - (LONG) hHeapNew, - 0 - ); + (LONG volatile *)&g_hHeap, + (LONG) hHeapNew, + 0 + ); - if( hPriorValue != NULL ) + if (hPriorValue != NULL) { HeapFree(GetProcessHeap(), 0, hHeapNew); } @@ -238,83 +238,84 @@ InitNumaHeapSupport( HANDLE ReturnHeapHandle( - VOID - ) + VOID + ) { - HANDLE hHeap; /* preferred heap handle to + HANDLE hHeap; /* preferred heap handle to return to caller */ - PROCESSOR_NUMBER CurrentProcessorNumber; /* processor number associated + PROCESSOR_NUMBER CurrentProcessorNumber; /* processor number associated with calling thread */ - USHORT CurrentNumaNodeNumber; /* NUMA node number assocaited + USHORT CurrentNumaNodeNumber; /* NUMA node number assocaited with calling thread */ /* determine NUMA status of system. */ - if( g_ulNumaStatus == NUMA_STATUS_UNKNOWN ) + if (g_ulNumaStatus == NUMA_STATUS_UNKNOWN) { InitNumaHeapSupport(); - if( g_ulNumaStatus == NUMA_STATUS_NOT_NUMA ) + if (g_ulNumaStatus == NUMA_STATUS_NOT_NUMA) { return GetProcessHeap(); } - } else if( g_ulNumaStatus == NUMA_STATUS_NOT_NUMA ) + } + else if (g_ulNumaStatus == NUMA_STATUS_NOT_NUMA) { /* not NUMA, return the process heap handle */ return GetProcessHeap(); } - /* return the preferred heap handle from the TLS slot, if set. + /* return the preferred heap handle from the TLS slot, if set. This is the commonly taken path. */ hHeap = (HANDLE)TlsGetValue( g_dwTlsHeap ); - if( hHeap != NULL ) + if (hHeap != NULL) { return hHeap; } /* preferred heap handle not yet set. - determine the numa node we're executing on, and create a heap which + determine the numa node we're executing on, and create a heap which is assigned to this node. - one (soft) assumption that is made here is that thread affinity has + one (soft) assumption that is made here is that thread affinity has been set such that threads do not move between NUMA nodes. - */ + */ smalloc_GetCurrentProcessorNumberEx(&CurrentProcessorNumber); - - if(!smalloc_GetNumaProcessorNodeEx(&CurrentProcessorNumber, &CurrentNumaNodeNumber)) + + if (!smalloc_GetNumaProcessorNodeEx(&CurrentProcessorNumber, &CurrentNumaNodeNumber)) { - /* GetNumaProcessorNodeEx() can fail on WOW64/32bit if invoked + /* GetNumaProcessorNodeEx() can fail on WOW64/32bit if invoked against processor numbers > 32. this should never be reached for 64bit builds. - */ + */ CurrentNumaNodeNumber = 0; } /* check if the NUMA node array slot already contains a heap */ - /* CurrentNumaNodeNumber cannot execeed count of heaps, as NUMA nodes + /* CurrentNumaNodeNumber cannot execeed count of heaps, as NUMA nodes cannot be added. */ hHeap = g_hHeap[ CurrentNumaNodeNumber ]; - if( hHeap == NULL ) + if (hHeap == NULL) { HANDLE hHeapPrior = NULL; - ULONG ulOption = 2; /* HEAP_LFH */ + ULONG ulOption = 2; /* HEAP_LFH */ /* create a heap for this numa node - defer creating the heap - while running on each node - to ensure + defer creating the heap - while running on each node - to ensure the heap control structures get created on the local NUMA node. - */ + */ hHeap = HeapCreate(0, 0, 0); - - if( hHeap == NULL ) + + if (hHeap == NULL) { - /* just return the process heap. We'll try to create a heap + /* just return the process heap. We'll try to create a heap again next time */ return GetProcessHeap(); } @@ -328,18 +329,18 @@ ReturnHeapHandle( sizeof(ulOption) ); - /* set the array slot entry for this NUMA node to contain the newly + /* set the array slot entry for this NUMA node to contain the newly allocated heap */ hHeapPrior = (HANDLE)InterlockedCompareExchangePointer(&(g_hHeap[CurrentNumaNodeNumber]), hHeap, NULL); - if( hHeapPrior != NULL ) + if (hHeapPrior != NULL) { HeapDestroy( hHeap ); hHeap = hHeapPrior; } } - /* we reached here since there was no heap assigned to the TLS slot. + /* we reached here since there was no heap assigned to the TLS slot. Assign it. */ TlsSetValue(g_dwTlsHeap, hHeap); @@ -351,10 +352,10 @@ ReturnHeapHandle( void *tMPI_Malloc_local(size_t size) { - HANDLE hHeap; + HANDLE hHeap; unsigned char *ptr; - size_t new_size; - HEAPHEADER *phdr; + size_t new_size; + HEAPHEADER *phdr; hHeap = ReturnHeapHandle(); @@ -362,17 +363,17 @@ void *tMPI_Malloc_local(size_t size) ptr = (unsigned char *)HeapAlloc( hHeap, 0, new_size ); - if( ptr == NULL ) + if (ptr == NULL) { return NULL; } phdr = (HEAPHEADER*)ptr; - phdr->dwMagic = HEAP_NUMA_MAGIC; - phdr->hHeap = hHeap; /* track the heap handle for realloc + phdr->dwMagic = HEAP_NUMA_MAGIC; + phdr->hHeap = hHeap; /* track the heap handle for realloc and free */ - phdr->cbAllocationSize = new_size; /* track the allocation size for + phdr->cbAllocationSize = new_size; /* track the allocation size for realloc and debugging */ return ( ptr + HEAPHEADER_SIZE ); @@ -381,12 +382,12 @@ void *tMPI_Malloc_local(size_t size) void *tMPI_Calloc_local(size_t nelem, size_t elsize) { - void *ptr; + void *ptr; size_t size = nelem * elsize; ptr = tMPI_Malloc_local(size); - if(ptr != NULL) + if (ptr != NULL) { memset(ptr, 0, size); } @@ -397,78 +398,82 @@ void *tMPI_Calloc_local(size_t nelem, size_t elsize) void *tMPI_Realloc_local(void *ptr, size_t size) { - HANDLE hHeap; - HEAPHEADER *phdr; + HANDLE hHeap; + HEAPHEADER *phdr; unsigned char *new_ptr; - size_t new_size; + size_t new_size; - /* calculate the allocation address and check for presence of the hint + /* calculate the allocation address and check for presence of the hint which indicates this was allocated by our allocator. - */ + */ phdr = (HEAPHEADER*)((unsigned char*)ptr - HEAPHEADER_SIZE); - if( phdr->dwMagic != HEAP_NUMA_MAGIC ) + if (phdr->dwMagic != HEAP_NUMA_MAGIC) { - /* TODO: call tMPI_Error() */ + /* TODO: call tMPI_Error() */ /*gmx_fatal(errno,__FILE__,__LINE__, - "Invalid Heap header during realloc. %p", ptr);*/ + "Invalid Heap header during realloc. %p", ptr);*/ return NULL; } /* calculate size of new/realloc'd block. - */ + */ new_size = size + HEAPHEADER_SIZE; - /* if the NUMA Node changed between the initial allocation and the + /* if the NUMA Node changed between the initial allocation and the reallocation, copy the memory to an allocation on the new local node: - we assume the new realloc'd block is more likely to be manipulated by + we assume the new realloc'd block is more likely to be manipulated by the current thread which is calling realloc. - the simple way to detect this condition is to compare the preferred heap + the simple way to detect this condition is to compare the preferred heap handle with the heap handle stored in the current memory block. - */ + */ hHeap = ReturnHeapHandle(); - if( hHeap != phdr->hHeap ) + if (hHeap != phdr->hHeap) { new_ptr = HeapAlloc( hHeap, 0, new_size ); - /* if the new allocation succeeded, copy the buffer and free the + /* if the new allocation succeeded, copy the buffer and free the original buffer. - */ + */ - if( new_ptr != NULL ) + if (new_ptr != NULL) { size_t copy_size; - /* the realloc can be larger or smaller than the original + /* the realloc can be larger or smaller than the original allocation size. - */ + */ - if( new_size > phdr->cbAllocationSize ) + if (new_size > phdr->cbAllocationSize) { copy_size = phdr->cbAllocationSize; - } else { + } + else + { copy_size = new_size; } - /* copy the current memory block contents into the newly allocated + /* copy the current memory block contents into the newly allocated buffer, and then free the original buffer. - */ + */ memcpy( new_ptr, phdr, copy_size ); HeapFree( phdr->hHeap, 0, phdr ); } - - } else { + + } + else + { /* NodeNumber of existing allocation matches current node number. realloc from the heap associated with the existing allocation. - */ + */ hHeap = phdr->hHeap; @@ -480,15 +485,15 @@ void *tMPI_Realloc_local(void *ptr, size_t size) ); } - if( new_ptr == NULL ) + if (new_ptr == NULL) { return NULL; } - phdr = (HEAPHEADER*)new_ptr; - phdr->cbAllocationSize = new_size; /* update allocation size to match + phdr = (HEAPHEADER*)new_ptr; + phdr->cbAllocationSize = new_size; /* update allocation size to match realloc */ - phdr->hHeap = hHeap; + phdr->hHeap = hHeap; return ( new_ptr + HEAPHEADER_SIZE ); } @@ -498,21 +503,21 @@ int tMPI_Free_numa(void *ptr) { HEAPHEADER *phdr; - /* caller doesn't call us on ptr == NULL case, so we don't need to + /* caller doesn't call us on ptr == NULL case, so we don't need to check that here. */ phdr = (HEAPHEADER*)((unsigned char*)ptr - HEAPHEADER_SIZE); - /* this check should happen in __try / __except block until the + /* this check should happen in __try / __except block until the mis-matched free/sfree calls are fixed, but this is here primarilly for debugging and catching mis-matched memory alloc and free references. - */ + */ - if(phdr->dwMagic != HEAP_NUMA_MAGIC) + if (phdr->dwMagic != HEAP_NUMA_MAGIC) { /* ptr is leaked here, rather than faulting in the allocator. this is done in order to track mis-matched alloc/free calls. - */ + */ return 1; } @@ -524,7 +529,3 @@ int tMPI_Free_numa(void *ptr) } #endif /* NUMA allocation functions for (_WIN32 || _WIN64) */ - - - - diff --git a/src/gromacs/gmxlib/thread_mpi/once.c b/src/gromacs/gmxlib/thread_mpi/once.c index bee468ceea..5c659d095f 100644 --- a/src/gromacs/gmxlib/thread_mpi/once.c +++ b/src/gromacs/gmxlib/thread_mpi/once.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -58,50 +58,52 @@ files. /* once */ -int tMPI_Once(tMPI_Comm comm, void (*function)(void*), void *param, - int *was_first) +int tMPI_Once(tMPI_Comm comm, void (*function)(void*), void *param, + int *was_first) { - int myrank; - int ret=TMPI_SUCCESS; + int myrank; + int ret = TMPI_SUCCESS; struct coll_sync *csync; - struct coll_env *cev; - int syncs; + struct coll_env *cev; + int syncs; if (!comm) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - myrank=tMPI_Comm_seek_rank(comm, tMPI_Get_current()); + myrank = tMPI_Comm_seek_rank(comm, tMPI_Get_current()); /* we increase our counter, and determine which coll_env we get */ - csync=&(comm->csync[myrank]); + csync = &(comm->csync[myrank]); csync->syncs++; - cev=&(comm->cev[csync->syncs % N_COLL_ENV]); + cev = &(comm->cev[csync->syncs % N_COLL_ENV]); /* now do a compare-and-swap on the current_syncc */ - syncs=tMPI_Atomic_get( &(cev->coll.current_sync)); - if ((csync->syncs - syncs > 0) && /* check if sync was an earlier number. - If it is a later number, we can't + syncs = tMPI_Atomic_get( &(cev->coll.current_sync)); + if ((csync->syncs - syncs > 0) && /* check if sync was an earlier number. + If it is a later number, we can't have been the first to arrive here. */ tMPI_Atomic_cas(&(cev->coll.current_sync), syncs, csync->syncs)) { /* we're the first! */ function(param); if (was_first) - *was_first=TRUE; + { + *was_first = TRUE; + } } return ret; } -void* tMPI_Once_wait(tMPI_Comm comm, void* (*function)(void*), void *param, +void* tMPI_Once_wait(tMPI_Comm comm, void* (*function)(void*), void *param, int *was_first) { - int myrank; + int myrank; struct coll_sync *csync; - struct coll_env *cev; - int syncs; - void *ret; + struct coll_env *cev; + int syncs; + void *ret; if (!comm) @@ -109,31 +111,33 @@ void* tMPI_Once_wait(tMPI_Comm comm, void* (*function)(void*), void *param, tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); return NULL; } - myrank=tMPI_Comm_seek_rank(comm, tMPI_Get_current()); + myrank = tMPI_Comm_seek_rank(comm, tMPI_Get_current()); /* we increase our counter, and determine which coll_env we get */ - csync=&(comm->csync[myrank]); + csync = &(comm->csync[myrank]); csync->syncs++; - cev=&(comm->cev[csync->syncs % N_COLL_ENV]); + cev = &(comm->cev[csync->syncs % N_COLL_ENV]); /* now do a compare-and-swap on the current_syncc */ - syncs=tMPI_Atomic_get( &(cev->coll.current_sync)); + syncs = tMPI_Atomic_get( &(cev->coll.current_sync)); tMPI_Atomic_memory_barrier_acq(); - if ((csync->syncs - syncs > 0) && /* check if sync was an earlier number. - If it is a later number, we can't - have been the first to arrive here. + if ((csync->syncs - syncs > 0) && /* check if sync was an earlier number. + If it is a later number, we can't + have been the first to arrive here. Calculating the difference instead - of comparing directly avoids ABA + of comparing directly avoids ABA problems. */ tMPI_Atomic_cas(&(cev->coll.current_sync), syncs, csync->syncs)) { /* we're the first! */ - ret=function(param); + ret = function(param); if (was_first) - *was_first=TRUE; + { + *was_first = TRUE; + } /* broadcast the output data */ - cev->coll.res=ret; + cev->coll.res = ret; tMPI_Atomic_memory_barrier_rel(); /* signal that we're done */ @@ -148,11 +152,12 @@ void* tMPI_Once_wait(tMPI_Comm comm, void* (*function)(void*), void *param, do { /*tMPI_Atomic_memory_barrier();*/ - syncs=tMPI_Atomic_get( &(cev->coll.current_sync) ); - } while (csync->syncs - syncs > 0); /* difference again due to ABA + syncs = tMPI_Atomic_get( &(cev->coll.current_sync) ); + } + while (csync->syncs - syncs > 0); /* difference again due to ABA problems */ tMPI_Atomic_memory_barrier_acq(); - ret=cev->coll.res; + ret = cev->coll.res; } return ret; } @@ -160,7 +165,7 @@ void* tMPI_Once_wait(tMPI_Comm comm, void* (*function)(void*), void *param, static void *tMPI_Shmallocator(void *prm) { - size_t sz=*((size_t*)prm); + size_t sz = *((size_t*)prm); return malloc(sz); } @@ -168,6 +173,3 @@ void *tMPI_Shmalloc(tMPI_Comm comm, size_t size) { return tMPI_Once_wait(comm, tMPI_Shmallocator, &size, NULL); } - - - diff --git a/src/gromacs/gmxlib/thread_mpi/p2p.h b/src/gromacs/gmxlib/thread_mpi/p2p.h index d14585c779..d3a8b8cc64 100644 --- a/src/gromacs/gmxlib/thread_mpi/p2p.h +++ b/src/gromacs/gmxlib/thread_mpi/p2p.h @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ /* request list: */ @@ -54,12 +54,12 @@ void tMPI_Wait_process_incoming(struct tmpi_thread *th); /* check for the completion of a single request */ -tmpi_bool tMPI_Test_single(struct tmpi_thread *cur, - struct tmpi_req_ *rq); +tmpi_bool tMPI_Test_single(struct tmpi_thread *cur, + struct tmpi_req_ *rq); /* check and wait for the completion of a single request */ void tMPI_Wait_single(struct tmpi_thread *cur, struct tmpi_req_ *rq); -/* check for the completion of a NULL-delimited doubly linked list of +/* check for the completion of a NULL-delimited doubly linked list of requests */ tmpi_bool tMPI_Test_multi(struct tmpi_thread *cur, struct tmpi_req_ *rqs, tmpi_bool *any_done); @@ -85,5 +85,3 @@ struct envelope* tMPI_Post_match_recv(struct tmpi_thread *cur, void *recv_buf, int recv_count, tMPI_Datatype datatype, int tag, tmpi_bool nonblock); - - diff --git a/src/gromacs/gmxlib/thread_mpi/p2p_buffer.c b/src/gromacs/gmxlib/thread_mpi/p2p_buffer.c index f6ad352bfb..dfcd86b86c 100644 --- a/src/gromacs/gmxlib/thread_mpi/p2p_buffer.c +++ b/src/gromacs/gmxlib/thread_mpi/p2p_buffer.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -68,4 +68,3 @@ int MPI_Buffer_attach(void* buffer, int size) int MPI_Buffer_detach(void* buffer_addr, int* size) { } - diff --git a/src/gromacs/gmxlib/thread_mpi/p2p_protocol.c b/src/gromacs/gmxlib/thread_mpi/p2p_protocol.c index 7d2a511e47..c1d565cf81 100644 --- a/src/gromacs/gmxlib/thread_mpi/p2p_protocol.c +++ b/src/gromacs/gmxlib/thread_mpi/p2p_protocol.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -65,7 +65,7 @@ static struct envelope *tMPI_Free_env_list_fetch_recv(struct free_envelope_list /* return an envelope to the free envelopes list */ static void tMPI_Free_env_list_return_recv(struct free_envelope_list *evl, - struct envelope *rev); + struct envelope *rev); @@ -73,13 +73,13 @@ static void tMPI_Free_env_list_return_recv(struct free_envelope_list *evl, /* send envelopes: */ /* get a new envelope from the send list's free envelope list */ static struct envelope* tMPI_Send_env_list_fetch_new(struct - send_envelope_list *evl); + send_envelope_list *evl); -/* return a send envelope to the send list's free envelope list, +/* return a send envelope to the send list's free envelope list, (to be used by the sending thread, who owns the send_envelope_list) */ static void tMPI_Send_env_list_return(struct envelope *ev); #ifdef USE_SEND_RECV_COPY_BUFFER -/* return a send envelope to the sender's send list. +/* return a send envelope to the sender's send list. (to be used by the receiving thread). */ static void tMPI_Send_env_list_rts(struct envelope *sev); #endif @@ -89,17 +89,17 @@ static void tMPI_Send_env_list_rts(struct envelope *sev); /* send envelopes: */ /* remove a send envelope from its head_old list. Does not lock */ -static void tMPI_Send_env_list_remove_old(struct envelope *sev); +static void tMPI_Send_env_list_remove_old(struct envelope *sev); /* add a send envelope to the new envelopes queue in a list */ -static void tMPI_Send_env_list_add_new(struct tmpi_thread *cur, +static void tMPI_Send_env_list_add_new(struct tmpi_thread *cur, struct send_envelope_list *evl, - struct envelope *sev); -/* move a send envelope to the old envelopes queue in a list. + struct envelope *sev); +/* move a send envelope to the old envelopes queue in a list. Assumes that this is safe to do without interference from other threads, i.e. the list it's in must have been detached. */ -static void tMPI_Send_env_list_move_to_old(struct envelope *sev); +static void tMPI_Send_env_list_move_to_old(struct envelope *sev); @@ -107,7 +107,7 @@ static void tMPI_Send_env_list_move_to_old(struct envelope *sev); /* receive envelopes: */ /* add a receive envelope to a list */ static void tMPI_Recv_env_list_add(struct recv_envelope_list *evl, - struct envelope *ev); + struct envelope *ev); /* remove a receive envelope from its list */ static void tMPI_Recv_env_list_remove(struct envelope *ev); @@ -115,7 +115,7 @@ static void tMPI_Recv_env_list_remove(struct envelope *ev); /* do the actual point-to-point transfer */ -static void tMPI_Xfer(struct tmpi_thread *cur, struct envelope *sev, +static void tMPI_Xfer(struct tmpi_thread *cur, struct envelope *sev, struct envelope *rev); @@ -127,60 +127,60 @@ void tMPI_Free_env_list_init(struct free_envelope_list *evl, int N) int i; /* allocate the head element */ - evl->recv_alloc_head=(struct envelope*)tMPI_Malloc(sizeof(struct envelope) - *N); - evl->head_recv=evl->recv_alloc_head; + evl->recv_alloc_head = (struct envelope*)tMPI_Malloc(sizeof(struct envelope) + *N); + evl->head_recv = evl->recv_alloc_head; - for(i=0;ihead_recv[i].next=&(evl->head_recv[i+1]); + evl->head_recv[i].next = &(evl->head_recv[i+1]); } else { - evl->head_recv[i].next=NULL; + evl->head_recv[i].next = NULL; } - evl->head_recv[i].rlist=NULL; - evl->head_recv[i].slist=NULL; + evl->head_recv[i].rlist = NULL; + evl->head_recv[i].slist = NULL; } } void tMPI_Free_env_list_destroy(struct free_envelope_list *evl) { free(evl->recv_alloc_head); - evl->head_recv=NULL; - evl->recv_alloc_head=NULL; + evl->head_recv = NULL; + evl->recv_alloc_head = NULL; } -static struct envelope* tMPI_Free_env_list_fetch_recv(struct +static struct envelope* tMPI_Free_env_list_fetch_recv(struct free_envelope_list *evl) { struct envelope *ret; - if (! evl->head_recv ) + if (!evl->head_recv) { /* TODO: make this do something better than crash */ fprintf(stderr, "Ran out of recv envelopes!!!!\n"); abort(); } - ret=evl->head_recv; - evl->head_recv=ret->next; - ret->next=NULL; - ret->prev=NULL; + ret = evl->head_recv; + evl->head_recv = ret->next; + ret->next = NULL; + ret->prev = NULL; /*evl->N--;*/ return ret; } static void tMPI_Free_env_list_return_recv(struct free_envelope_list *evl, - struct envelope *rev) + struct envelope *rev) { - rev->rlist=NULL; - rev->slist=NULL; - rev->prev=NULL; - rev->next=evl->head_recv; - evl->head_recv=rev; + rev->rlist = NULL; + rev->slist = NULL; + rev->prev = NULL; + rev->next = evl->head_recv; + evl->head_recv = rev; } @@ -201,20 +201,20 @@ void tMPI_Send_env_list_init(struct send_envelope_list *evl, int N) tMPI_Spinlock_init( &(evl->lock_rts) ); tMPI_Spinlock_init( &(evl->lock_new) ); #endif - evl->Nalloc=N; - - evl->alloc_head=(struct envelope*)tMPI_Malloc(sizeof(struct envelope)*N); - for(i=0;ialloc_head[i].next=(i<(N-1)) ? &(evl->alloc_head[i+1]) : NULL; - evl->alloc_head[i].prev=NULL; - evl->alloc_head[i].slist=evl; - evl->alloc_head[i].rlist=NULL; + evl->Nalloc = N; + + evl->alloc_head = (struct envelope*)tMPI_Malloc(sizeof(struct envelope)*N); + for (i = 0; i < N; i++) + { + evl->alloc_head[i].next = (i < (N-1)) ? &(evl->alloc_head[i+1]) : NULL; + evl->alloc_head[i].prev = NULL; + evl->alloc_head[i].slist = evl; + evl->alloc_head[i].rlist = NULL; #ifdef USE_SEND_RECV_COPY_BUFFER - evl->alloc_head[i].cb=(void*)tMPI_Malloc(sizeof(char)*COPY_BUFFER_SIZE); + evl->alloc_head[i].cb = (void*)tMPI_Malloc(sizeof(char)*COPY_BUFFER_SIZE); #endif } - + #ifdef TMPI_LOCK_FREE_LISTS tMPI_Atomic_ptr_set(&(evl->head_new), NULL); tMPI_Atomic_ptr_set(&(evl->head_rts), NULL); @@ -224,7 +224,7 @@ void tMPI_Send_env_list_init(struct send_envelope_list *evl, int N) #endif evl->head_free = &(evl->alloc_head[1]); /* initialize the head_old circular list with dummy element */ - evl->head_old = evl->alloc_head; /* the first element is a dummy */ + evl->head_old = evl->alloc_head; /* the first element is a dummy */ evl->head_old->next = evl->head_old; evl->head_old->prev = evl->head_old; } @@ -233,23 +233,23 @@ void tMPI_Send_env_list_destroy(struct send_envelope_list *evl) { #ifdef USE_SEND_RECV_COPY_BUFFER size_t i; - for(i=0;iNalloc;i++) + for (i = 0; i < evl->Nalloc; i++) { free(evl->alloc_head[i].cb); } #endif free(evl->alloc_head); - evl->alloc_head=NULL; + evl->alloc_head = NULL; #ifdef TMPI_LOCK_FREE_LISTS tMPI_Atomic_ptr_set(&(evl->head_new), NULL); #else - evl->head_new=NULL; + evl->head_new = NULL; #endif - evl->head_old=NULL; /* make it crash if used after tMPI_Finalize */ + evl->head_old = NULL; /* make it crash if used after tMPI_Finalize */ } -static struct envelope* tMPI_Send_env_list_fetch_new(struct +static struct envelope* tMPI_Send_env_list_fetch_new(struct send_envelope_list *evl) { struct envelope *ret; @@ -258,7 +258,7 @@ static struct envelope* tMPI_Send_env_list_fetch_new(struct { /* first check whether any envelopes were returned to sender */ #ifdef TMPI_LOCK_FREE_LISTS - if ((ret=(struct envelope*)tMPI_Atomic_ptr_get(&(evl->head_rts)))) + if ((ret = (struct envelope*)tMPI_Atomic_ptr_get(&(evl->head_rts)))) #else if (evl->head_rts) #endif @@ -266,30 +266,30 @@ static struct envelope* tMPI_Send_env_list_fetch_new(struct /* detach the list */ #ifdef TMPI_LOCK_FREE_LISTS /* we detach by swapping what we expect the pointer value to be, - with NULL. If there were a cross-platform way to atomically + with NULL. If there were a cross-platform way to atomically swap without checking, we could do that, too. */ - while(!tMPI_Atomic_ptr_cas( &(evl->head_rts), ret, NULL )) + while (!tMPI_Atomic_ptr_cas( &(evl->head_rts), ret, NULL )) { - ret=(struct envelope*)tMPI_Atomic_ptr_get(&(evl->head_rts)); + ret = (struct envelope*)tMPI_Atomic_ptr_get(&(evl->head_rts)); } #else tMPI_Spinlock_lock( &(evl->lock_rts) ); - ret=evl->head_rts; - evl->head_rts=NULL; + ret = evl->head_rts; + evl->head_rts = NULL; tMPI_Spinlock_unlock( &(evl->lock_rts) ); #endif /* now add the items to head_free */ - while(ret) + while (ret) { - struct envelope *next=ret->next; - ret->next=evl->head_free; - evl->head_free=ret; - ret=next; + struct envelope *next = ret->next; + ret->next = evl->head_free; + evl->head_free = ret; + ret = next; } } /* get the last free one off the list */ - ret=evl->head_free; + ret = evl->head_free; if (!ret) #ifdef USE_SEND_RECV_COPY_BUFFER { @@ -300,7 +300,7 @@ static struct envelope* tMPI_Send_env_list_fetch_new(struct } #else { - /* If this happens, it most likely indicates a bug in the + /* If this happens, it most likely indicates a bug in the calling program. We could fix the situation by waiting, but that would most likely lead to deadlocks - even more difficult to debug than this. */ @@ -308,14 +308,15 @@ static struct envelope* tMPI_Send_env_list_fetch_new(struct abort(); } #endif - } while(!ret); + } + while (!ret); - evl->head_free=ret->next; + evl->head_free = ret->next; - ret->next=NULL; - ret->prev=NULL; - ret->slist=evl; - ret->rlist=NULL; + ret->next = NULL; + ret->prev = NULL; + ret->slist = evl; + ret->rlist = NULL; /* and return it */ return ret; @@ -323,32 +324,32 @@ static struct envelope* tMPI_Send_env_list_fetch_new(struct static void tMPI_Send_env_list_return(struct envelope *sev) { - struct send_envelope_list *evl=sev->slist; + struct send_envelope_list *evl = sev->slist; - sev->next=evl->head_free; - evl->head_free=sev; + sev->next = evl->head_free; + evl->head_free = sev; } #ifdef USE_SEND_RECV_COPY_BUFFER static void tMPI_Send_env_list_rts(struct envelope *sev) { - struct send_envelope_list *evl=sev->slist; + struct send_envelope_list *evl = sev->slist; #ifdef TMPI_LOCK_FREE_LISTS - struct envelope *sevn; + struct envelope *sevn; do { - sevn=(struct envelope*)tMPI_Atomic_ptr_get(&evl->head_rts); - sev->next=sevn; + sevn = (struct envelope*)tMPI_Atomic_ptr_get(&evl->head_rts); + sev->next = sevn; /* the cmpxchg operation is a memory fence, so we shouldn't need to worry about out-of-order evaluation */ } while (!tMPI_Atomic_ptr_cas( &(evl->head_rts), sevn, sev )); #else tMPI_Spinlock_lock( &(evl->lock_rts) ); - ev->next=(struct envelope*)evl->head_rts; - evl->head_rts=sev; + ev->next = (struct envelope*)evl->head_rts; + evl->head_rts = sev; tMPI_Spinlock_unlock( &(evl->lock_rts) ); #endif } @@ -360,47 +361,52 @@ static void tMPI_Send_env_list_remove_old(struct envelope *sev) { /* pretty straighforward because it isn't a shared list */ if (sev->next) - sev->next->prev=sev->prev; + { + sev->next->prev = sev->prev; + } if (sev->prev) - sev->prev->next=sev->next; - sev->prev=NULL; - sev->next=NULL; + { + sev->prev->next = sev->next; + } + sev->prev = NULL; + sev->next = NULL; } -static void tMPI_Send_env_list_add_new(struct tmpi_thread *cur, - struct send_envelope_list *evl, - struct envelope *sev) +static void tMPI_Send_env_list_add_new(struct tmpi_thread *cur, + struct send_envelope_list *evl, + struct envelope *sev) { #ifdef TMPI_LOCK_FREE_LISTS struct envelope *evl_head_new_orig; #endif - sev->prev=NULL; + sev->prev = NULL; #ifdef TMPI_LOCK_FREE_LISTS - /* behold our lock-free shared linked list: - (it's actually quite simple because we only do operations at the head + /* behold our lock-free shared linked list: + (it's actually quite simple because we only do operations at the head of the list, either adding them - such as here - or detaching the whole list) */ - do + do { /* read the old head atomically */ - evl_head_new_orig=(struct envelope*) tMPI_Atomic_ptr_get( - &(evl->head_new) ); + evl_head_new_orig = (struct envelope*) tMPI_Atomic_ptr_get( + &(evl->head_new) ); /* set our envelope to have that as its next */ - sev->next=evl_head_new_orig; - /* do the compare-and-swap. + sev->next = evl_head_new_orig; + /* do the compare-and-swap. this operation is a memory fence, so we shouldn't need - to worry about out-of-order stores. If it returns false, + to worry about out-of-order stores. If it returns false, somebody else got there before us: */ - } while (!tMPI_Atomic_ptr_cas(&(evl->head_new), evl_head_new_orig, sev)); + } + while (!tMPI_Atomic_ptr_cas(&(evl->head_new), evl_head_new_orig, sev)); #else tMPI_Spinlock_lock( &(evl->lock_new) ); /* we add to the start of the list */ - sev->next=(struct send_envelope*)evl->head_new; + sev->next = (struct send_envelope*)evl->head_new; /* actually attach it to the list */ - evl->head_new=sev; + evl->head_new = sev; tMPI_Spinlock_unlock( &(evl->lock_new) ); #endif @@ -416,20 +422,24 @@ static void tMPI_Send_env_list_add_new(struct tmpi_thread *cur, static void tMPI_Send_env_list_move_to_old(struct envelope *sev) { - struct send_envelope_list *evl=sev->slist; + struct send_envelope_list *evl = sev->slist; /* remove from old list. We assume the list has been detached! */ if (sev->next) - sev->next->prev=sev->prev; + { + sev->next->prev = sev->prev; + } if (sev->prev) - sev->prev->next=sev->next; + { + sev->prev->next = sev->next; + } /* we add to the end of the list */ - sev->next=evl->head_old; - sev->prev=evl->head_old->prev; + sev->next = evl->head_old; + sev->prev = evl->head_old->prev; - sev->next->prev=sev; - sev->prev->next=sev; + sev->next->prev = sev; + sev->prev->next = sev; } @@ -443,37 +453,41 @@ static void tMPI_Send_env_list_move_to_old(struct envelope *sev) void tMPI_Recv_env_list_init(struct recv_envelope_list *evl) { - evl->head = &(evl->dummy); - evl->head->prev=evl->head; - evl->head->next=evl->head; + evl->head = &(evl->dummy); + evl->head->prev = evl->head; + evl->head->next = evl->head; } void tMPI_Recv_env_list_destroy(struct recv_envelope_list *evl) { - evl->head=NULL; + evl->head = NULL; } -static void tMPI_Recv_env_list_add(struct recv_envelope_list *evl, - struct envelope *rev) +static void tMPI_Recv_env_list_add(struct recv_envelope_list *evl, + struct envelope *rev) { - rev->rlist=evl; + rev->rlist = evl; /* we add to the end of the list */ - rev->next=evl->head; - rev->prev=evl->head->prev; + rev->next = evl->head; + rev->prev = evl->head->prev; - rev->next->prev=rev; - rev->prev->next=rev; + rev->next->prev = rev; + rev->prev->next = rev; } static void tMPI_Recv_env_list_remove(struct envelope *rev) { if (rev->next) - rev->next->prev=rev->prev; + { + rev->next->prev = rev->prev; + } if (rev->prev) - rev->prev->next=rev->next; - rev->prev=NULL; - rev->next=NULL; - rev->rlist=NULL; + { + rev->prev->next = rev->next; + } + rev->prev = NULL; + rev->next = NULL; + rev->rlist = NULL; } @@ -489,36 +503,44 @@ void tMPI_Req_list_init(struct req_list *rl, int N_reqs) { int i; - rl->alloc_head=(struct tmpi_req_*)tMPI_Malloc( - sizeof(struct tmpi_req_)*N_reqs); - rl->head=rl->alloc_head; - for(i=0;ialloc_head = (struct tmpi_req_*)tMPI_Malloc( + sizeof(struct tmpi_req_)*N_reqs); + rl->head = rl->alloc_head; + for (i = 0; i < N_reqs; i++) { - if (i==0) - rl->head[i].prev=NULL; + if (i == 0) + { + rl->head[i].prev = NULL; + } else - rl->head[i].prev=&(rl->head[i-1]); + { + rl->head[i].prev = &(rl->head[i-1]); + } if (i >= (N_reqs-1)) - rl->head[i].next=NULL; + { + rl->head[i].next = NULL; + } else - rl->head[i].next=&(rl->head[i+1]); + { + rl->head[i].next = &(rl->head[i+1]); + } } } void tMPI_Req_list_destroy(struct req_list *rl) { free(rl->alloc_head); - rl->head=NULL; - rl->alloc_head=NULL; + rl->head = NULL; + rl->alloc_head = NULL; } struct tmpi_req_ *tMPI_Get_req(struct req_list *rl) { - struct tmpi_req_ *req=rl->head; - + struct tmpi_req_ *req = rl->head; + /* we don't need locks here because requests are a per-thread property */ if (!req) @@ -527,34 +549,34 @@ struct tmpi_req_ *tMPI_Get_req(struct req_list *rl) tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_REQUESTS); return NULL; } - rl->head=req->next; - req->next=NULL; + rl->head = req->next; + req->next = NULL; return req; } void tMPI_Return_req(struct req_list *rl, struct tmpi_req_ *req) { - req->next=rl->head; - req->prev=NULL; - rl->head=req; + req->next = rl->head; + req->prev = NULL; + rl->head = req; } void tMPI_Req_init(struct tmpi_req_ *rq, struct envelope *ev) { - rq->ev=ev; - rq->finished=FALSE; - rq->next=rq; - rq->prev=rq; - - rq->source=ev->src; - rq->comm=ev->comm; - rq->tag=TMPI_ANY_TAG; - rq->error=TMPI_SUCCESS; - rq->transferred=0; - rq->cancelled=FALSE; + rq->ev = ev; + rq->finished = FALSE; + rq->next = rq; + rq->prev = rq; + + rq->source = ev->src; + rq->comm = ev->comm; + rq->tag = TMPI_ANY_TAG; + rq->error = TMPI_SUCCESS; + rq->transferred = 0; + rq->cancelled = FALSE; } @@ -569,22 +591,30 @@ void tMPI_Req_init(struct tmpi_req_ *rq, struct envelope *ev) void tMPI_Set_req(struct envelope *ev, struct tmpi_req_ *req) { req->source = ev->src; - req->comm = ev->comm; - req->tag = ev->tag; - req->error = ev->error; + req->comm = ev->comm; + req->tag = ev->tag; + req->error = ev->error; if (ev->send) { - if (tMPI_Atomic_get(&(ev->state))>env_unmatched) + if (tMPI_Atomic_get(&(ev->state)) > env_unmatched) + { req->transferred = ev->bufsize; + } else + { req->transferred = 0; + } } else { - if (tMPI_Atomic_get(&(ev->state))==env_finished) + if (tMPI_Atomic_get(&(ev->state)) == env_finished) + { req->transferred = ev->bufsize; + } else + { req->transferred = 0; + } } } @@ -593,10 +623,10 @@ void tMPI_Set_status(struct tmpi_req_ *req, tMPI_Status *st) if (st) { st->TMPI_SOURCE = tMPI_Comm_seek_rank(req->comm, req->source); - st->TMPI_TAG = req->tag; - st->TMPI_ERROR = req->error; + st->TMPI_TAG = req->tag; + st->TMPI_ERROR = req->error; st->transferred = req->transferred; - st->cancelled = req->cancelled; + st->cancelled = req->cancelled; } } @@ -606,28 +636,28 @@ tmpi_bool tMPI_Envelope_matches(const struct envelope *sev, { #ifdef TMPI_DEBUG printf("%5d: tMPI_Envelope_matches (%d->%d)==(%d->%d), tag=(%d==%d), \n datatype=(%ld==%ld), comm=(%ld,%ld),\n finished=(%d==%d)\n", - tMPI_This_threadnr(), - tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), - tMPI_Threadnr(rev->src), tMPI_Threadnr(rev->dest), - (int)(sev->tag), (int)(rev->tag), - (long int)sev->datatype, (long int)rev->datatype, - (long int)sev->comm, (long int)rev->comm, - (int)sev->state.value, (int)rev->state.value); + tMPI_This_threadnr(), + tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), + tMPI_Threadnr(rev->src), tMPI_Threadnr(rev->dest), + (int)(sev->tag), (int)(rev->tag), + (long int)sev->datatype, (long int)rev->datatype, + (long int)sev->comm, (long int)rev->comm, + (int)sev->state.value, (int)rev->state.value); fflush(stdout); #endif if ( ( (rev->tag == TMPI_ANY_TAG) || (rev->tag == sev->tag) ) && - ( sev->comm == rev->comm ) && - ( (!rev->src) || (rev->src == sev->src) ) && - ( sev->dest == rev->dest ) && - ( sev->datatype == rev->datatype ) && - ( sev->state.value < env_finished && - rev->state.value == env_unmatched ) ) + ( sev->comm == rev->comm ) && + ( (!rev->src) || (rev->src == sev->src) ) && + ( sev->dest == rev->dest ) && + ( sev->datatype == rev->datatype ) && + ( sev->state.value < env_finished && + rev->state.value == env_unmatched ) ) { #ifdef TMPI_DEBUG printf("%5d: (%d->%d) tag=%d found match\n", - tMPI_This_threadnr(), - tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), - (int)(sev->tag)); + tMPI_This_threadnr(), + tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), + (int)(sev->tag)); fflush(stdout); #endif return TRUE; @@ -639,12 +669,12 @@ tmpi_bool tMPI_Envelope_matches(const struct envelope *sev, struct envelope* tMPI_Send_env_list_search_old(struct send_envelope_list *evl, - struct envelope *rev) + struct envelope *rev) { struct envelope *sev; - sev=(struct envelope*)evl->head_old->next; - while(sev != evl->head_old) + sev = (struct envelope*)evl->head_old->next; + while (sev != evl->head_old) { if (tMPI_Envelope_matches(sev, rev)) { @@ -652,25 +682,25 @@ struct envelope* tMPI_Send_env_list_search_old(struct send_envelope_list *evl, tMPI_Send_env_list_remove_old(sev); return sev; } - sev=sev->next; + sev = sev->next; } return NULL; } struct envelope* tMPI_Recv_env_list_search_new(struct recv_envelope_list *evl, - struct envelope *sev) + struct envelope *sev) { struct envelope *rev; - rev=evl->head->next; - while(rev != evl->head) + rev = evl->head->next; + while (rev != evl->head) { if (tMPI_Envelope_matches(sev, rev)) { return rev; } - rev=rev->next; + rev = rev->next; } return NULL; } @@ -684,13 +714,15 @@ void tMPI_Send_copy_buffer(struct envelope *sev, struct tmpi_req_ *req) /* in the special case of a zero buffer size, we don't do anything and always let the receiver handle it */ - if (sev->bufsize==0) + if (sev->bufsize == 0) + { return; + } /* first check whether the other side hasn't started yet */ - state=tMPI_Atomic_get( &(sev->state) ); + state = tMPI_Atomic_get( &(sev->state) ); tMPI_Atomic_memory_barrier_acq(); - if (state == env_unmatched ) + if (state == env_unmatched) { /* first copy */ memcpy(sev->cb, sev->buf, sev->bufsize); @@ -698,32 +730,32 @@ void tMPI_Send_copy_buffer(struct envelope *sev, struct tmpi_req_ *req) tMPI_Atomic_memory_barrier_rel(); if (tMPI_Atomic_cas( &(sev->state), env_unmatched, env_cb_available)) { - /* if it was originally unmatched, the receiver wasn't + /* if it was originally unmatched, the receiver wasn't copying the old buffer. We can don't need to wait, and the receiver is going to clean up this envelope. */ #ifdef TMPI_DEBUG - printf("%5d: tMPI_Send_copy_buffer(%d->%d, tag=%d) completed\n", - tMPI_This_threadnr(), - tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), + printf("%5d: tMPI_Send_copy_buffer(%d->%d, tag=%d) completed\n", + tMPI_This_threadnr(), + tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), (int)(sev->tag)); fflush(stdout); #endif return; } } - /* and if we reached this point, the receiver had already started - copying, and we need to clean up the envelope ourselves. + /* and if we reached this point, the receiver had already started + copying, and we need to clean up the envelope ourselves. - we first need to wait until the receiver is finished copying. We + we first need to wait until the receiver is finished copying. We know this is a short wait (since the buffer was small enough to be buffered in the first place), so we just spin-wait. */ - while(tMPI_Atomic_get( &(sev->state) ) < env_cb_available) + while (tMPI_Atomic_get( &(sev->state) ) < env_cb_available) { } tMPI_Atomic_memory_barrier_acq(); #ifdef TMPI_DEBUG - printf("%5d: tMPI_Send_copy_buffer(%d->%d, tag=%d) waiting-completed\n", - tMPI_This_threadnr(), + printf("%5d: tMPI_Send_copy_buffer(%d->%d, tag=%d) waiting-completed\n", + tMPI_This_threadnr(), tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), (int)(sev->tag)); fflush(stdout); #endif @@ -734,86 +766,86 @@ void tMPI_Send_copy_buffer(struct envelope *sev, struct tmpi_req_ *req) #endif -struct envelope* tMPI_Prep_send_envelope(struct send_envelope_list *evl, - tMPI_Comm comm, - struct tmpi_thread *src, - struct tmpi_thread *dest, - void *buf, int count, - tMPI_Datatype datatype, +struct envelope* tMPI_Prep_send_envelope(struct send_envelope_list *evl, + tMPI_Comm comm, + struct tmpi_thread *src, + struct tmpi_thread *dest, + void *buf, int count, + tMPI_Datatype datatype, int tag, tmpi_bool nonblock) { /* get an envelope from the send-envelope stack */ - struct envelope *ev=tMPI_Send_env_list_fetch_new( evl ); + struct envelope *ev = tMPI_Send_env_list_fetch_new( evl ); - ev->tag=tag; - ev->nonblock=nonblock; + ev->tag = tag; + ev->nonblock = nonblock; - ev->comm=comm; + ev->comm = comm; - ev->src=src; - ev->dest=dest; + ev->src = src; + ev->dest = dest; - ev->buf=buf; - ev->bufsize=count*datatype->size; - ev->datatype=datatype; + ev->buf = buf; + ev->bufsize = count*datatype->size; + ev->datatype = datatype; - ev->send=TRUE; + ev->send = TRUE; - ev->rlist=NULL; + ev->rlist = NULL; #ifdef USE_SEND_RECV_COPY_BUFFER /* check whether we'll be double buffering */ - ev->using_cb=(ev->bufsize < COPY_BUFFER_SIZE); + ev->using_cb = (ev->bufsize < COPY_BUFFER_SIZE); /* but don't do anything yet */ #endif tMPI_Atomic_set(&(ev->state), env_unmatched); - ev->error=TMPI_SUCCESS; + ev->error = TMPI_SUCCESS; if (count < 0) { tMPI_Error(comm, TMPI_ERR_XFER_BUFSIZE); - ev->error=TMPI_ERR_XFER_BUFSIZE; + ev->error = TMPI_ERR_XFER_BUFSIZE; } return ev; } -struct envelope* tMPI_Prep_recv_envelope(struct tmpi_thread *cur, - tMPI_Comm comm, - struct tmpi_thread *src, - struct tmpi_thread *dest, - void *buf, int count, - tMPI_Datatype datatype, int tag, +struct envelope* tMPI_Prep_recv_envelope(struct tmpi_thread *cur, + tMPI_Comm comm, + struct tmpi_thread *src, + struct tmpi_thread *dest, + void *buf, int count, + tMPI_Datatype datatype, int tag, tmpi_bool nonblock) { /* get an envelope from the stack */ - struct envelope *ev=tMPI_Free_env_list_fetch_recv( &(cur->envelopes) ); + struct envelope *ev = tMPI_Free_env_list_fetch_recv( &(cur->envelopes) ); + + ev->tag = tag; + ev->nonblock = nonblock; - ev->tag=tag; - ev->nonblock=nonblock; + ev->comm = comm; - ev->comm=comm; + ev->src = src; + ev->dest = dest; - ev->src=src; - ev->dest=dest; + ev->buf = buf; + ev->bufsize = count*datatype->size; + ev->datatype = datatype; - ev->buf=buf; - ev->bufsize=count*datatype->size; - ev->datatype=datatype; - - ev->send=FALSE; + ev->send = FALSE; - ev->slist=NULL; - ev->rlist=NULL; + ev->slist = NULL; + ev->rlist = NULL; tMPI_Atomic_set(&(ev->state), env_unmatched); - ev->error=TMPI_SUCCESS; + ev->error = TMPI_SUCCESS; if (count < 0) { tMPI_Error(comm, TMPI_ERR_XFER_BUFSIZE); - ev->error=TMPI_ERR_XFER_BUFSIZE; + ev->error = TMPI_ERR_XFER_BUFSIZE; } return ev; @@ -826,27 +858,27 @@ struct envelope* tMPI_Prep_recv_envelope(struct tmpi_thread *cur, -static void tMPI_Xfer(struct tmpi_thread *cur, struct envelope *sev, +static void tMPI_Xfer(struct tmpi_thread *cur, struct envelope *sev, struct envelope *rev) { #ifdef USE_SEND_RECV_COPY_BUFFER - /* we remove the sender's envelope only if we do the transfer, which - we always do if the buffer size = 0 */ - tmpi_bool remove_sender = (sev->bufsize==0); + /* we remove the sender's envelope only if we do the transfer, which + we always do if the buffer size = 0 */ + tmpi_bool remove_sender = (sev->bufsize == 0); #endif #ifdef TMPI_DEBUG - printf("%5d: tMPI_Xfer (%d->%d, tag=%d) started\n", - tMPI_This_threadnr(), - tMPI_Threadnr(sev->src), tMPI_Threadnr(rev->dest), (int)(sev->tag)); + printf("%5d: tMPI_Xfer (%d->%d, tag=%d) started\n", + tMPI_This_threadnr(), + tMPI_Threadnr(sev->src), tMPI_Threadnr(rev->dest), (int)(sev->tag)); fflush(stdout); #endif /* first set data on the receiving end so status can be updated */ rev->src = sev->src; rev->tag = sev->tag; - if (sev->bufsize) /* do the actual transfer */ + if (sev->bufsize) /* do the actual transfer */ { - void *sbuf=sev->buf; /* source buffer */ + void *sbuf = sev->buf; /* source buffer */ if (sev->bufsize > rev->bufsize) { tMPI_Error((rev->comm), TMPI_ERR_XFER_BUFSIZE); @@ -863,10 +895,10 @@ static void tMPI_Xfer(struct tmpi_thread *cur, struct envelope *sev, /* check if the other side has already finished copying */ if (!tMPI_Atomic_cas( &(sev->state), env_unmatched, env_copying)) { - /* it has, and we're copying from the new buffer. + /* it has, and we're copying from the new buffer. We're now also tasked with removing the envelope */ - sbuf=sev->cb; - remove_sender=TRUE; + sbuf = sev->cb; + remove_sender = TRUE; #ifdef TMPI_PROFILE tMPI_Profile_count_buffered_p2p_xfer(cur); #endif @@ -889,37 +921,37 @@ static void tMPI_Xfer(struct tmpi_thread *cur, struct envelope *sev, #endif /* for status update */ } - rev->bufsize=sev->bufsize; + rev->bufsize = sev->bufsize; /* and mark that we're finished */ #if defined(TMPI_PROFILE) { tMPI_Profile_wait_start(cur); #endif - tMPI_Atomic_set( &(rev->state), env_finished); - tMPI_Atomic_set( &(sev->state), env_finished); + tMPI_Atomic_set( &(rev->state), env_finished); + tMPI_Atomic_set( &(sev->state), env_finished); - /* signal to a potentially waiting thread that we're done. */ - tMPI_Atomic_add_return( &(rev->src->ev_outgoing_received), 1); - tMPI_Event_signal(&(rev->src->p2p_event)); + /* signal to a potentially waiting thread that we're done. */ + tMPI_Atomic_add_return( &(rev->src->ev_outgoing_received), 1); + tMPI_Event_signal(&(rev->src->p2p_event)); - /* remove the receiving envelope if it's in a list */ - tMPI_Recv_env_list_remove(rev); + /* remove the receiving envelope if it's in a list */ + tMPI_Recv_env_list_remove(rev); #ifdef USE_SEND_RECV_COPY_BUFFER - if (remove_sender) - { - tMPI_Send_env_list_rts(sev); - } + if (remove_sender) + { + tMPI_Send_env_list_rts(sev); + } #endif #if defined(TMPI_PROFILE) - tMPI_Profile_wait_stop(cur, TMPIWAIT_P2p_signal); - } + tMPI_Profile_wait_stop(cur, TMPIWAIT_P2p_signal); +} #endif - + #ifdef TMPI_DEBUG - printf("%5d: tMPI_Xfer (%d->%d, tag=%d) done\n", - tMPI_This_threadnr(), - tMPI_Threadnr(sev->src), tMPI_Threadnr(rev->dest), (int)(sev->tag)); + printf("%5d: tMPI_Xfer (%d->%d, tag=%d) done\n", + tMPI_This_threadnr(), + tMPI_Threadnr(sev->src), tMPI_Threadnr(rev->dest), (int)(sev->tag)); fflush(stdout); #endif return; @@ -931,51 +963,53 @@ static void tMPI_Xfer(struct tmpi_thread *cur, struct envelope *sev, struct envelope* tMPI_Post_match_recv(struct tmpi_thread *cur, - tMPI_Comm comm, - struct tmpi_thread *src, - void *recv_buf, int recv_count, - tMPI_Datatype datatype, + tMPI_Comm comm, + struct tmpi_thread *src, + void *recv_buf, int recv_count, + tMPI_Datatype datatype, int tag, tmpi_bool nonblock) { - struct tmpi_thread *dest=cur; - struct envelope *rev; - struct envelope *sev=NULL; - int src_threadnr=src ? tMPI_Threadnr(src) : Nthreads; - int i; + struct tmpi_thread *dest = cur; + struct envelope *rev; + struct envelope *sev = NULL; + int src_threadnr = src ? tMPI_Threadnr(src) : Nthreads; + int i; /* reserve an envelope to post */ - rev=tMPI_Prep_recv_envelope(cur, comm, src, dest, recv_buf, recv_count, - datatype, tag, nonblock); + rev = tMPI_Prep_recv_envelope(cur, comm, src, dest, recv_buf, recv_count, + datatype, tag, nonblock); #ifdef TMPI_DEBUG - printf("%5d: tMPI_Post_match_recv (%d->%d, tag=%d) started\n", - tMPI_This_threadnr(), - tMPI_Threadnr(rev->src), tMPI_Threadnr(rev->dest), (int)(rev->tag)); + printf("%5d: tMPI_Post_match_recv (%d->%d, tag=%d) started\n", + tMPI_This_threadnr(), + tMPI_Threadnr(rev->src), tMPI_Threadnr(rev->dest), (int)(rev->tag)); fflush(stdout); #endif /* we now check the entire exisiting send queue */ if (src) { - sev=tMPI_Send_env_list_search_old( &(dest->evs[src_threadnr]), rev); + sev = tMPI_Send_env_list_search_old( &(dest->evs[src_threadnr]), rev); } else { /* if we don't know the source, we look at all possible sources */ - for(i=0;ievs[i]), rev); + sev = tMPI_Send_env_list_search_old(&(dest->evs[i]), rev); if (sev) + { break; - } + } + } } if (sev) { #ifdef TMPI_DEBUG - printf("%5d: tMPI_Post_match_recv (%d->%d, tag=%d) found match\n", - tMPI_This_threadnr(), - tMPI_Threadnr(rev->src), tMPI_Threadnr(rev->dest), - (int)(rev->tag)); + printf("%5d: tMPI_Post_match_recv (%d->%d, tag=%d) found match\n", + tMPI_This_threadnr(), + tMPI_Threadnr(rev->src), tMPI_Threadnr(rev->dest), + (int)(rev->tag)); fflush(stdout); #endif /* we found a matching send */ @@ -984,10 +1018,10 @@ struct envelope* tMPI_Post_match_recv(struct tmpi_thread *cur, else { #ifdef TMPI_DEBUG - printf("%5d: tMPI_Post_match_recv (%d->%d, tag=%d) no match\n", - tMPI_This_threadnr(), - tMPI_Threadnr(rev->src), tMPI_Threadnr(rev->dest), - (int)(rev->tag)); + printf("%5d: tMPI_Post_match_recv (%d->%d, tag=%d) no match\n", + tMPI_This_threadnr(), + tMPI_Threadnr(rev->src), tMPI_Threadnr(rev->dest), + (int)(rev->tag)); fflush(stdout); #endif /* we post the envelope in the right list */ @@ -1000,31 +1034,31 @@ struct envelope* tMPI_Post_match_recv(struct tmpi_thread *cur, struct envelope *tMPI_Post_send(struct tmpi_thread *cur, - tMPI_Comm comm, - struct tmpi_thread *dest, + tMPI_Comm comm, + struct tmpi_thread *dest, void *send_buf, int send_count, - tMPI_Datatype datatype, int tag, + tMPI_Datatype datatype, int tag, tmpi_bool nonblock) { - struct tmpi_thread *src=cur; - struct envelope *sev; - int src_threadnr=tMPI_Threadnr(src); - struct send_envelope_list *sevl=&(dest->evs[src_threadnr]); + struct tmpi_thread *src = cur; + struct envelope *sev; + int src_threadnr = tMPI_Threadnr(src); + struct send_envelope_list *sevl = &(dest->evs[src_threadnr]); /* reserve an envelope to post */ - sev=tMPI_Prep_send_envelope(sevl, comm, src, dest, send_buf, send_count, - datatype, tag, nonblock); + sev = tMPI_Prep_send_envelope(sevl, comm, src, dest, send_buf, send_count, + datatype, tag, nonblock); #ifdef TMPI_DEBUG - printf("%5d: tMPI_Post_send (%d->%d, tag=%d)\n", - tMPI_This_threadnr(), - tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), + printf("%5d: tMPI_Post_send (%d->%d, tag=%d)\n", + tMPI_This_threadnr(), + tMPI_Threadnr(sev->src), tMPI_Threadnr(sev->dest), (int)(sev->tag)); fflush(stdout); #endif /* we post the envelope in the right list */ tMPI_Send_env_list_add_new(cur, &(dest->evs[src_threadnr]), sev); - + return sev; } @@ -1035,7 +1069,7 @@ void tMPI_Wait_process_incoming(struct tmpi_thread *cur) { int i; int check_id; - int n_handled=0; + int n_handled = 0; #if defined(TMPI_PROFILE) @@ -1043,9 +1077,9 @@ void tMPI_Wait_process_incoming(struct tmpi_thread *cur) #endif /* we check for newly arrived send envelopes and finished send envelopes */ - check_id=tMPI_Event_wait( &(cur->p2p_event)); - /* the outgoing_received items are handled 'automatically' - by the function calling this function */ + check_id = tMPI_Event_wait( &(cur->p2p_event)); + /* the outgoing_received items are handled 'automatically' + by the function calling this function */ #if defined(TMPI_PROFILE) tMPI_Profile_wait_stop(cur, TMPIWAIT_P2p); #endif @@ -1053,12 +1087,12 @@ void tMPI_Wait_process_incoming(struct tmpi_thread *cur) tMPI_Atomic_add_return( &(cur->ev_outgoing_received), -n_handled); check_id -= n_handled; - if ( check_id > 0) + if (check_id > 0) { /*int repl=check_id;*/ /*int n=0;*/ /* there were new send envelopes. Let's check them all */ - for(i=0;ievs[i].head_new) ); + sev_head = (struct envelope*) + tMPI_Atomic_ptr_get( &(cur->evs[i].head_new) ); /* do the compare-and-swap to detach the list */ - } while (!tMPI_Atomic_ptr_cas(&(cur->evs[i].head_new), sev_head, - NULL)); + } + while (!tMPI_Atomic_ptr_cas(&(cur->evs[i].head_new), sev_head, + NULL)); #else tMPI_Spinlock_lock( &(cur->evs[i].lock_new) ); - sev_head=(struct send_envelope*)cur->evs[i].head_new; - cur->evs[i].head_new=NULL; /* detach the list */ + sev_head = (struct send_envelope*)cur->evs[i].head_new; + cur->evs[i].head_new = NULL; /* detach the list */ tMPI_Spinlock_unlock( &(cur->evs[i].lock_new) ); #endif - if (sev_head) /* there's a newly arrived send envelope from this + if (sev_head) /* there's a newly arrived send envelope from this thread*/ { - struct envelope *sev=sev_head; - struct envelope *prev_s=NULL; + struct envelope *sev = sev_head; + struct envelope *prev_s = NULL; struct envelope *rev; - /* first enable reversing order by creating a regular + /* first enable reversing order by creating a regular doubly-linked list from the singly-linked shared linked list */ - while(sev) + while (sev) { - sev->prev=prev_s; - prev_s=sev; - sev=sev->next; + sev->prev = prev_s; + prev_s = sev; + sev = sev->next; } - /* now walk through it backwards (in order of addition) */ - sev=prev_s; - while(sev) + /* now walk through it backwards (in order of addition) */ + sev = prev_s; + while (sev) { - struct envelope *sevp=sev->prev; + struct envelope *sevp = sev->prev; n_handled++; - rev=tMPI_Recv_env_list_search_new(&(cur->evr), sev); + rev = tMPI_Recv_env_list_search_new(&(cur->evr), sev); if (rev) { tMPI_Xfer(cur, sev, rev); @@ -1111,7 +1146,7 @@ void tMPI_Wait_process_incoming(struct tmpi_thread *cur) { tMPI_Send_env_list_move_to_old( sev ); } - sev=sevp; + sev = sevp; } } } @@ -1121,38 +1156,42 @@ void tMPI_Wait_process_incoming(struct tmpi_thread *cur) tmpi_bool tMPI_Test_single(struct tmpi_thread *cur, struct tmpi_req_ *rq) { - struct envelope *ev=rq->ev; + struct envelope *ev = rq->ev; if (ev && !(rq->finished) ) { #ifdef USE_SEND_RECV_COPY_BUFFER if (ev->send && ev->using_cb) { - /* We buffer-copy. Just do the transfer to the buffer and - return saying that we're done. It's now up to the + /* We buffer-copy. Just do the transfer to the buffer and + return saying that we're done. It's now up to the receiver to return our envelope.*/ - /* do our transfer and are guaranteed a finished + /* do our transfer and are guaranteed a finished envelope. */ tMPI_Send_copy_buffer(ev, rq); /* get the results */ - rq->error=rq->ev->error; - rq->finished=TRUE; + rq->error = rq->ev->error; + rq->finished = TRUE; } else #endif { - if( tMPI_Atomic_get( &(ev->state) ) >= env_finished ) + if (tMPI_Atomic_get( &(ev->state) ) >= env_finished) { - rq->finished=TRUE; + rq->finished = TRUE; /* get the results */ - rq->error=rq->ev->error; + rq->error = rq->ev->error; tMPI_Set_req(ev, rq); /* and release the envelope. After this point, the envelope may be reused, so its contents shouldn't be relied on. */ if (ev->send) + { tMPI_Send_env_list_return(ev); + } else + { tMPI_Free_env_list_return_recv( &(cur->envelopes), ev); + } } } } @@ -1164,52 +1203,55 @@ void tMPI_Wait_single(struct tmpi_thread *cur, struct tmpi_req_ *rq) do { if (tMPI_Test_single(cur, rq)) + { return; + } tMPI_Wait_process_incoming(cur); - } while(TRUE); + } + while (TRUE); } tmpi_bool tMPI_Test_multi(struct tmpi_thread *cur, struct tmpi_req_ *rqs, - tmpi_bool *any_done) + tmpi_bool *any_done) { - tmpi_bool all_done=TRUE; - struct tmpi_req_ *creq=rqs; + tmpi_bool all_done = TRUE; + struct tmpi_req_ *creq = rqs; - int i=0; + int i = 0; if (any_done) - *any_done=FALSE; + { + *any_done = FALSE; + } - while(creq) + while (creq) { - tmpi_bool finished=tMPI_Test_single(cur, creq); + tmpi_bool finished = tMPI_Test_single(cur, creq); i++; /* now do the check */ - if (! finished) - all_done=FALSE; - else + if (!finished) + { + all_done = FALSE; + } + else { /* remove the request from the list we've been given. */ if (creq->prev) + { creq->prev->next = creq->next; + } if (creq->next) + { creq->next->prev = creq->prev; + } if (any_done) - *any_done=TRUE; + { + *any_done = TRUE; + } } creq = creq->next; - } + } return all_done; } - - - - - - - - - - diff --git a/src/gromacs/gmxlib/thread_mpi/p2p_send_recv.c b/src/gromacs/gmxlib/thread_mpi/p2p_send_recv.c index b106a70f94..b2a305cfee 100644 --- a/src/gromacs/gmxlib/thread_mpi/p2p_send_recv.c +++ b/src/gromacs/gmxlib/thread_mpi/p2p_send_recv.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -64,34 +64,34 @@ files. int tMPI_Send(void* buf, int count, tMPI_Datatype datatype, int dest, int tag, tMPI_Comm comm) { - struct envelope *sev; + struct envelope *sev; struct tmpi_thread *send_dst; - struct tmpi_thread *cur=tMPI_Get_current(); - struct tmpi_req_ req; + struct tmpi_thread *cur = tMPI_Get_current(); + struct tmpi_req_ req; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Send(%p, %d, %p, %d, %d, %p)", buf, count, - datatype, dest, tag, comm); + tMPI_Trace_print("tMPI_Send(%p, %d, %p, %d, %d, %p)", buf, count, + datatype, dest, tag, comm); #endif if (!comm) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - send_dst=tMPI_Get_thread(comm, dest); + send_dst = tMPI_Get_thread(comm, dest); if (!send_dst) { return tMPI_Error(comm, TMPI_ERR_SEND_DEST); } - sev=tMPI_Post_send(cur, comm, send_dst, buf, count, datatype, tag, FALSE); + sev = tMPI_Post_send(cur, comm, send_dst, buf, count, datatype, tag, FALSE); tMPI_Req_init(&req, sev); tMPI_Wait_single(cur, &req); #ifdef TMPI_PROFILE - tMPI_Profile_count_stop(cur,TMPIFN_Send); + tMPI_Profile_count_stop(cur, TMPIFN_Send); #endif return req.error; } @@ -100,36 +100,36 @@ int tMPI_Send(void* buf, int count, tMPI_Datatype datatype, int dest, int tMPI_Recv(void* buf, int count, tMPI_Datatype datatype, int source, - int tag, tMPI_Comm comm, tMPI_Status *status) + int tag, tMPI_Comm comm, tMPI_Status *status) { - struct envelope *rev; - struct tmpi_thread *recv_src=0; - struct tmpi_thread *cur=tMPI_Get_current(); - struct tmpi_req_ req; + struct envelope *rev; + struct tmpi_thread *recv_src = 0; + struct tmpi_thread *cur = tMPI_Get_current(); + struct tmpi_req_ req; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Recv(%p, %d, %p, %d, %d, %p, %p)", buf, count, - datatype, source, tag, comm, status); + tMPI_Trace_print("tMPI_Recv(%p, %d, %p, %d, %d, %p, %p)", buf, count, + datatype, source, tag, comm, status); #endif if (!comm) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - if (source!=TMPI_ANY_SOURCE) + if (source != TMPI_ANY_SOURCE) { - recv_src=tMPI_Get_thread(comm, source); + recv_src = tMPI_Get_thread(comm, source); if (!recv_src) { - return tMPI_Error(comm, TMPI_ERR_RECV_SRC); + return tMPI_Error(comm, TMPI_ERR_RECV_SRC); } } - rev=tMPI_Post_match_recv(cur, comm, recv_src, buf, count, datatype, tag, - FALSE); + rev = tMPI_Post_match_recv(cur, comm, recv_src, buf, count, datatype, tag, + FALSE); tMPI_Req_init(&req, rev); tMPI_Wait_single(cur, &req); @@ -146,73 +146,78 @@ int tMPI_Recv(void* buf, int count, tMPI_Datatype datatype, int source, int tMPI_Sendrecv(void *sendbuf, int sendcount, tMPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, - tMPI_Datatype recvtype, int source, int recvtag, + tMPI_Datatype recvtype, int source, int recvtag, tMPI_Comm comm, tMPI_Status *status) { - struct envelope *rev, *sev; - struct tmpi_thread *cur=tMPI_Get_current(); - struct tmpi_thread *recv_src=0; + struct envelope *rev, *sev; + struct tmpi_thread *cur = tMPI_Get_current(); + struct tmpi_thread *recv_src = 0; struct tmpi_thread *send_dst; - struct tmpi_req_ sreq, rreq; - int ret=TMPI_SUCCESS; + struct tmpi_req_ sreq, rreq; + int ret = TMPI_SUCCESS; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Sendrecv(%p, %d, %p, %d, %d, %p, %d, %p, %d, %d, %p, %p)", - sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, - recvcount, recvtype, source, recvtag, comm, status); + tMPI_Trace_print("tMPI_Sendrecv(%p, %d, %p, %d, %d, %p, %d, %p, %d, %d, %p, %p)", + sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, + recvcount, recvtype, source, recvtag, comm, status); #endif if (!comm) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - send_dst=tMPI_Get_thread(comm, dest); + send_dst = tMPI_Get_thread(comm, dest); if (!send_dst) { - return tMPI_Error(comm, TMPI_ERR_SEND_DEST); + return tMPI_Error(comm, TMPI_ERR_SEND_DEST); } - if (source!=TMPI_ANY_SOURCE) + if (source != TMPI_ANY_SOURCE) { - recv_src=tMPI_Get_thread(comm, source); + recv_src = tMPI_Get_thread(comm, source); if (!recv_src) { return tMPI_Error(comm, TMPI_ERR_RECV_SRC); } } - /* we first prepare to send */ - sev=tMPI_Post_send(cur, comm, send_dst, sendbuf, sendcount, - sendtype, sendtag, FALSE); + /* we first prepare to send */ + sev = tMPI_Post_send(cur, comm, send_dst, sendbuf, sendcount, + sendtype, sendtag, FALSE); tMPI_Req_init(&sreq, sev); /* the we prepare to receive */ - rev=tMPI_Post_match_recv(cur, comm, recv_src, recvbuf, recvcount, - recvtype, recvtag, FALSE); + rev = tMPI_Post_match_recv(cur, comm, recv_src, recvbuf, recvcount, + recvtype, recvtag, FALSE); tMPI_Req_init(&rreq, rev); /* fix the pointers */ - sreq.next=&rreq; - sreq.prev=NULL; - rreq.prev=&sreq; - rreq.next=NULL; + sreq.next = &rreq; + sreq.prev = NULL; + rreq.prev = &sreq; + rreq.next = NULL; /* and wait for our requests */ do { if (tMPI_Test_multi(cur, &sreq, NULL)) + { break; + } tMPI_Wait_process_incoming(cur); - } while(TRUE); + } + while (TRUE); #ifdef TMPI_PROFILE tMPI_Profile_count_stop(cur, TMPIFN_Sendrecv); #endif tMPI_Set_status(&rreq, status); - ret=sreq.error; + ret = sreq.error; if (rreq.error != TMPI_SUCCESS) - ret=rreq.error; + { + ret = rreq.error; + } return ret; } @@ -226,82 +231,78 @@ int tMPI_Sendrecv(void *sendbuf, int sendcount, tMPI_Datatype sendtype, int tMPI_Isend(void* buf, int count, tMPI_Datatype datatype, int dest, int tag, tMPI_Comm comm, tMPI_Request *request) { - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); - struct tmpi_req_ *rq=tMPI_Get_req(rql); + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); + struct tmpi_req_ *rq = tMPI_Get_req(rql); struct tmpi_thread *send_dst; - struct envelope *ev; + struct envelope *ev; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Isend(%p, %d, %p, %d, %d, %p, %p)", buf, count, - datatype, dest, tag, comm, request); + tMPI_Trace_print("tMPI_Isend(%p, %d, %p, %d, %d, %p, %p)", buf, count, + datatype, dest, tag, comm, request); #endif if (!comm) { - tMPI_Return_req(rql,rq); + tMPI_Return_req(rql, rq); return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - send_dst=tMPI_Get_thread(comm, dest); + send_dst = tMPI_Get_thread(comm, dest); if (!send_dst) { - tMPI_Return_req(rql,rq); + tMPI_Return_req(rql, rq); return tMPI_Error(comm, TMPI_ERR_SEND_DEST); } - ev=tMPI_Post_send(cur, comm, send_dst, buf, count, datatype, tag, TRUE); + ev = tMPI_Post_send(cur, comm, send_dst, buf, count, datatype, tag, TRUE); tMPI_Req_init(rq, ev); - *request=rq; + *request = rq; #ifdef TMPI_PROFILE tMPI_Profile_count_stop(cur, TMPIFN_Isend); #endif - return ev->error; + return ev->error; } int tMPI_Irecv(void* buf, int count, tMPI_Datatype datatype, int source, int tag, tMPI_Comm comm, tMPI_Request *request) { - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); - struct tmpi_req_ *rq=tMPI_Get_req(rql); - struct tmpi_thread *recv_src=0; - struct envelope *ev; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); + struct tmpi_req_ *rq = tMPI_Get_req(rql); + struct tmpi_thread *recv_src = 0; + struct envelope *ev; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Irecv(%p, %d, %p, %d, %d, %p, %p)", buf, count, - datatype, source, tag, comm, request); + tMPI_Trace_print("tMPI_Irecv(%p, %d, %p, %d, %d, %p, %p)", buf, count, + datatype, source, tag, comm, request); #endif if (!comm) { - tMPI_Return_req(rql,rq); + tMPI_Return_req(rql, rq); return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - if (source!=TMPI_ANY_SOURCE) + if (source != TMPI_ANY_SOURCE) { - recv_src=tMPI_Get_thread(comm, source); + recv_src = tMPI_Get_thread(comm, source); if (!recv_src) { - tMPI_Return_req(rql,rq); + tMPI_Return_req(rql, rq); return tMPI_Error(comm, TMPI_ERR_RECV_SRC); } } - ev=tMPI_Post_match_recv(cur, comm, recv_src, buf, count, datatype, tag, - TRUE); + ev = tMPI_Post_match_recv(cur, comm, recv_src, buf, count, datatype, tag, + TRUE); tMPI_Req_init(rq, ev); - *request=rq; + *request = rq; #ifdef TMPI_PROFILE tMPI_Profile_count_stop(cur, TMPIFN_Irecv); #endif return ev->error; } - - - - diff --git a/src/gromacs/gmxlib/thread_mpi/p2p_wait.c b/src/gromacs/gmxlib/thread_mpi/p2p_wait.c index 1e97b0e935..01737af370 100644 --- a/src/gromacs/gmxlib/thread_mpi/p2p_wait.c +++ b/src/gromacs/gmxlib/thread_mpi/p2p_wait.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -61,10 +61,10 @@ files. int tMPI_Wait(tMPI_Request *request, tMPI_Status *status) { - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); - struct tmpi_req_ *rq; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); + struct tmpi_req_ *rq; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); @@ -73,23 +73,28 @@ int tMPI_Wait(tMPI_Request *request, tMPI_Status *status) tMPI_Trace_print("tMPI_Wait(%p, %p)", request, status); #endif if (!request || !(*request)) + { return TMPI_SUCCESS; + } - rq=*request; + rq = *request; /* fix the pointers */ - rq->next=rq; - rq->prev=rq; + rq->next = rq; + rq->prev = rq; /* and wait for our request */ do { if (tMPI_Test_single(cur, rq)) + { break; + } tMPI_Wait_process_incoming(cur); - } while(TRUE); + } + while (TRUE); - rq->ev=NULL; /* we won't be using that envelope any more */ - ret=rq->error; + rq->ev = NULL; /* we won't be using that envelope any more */ + ret = rq->error; tMPI_Set_status(rq, status); @@ -104,10 +109,10 @@ int tMPI_Wait(tMPI_Request *request, tMPI_Status *status) int tMPI_Test(tMPI_Request *request, int *flag, tMPI_Status *status) { - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); - struct tmpi_req_ *rq; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); + struct tmpi_req_ *rq; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); @@ -116,25 +121,29 @@ int tMPI_Test(tMPI_Request *request, int *flag, tMPI_Status *status) tMPI_Trace_print("tMPI_Test(%p, %p, %p)", request, flag, status); #endif if (!request || !(*request)) + { return TMPI_SUCCESS; + } - rq=*request; + rq = *request; /* fix the pointers */ - rq->next=rq; - rq->prev=rq; + rq->next = rq; + rq->prev = rq; /* and check our request */ if (tMPI_Test_single(cur, rq)) - *flag=TRUE; + { + *flag = TRUE; + } - ret=rq->error; + ret = rq->error; if (rq->finished) { tMPI_Set_status(rq, status); /* deallocate */ tMPI_Return_req(rql, *request); - *request=TMPI_REQUEST_NULL; + *request = TMPI_REQUEST_NULL; } #ifdef TMPI_PROFILE @@ -161,38 +170,40 @@ int tMPI_Test(tMPI_Request *request, int *flag, tMPI_Status *status) /* test multiple requests by first making a linked list of them, and then checking for their completion. Used in tMPI_{Test|Wait}{all|any|some} - wait = whether to wait for incoming events + wait = whether to wait for incoming events blocking = whether to block until all reqs are completed */ -static void tMPI_Test_multi_req(struct tmpi_thread *cur, +static void tMPI_Test_multi_req(struct tmpi_thread *cur, int count, tMPI_Request *array_of_requests, tmpi_bool wait, tmpi_bool blocking) { - int i; - struct tmpi_req_ *first=NULL, *last=NULL; + int i; + struct tmpi_req_ *first = NULL, *last = NULL; /* construct the list of requests */ - for(i=0;inext=NULL; - last->prev=NULL; + last = curr; + last->next = NULL; + last->prev = NULL; } else { /* we connect to the last */ - curr->next=NULL; - curr->prev=last; - last->next=curr; - last=curr; + curr->next = NULL; + curr->prev = last; + last->next = curr; + last = curr; } } } @@ -200,10 +211,15 @@ static void tMPI_Test_multi_req(struct tmpi_thread *cur, do { if (tMPI_Test_multi(cur, first, NULL)) + { break; + } if (wait) + { tMPI_Wait_process_incoming(cur); - } while(blocking && wait); + } + } + while (blocking && wait); } @@ -211,21 +227,21 @@ static void tMPI_Test_multi_req(struct tmpi_thread *cur, int tMPI_Waitall(int count, tMPI_Request *array_of_requests, tMPI_Status *array_of_statuses) { - int i; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); + int i; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Waitall(%d, %p, %p)", count, array_of_requests, - array_of_statuses); + tMPI_Trace_print("tMPI_Waitall(%d, %p, %p)", count, array_of_requests, + array_of_statuses); #endif tMPI_Test_multi_req(cur, count, array_of_requests, TRUE, TRUE); /* deallocate the now finished requests */ - for(i=0;ierror != TMPI_SUCCESS) { - ret=TMPI_ERR_IN_STATUS; + ret = TMPI_ERR_IN_STATUS; } tMPI_Return_req(rql, array_of_requests[i]); - array_of_requests[i]=TMPI_REQUEST_NULL; + array_of_requests[i] = TMPI_REQUEST_NULL; } } @@ -251,23 +267,25 @@ int tMPI_Waitall(int count, tMPI_Request *array_of_requests, int tMPI_Testall(int count, tMPI_Request *array_of_requests, int *flag, tMPI_Status *array_of_statuses) { - int i; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); + int i; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Testall(%d, %p, %p, %p)", count, array_of_requests, - flag, array_of_statuses); + tMPI_Trace_print("tMPI_Testall(%d, %p, %p, %p)", count, array_of_requests, + flag, array_of_statuses); #endif tMPI_Test_multi_req(cur, count, array_of_requests, FALSE, TRUE); if (flag) - *flag=1; + { + *flag = 1; + } /* deallocate the possibly finished requests */ - for(i=0;ifinished) @@ -278,16 +296,18 @@ int tMPI_Testall(int count, tMPI_Request *array_of_requests, } if (array_of_requests[i]->error != TMPI_SUCCESS) { - ret=TMPI_ERR_IN_STATUS; + ret = TMPI_ERR_IN_STATUS; } tMPI_Return_req(rql, array_of_requests[i]); - array_of_requests[i]=TMPI_REQUEST_NULL; + array_of_requests[i] = TMPI_REQUEST_NULL; } else { if (flag) - *flag=0; - } + { + *flag = 0; + } + } } @@ -301,34 +321,36 @@ int tMPI_Testall(int count, tMPI_Request *array_of_requests, int tMPI_Waitany(int count, tMPI_Request *array_of_requests, int *index, tMPI_Status *status) { - int i; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); + int i; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Waitany(%d, %p, %p, %p)", count, array_of_requests, - index, status); + tMPI_Trace_print("tMPI_Waitany(%d, %p, %p, %p)", count, array_of_requests, + index, status); #endif tMPI_Test_multi_req(cur, count, array_of_requests, TRUE, FALSE); /* deallocate the possibly finished requests */ - for(i=0;ifinished) { tMPI_Set_status(array_of_requests[i], status); if (index) - *index=i; + { + *index = i; + } if (array_of_requests[i]->error != TMPI_SUCCESS) { - ret=TMPI_ERR_IN_STATUS; + ret = TMPI_ERR_IN_STATUS; } tMPI_Return_req(rql, array_of_requests[i]); - array_of_requests[i]=TMPI_REQUEST_NULL; + array_of_requests[i] = TMPI_REQUEST_NULL; /* and we only need one */ break; } @@ -345,40 +367,48 @@ int tMPI_Waitany(int count, tMPI_Request *array_of_requests, int *index, int tMPI_Testany(int count, tMPI_Request *array_of_requests, int *index, int *flag, tMPI_Status *status) { - int i; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); + int i; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Testany(%d, %p, %p %p, %p)", count, + tMPI_Trace_print("tMPI_Testany(%d, %p, %p %p, %p)", count, array_of_requests, flag, index, status); #endif tMPI_Test_multi_req(cur, count, array_of_requests, FALSE, FALSE); if (flag) - *flag=0; + { + *flag = 0; + } if (index) - *index=TMPI_UNDEFINED; + { + *index = TMPI_UNDEFINED; + } /* deallocate the possibly finished requests */ - for(i=0;ifinished) { tMPI_Set_status(array_of_requests[i], status); if (index) - *index=i; + { + *index = i; + } if (flag) - *flag=1; + { + *flag = 1; + } if (array_of_requests[i]->error != TMPI_SUCCESS) { - ret=TMPI_ERR_IN_STATUS; + ret = TMPI_ERR_IN_STATUS; } tMPI_Return_req(rql, array_of_requests[i]); - array_of_requests[i]=TMPI_REQUEST_NULL; + array_of_requests[i] = TMPI_REQUEST_NULL; /* and we only need one */ break; } @@ -396,23 +426,23 @@ int tMPI_Waitsome(int incount, tMPI_Request *array_of_requests, int *outcount, int *array_of_indices, tMPI_Status *array_of_statuses) { - int i; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); + int i; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Waitsome(%d, %p, %p, %p, %p)", incount, - array_of_requests, outcount, array_of_indices, + tMPI_Trace_print("tMPI_Waitsome(%d, %p, %p, %p, %p)", incount, + array_of_requests, outcount, array_of_indices, array_of_statuses); #endif tMPI_Test_multi_req(cur, incount, array_of_requests, TRUE, FALSE); - (*outcount)=0; + (*outcount) = 0; /* deallocate the possibly finished requests */ - for(i=0;ifinished) { @@ -424,10 +454,10 @@ int tMPI_Waitsome(int incount, tMPI_Request *array_of_requests, } if (array_of_requests[i]->error != TMPI_SUCCESS) { - ret=TMPI_ERR_IN_STATUS; + ret = TMPI_ERR_IN_STATUS; } tMPI_Return_req(rql, array_of_requests[i]); - array_of_requests[i]=TMPI_REQUEST_NULL; + array_of_requests[i] = TMPI_REQUEST_NULL; } } @@ -441,23 +471,23 @@ int tMPI_Testsome(int incount, tMPI_Request *array_of_requests, int *outcount, int *array_of_indices, tMPI_Status *array_of_statuses) { - int i; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); - struct req_list *rql=&(cur->rql); + int i; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); + struct req_list *rql = &(cur->rql); #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Testsome(%d, %p, %p, %p, %p)", incount, - array_of_requests, outcount, array_of_indices, + tMPI_Trace_print("tMPI_Testsome(%d, %p, %p, %p, %p)", incount, + array_of_requests, outcount, array_of_indices, array_of_statuses); #endif tMPI_Test_multi_req(cur, incount, array_of_requests, FALSE, TRUE); - (*outcount)=0; + (*outcount) = 0; /* deallocate the possibly finished requests */ - for(i=0;ifinished) { @@ -469,10 +499,10 @@ int tMPI_Testsome(int incount, tMPI_Request *array_of_requests, } if (array_of_requests[i]->error != TMPI_SUCCESS) { - ret=TMPI_ERR_IN_STATUS; + ret = TMPI_ERR_IN_STATUS; } tMPI_Return_req(rql, array_of_requests[i]); - array_of_requests[i]=TMPI_REQUEST_NULL; + array_of_requests[i] = TMPI_REQUEST_NULL; } } @@ -482,5 +512,3 @@ int tMPI_Testsome(int incount, tMPI_Request *array_of_requests, #endif return ret; } - - diff --git a/src/gromacs/gmxlib/thread_mpi/profile.c b/src/gromacs/gmxlib/thread_mpi/profile.c index be5920012b..a7de36be2c 100644 --- a/src/gromacs/gmxlib/thread_mpi/profile.c +++ b/src/gromacs/gmxlib/thread_mpi/profile.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ /* the profiling functions */ @@ -54,7 +54,7 @@ files. #include #include #include -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) #include #else /* windows doesn't do standard C */ @@ -68,11 +68,11 @@ files. #include #endif -int tMPI_Profile_started=0; +int tMPI_Profile_started = 0; /* this must match the tmpi_functions enum: */ -const char *tmpi_function_names[] = +const char *tmpi_function_names[] = { "Send", "Recv", @@ -104,7 +104,7 @@ const char *tmpi_function_names[] = /* this must match the tmpi_wait_functions enum: */ -const char *tmpi_waitfn_names[] = +const char *tmpi_waitfn_names[] = { "P2p", "P2p signal", @@ -125,29 +125,29 @@ void tMPI_Profile_init(struct tmpi_profile *prof) int i; /* reset counters */ - for(i=0;impifn_calls[i]=0; + prof->mpifn_calls[i] = 0; } #ifdef TMPI_CYCLE_COUNT - for(i=0;impifn_cycles[i]=0; + prof->mpifn_cycles[i] = 0; } - for(i=0;iwait_cycles[i]=0; + prof->wait_cycles[i] = 0; } - prof->global_start=tmpi_cycles_read(); - prof->global_stop=0; - prof->wait_start=0; + prof->global_start = tmpi_cycles_read(); + prof->global_stop = 0; + prof->wait_start = 0; #endif - prof->buffered_p2p_xfers=0; - prof->buffered_coll_xfers=0; - prof->total_p2p_xfers=0; - prof->total_coll_xfers=0; - tMPI_Profile_started=1; + prof->buffered_p2p_xfers = 0; + prof->buffered_coll_xfers = 0; + prof->total_p2p_xfers = 0; + prof->total_coll_xfers = 0; + tMPI_Profile_started = 1; } @@ -162,42 +162,44 @@ void tMPI_Profile_destroy(struct tmpi_profile *prof) void tMPI_Profile_stop(struct tmpi_profile *prof) { #ifdef TMPI_CYCLE_COUNT - prof->global_stop=tmpi_cycles_read(); + prof->global_stop = tmpi_cycles_read(); #endif - tMPI_Profile_started=0; + tMPI_Profile_started = 0; } /* output functions */ void tMPI_Profiles_summarize(int Nthreads, struct tmpi_thread *threads) { - int i,j,len=0; + int i, j, len = 0; printf("\nTMPI PROFILE:\n"); printf("%11s", " "); - len+=11; - for(j=0;jprofile.mpifn_cycles[fn] += (stop - th->profile.mpifn_start); \ - (th->profile.mpifn_calls[fn])++; \ -} + { \ + tmpi_cycles_t stop = tmpi_cycles_read(); \ + th->profile.mpifn_cycles[fn] += (stop - th->profile.mpifn_start); \ + (th->profile.mpifn_calls[fn])++; \ + } #else #define tMPI_Profile_count_stop(th, fn) \ -{ \ - (th->profile.mpifn_calls[fn])++; \ -} + { \ + (th->profile.mpifn_calls[fn])++; \ + } #endif @@ -175,18 +175,18 @@ void tMPI_Profile_stop(struct tmpi_profile *prof); /* start waiting cycle count */ /*void tMPI_Profile_wait_start(struct tmpi_thread *th);*/ #define tMPI_Profile_wait_start(th) \ -{\ - th->profile.wait_start=tmpi_cycles_read(); \ -} + { \ + th->profile.wait_start = tmpi_cycles_read(); \ + } /* stop waiting cycle count */ -/*void tMPI_Profile_wait_stop(struct tmpi_thread *th, +/*void tMPI_Profile_wait_stop(struct tmpi_thread *th, enum tmpi_wait_functions fn);*/ -#define tMPI_Profile_wait_stop(th, fn)\ -{ \ - tmpi_cycles_t wait_stop=tmpi_cycles_read();\ - th->profile.wait_cycles[fn] += (wait_stop - th->profile.wait_start);\ -} +#define tMPI_Profile_wait_stop(th, fn) \ + { \ + tmpi_cycles_t wait_stop = tmpi_cycles_read(); \ + th->profile.wait_cycles[fn] += (wait_stop - th->profile.wait_start); \ + } #else #define tMPI_Profile_wait_start(th) {} #define tMPI_Profile_wait_stop(th, fn) {} @@ -195,28 +195,28 @@ void tMPI_Profile_stop(struct tmpi_profile *prof); /* count the number of transfers at the receiving end. */ /*void tMPI_Profile_count_buffered_p2p_xfer(struct tmpi_thread *th); -void tMPI_Profile_count_p2p_xfer(struct tmpi_thread *th); -void tMPI_Profile_count_buffered_coll_xfer(struct tmpi_thread *th); -void tMPI_Profile_count_coll_xfer(struct tmpi_thread *th);*/ + void tMPI_Profile_count_p2p_xfer(struct tmpi_thread *th); + void tMPI_Profile_count_buffered_coll_xfer(struct tmpi_thread *th); + void tMPI_Profile_count_coll_xfer(struct tmpi_thread *th);*/ #define tMPI_Profile_count_buffered_p2p_xfer(th) \ -{ \ - (th->profile.buffered_p2p_xfers)++; \ -} + { \ + (th->profile.buffered_p2p_xfers)++; \ + } #define tMPI_Profile_count_p2p_xfer(th) \ -{ \ - (th->profile.total_p2p_xfers)++; \ -} + { \ + (th->profile.total_p2p_xfers)++; \ + } #define tMPI_Profile_count_buffered_coll_xfer(th) \ -{ \ - (th->profile.buffered_coll_xfers)++; \ -} + { \ + (th->profile.buffered_coll_xfers)++; \ + } #define tMPI_Profile_count_coll_xfer(th) \ -{ \ - (th->profile.total_coll_xfers)++; \ -} + { \ + (th->profile.total_coll_xfers)++; \ + } @@ -224,5 +224,3 @@ void tMPI_Profile_count_coll_xfer(struct tmpi_thread *th);*/ void tMPI_Profiles_summarize(int Nthreads, struct tmpi_thread *threads); #endif - - diff --git a/src/gromacs/gmxlib/thread_mpi/pthreads.c b/src/gromacs/gmxlib/thread_mpi/pthreads.c index 612604697d..62d8c52cae 100644 --- a/src/gromacs/gmxlib/thread_mpi/pthreads.c +++ b/src/gromacs/gmxlib/thread_mpi/pthreads.c @@ -1,46 +1,46 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ /* Include the defines that determine which thread library to use. -* We do not use HAVE_PTHREAD_H directly, since we might want to -* turn off thread support explicity (e.g. for debugging). -*/ + * We do not use HAVE_PTHREAD_H directly, since we might want to + * turn off thread support explicity (e.g. for debugging). + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" #endif @@ -50,7 +50,7 @@ files. #endif -#ifdef THREAD_PTHREADS +#ifdef THREAD_PTHREADS #ifdef HAVE_PTHREAD_SETAFFINITY #define _GNU_SOURCE @@ -79,18 +79,18 @@ files. /* mutex for initializing mutexes */ -static pthread_mutex_t mutex_init=PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t mutex_init = PTHREAD_MUTEX_INITIALIZER; /* mutex for initializing barriers */ -static pthread_mutex_t once_init=PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t once_init = PTHREAD_MUTEX_INITIALIZER; /* mutex for initializing thread_conds */ -static pthread_mutex_t cond_init=PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t cond_init = PTHREAD_MUTEX_INITIALIZER; /* mutex for initializing barriers */ -static pthread_mutex_t barrier_init=PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t barrier_init = PTHREAD_MUTEX_INITIALIZER; /* mutex for managing thread IDs */ -static pthread_mutex_t thread_id_mutex=PTHREAD_MUTEX_INITIALIZER; -static pthread_key_t thread_id_key; -static int thread_id_key_initialized=0; +static pthread_mutex_t thread_id_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_key_t thread_id_key; +static int thread_id_key_initialized = 0; @@ -104,7 +104,7 @@ void tMPI_Fatal_error(const char *file, int line, const char *message, ...) va_start(ap, message); vfprintf(stderr, message, ap); va_end(ap); - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); abort(); } @@ -117,16 +117,16 @@ enum tMPI_Thread_support tMPI_Thread_support(void) int tMPI_Thread_get_hw_number(void) { - int ret=0; + int ret = 0; #ifdef HAVE_SYSCONF #if defined(_SC_NPROCESSORS_ONLN) - ret=sysconf(_SC_NPROCESSORS_ONLN); + ret = sysconf(_SC_NPROCESSORS_ONLN); #elif defined(_SC_NPROC_ONLN) - ret=sysconf(_SC_NPROC_ONLN); + ret = sysconf(_SC_NPROC_ONLN); #elif defined(_SC_NPROCESSORS_CONF) - ret=sysconf(_SC_NPROCESSORS_CONF); + ret = sysconf(_SC_NPROCESSORS_CONF); #elif defined(_SC_NPROC_CONF) - ret=sysconf(_SC_NPROC_CONF); + ret = sysconf(_SC_NPROC_CONF); #endif #endif @@ -136,10 +136,10 @@ int tMPI_Thread_get_hw_number(void) /* destructor for thread ids */ static void tMPI_Destroy_thread_id(void* thread_id) { - struct tMPI_Thread *thread=(struct tMPI_Thread*)thread_id; + struct tMPI_Thread *thread = (struct tMPI_Thread*)thread_id; if (!thread->started_by_tmpi) { - /* if the thread is started by tMPI, it must be freed in the join() + /* if the thread is started by tMPI, it must be freed in the join() call. */ free(thread_id); } @@ -154,11 +154,11 @@ static void tMPI_Init_thread_ids(void) /* initialize and set the thread id thread-specific variable */ struct tMPI_Thread *main_thread; - thread_id_key_initialized=1; + thread_id_key_initialized = 1; pthread_key_create(&thread_id_key, tMPI_Destroy_thread_id); - main_thread=(struct tMPI_Thread*)malloc(sizeof(struct tMPI_Thread)*1); - main_thread->th=pthread_self(); - main_thread->started_by_tmpi=0; + main_thread = (struct tMPI_Thread*)malloc(sizeof(struct tMPI_Thread)*1); + main_thread->th = pthread_self(); + main_thread->started_by_tmpi = 0; pthread_setspecific(thread_id_key, main_thread); } pthread_mutex_unlock( &thread_id_mutex ); @@ -168,20 +168,20 @@ static void tMPI_Init_thread_ids(void) struct tMPI_Thread_starter { struct tMPI_Thread *thread; - void *(*start_routine)(void*); - void *arg; + void *(*start_routine)(void*); + void *arg; }; /* the thread_starter function that sets the thread id */ static void *tMPI_Thread_starter(void *arg) { - struct tMPI_Thread_starter *starter=(struct tMPI_Thread_starter *)arg; + struct tMPI_Thread_starter *starter = (struct tMPI_Thread_starter *)arg; void *(*start_routine)(void*); void *parg; pthread_setspecific(thread_id_key, starter->thread); - start_routine=starter->start_routine; - parg=starter->arg; + start_routine = starter->start_routine; + parg = starter->arg; free(starter); return (*start_routine)(parg); @@ -193,30 +193,30 @@ int tMPI_Thread_create(tMPI_Thread_t *thread, void *(*start_routine)(void *), int ret; struct tMPI_Thread_starter *starter; - if(thread==NULL) + if (thread == NULL) { - tMPI_Fatal_error(TMPI_FARGS,"Invalid thread pointer."); + tMPI_Fatal_error(TMPI_FARGS, "Invalid thread pointer."); return EINVAL; } tMPI_Init_thread_ids(); - *thread=(struct tMPI_Thread*)malloc(sizeof(struct tMPI_Thread)*1); + *thread = (struct tMPI_Thread*)malloc(sizeof(struct tMPI_Thread)*1); (*thread)->started_by_tmpi = 1; - starter=(struct tMPI_Thread_starter*) - malloc(sizeof(struct tMPI_Thread_starter)*1); + starter = (struct tMPI_Thread_starter*) + malloc(sizeof(struct tMPI_Thread_starter)*1); /* fill the starter structure */ - starter->thread=*thread; - starter->start_routine=start_routine; - starter->arg=arg; + starter->thread = *thread; + starter->start_routine = start_routine; + starter->arg = arg; /*ret=pthread_create(&((*thread)->th),NULL,start_routine,arg);*/ - ret=pthread_create(&((*thread)->th),NULL,tMPI_Thread_starter, - (void*)starter); + ret = pthread_create(&((*thread)->th), NULL, tMPI_Thread_starter, + (void*)starter); - if(ret!=0) + if (ret != 0) { /* Cannot use tMPI_error() since messages use threads for locking */ - tMPI_Fatal_error(TMPI_FARGS,"Failed to create POSIX thread:%s, rc=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed to create POSIX thread:%s, rc=%d", strerror(errno), ret); /* Use system memory allocation routines */ return -1; @@ -229,16 +229,16 @@ int tMPI_Thread_create(tMPI_Thread_t *thread, void *(*start_routine)(void *), int tMPI_Thread_join(tMPI_Thread_t thread, void **value_ptr) { - int ret; - pthread_t th=thread->th; + int ret; + pthread_t th = thread->th; + - ret = pthread_join( th, value_ptr ); free(thread); - if(ret != 0 ) + if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Failed to join POSIX thread. rc=%d",ret); + tMPI_Fatal_error(TMPI_FARGS, "Failed to join POSIX thread. rc=%d", ret); } return ret; } @@ -250,15 +250,15 @@ tMPI_Thread_t tMPI_Thread_self(void) /* make sure the key var is set */ tMPI_Init_thread_ids(); - th=pthread_getspecific(thread_id_key); + th = pthread_getspecific(thread_id_key); /* check if it is already in our list */ if (th == NULL) { /* if not, create an ID, set it and return it */ - th=(struct tMPI_Thread*)malloc(sizeof(struct tMPI_Thread)*1); - th->started_by_tmpi=0; - th->th=pthread_self(); + th = (struct tMPI_Thread*)malloc(sizeof(struct tMPI_Thread)*1); + th->started_by_tmpi = 0; + th->th = pthread_self(); pthread_setspecific(thread_id_key, th); } return th; @@ -284,7 +284,7 @@ enum tMPI_Thread_setaffinity_support tMPI_Thread_setaffinity_support(void) int tMPI_Thread_setaffinity_single(tMPI_Thread_t thread, unsigned int nr) { #ifdef HAVE_PTHREAD_SETAFFINITY - int nt=tMPI_Thread_get_hw_number(); + int nt = tMPI_Thread_get_hw_number(); cpu_set_t set; if (nt < nr) @@ -302,21 +302,21 @@ int tMPI_Thread_setaffinity_single(tMPI_Thread_t thread, unsigned int nr) -int tMPI_Thread_mutex_init(tMPI_Thread_mutex_t *mtx) +int tMPI_Thread_mutex_init(tMPI_Thread_mutex_t *mtx) { int ret; - + if (mtx == NULL) { return EINVAL; } - mtx->mutex=(struct tMPI_Mutex*)tMPI_Malloc(sizeof(struct tMPI_Mutex)*1); - ret = pthread_mutex_init(&(mtx->mutex->mtx),NULL); - - if(ret!=0) + mtx->mutex = (struct tMPI_Mutex*)tMPI_Malloc(sizeof(struct tMPI_Mutex)*1); + ret = pthread_mutex_init(&(mtx->mutex->mtx), NULL); + + if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Error initializing POSIX mutex. rc=%d"); + tMPI_Fatal_error(TMPI_FARGS, "Error initializing POSIX mutex. rc=%d"); /* Use system memory allocation routines */ return ret; } @@ -327,36 +327,36 @@ int tMPI_Thread_mutex_init(tMPI_Thread_mutex_t *mtx) static int tMPI_Thread_mutex_init_once(tMPI_Thread_mutex_t *mtx) { - int ret=0; + int ret = 0; /* we're relying on the memory barrier semantics of mutex_lock/unlock for the check preceding this function call to have worked */ - pthread_mutex_lock( &(mutex_init) ); - if(mtx->mutex==NULL) + pthread_mutex_lock( &(mutex_init) ); + if (mtx->mutex == NULL) { - mtx->mutex=(struct tMPI_Mutex*)tMPI_Malloc(sizeof(struct tMPI_Mutex)*1); - ret=pthread_mutex_init( &(mtx->mutex->mtx), NULL); + mtx->mutex = (struct tMPI_Mutex*)tMPI_Malloc(sizeof(struct tMPI_Mutex)*1); + ret = pthread_mutex_init( &(mtx->mutex->mtx), NULL); } - pthread_mutex_unlock( &(mutex_init) ); + pthread_mutex_unlock( &(mutex_init) ); return ret; } -int tMPI_Thread_mutex_destroy(tMPI_Thread_mutex_t *mtx) +int tMPI_Thread_mutex_destroy(tMPI_Thread_mutex_t *mtx) { int ret; - if(mtx == NULL) + if (mtx == NULL) { return EINVAL; } - + ret = pthread_mutex_destroy( &(mtx->mutex->mtx) ); free(mtx->mutex); - - if(ret!=0) + + if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Error destroying POSIX mutex. rc=%d",ret); + tMPI_Fatal_error(TMPI_FARGS, "Error destroying POSIX mutex. rc=%d", ret); /* Use system memory allocation routines */ } return ret; @@ -371,17 +371,19 @@ int tMPI_Thread_mutex_lock(tMPI_Thread_mutex_t *mtx) /* check whether the mutex is initialized */ if (tMPI_Atomic_get( &(mtx->initialized) ) == 0) { - ret=tMPI_Thread_mutex_init_once(mtx); + ret = tMPI_Thread_mutex_init_once(mtx); if (ret) + { return ret; + } } - - ret=pthread_mutex_lock(&(mtx->mutex->mtx)); + + ret = pthread_mutex_lock(&(mtx->mutex->mtx)); return ret; } - + int tMPI_Thread_mutex_trylock(tMPI_Thread_mutex_t *mtx) @@ -391,13 +393,15 @@ int tMPI_Thread_mutex_trylock(tMPI_Thread_mutex_t *mtx) /* check whether the mutex is initialized */ if (tMPI_Atomic_get( &(mtx->initialized) ) == 0) { - ret=tMPI_Thread_mutex_init_once(mtx); + ret = tMPI_Thread_mutex_init_once(mtx); if (ret) + { return ret; + } } - ret=pthread_mutex_trylock(&(mtx->mutex->mtx)); - + ret = pthread_mutex_trylock(&(mtx->mutex->mtx)); + return ret; } @@ -406,17 +410,19 @@ int tMPI_Thread_mutex_trylock(tMPI_Thread_mutex_t *mtx) int tMPI_Thread_mutex_unlock(tMPI_Thread_mutex_t *mtx) { int ret; - + /* check whether the mutex is initialized */ if (tMPI_Atomic_get( &(mtx->initialized) ) == 0) { - ret=tMPI_Thread_mutex_init_once(mtx); + ret = tMPI_Thread_mutex_init_once(mtx); if (ret) + { return ret; + } } - + ret = pthread_mutex_unlock(&(mtx->mutex->mtx)); - + return ret; } @@ -426,19 +432,19 @@ int tMPI_Thread_key_create(tMPI_Thread_key_t *key, void (*destructor)(void *)) { int ret; - if(key==NULL) + if (key == NULL) { - tMPI_Fatal_error(TMPI_FARGS,"Invalid key pointer."); + tMPI_Fatal_error(TMPI_FARGS, "Invalid key pointer."); return EINVAL; } - key->key=(struct tMPI_Thread_key*)tMPI_Malloc(sizeof(struct - tMPI_Thread_key)*1); + key->key = (struct tMPI_Thread_key*)tMPI_Malloc(sizeof(struct + tMPI_Thread_key)*1); ret = pthread_key_create(&((key)->key->pkey), destructor); - if(ret!=0) + if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Failed to create thread key, rc=%d.",ret); + tMPI_Fatal_error(TMPI_FARGS, "Failed to create thread key, rc=%d.", ret); fflush(stderr); return -1; } @@ -452,15 +458,15 @@ int tMPI_Thread_key_delete(tMPI_Thread_key_t key) { int ret; - ret=pthread_key_delete((key.key->pkey)); + ret = pthread_key_delete((key.key->pkey)); free(key.key); - if(ret!=0) + if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Failed to delete thread key, rc=%d.",ret); + tMPI_Fatal_error(TMPI_FARGS, "Failed to delete thread key, rc=%d.", ret); fflush(stderr); } - + return ret; } @@ -470,7 +476,7 @@ void * tMPI_Thread_getspecific(tMPI_Thread_key_t key) { void *p = NULL; - p=pthread_getspecific((key.key->pkey)); + p = pthread_getspecific((key.key->pkey)); return p; } @@ -479,15 +485,15 @@ void * tMPI_Thread_getspecific(tMPI_Thread_key_t key) int tMPI_Thread_setspecific(tMPI_Thread_key_t key, void *value) { int ret; - - ret=pthread_setspecific((key.key->pkey),value); - + + ret = pthread_setspecific((key.key->pkey), value); + return ret; } int tMPI_Thread_once(tMPI_Thread_once_t *once_control, - void (*init_routine)(void)) + void (*init_routine)(void)) { int ret; if (!once_control || !init_routine) @@ -496,8 +502,10 @@ int tMPI_Thread_once(tMPI_Thread_once_t *once_control, } /* really ugly hack - and it's slow... */ - if ( (ret=pthread_mutex_lock( &once_init )) ) + if ( (ret = pthread_mutex_lock( &once_init )) ) + { return ret; + } if (tMPI_Atomic_get(&(once_control->once)) == 0) { (*init_routine)(); @@ -511,61 +519,61 @@ int tMPI_Thread_once(tMPI_Thread_once_t *once_control, -int tMPI_Thread_cond_init(tMPI_Thread_cond_t *cond) +int tMPI_Thread_cond_init(tMPI_Thread_cond_t *cond) { int ret; - - if(cond==NULL) + + if (cond == NULL) { return EINVAL; } - - cond->condp=(struct tMPI_Thread_cond*) - tMPI_Malloc(sizeof(struct tMPI_Thread_cond)*1); + + cond->condp = (struct tMPI_Thread_cond*) + tMPI_Malloc(sizeof(struct tMPI_Thread_cond)*1); ret = pthread_cond_init(&(cond->condp->cond), NULL); - - if(ret!=0) + + if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Error initializing POSIX condition variable. rc=%d",ret); + tMPI_Fatal_error(TMPI_FARGS, "Error initializing POSIX condition variable. rc=%d", ret); fflush(stderr); } - tMPI_Atomic_set(&(cond->initialized),1); + tMPI_Atomic_set(&(cond->initialized), 1); return ret; } static int tMPI_Thread_cond_init_once(tMPI_Thread_cond_t *cond) { - int ret=0; + int ret = 0; /* we're relying on the memory barrier semantics of mutex_lock/unlock for the check preceding this function call to have worked */ - pthread_mutex_lock( &(cond_init) ); - if(cond->condp==NULL) + pthread_mutex_lock( &(cond_init) ); + if (cond->condp == NULL) { - cond->condp=(struct tMPI_Thread_cond*) - tMPI_Malloc(sizeof(struct tMPI_Thread_cond)*1); - ret=pthread_cond_init( &(cond->condp->cond), NULL); + cond->condp = (struct tMPI_Thread_cond*) + tMPI_Malloc(sizeof(struct tMPI_Thread_cond)*1); + ret = pthread_cond_init( &(cond->condp->cond), NULL); } - pthread_mutex_unlock( &(cond_init) ); + pthread_mutex_unlock( &(cond_init) ); return ret; } -int tMPI_Thread_cond_destroy(tMPI_Thread_cond_t *cond) +int tMPI_Thread_cond_destroy(tMPI_Thread_cond_t *cond) { int ret; - - if(cond == NULL) + + if (cond == NULL) { return EINVAL; } - + ret = pthread_cond_destroy(&(cond->condp->cond)); free(cond->condp); - - if(ret!=0) + + if (ret != 0) { tMPI_Fatal_error(TMPI_FARGS, "Error destroying POSIX condition variable. rc=%d", @@ -586,9 +594,9 @@ int tMPI_Thread_cond_wait(tMPI_Thread_cond_t *cond, tMPI_Thread_mutex_t *mtx) tMPI_Thread_cond_init_once(cond); } /* the mutex must have been initialized because it should be locked here */ - + ret = pthread_cond_wait( &(cond->condp->cond), &(mtx->mutex->mtx) ); - + return ret; } @@ -604,9 +612,9 @@ int tMPI_Thread_cond_signal(tMPI_Thread_cond_t *cond) { tMPI_Thread_cond_init_once(cond); } - + ret = pthread_cond_signal( &(cond->condp->cond) ); - + return ret; } @@ -621,9 +629,9 @@ int tMPI_Thread_cond_broadcast(tMPI_Thread_cond_t *cond) { tMPI_Thread_cond_init_once(cond); } - + ret = pthread_cond_broadcast( &(cond->condp->cond) ); - + return ret; } @@ -648,33 +656,33 @@ int tMPI_Thread_barrier_init(tMPI_Thread_barrier_t *barrier, int n) { int ret; /*tMPI_Thread_pthread_barrier_t *p;*/ - - if(barrier==NULL) + + if (barrier == NULL) { return EINVAL; } - - barrier->barrierp=(struct tMPI_Thread_barrier*) - tMPI_Malloc(sizeof(struct tMPI_Thread_barrier)*1); - ret = pthread_mutex_init(&(barrier->barrierp->mutex),NULL); - - if(ret!=0) + + barrier->barrierp = (struct tMPI_Thread_barrier*) + tMPI_Malloc(sizeof(struct tMPI_Thread_barrier)*1); + ret = pthread_mutex_init(&(barrier->barrierp->mutex), NULL); + + if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Error initializing POSIX mutex. rc=%d", + tMPI_Fatal_error(TMPI_FARGS, "Error initializing POSIX mutex. rc=%d", ret); return ret; } - - ret = pthread_cond_init(&(barrier->barrierp->cv),NULL); - - if(ret!=0) + + ret = pthread_cond_init(&(barrier->barrierp->cv), NULL); + + if (ret != 0) { tMPI_Fatal_error(TMPI_FARGS, "Error initializing POSIX condition variable. rc=%d", ret); return ret; } - + barrier->threshold = n; barrier->count = n; barrier->cycle = 0; @@ -685,27 +693,27 @@ int tMPI_Thread_barrier_init(tMPI_Thread_barrier_t *barrier, int n) static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier) { - int ret=0; + int ret = 0; /* we're relying on the memory barrier semantics of mutex_lock/unlock for the check preceding this function call to have worked */ - pthread_mutex_lock( &(barrier_init) ); - if(barrier->barrierp==NULL) + pthread_mutex_lock( &(barrier_init) ); + if (barrier->barrierp == NULL) { - barrier->barrierp=(struct tMPI_Thread_barrier*) - tMPI_Malloc(sizeof(struct tMPI_Thread_barrier)*1); - ret = pthread_mutex_init(&(barrier->barrierp->mutex),NULL); + barrier->barrierp = (struct tMPI_Thread_barrier*) + tMPI_Malloc(sizeof(struct tMPI_Thread_barrier)*1); + ret = pthread_mutex_init(&(barrier->barrierp->mutex), NULL); - if(ret!=0) + if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Error initializing POSIX mutex. rc=%d", + tMPI_Fatal_error(TMPI_FARGS, "Error initializing POSIX mutex. rc=%d", ret); return ret; } - ret = pthread_cond_init(&(barrier->barrierp->cv),NULL); + ret = pthread_cond_init(&(barrier->barrierp->cv), NULL); - if(ret!=0) + if (ret != 0) { tMPI_Fatal_error(TMPI_FARGS, "Error initializing POSIX condition variable. rc=%d", @@ -713,7 +721,7 @@ static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier) return ret; } } - pthread_mutex_unlock( &(barrier_init) ); + pthread_mutex_unlock( &(barrier_init) ); return ret; } @@ -722,7 +730,7 @@ static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier) int tMPI_Thread_barrier_destroy(tMPI_Thread_barrier_t *barrier) { - if(barrier==NULL) + if (barrier == NULL) { return EINVAL; } @@ -731,16 +739,16 @@ int tMPI_Thread_barrier_destroy(tMPI_Thread_barrier_t *barrier) pthread_cond_destroy(&(barrier->barrierp->cv)); free(barrier->barrierp); - + return 0; } - + int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t * barrier) { int cycle; int rc; - + /* check whether the barrier is initialized */ if (tMPI_Atomic_get( &(barrier->initialized) ) == 0) { @@ -750,34 +758,41 @@ int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t * barrier) rc = pthread_mutex_lock(&barrier->barrierp->mutex); - - if(rc != 0) + + if (rc != 0) + { return EBUSY; + } cycle = barrier->cycle; - + /* Decrement the count atomically and check if it is zero. - * This will only be true for the last thread calling us. - */ - if( --barrier->count <= 0 ) - { + * This will only be true for the last thread calling us. + */ + if (--barrier->count <= 0) + { barrier->cycle = !barrier->cycle; barrier->count = barrier->threshold; - rc = pthread_cond_broadcast(&barrier->barrierp->cv); - - if(rc == 0) + rc = pthread_cond_broadcast(&barrier->barrierp->cv); + + if (rc == 0) + { rc = -1; + } } else { - while(cycle == barrier->cycle) + while (cycle == barrier->cycle) { rc = pthread_cond_wait(&barrier->barrierp->cv, &barrier->barrierp->mutex); - if(rc != 0) break; + if (rc != 0) + { + break; + } } } - + pthread_mutex_unlock(&barrier->barrierp->mutex); return rc; } @@ -785,7 +800,6 @@ int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t * barrier) #else /* just to have some symbols */ -int tMPI_Thread_pthreads=0; +int tMPI_Thread_pthreads = 0; #endif /* THREAD_PTHREADS */ - diff --git a/src/gromacs/gmxlib/thread_mpi/pthreads.h b/src/gromacs/gmxlib/thread_mpi/pthreads.h index ec31a342a2..78905aac26 100644 --- a/src/gromacs/gmxlib/thread_mpi/pthreads.h +++ b/src/gromacs/gmxlib/thread_mpi/pthreads.h @@ -1,46 +1,46 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ /* the types that were defined in include/thread_mpi/threads.h */ struct tMPI_Thread { - pthread_t th; /*!< The POSIX thread ID */ - int started_by_tmpi; /*!< whether the thread is started by tMPI */ + pthread_t th; /*!< The POSIX thread ID */ + int started_by_tmpi; /*!< whether the thread is started by tMPI */ }; struct tMPI_Thread_key @@ -60,15 +60,10 @@ struct tMPI_Thread_cond struct tMPI_Thread_barrier { - tMPI_Atomic_t initialized; + tMPI_Atomic_t initialized; pthread_mutex_t mutex; /*!< Lock for the barrier contents */ pthread_cond_t cv; /*!< Condition to signal barrier completion */ int threshold; /*!< Total number of members in barrier */ int count; /*!< Remaining count before completion */ int cycle; /*!< Alternating 0/1 to indicate round */ }; - - - - - diff --git a/src/gromacs/gmxlib/thread_mpi/reduce.c b/src/gromacs/gmxlib/thread_mpi/reduce.c index 77056cf116..b155b67d4c 100644 --- a/src/gromacs/gmxlib/thread_mpi/reduce.c +++ b/src/gromacs/gmxlib/thread_mpi/reduce.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -58,13 +58,13 @@ files. #include "collective.h" -int tMPI_Reduce_run_op(void *dest, void *src_a, void *src_b, - tMPI_Datatype datatype, int count, tMPI_Op op, +int tMPI_Reduce_run_op(void *dest, void *src_a, void *src_b, + tMPI_Datatype datatype, int count, tMPI_Op op, tMPI_Comm comm) { - tMPI_Op_fn fn=datatype->op_functions[op]; + tMPI_Op_fn fn = datatype->op_functions[op]; - if (src_a==src_b) + if (src_a == src_b) { return tMPI_Error(comm, TMPI_ERR_XFER_BUF_OVERLAP); } @@ -72,26 +72,28 @@ int tMPI_Reduce_run_op(void *dest, void *src_a, void *src_b, return TMPI_SUCCESS; } -int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count, - tMPI_Datatype datatype, tMPI_Op op, int root, +int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count, + tMPI_Datatype datatype, tMPI_Op op, int root, tMPI_Comm comm) { - struct tmpi_thread *cur=tMPI_Get_current(); - int myrank=tMPI_Comm_seek_rank(comm, cur); + struct tmpi_thread *cur = tMPI_Get_current(); + int myrank = tMPI_Comm_seek_rank(comm, cur); /* this function uses a binary tree-like reduction algorithm: */ - int N=tMPI_Comm_N(comm); - int myrank_rtr=(N+myrank-root)%N; /* my rank relative to root */ - int Nred=N; /* number of neighbours that still communicate - (decreases exponentially) */ - int nbr_dist=1; /* distance between communicating neighbours - (increases exponentially) */ - int stepping=2; /* distance between non-communicating neighbours - (increases exponentially) */ - int iteration=0; - - if (count==0) + int N = tMPI_Comm_N(comm); + int myrank_rtr = (N+myrank-root)%N; /* my rank relative to root */ + int Nred = N; /* number of neighbours that still communicate + (decreases exponentially) */ + int nbr_dist = 1; /* distance between communicating neighbours + (increases exponentially) */ + int stepping = 2; /* distance between non-communicating neighbours + (increases exponentially) */ + int iteration = 0; + + if (count == 0) + { return TMPI_SUCCESS; + } if (!comm) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); @@ -105,38 +107,38 @@ int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count, return tMPI_Error(comm, TMPI_ERR_OP_FN); } - if (sendbuf==TMPI_IN_PLACE)/* i.e. sendbuf == tMPI_IN_PLACE */ + if (sendbuf == TMPI_IN_PLACE) /* i.e. sendbuf == tMPI_IN_PLACE */ { - sendbuf=recvbuf; + sendbuf = recvbuf; } /* we set our send and recv buffer s*/ - tMPI_Atomic_ptr_set(&(comm->reduce_sendbuf[myrank]),sendbuf); - tMPI_Atomic_ptr_set(&(comm->reduce_recvbuf[myrank]),recvbuf); + tMPI_Atomic_ptr_set(&(comm->reduce_sendbuf[myrank]), sendbuf); + tMPI_Atomic_ptr_set(&(comm->reduce_recvbuf[myrank]), recvbuf); - while (Nred>1) + while (Nred > 1) { /* calculate neighbour rank (here we use the real rank) */ - int nbr=(myrank_rtr%stepping==0) ? - (N+myrank+nbr_dist)%N : - (N+myrank-nbr_dist)%N; + int nbr = (myrank_rtr%stepping == 0) ? + (N+myrank+nbr_dist)%N : + (N+myrank-nbr_dist)%N; #ifdef TMPI_DEBUG - printf("%d: iteration %d: myrank_rtr=%d, stepping=%d\n", + printf("%d: iteration %d: myrank_rtr=%d, stepping=%d\n", myrank, iteration, myrank_rtr, stepping); fflush(stdout); #endif /* check if I'm the reducing thread in this iteration's pair: */ if (myrank_rtr%stepping == 0) { - void *a,*b; - int ret; + void *a, *b; + int ret; - /* now wait for my neighbor's data to become ready. + /* now wait for my neighbor's data to become ready. First check if I actually have a neighbor. */ - if (myrank_rtr+nbr_distreduce_sendbuf[nbr])); + a = sendbuf; + b = (void*)tMPI_Atomic_ptr_get(&(comm->reduce_sendbuf[nbr])); } else { - /* after the first operation, they're already in + /* after the first operation, they're already in the recvbuf */ - a=recvbuf; - b=(void*)tMPI_Atomic_ptr_get(&(comm->reduce_recvbuf[nbr])); + a = recvbuf; + b = (void*)tMPI_Atomic_ptr_get(&(comm->reduce_recvbuf[nbr])); } - if ((ret=tMPI_Reduce_run_op(recvbuf, a, b, datatype, - count, op, comm)) != TMPI_SUCCESS) + if ((ret = tMPI_Reduce_run_op(recvbuf, a, b, datatype, + count, op, comm)) != TMPI_SUCCESS) + { return ret; + } /* signal to my neighbour that I'm ready. */ tMPI_Event_signal( &(comm->csync[nbr].events[myrank]) ); @@ -181,15 +185,17 @@ int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count, else { #ifdef TMPI_DEBUG - printf("%d: not waiting copying buffer\n", myrank); - fflush(stdout); + printf("%d: not waiting copying buffer\n", myrank); + fflush(stdout); #endif /* we still need to put things in the right buffer for the next iteration. We need to check for overlapping buffers here because MPI_IN_PLACE might cause recvbuf to be the same as sendbuf. */ - if (iteration==0 && (recvbuf!=sendbuf)) + if (iteration == 0 && (recvbuf != sendbuf)) + { memcpy(recvbuf, sendbuf, datatype->size*count); + } } } @@ -197,16 +203,16 @@ int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count, { /* the other thread is doing the reducing; we can just wait and break when ready */ - /* Awake our neighbour */ + /* Awake our neighbour */ tMPI_Event_signal( &(comm->csync[nbr].events[myrank]) ); #ifdef TMPI_DEBUG - printf("%d: signalled %d, now waiting: iteration=%d\n", + printf("%d: signalled %d, now waiting: iteration=%d\n", nbr, myrank, iteration); fflush(stdout); #endif - + /* And wait for an incoming event from out neighbour */ #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_start(cur); @@ -218,7 +224,7 @@ int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count, #endif /* now we can break because our data is reduced, and our neighbour goes on reducing it further. */ - break; + break; } #ifdef TMPI_DEBUG @@ -226,9 +232,9 @@ int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count, fflush(stdout); #endif - Nred = Nred/2 + Nred%2; - nbr_dist*=2; - stepping*=2; + Nred = Nred/2 + Nred%2; + nbr_dist *= 2; + stepping *= 2; iteration++; } @@ -236,25 +242,25 @@ int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count, } int tMPI_Reduce(void* sendbuf, void* recvbuf, int count, - tMPI_Datatype datatype, tMPI_Op op, int root, tMPI_Comm comm) + tMPI_Datatype datatype, tMPI_Op op, int root, tMPI_Comm comm) { - struct tmpi_thread *cur=tMPI_Get_current(); - int myrank=tMPI_Comm_seek_rank(comm, cur); - int ret; + struct tmpi_thread *cur = tMPI_Get_current(); + int myrank = tMPI_Comm_seek_rank(comm, cur); + int ret; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Reduce(%p, %p, %d, %p, %p, %d, %p)", - sendbuf, recvbuf, count, datatype, op, root, comm); + sendbuf, recvbuf, count, datatype, op, root, comm); #endif - if (myrank==root) + if (myrank == root) { - if (sendbuf==TMPI_IN_PLACE) /* i.e. sendbuf == TMPI_IN_PLACE */ + if (sendbuf == TMPI_IN_PLACE) /* i.e. sendbuf == TMPI_IN_PLACE */ { - sendbuf=recvbuf; + sendbuf = recvbuf; } } else @@ -262,10 +268,10 @@ int tMPI_Reduce(void* sendbuf, void* recvbuf, int count, #ifdef TMPI_WARN_MALLOC fprintf(stderr, "Warning: malloc during tMPI_Reduce\n"); #endif - recvbuf=(void*)tMPI_Malloc(datatype->size*count); + recvbuf = (void*)tMPI_Malloc(datatype->size*count); } - ret=tMPI_Reduce_fast(sendbuf, recvbuf, count, datatype, op, root, comm); - if (myrank!=root) + ret = tMPI_Reduce_fast(sendbuf, recvbuf, count, datatype, op, root, comm); + if (myrank != root) { free(recvbuf); } @@ -278,10 +284,10 @@ int tMPI_Reduce(void* sendbuf, void* recvbuf, int count, int tMPI_Allreduce(void* sendbuf, void* recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, tMPI_Comm comm) { - void *rootbuf=NULL; /* root process' receive buffer */ - struct tmpi_thread *cur=tMPI_Get_current(); - int myrank=tMPI_Comm_seek_rank(comm, cur); - int ret; + void *rootbuf = NULL; /* root process' receive buffer */ + struct tmpi_thread *cur = tMPI_Get_current(); + int myrank = tMPI_Comm_seek_rank(comm, cur); + int ret; #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); @@ -290,19 +296,21 @@ int tMPI_Allreduce(void* sendbuf, void* recvbuf, int count, tMPI_Trace_print("tMPI_Allreduce(%p, %p, %d, %p, %p, %p)", sendbuf, recvbuf, count, datatype, op, comm); #endif - if (count==0) + if (count == 0) + { return TMPI_SUCCESS; + } if (!recvbuf) { return tMPI_Error(comm, TMPI_ERR_BUF); } - if (sendbuf==TMPI_IN_PLACE) /* i.e. sendbuf == TMPI_IN_PLACE */ + if (sendbuf == TMPI_IN_PLACE) /* i.e. sendbuf == TMPI_IN_PLACE */ { - sendbuf=recvbuf; + sendbuf = recvbuf; } - ret=tMPI_Reduce_fast(sendbuf, recvbuf, count, datatype, op, 0, comm); -#if defined(TMPI_PROFILE) + ret = tMPI_Reduce_fast(sendbuf, recvbuf, count, datatype, op, 0, comm); +#if defined(TMPI_PROFILE) tMPI_Profile_wait_start(cur); #endif tMPI_Barrier_wait( &(comm->barrier)); @@ -310,14 +318,14 @@ int tMPI_Allreduce(void* sendbuf, void* recvbuf, int count, tMPI_Profile_wait_stop(cur, TMPIWAIT_Reduce); #endif /* distribute rootbuf */ - rootbuf=(void*)tMPI_Atomic_ptr_get(&(comm->reduce_recvbuf[0])); + rootbuf = (void*)tMPI_Atomic_ptr_get(&(comm->reduce_recvbuf[0])); - /* and now we just copy things back. We know that the root thread - arrives last, so there's no point in using tMPI_Scatter with + /* and now we just copy things back. We know that the root thread + arrives last, so there's no point in using tMPI_Scatter with copy buffers, etc. */ if (myrank != 0) { - if (rootbuf==recvbuf) + if (rootbuf == recvbuf) { return tMPI_Error(comm, TMPI_ERR_XFER_BUF_OVERLAP); } @@ -334,5 +342,3 @@ int tMPI_Allreduce(void* sendbuf, void* recvbuf, int count, #endif return ret; } - - diff --git a/src/gromacs/gmxlib/thread_mpi/reduce_fast.c b/src/gromacs/gmxlib/thread_mpi/reduce_fast.c index 3f49eb23a4..4c0ff6d7ae 100644 --- a/src/gromacs/gmxlib/thread_mpi/reduce_fast.c +++ b/src/gromacs/gmxlib/thread_mpi/reduce_fast.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -63,9 +63,9 @@ static void *tMPI_Reduce_req_allocator(void *arg) tMPI_Reduce_req *ret; /*tMPI_Comm comm=(tMPI_Comm)arg;*/ - ret=(tMPI_Reduce_req*)tMPI_Malloc(sizeof(tMPI_Reduce_req)); + ret = (tMPI_Reduce_req*)tMPI_Malloc(sizeof(tMPI_Reduce_req)); tMPI_Atomic_set( &(ret->n_remaining), 0); - ret->comm=(tMPI_Comm)arg; + ret->comm = (tMPI_Comm)arg; return (void*)ret; } @@ -73,20 +73,17 @@ static void *tMPI_Reduce_req_allocator(void *arg) tMPI_Reduce_req *tMPI_Reduce_req_alloc(tMPI_Comm comm) { tMPI_Reduce_req *ret; - ret=(tMPI_Reduce_req*)tMPI_Once_wait(comm, tMPI_Reduce_req_allocator, - comm, NULL); + ret = (tMPI_Reduce_req*)tMPI_Once_wait(comm, tMPI_Reduce_req_allocator, + comm, NULL); return ret; } #if 0 -void tMPI_Reduce_async(tMPI_Reduce_req *req, - void (*function)(int, void*, void*, void *), +void tMPI_Reduce_async(tMPI_Reduce_req *req, + void (*function)(int, void*, void*, void *), size_t n, void *input, void *res) { - + } #endif - - - diff --git a/src/gromacs/gmxlib/thread_mpi/scan.c b/src/gromacs/gmxlib/thread_mpi/scan.c index f222bf9d54..1b7adf528e 100644 --- a/src/gromacs/gmxlib/thread_mpi/scan.c +++ b/src/gromacs/gmxlib/thread_mpi/scan.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -62,11 +62,11 @@ files. int tMPI_Scan(void* sendbuf, void* recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, tMPI_Comm comm) { - struct tmpi_thread *cur=tMPI_Get_current(); - int myrank=tMPI_Comm_seek_rank(comm, cur); - int N=tMPI_Comm_N(comm); - int prev=myrank - 1; /* my previous neighbor */ - int next=myrank + 1; /* my next neighbor */ + struct tmpi_thread *cur = tMPI_Get_current(); + int myrank = tMPI_Comm_seek_rank(comm, cur); + int N = tMPI_Comm_N(comm); + int prev = myrank - 1; /* my previous neighbor */ + int next = myrank + 1; /* my next neighbor */ #ifdef TMPI_PROFILE tMPI_Profile_count_start(cur); @@ -75,26 +75,28 @@ int tMPI_Scan(void* sendbuf, void* recvbuf, int count, tMPI_Trace_print("tMPI_Scan(%p, %p, %d, %p, %p, %p)", sendbuf, recvbuf, count, datatype, op, comm); #endif - if (count==0) + if (count == 0) + { return TMPI_SUCCESS; + } if (!recvbuf) { return tMPI_Error(comm, TMPI_ERR_BUF); } - if (sendbuf==TMPI_IN_PLACE) + if (sendbuf == TMPI_IN_PLACE) { - sendbuf=recvbuf; + sendbuf = recvbuf; } /* we set our send and recv buffers */ - tMPI_Atomic_ptr_set(&(comm->reduce_sendbuf[myrank]),sendbuf); - tMPI_Atomic_ptr_set(&(comm->reduce_recvbuf[myrank]),recvbuf); + tMPI_Atomic_ptr_set(&(comm->reduce_sendbuf[myrank]), sendbuf); + tMPI_Atomic_ptr_set(&(comm->reduce_recvbuf[myrank]), recvbuf); /* now wait for the previous rank to finish */ if (myrank > 0) { void *a, *b; - int ret; + int ret; #if defined(TMPI_PROFILE) && defined(TMPI_CYCLE_COUNT) tMPI_Profile_wait_start(cur); @@ -120,8 +122,8 @@ int tMPI_Scan(void* sendbuf, void* recvbuf, int count, } b = sendbuf; - if ((ret=tMPI_Reduce_run_op(recvbuf, a, b, datatype, - count, op, comm)) != TMPI_SUCCESS) + if ((ret = tMPI_Reduce_run_op(recvbuf, a, b, datatype, + count, op, comm)) != TMPI_SUCCESS) { return ret; } @@ -158,6 +160,3 @@ int tMPI_Scan(void* sendbuf, void* recvbuf, int count, #endif return TMPI_SUCCESS; } - - - diff --git a/src/gromacs/gmxlib/thread_mpi/scatter.c b/src/gromacs/gmxlib/thread_mpi/scatter.c index 2f25373a95..dab23f0bec 100644 --- a/src/gromacs/gmxlib/thread_mpi/scatter.c +++ b/src/gromacs/gmxlib/thread_mpi/scatter.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -60,37 +60,37 @@ files. int tMPI_Scatter(void* sendbuf, int sendcount, tMPI_Datatype sendtype, - void* recvbuf, int recvcount, tMPI_Datatype recvtype, + void* recvbuf, int recvcount, tMPI_Datatype recvtype, int root, tMPI_Comm comm) { - int synct; - struct coll_env *cev; - int myrank; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); + int synct; + struct coll_env *cev; + int myrank; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); #ifdef TMPI_PROFILE - tMPI_Profile_count_start(cur); + tMPI_Profile_count_start(cur); #endif #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Scatter(%p, %d, %p, %p, %d, %p, %d, %p)", - sendbuf, sendcount, sendtype, + tMPI_Trace_print("tMPI_Scatter(%p, %d, %p, %p, %d, %p, %d, %p)", + sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm); #endif if (!comm) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - myrank=tMPI_Comm_seek_rank(comm, cur); + myrank = tMPI_Comm_seek_rank(comm, cur); /* we increase our counter, and determine which coll_env we get */ - cev=tMPI_Get_cev(comm, myrank, &synct); + cev = tMPI_Get_cev(comm, myrank, &synct); - if (myrank==root) + if (myrank == root) { - int i; - size_t sendsize=sendtype->size*sendcount; - size_t total_send_size=0; + int i; + size_t sendsize = sendtype->size*sendcount; + size_t total_send_size = 0; #ifdef USE_COLLECTIVE_COPY_BUFFER tmpi_bool using_cb; #endif @@ -101,25 +101,25 @@ int tMPI_Scatter(void* sendbuf, int sendcount, tMPI_Datatype sendtype, } /* we set up multiple posts, so no Post_multi */ - cev->met[myrank].tag=TMPI_SCATTER_TAG; - cev->met[myrank].datatype=sendtype; + cev->met[myrank].tag = TMPI_SCATTER_TAG; + cev->met[myrank].datatype = sendtype; tMPI_Atomic_memory_barrier_rel(); tMPI_Atomic_set( &(cev->met[myrank].n_remaining), cev->N-1 ); - for(i=0;igrp.N;i++) - { - total_send_size += sendtype->size*sendcount; - cev->met[myrank].bufsize[i]=sendsize; - cev->met[myrank].buf[i]=(char*)sendbuf+sendsize*i; + for (i = 0; i < comm->grp.N; i++) + { + total_send_size += sendtype->size*sendcount; + cev->met[myrank].bufsize[i] = sendsize; + cev->met[myrank].buf[i] = (char*)sendbuf+sendsize*i; } #ifdef USE_COLLECTIVE_COPY_BUFFER - /* we must copy our own data too, unfortunately (otherwise there's + /* we must copy our own data too, unfortunately (otherwise there's a hole) */ - using_cb=(total_send_size < (size_t)((cev->N)*COPY_BUFFER_SIZE)); - cev->met[myrank].using_cb=using_cb; + using_cb = (total_send_size < (size_t)((cev->N)*COPY_BUFFER_SIZE)); + cev->met[myrank].using_cb = using_cb; if (using_cb) { /* we set cpbuf stuff to NULL initially */ - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { /*cev->met[myrank].cpbuf[i]=NULL;*/ tMPI_Atomic_ptr_set(&(cev->met[myrank].cpbuf[i]), NULL); @@ -129,10 +129,12 @@ int tMPI_Scatter(void* sendbuf, int sendcount, tMPI_Datatype sendtype, #endif /* post availability */ - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { if (i != myrank) + { tMPI_Event_signal( &(cev->met[i].recv_ev) ); + } } @@ -143,8 +145,8 @@ int tMPI_Scatter(void* sendbuf, int sendcount, tMPI_Datatype sendtype, if (using_cb) { /* copy the buffer locally. First allocate */ - cev->met[myrank].cb=tMPI_Copy_buffer_list_get( - &(tMPI_Get_thread(comm,myrank)->cbl_multi)); + cev->met[myrank].cb = tMPI_Copy_buffer_list_get( + &(tMPI_Get_thread(comm, myrank)->cbl_multi)); if (cev->met[myrank].cb->size < total_send_size) { fprintf(stderr, "ERROR: cb size too small\n"); @@ -154,23 +156,23 @@ int tMPI_Scatter(void* sendbuf, int sendcount, tMPI_Datatype sendtype, memcpy(cev->met[myrank].cb->buf, sendbuf, total_send_size); /* post the new buf */ - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { tMPI_Atomic_memory_barrier_rel(); tMPI_Atomic_ptr_set(&(cev->met[myrank].cpbuf[i]), (char*)cev->met[myrank].cb->buf+sendsize*i); - /*cev->met[myrank].cpbuf[i] = (char*)cev->met[myrank].cb->buf + + /*cev->met[myrank].cpbuf[i] = (char*)cev->met[myrank].cb->buf + sendsize*i ;*/ } } #endif /* do root transfer */ - if (recvbuf!=TMPI_IN_PLACE) + if (recvbuf != TMPI_IN_PLACE) { tMPI_Coll_root_xfer(comm, sendtype, recvtype, - sendsize, recvtype->size*recvcount, - (char*)sendbuf+sendsize*myrank, + sendsize, recvtype->size*recvcount, + (char*)sendbuf+sendsize*myrank, recvbuf, &ret); } @@ -180,14 +182,14 @@ int tMPI_Scatter(void* sendbuf, int sendcount, tMPI_Datatype sendtype, else { /* get the root cev */ - size_t bufsize=recvcount*recvtype->size; + size_t bufsize = recvcount*recvtype->size; /* wait until root becomes available */ tMPI_Wait_for_data(cur, cev, myrank); - tMPI_Mult_recv(comm, cev, root, myrank,TMPI_SCATTER_TAG, recvtype, + tMPI_Mult_recv(comm, cev, root, myrank, TMPI_SCATTER_TAG, recvtype, bufsize, recvbuf, &ret); } #ifdef TMPI_PROFILE - tMPI_Profile_count_stop(cur, TMPIFN_Scatter); + tMPI_Profile_count_stop(cur, TMPIFN_Scatter); #endif return ret; } @@ -195,22 +197,22 @@ int tMPI_Scatter(void* sendbuf, int sendcount, tMPI_Datatype sendtype, int tMPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, - tMPI_Datatype sendtype, void* recvbuf, int recvcount, - tMPI_Datatype recvtype, int root, tMPI_Comm comm) + tMPI_Datatype sendtype, void* recvbuf, int recvcount, + tMPI_Datatype recvtype, int root, tMPI_Comm comm) { - int synct; - struct coll_env *cev; - int myrank; - int ret=TMPI_SUCCESS; - struct tmpi_thread *cur=tMPI_Get_current(); + int synct; + struct coll_env *cev; + int myrank; + int ret = TMPI_SUCCESS; + struct tmpi_thread *cur = tMPI_Get_current(); #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Scatterv(%p, %p, %p, %p, %p, %d, %p, %d, %p)", + tMPI_Trace_print("tMPI_Scatterv(%p, %p, %p, %p, %p, %d, %p, %d, %p)", sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm); #endif #ifdef TMPI_PROFILE - tMPI_Profile_count_start(cur); + tMPI_Profile_count_start(cur); #endif @@ -218,15 +220,15 @@ int tMPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - myrank=tMPI_Comm_seek_rank(comm, cur); + myrank = tMPI_Comm_seek_rank(comm, cur); /* we increase our counter, and determine which coll_env we get */ - cev=tMPI_Get_cev(comm, myrank, &synct); + cev = tMPI_Get_cev(comm, myrank, &synct); - if (myrank==root) + if (myrank == root) { - int i; - size_t total_send_size=0; + int i; + size_t total_send_size = 0; #ifdef USE_COLLECTIVE_COPY_BUFFER tmpi_bool using_cb; #endif @@ -237,25 +239,25 @@ int tMPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, } /* we set up multiple posts, so no Post_multi */ - cev->met[myrank].tag=TMPI_SCATTERV_TAG; - cev->met[myrank].datatype=sendtype; + cev->met[myrank].tag = TMPI_SCATTERV_TAG; + cev->met[myrank].datatype = sendtype; tMPI_Atomic_memory_barrier_rel(); tMPI_Atomic_set( &(cev->met[myrank].n_remaining), cev->N-1 ); - for(i=0;iN;i++) - { - total_send_size += sendtype->size*sendcounts[i]; - cev->met[myrank].bufsize[i]=sendtype->size*sendcounts[i]; - cev->met[myrank].buf[i]=(char*)sendbuf+sendtype->size*displs[i]; + for (i = 0; i < cev->N; i++) + { + total_send_size += sendtype->size*sendcounts[i]; + cev->met[myrank].bufsize[i] = sendtype->size*sendcounts[i]; + cev->met[myrank].buf[i] = (char*)sendbuf+sendtype->size*displs[i]; } #ifdef USE_COLLECTIVE_COPY_BUFFER - /* we must copy our own data too, unfortunately (otherwise there's + /* we must copy our own data too, unfortunately (otherwise there's a hole) */ - using_cb=(total_send_size < (size_t)((cev->N)*COPY_BUFFER_SIZE)); - cev->met[myrank].using_cb=using_cb; + using_cb = (total_send_size < (size_t)((cev->N)*COPY_BUFFER_SIZE)); + cev->met[myrank].using_cb = using_cb; if (using_cb) { /* we set cpbuf stuff to NULL initially */ - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { /*cev->met[myrank].cpbuf[i]=NULL;*/ tMPI_Atomic_ptr_set(&(cev->met[myrank].cpbuf[i]), NULL); @@ -265,10 +267,12 @@ int tMPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, #endif /* post availability */ - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { if (i != myrank) + { tMPI_Event_signal( &(cev->met[i].recv_ev) ); + } } @@ -278,8 +282,8 @@ int tMPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, if (using_cb) { /* copy the buffer locally. First allocate */ - cev->met[myrank].cb=tMPI_Copy_buffer_list_get( - &(tMPI_Get_thread(comm,myrank)->cbl_multi)); + cev->met[myrank].cb = tMPI_Copy_buffer_list_get( + &(tMPI_Get_thread(comm, myrank)->cbl_multi)); if (cev->met[myrank].cb->size < total_send_size) { fprintf(stderr, "ERROR: cb size too small\n"); @@ -288,25 +292,25 @@ int tMPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, /* copy to the new buf */ memcpy(cev->met[myrank].cb->buf, sendbuf, total_send_size); /* post the new buf */ - for(i=0;iN;i++) + for (i = 0; i < cev->N; i++) { tMPI_Atomic_memory_barrier_rel(); tMPI_Atomic_ptr_set(&(cev->met[myrank].cpbuf[i]), - (char*)cev->met[myrank].cb->buf + + (char*)cev->met[myrank].cb->buf + sendtype->size*displs[i]); - /*cev->met[myrank].cpbuf[i]=(char*)cev->met[myrank].cb->buf + + /*cev->met[myrank].cpbuf[i]=(char*)cev->met[myrank].cb->buf + sendtype->size*displs[i];*/ } } #endif /* do root transfer */ - if (recvbuf!=TMPI_IN_PLACE) + if (recvbuf != TMPI_IN_PLACE) { tMPI_Coll_root_xfer(comm, sendtype, recvtype, - sendtype->size*sendcounts[myrank], - recvtype->size*recvcount, - (char*)sendbuf+sendtype->size*displs[myrank], + sendtype->size*sendcounts[myrank], + recvtype->size*recvcount, + (char*)sendbuf+sendtype->size*displs[myrank], recvbuf, &ret); } @@ -317,15 +321,14 @@ int tMPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, else { /* get the root cev */ - size_t bufsize=recvcount*recvtype->size; + size_t bufsize = recvcount*recvtype->size; /* wait until root becomes available */ tMPI_Wait_for_data(cur, cev, myrank); - tMPI_Mult_recv(comm, cev, root, myrank, TMPI_SCATTERV_TAG, + tMPI_Mult_recv(comm, cev, root, myrank, TMPI_SCATTERV_TAG, recvtype, bufsize, recvbuf, &ret); } #ifdef TMPI_PROFILE - tMPI_Profile_count_stop(cur, TMPIFN_Scatterv); + tMPI_Profile_count_stop(cur, TMPIFN_Scatterv); #endif return ret; } - diff --git a/src/gromacs/gmxlib/thread_mpi/settings.h b/src/gromacs/gmxlib/thread_mpi/settings.h index a8a8724f4c..e6170d497a 100644 --- a/src/gromacs/gmxlib/thread_mpi/settings.h +++ b/src/gromacs/gmxlib/thread_mpi/settings.h @@ -1,55 +1,55 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ /*#define TMPI_DEBUG*/ /* If this is defined, thread_mpi will print a message when for every MPI - call is called or returns. Useful for debugging MPI-related issues + call is called or returns. Useful for debugging MPI-related issues in the calling program. */ /*#define TMPI_TRACE*/ /* if this is defined, MPI will warn/hang/crash on practices that don't conform to the MPI standard (such as not calling tMPI_Comm_free on all threads that are part of the comm being freed). */ -#define TMPI_STRICT +#define TMPI_STRICT -/* whether to warn if there are mallocs at performance-critical sections +/* whether to warn if there are mallocs at performance-critical sections (due to preallocations being too small) */ /*#define TMPI_WARN_MALLOC*/ @@ -63,34 +63,34 @@ files. #define MAX_PREALLOC_THREADS 64 /* Whether to use lock-free lists using compare-and-swap (cmpxchg on x86) - pointer functions. Message passing using blocking Send/Recv, and multicasts + pointer functions. Message passing using blocking Send/Recv, and multicasts are is still blocking, of course. */ #define TMPI_LOCK_FREE_LISTS /* Whether to disable yielding to the OS scheduler during waits. Disabling - this improves performance very slightly if Nthreads<=Ncores on an + this improves performance very slightly if Nthreads<=Ncores on an otherwise idle system because waits have slightly lower latencies, but causes very poor performance if threads are competing for CPU time (for - example, when Nthreads>Ncores, or another process is running on the + example, when Nthreads>Ncores, or another process is running on the system. This option can be set with cmake. */ -/*#define TMPI_WAIT_FOR_NO_ONE */ +/*#define TMPI_WAIT_FOR_NO_ONE */ -/* whether to enable double-copying (where the sender copies data to an +/* whether to enable double-copying (where the sender copies data to an intermediate buffer for small enough buffers, allowing it to return from a blocking send call early. The receiver is free to copy from the original buffer while the sender is copying, possibly allowing them to - work in parallel). - + work in parallel). + This option can be set with cmake. */ /*#define TMPI_COPY_BUFFER*/ -/* The size (in bytes) of the maximum transmission size for which double - copying is allowed (i.e. the sender doesn't wait for the receiver to +/* The size (in bytes) of the maximum transmission size for which double + copying is allowed (i.e. the sender doesn't wait for the receiver to become ready, but posts a copied buffer in its envelope). A size of 8192 bytes was chosen after some testing with Gromacs. */ @@ -104,7 +104,7 @@ files. /* The number of collective envelopes per comm object. This is the maximum - number of simulataneous collective communications that can + number of simulataneous collective communications that can take place per comm object. If TMPI_NO_COPY_BUFFER is set, simultaneous collective communications don't happen and 2 is the right value. */ #ifdef USE_COLLECTIVE_COPY_BUFFER @@ -114,16 +114,14 @@ files. #endif -/* Whether to do profiling of the number of MPI communication calls. A +/* Whether to do profiling of the number of MPI communication calls. A report with the total number of calls for each communication function - will be generated at MPI_Finalize(). - + will be generated at MPI_Finalize(). + This option can be set with cmake.*/ /*#define TMPI_PROFILE*/ -/* whether to turn on thread affinity (required for NUMA optimizations) +/* whether to turn on thread affinity (required for NUMA optimizations) if the number of threads to spawn is equal to the number of processors. */ #define TMPI_THREAD_AFFINITY - - diff --git a/src/gromacs/gmxlib/thread_mpi/system_error.cpp b/src/gromacs/gmxlib/thread_mpi/system_error.cpp index 8ae7d55b66..428aebe256 100644 --- a/src/gromacs/gmxlib/thread_mpi/system_error.cpp +++ b/src/gromacs/gmxlib/thread_mpi/system_error.cpp @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef __cplusplus @@ -43,10 +43,9 @@ files. #include #include "thread_mpi/system_error.h" -tMPI::system_error::system_error(error_code ec) +tMPI::system_error::system_error(error_code ec) : runtime_error(std::strerror(ec)), ec_(ec) { } #endif /* __cplusplus */ - diff --git a/src/gromacs/gmxlib/thread_mpi/tmpi_init.c b/src/gromacs/gmxlib/thread_mpi/tmpi_init.c index ee3a906a0f..4fa6169513 100644 --- a/src/gromacs/gmxlib/thread_mpi/tmpi_init.c +++ b/src/gromacs/gmxlib/thread_mpi/tmpi_init.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H @@ -52,7 +52,7 @@ files. #include #include #include -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) #include #endif @@ -72,13 +72,13 @@ files. /* there are a few global variables that maintain information about the running threads. Some are defined by the MPI standard: */ /* TMPI_COMM_WORLD is in tmpi_malloc.c due to technical reasons */ -tMPI_Group TMPI_GROUP_EMPTY=NULL; +tMPI_Group TMPI_GROUP_EMPTY = NULL; /* the threads themselves (tmpi_comm only contains lists of pointers to this structure */ -struct tmpi_thread *threads=NULL; -int Nthreads=0; +struct tmpi_thread *threads = NULL; +int Nthreads = 0; /* thread info */ tMPI_Thread_key_t id_key; /* the key to get the thread id */ @@ -87,10 +87,10 @@ tMPI_Thread_key_t id_key; /* the key to get the thread id */ /* whether MPI has finalized (we need this to distinguish pre-inited from post-finalized states */ -static tmpi_bool tmpi_finalized=FALSE; +static tmpi_bool tmpi_finalized = FALSE; /* misc. global information about MPI */ -struct tmpi_global *tmpi_global=NULL; +struct tmpi_global *tmpi_global = NULL; @@ -98,9 +98,9 @@ struct tmpi_global *tmpi_global=NULL; /* start N threads with argc, argv (used by tMPI_Init)*/ -void tMPI_Start_threads(tmpi_bool main_returns, int N, +void tMPI_Start_threads(tmpi_bool main_returns, int N, tMPI_Affinity_strategy aff_strategy, - int *argc, char ***argv, + int *argc, char ***argv, void (*start_fn)(void*), void *start_arg, int (*start_fn_main)(int, char**)); @@ -119,14 +119,14 @@ static void tMPI_Thread_destroy(struct tmpi_thread *th); #ifdef TMPI_TRACE void tMPI_Trace_print(const char *fmt, ...) { - va_list argp; - struct tmpi_thread* th=NULL; - static tMPI_Thread_mutex_t mtx=TMPI_THREAD_MUTEX_INITIALIZER; + va_list argp; + struct tmpi_thread * th = NULL; + static tMPI_Thread_mutex_t mtx = TMPI_THREAD_MUTEX_INITIALIZER; tMPI_Thread_mutex_lock(&mtx); if (threads) { - th=tMPI_Get_current(); + th = tMPI_Get_current(); printf("THREAD %02d: ", (int)(th-threads)); } else @@ -147,10 +147,12 @@ void tMPI_Trace_print(const char *fmt, ...) struct tmpi_thread *tMPI_Get_current(void) { if (!threads) + { return NULL; + } return (struct tmpi_thread*)tMPI_thread_getspecific(id_key); -} +} unsigned int tMPI_Threadnr(struct tmpi_thread *thr) @@ -179,17 +181,19 @@ struct tmpi_thread *tMPI_Get_thread(tMPI_Comm comm, int rank) tmpi_bool tMPI_Is_master(void) { /* if there are no other threads, we're the main thread */ - if ( (!TMPI_COMM_WORLD) || TMPI_COMM_WORLD->grp.N==0) + if ( (!TMPI_COMM_WORLD) || TMPI_COMM_WORLD->grp.N == 0) + { return TRUE; + } /* otherwise we know this through thread specific data: */ /* whether the thread pointer points to the head of the threads array */ - return (tmpi_bool)(tMPI_Get_current() == threads); + return (tmpi_bool)(tMPI_Get_current() == threads); } tMPI_Comm tMPI_Get_comm_self(void) { - struct tmpi_thread* th=tMPI_Get_current(); + struct tmpi_thread* th = tMPI_Get_current(); return th->self_comm; } @@ -197,16 +201,16 @@ tMPI_Comm tMPI_Get_comm_self(void) int tMPI_Get_N(int *argc, char ***argv, const char *optname, int *nthreads) { int i; - int ret=TMPI_SUCCESS; + int ret = TMPI_SUCCESS; - *nthreads=0; + *nthreads = 0; if (!optname) { - i=0; + i = 0; } else { - for(i=1;i<*argc;i++) + for (i = 1; i < *argc; i++) { if (strcmp(optname, (*argv)[i]) == 0) { @@ -218,19 +222,22 @@ int tMPI_Get_N(int *argc, char ***argv, const char *optname, int *nthreads) { /* the number of processes is an argument */ char *end; - *nthreads=strtol((*argv)[i+1], &end, 10); - if ( !end || (*end != 0) ) + *nthreads = strtol((*argv)[i+1], &end, 10); + if (!end || (*end != 0) ) { - *nthreads=0; - ret=TMPI_FAILURE; + *nthreads = 0; + ret = TMPI_FAILURE; } } - if (*nthreads<1) + if (*nthreads < 1) { - int nth=tMPI_Thread_get_hw_number(); + int nth = tMPI_Thread_get_hw_number(); - if (nth<1) nth=1; /* make sure it's at least 1 */ - *nthreads=nth; + if (nth < 1) + { + nth = 1; /* make sure it's at least 1 */ + } + *nthreads = nth; } return ret; @@ -238,26 +245,26 @@ int tMPI_Get_N(int *argc, char ***argv, const char *optname, int *nthreads) static void tMPI_Thread_init(struct tmpi_thread *th) { - int N_envelopes=(Nthreads+1)*N_EV_ALLOC; - int N_send_envelopes=N_EV_ALLOC; - int N_reqs=(Nthreads+1)*N_EV_ALLOC; + int N_envelopes = (Nthreads+1)*N_EV_ALLOC; + int N_send_envelopes = N_EV_ALLOC; + int N_reqs = (Nthreads+1)*N_EV_ALLOC; int i; /* we set our thread id, as a thread-specific piece of global data. */ tMPI_Thread_setspecific(id_key, th); /* allocate comm.self */ - th->self_comm=tMPI_Comm_alloc(TMPI_COMM_WORLD, 1); - th->self_comm->grp.peers[0]=th; + th->self_comm = tMPI_Comm_alloc(TMPI_COMM_WORLD, 1); + th->self_comm->grp.peers[0] = th; /* allocate envelopes */ tMPI_Free_env_list_init( &(th->envelopes), N_envelopes ); /* recv list */ tMPI_Recv_env_list_init( &(th->evr)); /* send lists */ - th->evs=(struct send_envelope_list*)tMPI_Malloc( - sizeof(struct send_envelope_list)*Nthreads); - for(i=0;ievs = (struct send_envelope_list*)tMPI_Malloc( + sizeof(struct send_envelope_list)*Nthreads); + for (i = 0; i < Nthreads; i++) { tMPI_Send_env_list_init( &(th->evs[i]), N_send_envelopes); } @@ -289,7 +296,7 @@ static void tMPI_Thread_destroy(struct tmpi_thread *th) int i; tMPI_Recv_env_list_destroy( &(th->evr)); - for(i=0;ievs[i])); } @@ -302,7 +309,7 @@ static void tMPI_Thread_destroy(struct tmpi_thread *th) tMPI_Copy_buffer_list_destroy(&(th->cbl_multi)); #endif - for(i=0;iargc;i++) + for (i = 0; i < th->argc; i++) { free(th->argv[i]); } @@ -310,9 +317,9 @@ static void tMPI_Thread_destroy(struct tmpi_thread *th) static void tMPI_Global_init(struct tmpi_global *g, int Nthreads) { - g->usertypes=NULL; - g->N_usertypes=0; - g->Nalloc_usertypes=0; + g->usertypes = NULL; + g->N_usertypes = 0; + g->Nalloc_usertypes = 0; tMPI_Thread_mutex_init(&(g->timer_mutex)); tMPI_Spinlock_init(&(g->datatype_lock)); @@ -320,12 +327,12 @@ static void tMPI_Global_init(struct tmpi_global *g, int Nthreads) tMPI_Thread_mutex_init(&(g->comm_link_lock)); -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) /* the time at initialization. */ gettimeofday( &(g->timer_init), NULL); #else /* the time at initialization. */ - g->timer_init=GetTickCount(); + g->timer_init = GetTickCount(); #endif } @@ -342,7 +349,7 @@ static void tMPI_Global_destroy(struct tmpi_global *g) static void* tMPI_Thread_starter(void *arg) { - struct tmpi_thread *th=(struct tmpi_thread*)arg; + struct tmpi_thread *th = (struct tmpi_thread*)arg; #ifdef TMPI_TRACE tMPI_Trace_print("Created thread nr. %d", (int)(th-threads)); @@ -350,8 +357,8 @@ static void* tMPI_Thread_starter(void *arg) tMPI_Thread_init(th); - /* start_fn, start_arg, argc and argv were set by the calling function */ - if (! th->start_fn ) + /* start_fn, start_arg, argc and argv were set by the calling function */ + if (!th->start_fn) { th->start_fn_main(th->argc, th->argv); } @@ -359,106 +366,108 @@ static void* tMPI_Thread_starter(void *arg) { th->start_fn(th->start_arg); if (!tmpi_finalized) + { tMPI_Finalize(); + } } return 0; } -void tMPI_Start_threads(tmpi_bool main_returns, int N, +void tMPI_Start_threads(tmpi_bool main_returns, int N, tMPI_Affinity_strategy aff_strategy, - int *argc, char ***argv, + int *argc, char ***argv, void (*start_fn)(void*), void *start_arg, int (*start_fn_main)(int, char**)) { #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Start_threads(%d, %d, %d, %d, %d, %p, %p, %p, %p)", - main_returns, N, aff_strategy, argc, argv, start_fn, - start_arg); + tMPI_Trace_print("tMPI_Start_threads(%d, %d, %d, %d, %d, %p, %p, %p, %p)", + main_returns, N, aff_strategy, argc, argv, start_fn, + start_arg); #endif - if (N>0) + if (N > 0) { int i; - int set_affinity=FALSE; + int set_affinity = FALSE; - tmpi_finalized=FALSE; - Nthreads=N; + tmpi_finalized = FALSE; + Nthreads = N; /* allocate global data */ - tmpi_global=(struct tmpi_global*) - tMPI_Malloc(sizeof(struct tmpi_global)); + tmpi_global = (struct tmpi_global*) + tMPI_Malloc(sizeof(struct tmpi_global)); tMPI_Global_init(tmpi_global, N); /* allocate world and thread data */ - threads=(struct tmpi_thread*)tMPI_Malloc(sizeof(struct tmpi_thread)*N); - TMPI_COMM_WORLD=tMPI_Comm_alloc(NULL, N); - TMPI_GROUP_EMPTY=tMPI_Group_alloc(); + threads = (struct tmpi_thread*)tMPI_Malloc(sizeof(struct tmpi_thread)*N); + TMPI_COMM_WORLD = tMPI_Comm_alloc(NULL, N); + TMPI_GROUP_EMPTY = tMPI_Group_alloc(); if (tMPI_Thread_key_create(&id_key, NULL)) { tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_INIT); } - for(i=0;igrp.peers[i]=&(threads[i]); + TMPI_COMM_WORLD->grp.peers[i] = &(threads[i]); /* copy argc, argv */ if (argc && argv) { int j; - threads[i].argc=*argc; - threads[i].argv=(char**)tMPI_Malloc(threads[i].argc* - sizeof(char*)); - for(j=0;j 1) && (nhw == N)) { - set_affinity=TRUE; + set_affinity = TRUE; } } /* set thread 0's properties */ - threads[0].thread_id=tMPI_Thread_self(); + threads[0].thread_id = tMPI_Thread_self(); if (set_affinity) { /* set the main thread's affinity */ tMPI_Thread_setaffinity_single(threads[0].thread_id, 0); } - for(i=1;i=1) /* we're the main process */ + if (TMPI_COMM_WORLD == 0 && N >= 1) /* we're the main process */ { - tMPI_Start_threads(main_thread_returns, N, aff_strategy, + tMPI_Start_threads(main_thread_returns, N, aff_strategy, 0, 0, start_function, arg, NULL); } return TMPI_SUCCESS; @@ -527,7 +543,7 @@ int tMPI_Initialized(int *flag) tMPI_Trace_print("tMPI_Initialized(%p)", flag); #endif - *flag=(TMPI_COMM_WORLD && !tmpi_finalized); + *flag = (TMPI_COMM_WORLD && !tmpi_finalized); return TMPI_SUCCESS; } @@ -545,7 +561,7 @@ int tMPI_Finalize(void) #ifdef TMPI_PROFILE { - struct tmpi_thread *cur=tMPI_Get_current(); + struct tmpi_thread *cur = tMPI_Get_current(); tMPI_Profile_stop( &(cur->profile) ); tMPI_Thread_barrier_wait( &(tmpi_global->barrier) ); @@ -561,9 +577,9 @@ int tMPI_Finalize(void) if (tMPI_Is_master()) { - /* we just wait for all threads to finish; the order isn't very + /* we just wait for all threads to finish; the order isn't very relevant, as all threads should arrive at their endpoints soon. */ - for(i=1;icomm_link_lock)); - cur=TMPI_COMM_WORLD->next; - while(cur && (cur!=TMPI_COMM_WORLD) ) + cur = TMPI_COMM_WORLD->next; + while (cur && (cur != TMPI_COMM_WORLD) ) { - tMPI_Comm next=cur->next; + tMPI_Comm next = cur->next; tMPI_Comm_destroy(cur, FALSE); - cur=next; + cur = next; } tMPI_Comm_destroy(TMPI_COMM_WORLD, FALSE); tMPI_Thread_mutex_unlock(&(tmpi_global->comm_link_lock)); } tMPI_Group_free(&TMPI_GROUP_EMPTY); - threads=0; - TMPI_COMM_WORLD=NULL; - TMPI_GROUP_EMPTY=NULL; - Nthreads=0; + threads = 0; + TMPI_COMM_WORLD = NULL; + TMPI_GROUP_EMPTY = NULL; + Nthreads = 0; /* deallocate the 'global' structure */ tMPI_Global_destroy(tmpi_global); free(tmpi_global); - tmpi_finalized=TRUE; + tmpi_finalized = TRUE; } else { @@ -618,7 +634,7 @@ int tMPI_Finalized(int *flag) #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Finalized(%p)", flag); #endif - *flag=tmpi_finalized; + *flag = tmpi_finalized; return TMPI_SUCCESS; } @@ -632,25 +648,31 @@ int tMPI_Abort(tMPI_Comm comm, int errorcode) #endif #if 0 /* we abort(). This way we can run a debugger on it */ - fprintf(stderr, "tMPI_Abort called with error code %d",errorcode); - if (comm==TMPI_COMM_WORLD) + fprintf(stderr, "tMPI_Abort called with error code %d", errorcode); + if (comm == TMPI_COMM_WORLD) + { fprintf(stderr, " on TMPI_COMM_WORLD"); - fprintf(stderr,"\n"); + } + fprintf(stderr, "\n"); fflush(stdout); abort(); #else /* we just kill all threads, but not the main process */ - + if (tMPI_Is_master()) { - if (comm==TMPI_COMM_WORLD) - fprintf(stderr, - "tMPI_Abort called on TMPI_COMM_WORLD main with errorcode=%d\n", - errorcode); + if (comm == TMPI_COMM_WORLD) + { + fprintf(stderr, + "tMPI_Abort called on TMPI_COMM_WORLD main with errorcode=%d\n", + errorcode); + } else - fprintf(stderr, "tMPI_Abort called on main thread with errorcode=%d\n", - errorcode); + { + fprintf(stderr, "tMPI_Abort called on main thread with errorcode=%d\n", + errorcode); + } fflush(stderr); exit(errorcode); } @@ -658,10 +680,10 @@ int tMPI_Abort(tMPI_Comm comm, int errorcode) { int *ret; /* kill myself */ - fprintf(stderr, "tMPI_Abort called with error code %d on thread %d\n", - errorcode, tMPI_This_threadnr()); + fprintf(stderr, "tMPI_Abort called with error code %d on thread %d\n", + errorcode, tMPI_This_threadnr()); fflush(stderr); - ret=(int*)malloc(sizeof(int)); + ret = (int*)malloc(sizeof(int)); tMPI_Thread_exit(ret); } #endif @@ -671,9 +693,9 @@ int tMPI_Abort(tMPI_Comm comm, int errorcode) int tMPI_Get_processor_name(char *name, int *resultlen) { - int nr=tMPI_Threadnr(tMPI_Get_current()); - unsigned int digits=0; - const unsigned int base=10; + int nr = tMPI_Threadnr(tMPI_Get_current()); + unsigned int digits = 0; + const unsigned int base = 10; #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Get_processor_name(%p, %p)", name, resultlen); @@ -683,43 +705,53 @@ int tMPI_Get_processor_name(char *name, int *resultlen) /* first determine number of digits */ { - int rest=nr; - while(rest > 0) + int rest = nr; + while (rest > 0) { rest /= base; digits++; } - if (digits==0) - digits=1; + if (digits == 0) + { + digits = 1; + } } -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) strcpy(name, "thread #"); #else strncpy_s(name, TMPI_MAX_PROCESSOR_NAME, "thread #", TMPI_MAX_PROCESSOR_NAME); #endif /* now construct the number */ { - size_t len=strlen(name); + size_t len = strlen(name); unsigned int i; - int rest=nr; + int rest = nr; - for(i=0;itimer_init.tv_sec; + secdiff = tv.tv_sec - tmpi_global->timer_init.tv_sec; usecdiff = tv.tv_usec - tmpi_global->timer_init.tv_usec; - ret=(double)secdiff + 1e-6*usecdiff; + ret = (double)secdiff + 1e-6*usecdiff; } #else { - DWORD tv=GetTickCount(); - + DWORD tv = GetTickCount(); + /* the windows absolute time GetTickCount() wraps around in ~49 days, so it's safer to always use differences, and assume that our program doesn't run that long.. */ - ret=1e-3*((unsigned int)(tv - tmpi_global->timer_init)); + ret = 1e-3*((unsigned int)(tv - tmpi_global->timer_init)); } #endif return ret; @@ -763,7 +795,7 @@ double tMPI_Wtime(void) double tMPI_Wtick(void) { -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) /* In Unix, we don't really know. Any modern OS should be at least this precise, though */ return 1./100.; @@ -791,6 +823,3 @@ int tMPI_Get_count(tMPI_Status *status, tMPI_Datatype datatype, int *count) *count = (int)(status->transferred/datatype->size); return TMPI_SUCCESS; } - - - diff --git a/src/gromacs/gmxlib/thread_mpi/tmpi_malloc.c b/src/gromacs/gmxlib/thread_mpi/tmpi_malloc.c index 4acd76ede4..cc1a2c2c21 100644 --- a/src/gromacs/gmxlib/thread_mpi/tmpi_malloc.c +++ b/src/gromacs/gmxlib/thread_mpi/tmpi_malloc.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H @@ -57,12 +57,12 @@ files. /* there are a few global variables that maintain information about the running threads. Some are defined by the MPI standard: */ /* This is declared here because it is needed for the error handling */ -tMPI_Comm TMPI_COMM_WORLD=NULL; +tMPI_Comm TMPI_COMM_WORLD = NULL; void *tMPI_Malloc(size_t size) { - void *ret=(void*)malloc(size); + void *ret = (void*)malloc(size); if (!ret) { @@ -73,7 +73,7 @@ void *tMPI_Malloc(size_t size) void *tMPI_Realloc(void *p, size_t size) { - void *ret=(void*)realloc(p, size); + void *ret = (void*)realloc(p, size); if (!ret) { tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_MALLOC); diff --git a/src/gromacs/gmxlib/thread_mpi/tmpi_ops.h b/src/gromacs/gmxlib/thread_mpi/tmpi_ops.h index bba8ba4e55..1846ae375e 100644 --- a/src/gromacs/gmxlib/thread_mpi/tmpi_ops.h +++ b/src/gromacs/gmxlib/thread_mpi/tmpi_ops.h @@ -1,128 +1,129 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef THREAD_MPI_OPS -/* cpp wizardry follows... +/* cpp wizardry follows... -This file is #included directly from thread_mpi.c, and constructs -MPI_Reduce operators. + This file is #included directly from thread_mpi.c, and constructs + MPI_Reduce operators. -What this does is create the min, max, sum, prod, etc. functions for a given -datatype (pre-defined as TYPE, with identifier name TYPENM) and puts pointers -to these functions in an array called oplist_TYPENM. + What this does is create the min, max, sum, prod, etc. functions for a given + datatype (pre-defined as TYPE, with identifier name TYPENM) and puts pointers + to these functions in an array called oplist_TYPENM. -gmx_thread_mpi_reduce.c includes this file once for each type used by MPI, -and thus builds up a set of arrays of function pointers, that then get used -in the mpi_datatype_ structure. This way, each operation/datatype entry -that makes sense can be extracted easily. Note that we don't (yet) support -user-defined ops */ + gmx_thread_mpi_reduce.c includes this file once for each type used by MPI, + and thus builds up a set of arrays of function pointers, that then get used + in the mpi_datatype_ structure. This way, each operation/datatype entry + that makes sense can be extracted easily. Note that we don't (yet) support + user-defined ops */ -#define FNAMEr(tp,fn) tMPI_##tp##_##fn -#define FNAME(tp,fn) FNAMEr(tp,fn) +#define FNAMEr(tp, fn) tMPI_ ## tp ## _ ## fn +#define FNAME(tp, fn) FNAMEr(tp, fn) /* macros to define functions and prototypes based on a name and an operation */ -#define FNr(tp,fname,fn) \ -static void tMPI_##tp##_##fname (void *dest, void *src_a, void *src_b, \ - int count) \ -{ \ - /*printf("in function %s, count=%d\n", __FUNCTION__, count);*/\ - TYPE *a=(TYPE*)src_a; \ - TYPE *b=(TYPE*)src_b; \ - TYPE *d=(TYPE*)dest; \ - int i; \ - for(i=0;i (b) ) ? (a) : (b)) -FN(TYPENM,max,MAX) +FN(TYPENM, max, MAX) #undef MAX #define MIN(a, b) (( (a) < (b) ) ? (a) : (b)) -FN(TYPENM,min,MIN) +FN(TYPENM, min, MIN) #undef MIN -OPFN(TYPENM,sum,+) -OPFN(TYPENM,prod,*) -#if INTTYPE!=0 -OPFN(TYPENM,land,&&) -OPFN(TYPENM,band,&) -OPFN(TYPENM,lor,||) -OPFN(TYPENM,bor,|) -OPFN(TYPENM,bxor,^) -#define XOR(a, b) ( (!a) ^ (!b) ) -FN(TYPENM,lxor,XOR) +OPFN(TYPENM, sum, +) +OPFN(TYPENM, prod, *) +#if INTTYPE != 0 +OPFN(TYPENM, land, &&) +OPFN(TYPENM, band, &) +OPFN(TYPENM, lor, ||) +OPFN(TYPENM, bor, |) +OPFN(TYPENM, bxor, ^) +#define XOR(a, b) ( (!a) ^ (!b) ) +FN(TYPENM, lxor, XOR) #undef XOR #endif -#define OPARRAYr(tp) oplist_##tp +#define OPARRAYr(tp) oplist_ ## tp #define OPARRAY(tp) OPARRAYr(tp) -tMPI_Op_fn OPARRAY(TYPENM)[] = { - FNAME(TYPENM,max), - FNAME(TYPENM,min), - FNAME(TYPENM,sum), - FNAME(TYPENM,prod), +tMPI_Op_fn OPARRAY(TYPENM)[] = +{ + FNAME(TYPENM, max), + FNAME(TYPENM, min), + FNAME(TYPENM, sum), + FNAME(TYPENM, prod), #if INTTYPE - FNAME(TYPENM,land), - FNAME(TYPENM,band), - FNAME(TYPENM,lor), - FNAME(TYPENM,bor), - FNAME(TYPENM,lxor), - FNAME(TYPENM,bxor) + FNAME(TYPENM, land), + FNAME(TYPENM, band), + FNAME(TYPENM, lor), + FNAME(TYPENM, bor), + FNAME(TYPENM, lxor), + FNAME(TYPENM, bxor) #else 0, 0, diff --git a/src/gromacs/gmxlib/thread_mpi/topology.c b/src/gromacs/gmxlib/thread_mpi/topology.c index abed1450e4..a598b77538 100644 --- a/src/gromacs/gmxlib/thread_mpi/topology.c +++ b/src/gromacs/gmxlib/thread_mpi/topology.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -71,11 +71,15 @@ int tMPI_Topo_test(tMPI_Comm comm, int *status) } if (comm->cart) - *status=TMPI_CART; + { + *status = TMPI_CART; + } /*else if (comm->graph) status=MPI_GRAPH;*/ - else - *status=TMPI_UNDEFINED; + else + { + *status = TMPI_UNDEFINED; + } return TMPI_SUCCESS; } @@ -89,11 +93,11 @@ int tMPI_Cartdim_get(tMPI_Comm comm, int *ndims) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - if (!comm->cart || comm->cart->ndims==0) + if (!comm->cart || comm->cart->ndims == 0) { return TMPI_SUCCESS; } - *ndims=comm->cart->ndims; + *ndims = comm->cart->ndims; return TMPI_SUCCESS; } @@ -102,29 +106,31 @@ int tMPI_Cart_get(tMPI_Comm comm, int maxdims, int *dims, int *periods, int *coords) { int i; - int myrank=tMPI_Comm_seek_rank(comm, tMPI_Get_current()); + int myrank = tMPI_Comm_seek_rank(comm, tMPI_Get_current()); #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Cart_get(%p, %d, %p, %p, %p)", comm, maxdims, - dims, periods, coords); + tMPI_Trace_print("tMPI_Cart_get(%p, %d, %p, %p, %p)", comm, maxdims, + dims, periods, coords); #endif if (!comm) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - if (!comm->cart || comm->cart->ndims==0) + if (!comm->cart || comm->cart->ndims == 0) + { return TMPI_SUCCESS; + } tMPI_Cart_coords(comm, myrank, maxdims, coords); - for(i=0;icart->ndims;i++) + for (i = 0; i < comm->cart->ndims; i++) { - if (i>=maxdims) + if (i >= maxdims) { return tMPI_Error(comm, TMPI_ERR_DIMS); } - dims[i]=comm->cart->dims[i]; - periods[i]=comm->cart->periods[i]; + dims[i] = comm->cart->dims[i]; + periods[i] = comm->cart->periods[i]; } return TMPI_SUCCESS; @@ -132,7 +138,7 @@ int tMPI_Cart_get(tMPI_Comm comm, int maxdims, int *dims, int *periods, int tMPI_Cart_rank(tMPI_Comm comm, int *coords, int *rank) { - int i,mul=1,ret=0; + int i, mul = 1, ret = 0; #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Cart_get(%p, %p, %p)", comm, coords, rank); @@ -141,19 +147,23 @@ int tMPI_Cart_rank(tMPI_Comm comm, int *coords, int *rank) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - if (!comm->cart || comm->cart->ndims==0) + if (!comm->cart || comm->cart->ndims == 0) + { return TMPI_SUCCESS; + } /* because of row-major ordering, we count the dimensions down */ - for(i=comm->cart->ndims-1;i>=0;i--) + for (i = comm->cart->ndims-1; i >= 0; i--) { - int rcoord=coords[i]; + int rcoord = coords[i]; if (comm->cart->periods[i]) { /* apply periodic boundary conditions */ rcoord = rcoord % comm->cart->dims[i]; if (rcoord < 0) + { rcoord += comm->cart->dims[i]; + } } else { @@ -165,53 +175,55 @@ int tMPI_Cart_rank(tMPI_Comm comm, int *coords, int *rank) ret += mul*rcoord; mul *= comm->cart->dims[i]; } - *rank=ret; + *rank = ret; return TMPI_SUCCESS; } int tMPI_Cart_coords(tMPI_Comm comm, int rank, int maxdims, int *coords) { int i; - int rank_left=rank; + int rank_left = rank; #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Cart_coords(%p, %d, %d, %p)", comm, rank, maxdims, + tMPI_Trace_print("tMPI_Cart_coords(%p, %d, %d, %p)", comm, rank, maxdims, coords); #endif if (!comm) { return tMPI_Error(TMPI_COMM_WORLD, TMPI_ERR_COMM); } - if (!comm->cart || comm->cart->ndims==0) + if (!comm->cart || comm->cart->ndims == 0) + { return TMPI_SUCCESS; + } if (maxdims < comm->cart->ndims) { return tMPI_Error(comm, TMPI_ERR_DIMS); } /* again, row-major ordering */ - for(i=comm->cart->ndims-1;i>=0;i--) + for (i = comm->cart->ndims-1; i >= 0; i--) { - coords[i]=rank_left%comm->cart->dims[i]; + coords[i] = rank_left%comm->cart->dims[i]; rank_left /= comm->cart->dims[i]; - } + } return TMPI_SUCCESS; } -int tMPI_Cart_map(tMPI_Comm comm, int ndims, int *dims, int *periods, +int tMPI_Cart_map(tMPI_Comm comm, int ndims, int *dims, int *periods, int *newrank) { - /* this function doesn't actually do anything beyond returning the current + /* this function doesn't actually do anything beyond returning the current rank (or TMPI_UNDEFINED if it doesn't fit in the new topology */ - int myrank=tMPI_Comm_seek_rank(comm, tMPI_Get_current()); - int Ntot=1; + int myrank = tMPI_Comm_seek_rank(comm, tMPI_Get_current()); + int Ntot = 1; int i; #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Cart_map(%p, %d, %p, %p, %p)", comm, ndims, dims, + tMPI_Trace_print("tMPI_Cart_map(%p, %d, %p, %p, %p)", comm, ndims, dims, periods, newrank); #endif if (!comm) @@ -222,20 +234,20 @@ int tMPI_Cart_map(tMPI_Comm comm, int ndims, int *dims, int *periods, { return tMPI_Error(comm, TMPI_ERR_DIMS); } - + /* calculate the total number of procs in cartesian comm */ - for(i=0;i= Ntot) { - *newrank=TMPI_UNDEFINED; + *newrank = TMPI_UNDEFINED; } else { - *newrank=myrank; + *newrank = myrank; } return TMPI_SUCCESS; @@ -244,10 +256,10 @@ int tMPI_Cart_map(tMPI_Comm comm, int ndims, int *dims, int *periods, /* initialize Cartesian topology info in comm. If ndims==0, dims and periods are not referenced */ -static void tMPI_Cart_init(tMPI_Comm *comm_cart, int ndims, int *dims, +static void tMPI_Cart_init(tMPI_Comm *comm_cart, int ndims, int *dims, int *periods) { - int newrank=-1; + int newrank = -1; int i; if (*comm_cart) @@ -255,21 +267,21 @@ static void tMPI_Cart_init(tMPI_Comm *comm_cart, int ndims, int *dims, tMPI_Comm_rank(*comm_cart, &newrank); } - if (newrank==0) + if (newrank == 0) { - (*comm_cart)->cart=(struct cart_topol*)tMPI_Malloc( - sizeof(struct cart_topol)); - (*comm_cart)->cart->dims=(int*)tMPI_Malloc(ndims*sizeof(int)); - (*comm_cart)->cart->periods=(int*)tMPI_Malloc(ndims*sizeof(int)); - (*comm_cart)->cart->ndims=ndims; - for(i=0;icart = (struct cart_topol*)tMPI_Malloc( + sizeof(struct cart_topol)); + (*comm_cart)->cart->dims = (int*)tMPI_Malloc(ndims*sizeof(int)); + (*comm_cart)->cart->periods = (int*)tMPI_Malloc(ndims*sizeof(int)); + (*comm_cart)->cart->ndims = ndims; + for (i = 0; i < ndims; i++) { - (*comm_cart)->cart->dims[i]=dims[i]; - (*comm_cart)->cart->periods[i]=periods[i]; + (*comm_cart)->cart->dims[i] = dims[i]; + (*comm_cart)->cart->periods[i] = periods[i]; } } - /* and we add a barrier to make sure the cart object is seen by + /* and we add a barrier to make sure the cart object is seen by every thread that is part of the new communicator */ if (*comm_cart) { @@ -289,15 +301,15 @@ void tMPI_Cart_destroy(struct cart_topol *cart) int tMPI_Cart_create(tMPI_Comm comm_old, int ndims, int *dims, int *periods, int reorder, tMPI_Comm *comm_cart) { - int myrank=tMPI_Comm_seek_rank(comm_old, tMPI_Get_current()); - int key=myrank; - int color=0; - int Ntot=1; + int myrank = tMPI_Comm_seek_rank(comm_old, tMPI_Get_current()); + int key = myrank; + int color = 0; + int Ntot = 1; int i; - + #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Cart_create(%p, %d, %p, %p, %d, %p)", comm_old, + tMPI_Trace_print("tMPI_Cart_create(%p, %d, %p, %p, %d, %p)", comm_old, ndims, dims, periods, reorder, comm_cart); #endif if (!comm_old) @@ -305,30 +317,32 @@ int tMPI_Cart_create(tMPI_Comm comm_old, int ndims, int *dims, int *periods, return tMPI_Error(comm_old, TMPI_ERR_COMM); } /* calculate the total number of procs in cartesian comm */ - for(i=0;igrp.N < Ntot) { - *comm_cart=TMPI_COMM_NULL; + *comm_cart = TMPI_COMM_NULL; #if 1 return tMPI_Error(comm_old, TMPI_ERR_CART_CREATE_NPROCS); #endif } if (key >= Ntot) - key=TMPI_UNDEFINED; + { + key = TMPI_UNDEFINED; + } if (reorder) { tMPI_Cart_map(comm_old, ndims, dims, periods, &key); } - if (key==TMPI_UNDEFINED) + if (key == TMPI_UNDEFINED) { - color=TMPI_UNDEFINED; + color = TMPI_UNDEFINED; } tMPI_Comm_split(comm_old, color, key, comm_cart); @@ -341,40 +355,40 @@ int tMPI_Cart_create(tMPI_Comm comm_old, int ndims, int *dims, int *periods, int tMPI_Cart_sub(tMPI_Comm comm, int *remain_dims, tMPI_Comm *newcomm) { - int myrank; - int ndims=0; - int *dims=NULL; - int *periods=NULL; - int *oldcoords=NULL; - int i; - int ndims_notused=1; - int color_notused=0; + int myrank; + int ndims = 0; + int *dims = NULL; + int *periods = NULL; + int *oldcoords = NULL; + int i; + int ndims_notused = 1; + int color_notused = 0; #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Cart_sub(%p, %p, %p)", comm, remain_dims, newcomm); #endif tMPI_Comm_rank(comm, &myrank); - if ( comm->cart ) + if (comm->cart) { - oldcoords=(int*)tMPI_Malloc(sizeof(int)*comm->cart->ndims); - dims=(int*)tMPI_Malloc(sizeof(int)*comm->cart->ndims); - periods=(int*)tMPI_Malloc(sizeof(int)*comm->cart->ndims); + oldcoords = (int*)tMPI_Malloc(sizeof(int)*comm->cart->ndims); + dims = (int*)tMPI_Malloc(sizeof(int)*comm->cart->ndims); + periods = (int*)tMPI_Malloc(sizeof(int)*comm->cart->ndims); /* get old coordinates */ tMPI_Cart_coords(comm, myrank, comm->cart->ndims, oldcoords); - for(i=0;icart->ndims;i++) + for (i = 0; i < comm->cart->ndims; i++) { if (remain_dims[i]) { /* for the remaining dimensions, copy dimensionality data */ - dims[ndims]=comm->cart->dims[i]; - periods[ndims]=comm->cart->periods[i]; + dims[ndims] = comm->cart->dims[i]; + periods[ndims] = comm->cart->periods[i]; ndims++; } else { - /* base color on not used coordinates. We keep a + /* base color on not used coordinates. We keep a ndims_notused index multiplier.*/ color_notused += oldcoords[i]*ndims_notused; ndims_notused *= comm->cart->dims[i]; @@ -387,12 +401,17 @@ int tMPI_Cart_sub(tMPI_Comm comm, int *remain_dims, tMPI_Comm *newcomm) tMPI_Cart_init(newcomm, ndims, dims, periods); if (oldcoords) + { free(oldcoords); + } if (dims) + { free(dims); + } if (periods) + { free(periods); + } return TMPI_SUCCESS; } - diff --git a/src/gromacs/gmxlib/thread_mpi/type.c b/src/gromacs/gmxlib/thread_mpi/type.c index 5d1e76ade3..6390705d8c 100644 --- a/src/gromacs/gmxlib/thread_mpi/type.c +++ b/src/gromacs/gmxlib/thread_mpi/type.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ #ifdef HAVE_TMPI_CONFIG_H #include "tmpi_config.h" @@ -53,7 +53,7 @@ files. #include #include #include -#if ! (defined( _WIN32 ) || defined( _WIN64 ) ) +#if !(defined( _WIN32 ) || defined( _WIN64 ) ) #include #endif @@ -112,7 +112,7 @@ files. #define INTTYPE 1 #include "tmpi_ops.h" -#define TYPE unsigned +#define TYPE unsigned #define TYPENM UNSIGNED #define INTTYPE 1 #include "tmpi_ops.h" @@ -153,27 +153,27 @@ files. /* These are the fundamental data types. They exist as global variables */ -tmpi_dt tmpi_char ={sizeof(char), oplist_CHAR, 0,NULL,TRUE}; -tmpi_dt tmpi_short ={sizeof(short), oplist_SHORT, 0,NULL,TRUE}; -tmpi_dt tmpi_int ={sizeof(int), oplist_INT, 0,NULL,TRUE}; -tmpi_dt tmpi_long ={sizeof(long), oplist_LONG, 0,NULL,TRUE}; +tmpi_dt tmpi_char = {sizeof(char), oplist_CHAR, 0, NULL, TRUE}; +tmpi_dt tmpi_short = {sizeof(short), oplist_SHORT, 0, NULL, TRUE}; +tmpi_dt tmpi_int = {sizeof(int), oplist_INT, 0, NULL, TRUE}; +tmpi_dt tmpi_long = {sizeof(long), oplist_LONG, 0, NULL, TRUE}; #ifdef SIZEOF_LONG_LONG_INT -tmpi_dt tmpi_l_long ={sizeof(long long), oplist_L_LONG, 0,NULL,TRUE}; -tmpi_dt tmpi_l_l_int ={sizeof(long long int), oplist_L_L_INT, 0,NULL,TRUE}; +tmpi_dt tmpi_l_long = {sizeof(long long), oplist_L_LONG, 0, NULL, TRUE}; +tmpi_dt tmpi_l_l_int = {sizeof(long long int), oplist_L_L_INT, 0, NULL, TRUE}; #endif -tmpi_dt tmpi_s_char ={sizeof(signed char), oplist_S_CHAR, 0,NULL,TRUE}; -tmpi_dt tmpi_u_char ={sizeof(unsigned char), oplist_U_CHAR, 0,NULL,TRUE}; -tmpi_dt tmpi_u_short ={sizeof(unsigned short), oplist_U_SHORT, 0,NULL,TRUE}; -tmpi_dt tmpi_unsigned={sizeof(unsigned), oplist_UNSIGNED, 0,NULL,TRUE}; -tmpi_dt tmpi_u_long ={sizeof(unsigned long), oplist_U_LONG, 0,NULL,TRUE}; +tmpi_dt tmpi_s_char = {sizeof(signed char), oplist_S_CHAR, 0, NULL, TRUE}; +tmpi_dt tmpi_u_char = {sizeof(unsigned char), oplist_U_CHAR, 0, NULL, TRUE}; +tmpi_dt tmpi_u_short = {sizeof(unsigned short), oplist_U_SHORT, 0, NULL, TRUE}; +tmpi_dt tmpi_unsigned = {sizeof(unsigned), oplist_UNSIGNED, 0, NULL, TRUE}; +tmpi_dt tmpi_u_long = {sizeof(unsigned long), oplist_U_LONG, 0, NULL, TRUE}; #ifdef SIZEOF_LONG_LONG_INT -tmpi_dt tmpi_u_l_long={sizeof(unsigned long long),oplist_U_L_LONG, 0,NULL,TRUE}; +tmpi_dt tmpi_u_l_long = {sizeof(unsigned long long), oplist_U_L_LONG, 0, NULL, TRUE}; #endif -tmpi_dt tmpi_float ={sizeof(float), oplist_FLOAT, 0,NULL,TRUE}; -tmpi_dt tmpi_double ={sizeof(double), oplist_DOUBLE, 0,NULL,TRUE}; -tmpi_dt tmpi_l_double={sizeof(long double), oplist_L_DOUBLE, 0,NULL,TRUE}; -tmpi_dt tmpi_byte ={sizeof(char), oplist_CHAR, 0,NULL,TRUE}; -tmpi_dt tmpi_pointer ={sizeof(void*), NULL, 0,NULL,TRUE}; +tmpi_dt tmpi_float = {sizeof(float), oplist_FLOAT, 0, NULL, TRUE}; +tmpi_dt tmpi_double = {sizeof(double), oplist_DOUBLE, 0, NULL, TRUE}; +tmpi_dt tmpi_l_double = {sizeof(long double), oplist_L_DOUBLE, 0, NULL, TRUE}; +tmpi_dt tmpi_byte = {sizeof(char), oplist_CHAR, 0, NULL, TRUE}; +tmpi_dt tmpi_pointer = {sizeof(void*), NULL, 0, NULL, TRUE}; @@ -209,26 +209,26 @@ const tMPI_Datatype TMPI_POINTER = &tmpi_pointer; -int tMPI_Type_contiguous(int count, tMPI_Datatype oldtype, +int tMPI_Type_contiguous(int count, tMPI_Datatype oldtype, tMPI_Datatype *newtype) { struct tmpi_datatype_ *ntp; #ifdef TMPI_TRACE - tMPI_Trace_print("tMPI_Type_contiguous(%d, %p, %p)", count, oldtype, - newtype); + tMPI_Trace_print("tMPI_Type_contiguous(%d, %p, %p)", count, oldtype, + newtype); #endif - ntp=(struct tmpi_datatype_*)tMPI_Malloc(sizeof(struct tmpi_datatype_)); - ntp->size=count*oldtype->size; - ntp->op_functions=NULL; + ntp = (struct tmpi_datatype_*)tMPI_Malloc(sizeof(struct tmpi_datatype_)); + ntp->size = count*oldtype->size; + ntp->op_functions = NULL; /* establish components */ - ntp->N_comp=1; - ntp->comps=(struct tmpi_datatype_component*)tMPI_Malloc( - sizeof(struct tmpi_datatype_component)*1); - ntp->comps[0].type=oldtype; - ntp->comps[0].count=1; - ntp->committed=FALSE; + ntp->N_comp = 1; + ntp->comps = (struct tmpi_datatype_component*)tMPI_Malloc( + sizeof(struct tmpi_datatype_component)*1); + ntp->comps[0].type = oldtype; + ntp->comps[0].count = 1; + ntp->committed = FALSE; /* now add it to the list. */ tMPI_Spinlock_lock(&(tmpi_global->datatype_lock)); @@ -236,18 +236,18 @@ int tMPI_Type_contiguous(int count, tMPI_Datatype oldtype, if (tmpi_global->N_usertypes + 1 >= tmpi_global->Nalloc_usertypes) { /* make space */ - tmpi_global->Nalloc_usertypes=Nthreads*(tmpi_global->N_usertypes) + 1; - tmpi_global->usertypes=(struct tmpi_datatype_**) - tMPI_Realloc(tmpi_global->usertypes, - (sizeof(struct tmpi_datatype_ *)* - tmpi_global->Nalloc_usertypes) - ); + tmpi_global->Nalloc_usertypes = Nthreads*(tmpi_global->N_usertypes) + 1; + tmpi_global->usertypes = (struct tmpi_datatype_**) + tMPI_Realloc(tmpi_global->usertypes, + (sizeof(struct tmpi_datatype_ *)* + tmpi_global->Nalloc_usertypes) + ); } /* add to the list */ - tmpi_global->usertypes[tmpi_global->N_usertypes]=ntp; + tmpi_global->usertypes[tmpi_global->N_usertypes] = ntp; tmpi_global->N_usertypes++; - *newtype=ntp; + *newtype = ntp; tMPI_Spinlock_unlock(&(tmpi_global->datatype_lock)); return TMPI_SUCCESS; @@ -256,72 +256,73 @@ int tMPI_Type_contiguous(int count, tMPI_Datatype oldtype, int tMPI_Type_commit(tMPI_Datatype *datatype) { - int i,j; - struct tmpi_datatype_ *dt=*datatype; + int i, j; + struct tmpi_datatype_ *dt = *datatype; #ifdef TMPI_TRACE tMPI_Trace_print("tMPI_Type_commit(%p)", datatype); #endif if (dt->committed) + { return TMPI_SUCCESS; + } /* search the list for a matching committed type, because if there's - already a committed type that has the same composition, we just - make the datatype pointer point to it, ensuring we share datatype + already a committed type that has the same composition, we just + make the datatype pointer point to it, ensuring we share datatype information across threads. */ tMPI_Spinlock_lock(&(tmpi_global->datatype_lock)); - for(i=0;iN_usertypes;i++) + for (i = 0; i < tmpi_global->N_usertypes; i++) { - struct tmpi_datatype_ *lt=tmpi_global->usertypes[i]; - if (lt->committed && lt->N_comp==dt->N_comp) + struct tmpi_datatype_ *lt = tmpi_global->usertypes[i]; + if (lt->committed && lt->N_comp == dt->N_comp) { - tmpi_bool found=TRUE; - for(j=0;jN_comp;j++) + tmpi_bool found = TRUE; + for (j = 0; j < lt->N_comp; j++) { if ( (lt->comps[j].type != dt->comps[j].type) || (lt->comps[j].count != dt->comps[j].count) ) { - found=FALSE; + found = FALSE; break; } } if (found) { - dt=lt; + dt = lt; } } } if (dt != *datatype) { - tmpi_bool found=FALSE; + tmpi_bool found = FALSE; /* we remove the old one from the list */ - for(i=0;iN_usertypes;i++) + for (i = 0; i < tmpi_global->N_usertypes; i++) { - if (tmpi_global->usertypes[i]==*datatype) + if (tmpi_global->usertypes[i] == *datatype) { - found=TRUE; + found = TRUE; break; } } if (found) { /* we put the last one in the list in our slot */ - tmpi_global->usertypes[i]=tmpi_global-> - usertypes[tmpi_global->N_usertypes-1]; + tmpi_global->usertypes[i] = tmpi_global-> + usertypes[tmpi_global->N_usertypes-1]; tmpi_global->N_usertypes--; } free( (*datatype)->comps); free( *datatype ); /* and overwrite the pointer with the new data type */ - *datatype=dt; + *datatype = dt; } else { /* it was the first one of its type */ - dt->committed=TRUE; + dt->committed = TRUE; } tMPI_Spinlock_unlock(&(tmpi_global->datatype_lock)); return TMPI_SUCCESS; } - diff --git a/src/gromacs/gmxlib/thread_mpi/winthreads.c b/src/gromacs/gmxlib/thread_mpi/winthreads.c index bedfef5b5d..c944a43444 100644 --- a/src/gromacs/gmxlib/thread_mpi/winthreads.c +++ b/src/gromacs/gmxlib/thread_mpi/winthreads.c @@ -1,39 +1,39 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ @@ -69,9 +69,9 @@ files. #include "winthreads.h" -/*! \brief System mutex for all one-time initialization +/*! \brief System mutex for all one-time initialization * - * This static variable is necessary in order to make the header file + * This static variable is necessary in order to make the header file * independent of the thread library implementation. Anyway, it * will only be locked a handful of times at the start of program execution. */ @@ -83,65 +83,65 @@ static CRITICAL_SECTION barrier_init; /* mutex for initializing barriers */ /* spinlock for initializing the above mutexes */ -static tMPI_Spinlock_t init_init=TMPI_SPINLOCK_INITIALIZER; +static tMPI_Spinlock_t init_init = TMPI_SPINLOCK_INITIALIZER; /* whether tMPI_Thread_create has initialized these mutexes */ -static tMPI_Atomic_t init_inited={ 0 }; +static tMPI_Atomic_t init_inited = { 0 }; /* whether the main thread affinity has been set */ -static tMPI_Spinlock_t main_thread_aff_lock=TMPI_SPINLOCK_INITIALIZER; -static tMPI_Atomic_t main_thread_aff_set={ 0 }; +static tMPI_Spinlock_t main_thread_aff_lock = TMPI_SPINLOCK_INITIALIZER; +static tMPI_Atomic_t main_thread_aff_set = { 0 }; /* mutex for managing thread IDs */ static CRITICAL_SECTION thread_id_list_lock; -typedef struct -{ - DWORD thread_id; /* the thread ID as returned by GetCurrentTreadID() */ - struct tMPI_Thread* th; /* the associated tMPI thread structure */ +typedef struct +{ + DWORD thread_id; /* the thread ID as returned by GetCurrentTreadID() */ + struct tMPI_Thread* th; /* the associated tMPI thread structure */ } thread_id_list_t; /* the size of the thrread id list */ -static int Nalloc_thread_id_list = 0; +static int Nalloc_thread_id_list = 0; /* the number of elements in the thread id list */ -static int N_thread_id_list = 0; +static int N_thread_id_list = 0; /* the thread ID list */ static thread_id_list_t *thread_id_list; /* data structure to keep track of thread key destructors. */ -typedef struct +typedef struct { - void (*destructor) (void*); + void (*destructor)(void*); DWORD key; } thread_key_destructors; -static thread_key_destructors *destructors=NULL; +static thread_key_destructors *destructors = NULL; /* NUMA and Processor Group awareness support. - NUMA support is implemented to maximize the chance that memory access + NUMA support is implemented to maximize the chance that memory access patterns remain Local to the NUMA node. - NUMA node processor affinity is utilized to prevent scheduler associated + NUMA node processor affinity is utilized to prevent scheduler associated drift across NUMA nodes. - Process Group support is implemented to enable > 64 processors to be + Process Group support is implemented to enable > 64 processors to be utilized. This is only supported when building 64bit. The high level approach is: - 1. Build a description of CPU topology, including processor numbers, NUMA + 1. Build a description of CPU topology, including processor numbers, NUMA node numbers, and affinity masks. - 2. For processor intensive worker threads, create threads such that + 2. For processor intensive worker threads, create threads such that the processor affinity and thread stack is kept local within a NUMA node. - 3. Employ simple round-robin affinity and node assignment approach when + 3. Employ simple round-robin affinity and node assignment approach when creating threads. - 4. Use GetProcAddress() to obtain function pointers to functions that - are operating system version dependent, to allow maximum binary - compatibility. + 4. Use GetProcAddress() to obtain function pointers to functions that + are operating system version dependent, to allow maximum binary + compatibility. - Scott Field (sfield@microsoft.com) Jan-2011 -*/ + Scott Field (sfield@microsoft.com) Jan-2011 + */ typedef struct { @@ -152,60 +152,60 @@ typedef struct { /* thread/processor index, to allow setting round-robin affinity. */ -volatile ULONG g_ulThreadIndex; +volatile ULONG g_ulThreadIndex; /* a value of zero implies the system is not NUMA */ -ULONG g_ulHighestNumaNodeNumber=0; +ULONG g_ulHighestNumaNodeNumber = 0; /* total number of processors in g_MPI_ProcessInfo array */ -ULONG g_ulTotalProcessors; +ULONG g_ulTotalProcessors; /* array describing available processors, affinity masks, and NUMA node */ -MPI_NUMA_PROCESSOR_INFO *g_MPI_ProcessorInfo=NULL; +MPI_NUMA_PROCESSOR_INFO *g_MPI_ProcessorInfo = NULL; -/* function prototypes and variables to support obtaining function addresses +/* function prototypes and variables to support obtaining function addresses dynamically -- supports down-level operating systems */ -typedef BOOL (WINAPI *func_GetNumaHighestNodeNumber_t)( PULONG +typedef BOOL (WINAPI *func_GetNumaHighestNodeNumber_t)( PULONG HighestNodeNumber ); typedef DWORD (WINAPI *func_SetThreadIdealProcessor_t)( HANDLE hThread, - DWORD dwIdealProcessor ); -typedef BOOL (WINAPI *func_SetThreadGroupAffinity_t)( HANDLE hThread, - const GROUP_AFFINITY *GroupAffinity, - PGROUP_AFFINITY PreviousGroupAffinity ); -typedef BOOL (WINAPI *func_SetThreadIdealProcessorEx_t)( HANDLE hThread, - PPROCESSOR_NUMBER lpIdealProcessor, - PPROCESSOR_NUMBER lpPreviousIdealProcessor ); -typedef BOOL (WINAPI *func_GetNumaNodeProcessorMaskEx_t)( USHORT Node, - PGROUP_AFFINITY ProcessorMask ); -typedef BOOL (WINAPI *func_GetNumaProcessorNodeEx_t)( - PPROCESSOR_NUMBER Processor, - PUSHORT NodeNumber ); -typedef VOID (WINAPI *func_GetCurrentProcessorNumberEx_t)( - PPROCESSOR_NUMBER ProcNumber ); + DWORD dwIdealProcessor ); +typedef BOOL (WINAPI *func_SetThreadGroupAffinity_t)( HANDLE hThread, + const GROUP_AFFINITY *GroupAffinity, + PGROUP_AFFINITY PreviousGroupAffinity ); +typedef BOOL (WINAPI *func_SetThreadIdealProcessorEx_t)( HANDLE hThread, + PPROCESSOR_NUMBER lpIdealProcessor, + PPROCESSOR_NUMBER lpPreviousIdealProcessor ); +typedef BOOL (WINAPI *func_GetNumaNodeProcessorMaskEx_t)( USHORT Node, + PGROUP_AFFINITY ProcessorMask ); +typedef BOOL (WINAPI *func_GetNumaProcessorNodeEx_t)( + PPROCESSOR_NUMBER Processor, + PUSHORT NodeNumber ); +typedef VOID (WINAPI *func_GetCurrentProcessorNumberEx_t)( + PPROCESSOR_NUMBER ProcNumber ); typedef HANDLE (WINAPI *func_CreateRemoteThreadEx_t)( - HANDLE hProcess, - LPSECURITY_ATTRIBUTES lpThreadAttributes, - SIZE_T dwStackSize, - LPTHREAD_START_ROUTINE lpStartAddress, - LPVOID lpParameter, - DWORD dwCreationFlags, - LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, - LPDWORD lpThreadId); + HANDLE hProcess, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + SIZE_T dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, + LPVOID lpParameter, + DWORD dwCreationFlags, + LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, + LPDWORD lpThreadId); typedef BOOL (WINAPI *func_InitializeProcThreadAttributeList_t)( - LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, - DWORD dwAttributeCount, - DWORD dwFlags, - PSIZE_T lpSize); + LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, + DWORD dwAttributeCount, + DWORD dwFlags, + PSIZE_T lpSize); typedef BOOL (WINAPI *func_UpdateProcThreadAttribute_t)( - LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, - DWORD dwFlags, - DWORD_PTR Attribute, - PVOID lpValue, - SIZE_T cbSize, - PVOID lpPreviousValue, - PSIZE_T lpReturnSize); + LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, + DWORD dwFlags, + DWORD_PTR Attribute, + PVOID lpValue, + SIZE_T cbSize, + PVOID lpPreviousValue, + PSIZE_T lpReturnSize); typedef VOID (WINAPI *func_DeleteProcThreadAttributeList_t)( - LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList); + LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList); typedef DWORD (WINAPI *func_GetActiveProcessorCount_t)(WORD GroupNumber); typedef WORD (WINAPI *func_GetActiveProcessorGroupCount_t)(void); @@ -214,42 +214,42 @@ typedef WORD (WINAPI *func_GetActiveProcessorGroupCount_t)(void); func_GetNumaHighestNodeNumber_t func_GetNumaHighestNodeNumber; func_SetThreadIdealProcessor_t func_SetThreadIdealProcessor; /* Windows 7, WinSrv 2008R2 */ -func_SetThreadGroupAffinity_t func_SetThreadGroupAffinity; -func_SetThreadIdealProcessorEx_t func_SetThreadIdealProcessorEx; +func_SetThreadGroupAffinity_t func_SetThreadGroupAffinity; +func_SetThreadIdealProcessorEx_t func_SetThreadIdealProcessorEx; func_GetNumaNodeProcessorMaskEx_t func_GetNumaNodeProcessorMaskEx; -func_GetNumaProcessorNodeEx_t func_GetNumaProcessorNodeEx; +func_GetNumaProcessorNodeEx_t func_GetNumaProcessorNodeEx; func_GetCurrentProcessorNumberEx_t func_GetCurrentProcessorNumberEx; -func_GetActiveProcessorCount_t func_GetActiveProcessorCount; +func_GetActiveProcessorCount_t func_GetActiveProcessorCount; func_GetActiveProcessorGroupCount_t func_GetActiveProcessorGroupCount; -func_CreateRemoteThreadEx_t func_CreateRemoteThreadEx; -/* Windows Vista, WinSrv 2008 */ -func_InitializeProcThreadAttributeList_t func_InitializeProcThreadAttributeList; -func_UpdateProcThreadAttribute_t func_UpdateProcThreadAttribute; -func_DeleteProcThreadAttributeList_t func_DeleteProcThreadAttributeList; +func_CreateRemoteThreadEx_t func_CreateRemoteThreadEx; +/* Windows Vista, WinSrv 2008 */ +func_InitializeProcThreadAttributeList_t func_InitializeProcThreadAttributeList; +func_UpdateProcThreadAttribute_t func_UpdateProcThreadAttribute; +func_DeleteProcThreadAttributeList_t func_DeleteProcThreadAttributeList; /* returns 0 on success. - Success is returned if the system is non-NUMA, OR the system doesn't - support appropriate NUMA APIs, OR the system is NUMA and we successfully + Success is returned if the system is non-NUMA, OR the system doesn't + support appropriate NUMA APIs, OR the system is NUMA and we successfully initialized support. - + returns -1 on error. - This can happen if an API returned an error, a memory allocation failed, or + This can happen if an API returned an error, a memory allocation failed, or we failed to initialize affinity mapping information. -*/ + */ int tMPI_Init_NUMA(void) { /* module handle to kernel32.dll -- we already reference it, so it's already loaded */ - HMODULE hModKernel32 = NULL; + HMODULE hModKernel32 = NULL; /* 0-based NUMA node count -- does not imply all nodes have available (eg: hot-plug) processors */ - ULONG ulHighestNumaNodeNumber; + ULONG ulHighestNumaNodeNumber; /* total number of processors available per affinity masks */ - DWORD dwTotalProcessors = 0; - ULONG i = 0; + DWORD dwTotalProcessors = 0; + ULONG i = 0; /* calling thread PROCESSOR_NUMBER */ - PROCESSOR_NUMBER CurrentProcessorNumber; + PROCESSOR_NUMBER CurrentProcessorNumber; /* calling thread GROUP_AFFINITY */ /*GROUP_AFFINITY CurrentThreadGroupAffinity; */ /* calling thread NUMA node */ @@ -259,72 +259,72 @@ int tMPI_Init_NUMA(void) WORD GroupIndex; /* array of processor information structures */ - MPI_NUMA_PROCESSOR_INFO *pMPI_ProcessorInfo = NULL; + MPI_NUMA_PROCESSOR_INFO *pMPI_ProcessorInfo = NULL; /* assume an error condition */ int iRet = -1; hModKernel32 = GetModuleHandleA("kernel32.dll"); - if( hModKernel32 == NULL ) + if (hModKernel32 == NULL) { return 0; } - /* obtain addresses of relevant NUMA functions, most of which are + /* obtain addresses of relevant NUMA functions, most of which are Windows 7 / Windows Server 2008R2 only functions - this is done using GetProcAddress to enable the binary to run on older + this is done using GetProcAddress to enable the binary to run on older Windows versions. - */ + */ func_GetNumaHighestNodeNumber = (func_GetNumaHighestNodeNumber_t) GetProcAddress( hModKernel32, "GetNumaHighestNodeNumber" ); - func_SetThreadIdealProcessor = (func_SetThreadIdealProcessor_t) GetProcAddress( hModKernel32, "SetThreadIdealProcessor" ); + func_SetThreadIdealProcessor = (func_SetThreadIdealProcessor_t) GetProcAddress( hModKernel32, "SetThreadIdealProcessor" ); - if( func_GetNumaHighestNodeNumber == NULL ) + if (func_GetNumaHighestNodeNumber == NULL) { return 0; } - /* determine if we're on a NUMA system and if so, determine the number of + /* determine if we're on a NUMA system and if so, determine the number of (potential) nodes */ - if(!func_GetNumaHighestNodeNumber( &ulHighestNumaNodeNumber )) + if (!func_GetNumaHighestNodeNumber( &ulHighestNumaNodeNumber )) { return -1; } - func_SetThreadGroupAffinity = (func_SetThreadGroupAffinity_t)GetProcAddress( hModKernel32, "SetThreadGroupAffinity" ); - func_SetThreadIdealProcessorEx = (func_SetThreadIdealProcessorEx_t)GetProcAddress( hModKernel32, "SetThreadIdealProcessorEx" ); - func_CreateRemoteThreadEx = (func_CreateRemoteThreadEx_t)GetProcAddress( hModKernel32, "CreateRemoteThreadEx" ); - func_GetNumaNodeProcessorMaskEx = (func_GetNumaNodeProcessorMaskEx_t)GetProcAddress( hModKernel32, "GetNumaNodeProcessorMaskEx" ); - func_GetNumaProcessorNodeEx = (func_GetNumaProcessorNodeEx_t)GetProcAddress( hModKernel32, "GetNumaProcessorNodeEx" ); - func_GetCurrentProcessorNumberEx = (func_GetCurrentProcessorNumberEx_t)GetProcAddress( hModKernel32, "GetCurrentProcessorNumberEx" ); - func_GetActiveProcessorCount = (func_GetActiveProcessorCount_t)GetProcAddress( hModKernel32, "GetActiveProcessorCount" ); - func_GetActiveProcessorGroupCount = (func_GetActiveProcessorGroupCount_t)GetProcAddress( hModKernel32, "GetActiveProcessorGroupCount" ); + func_SetThreadGroupAffinity = (func_SetThreadGroupAffinity_t)GetProcAddress( hModKernel32, "SetThreadGroupAffinity" ); + func_SetThreadIdealProcessorEx = (func_SetThreadIdealProcessorEx_t)GetProcAddress( hModKernel32, "SetThreadIdealProcessorEx" ); + func_CreateRemoteThreadEx = (func_CreateRemoteThreadEx_t)GetProcAddress( hModKernel32, "CreateRemoteThreadEx" ); + func_GetNumaNodeProcessorMaskEx = (func_GetNumaNodeProcessorMaskEx_t)GetProcAddress( hModKernel32, "GetNumaNodeProcessorMaskEx" ); + func_GetNumaProcessorNodeEx = (func_GetNumaProcessorNodeEx_t)GetProcAddress( hModKernel32, "GetNumaProcessorNodeEx" ); + func_GetCurrentProcessorNumberEx = (func_GetCurrentProcessorNumberEx_t)GetProcAddress( hModKernel32, "GetCurrentProcessorNumberEx" ); + func_GetActiveProcessorCount = (func_GetActiveProcessorCount_t)GetProcAddress( hModKernel32, "GetActiveProcessorCount" ); + func_GetActiveProcessorGroupCount = (func_GetActiveProcessorGroupCount_t)GetProcAddress( hModKernel32, "GetActiveProcessorGroupCount" ); func_InitializeProcThreadAttributeList = (func_InitializeProcThreadAttributeList_t)GetProcAddress( hModKernel32, "InitializeProcThreadAttributeList" ); - func_UpdateProcThreadAttribute = (func_UpdateProcThreadAttribute_t)GetProcAddress( hModKernel32, "UpdateProcThreadAttribute" ); - func_DeleteProcThreadAttributeList = (func_DeleteProcThreadAttributeList_t)GetProcAddress( hModKernel32, "DeleteProcThreadAttributeList" ); - - if( (func_SetThreadGroupAffinity == NULL) || - (func_SetThreadIdealProcessorEx == NULL) || - (func_CreateRemoteThreadEx == NULL) || - (func_GetNumaNodeProcessorMaskEx == NULL) || - (func_GetNumaProcessorNodeEx == NULL) || - (func_GetCurrentProcessorNumberEx == NULL) || - (func_GetActiveProcessorCount == NULL) || - (func_GetActiveProcessorGroupCount == NULL) || - (func_InitializeProcThreadAttributeList == NULL) || - (func_UpdateProcThreadAttribute == NULL) || - (func_DeleteProcThreadAttributeList == NULL) ) + func_UpdateProcThreadAttribute = (func_UpdateProcThreadAttribute_t)GetProcAddress( hModKernel32, "UpdateProcThreadAttribute" ); + func_DeleteProcThreadAttributeList = (func_DeleteProcThreadAttributeList_t)GetProcAddress( hModKernel32, "DeleteProcThreadAttributeList" ); + + if ( (func_SetThreadGroupAffinity == NULL) || + (func_SetThreadIdealProcessorEx == NULL) || + (func_CreateRemoteThreadEx == NULL) || + (func_GetNumaNodeProcessorMaskEx == NULL) || + (func_GetNumaProcessorNodeEx == NULL) || + (func_GetCurrentProcessorNumberEx == NULL) || + (func_GetActiveProcessorCount == NULL) || + (func_GetActiveProcessorGroupCount == NULL) || + (func_InitializeProcThreadAttributeList == NULL) || + (func_UpdateProcThreadAttribute == NULL) || + (func_DeleteProcThreadAttributeList == NULL) ) { - /* if any addresses couldn't be located, assume NUMA functionality + /* if any addresses couldn't be located, assume NUMA functionality isn't supported */ return 0; } #if 0 - if( ulHighestNumaNodeNumber == 0 ) + if (ulHighestNumaNodeNumber == 0) { /* system is not NUMA */ return 0; @@ -336,20 +336,20 @@ int tMPI_Init_NUMA(void) func_GetCurrentProcessorNumberEx(&CurrentProcessorNumber); wActiveGroupCount = func_GetActiveProcessorGroupCount(); - + dwTotalProcessors = func_GetActiveProcessorCount( ALL_PROCESSOR_GROUPS ); #if !((defined WIN64 || defined _WIN64)) - /* WOW64 doesn't allow setting the affinity correctly beyond 32 + /* WOW64 doesn't allow setting the affinity correctly beyond 32 processors -- the KAFFINITY mask is only 32 bits wide - This check is only here for completeness -- large systems should be - running 64bit Gromacs code, where the processor quantity is not + This check is only here for completeness -- large systems should be + running 64bit Gromacs code, where the processor quantity is not constrained. - By failing here, the WOW64 32bit client will use normal CreateThread(), + By failing here, the WOW64 32bit client will use normal CreateThread(), which can schedule up to 64 un-affinitized threads - */ + */ - if( dwTotalProcessors > 32 ) + if (dwTotalProcessors > 32) { return 0; } @@ -357,55 +357,55 @@ int tMPI_Init_NUMA(void) /* allocate array of processor info blocks */ - pMPI_ProcessorInfo = tMPI_Malloc( sizeof(MPI_NUMA_PROCESSOR_INFO) * + pMPI_ProcessorInfo = tMPI_Malloc( sizeof(MPI_NUMA_PROCESSOR_INFO) * dwTotalProcessors ); - if(pMPI_ProcessorInfo == NULL) + if (pMPI_ProcessorInfo == NULL) { - tMPI_Fatal_error(TMPI_FARGS,"tMPI_Malloc failed for processor information"); + tMPI_Fatal_error(TMPI_FARGS, "tMPI_Malloc failed for processor information"); goto cleanup; } /* zero fill to cover reserved must be-zero fields */ memset(pMPI_ProcessorInfo, 0, sizeof(MPI_NUMA_PROCESSOR_INFO) * dwTotalProcessors); - /* loop through each processor group, and for each group, capture the + /* loop through each processor group, and for each group, capture the processor numbers and NUMA node information. */ - for(GroupIndex = 0 ; GroupIndex < wActiveGroupCount ; GroupIndex++) + for (GroupIndex = 0; GroupIndex < wActiveGroupCount; GroupIndex++) { DWORD dwGroupProcessorCount; - BYTE ProcessorIndex; + BYTE ProcessorIndex; dwGroupProcessorCount = func_GetActiveProcessorCount( GroupIndex ); - for(ProcessorIndex = 0 ; ProcessorIndex < dwGroupProcessorCount ; - ProcessorIndex++) + for (ProcessorIndex = 0; ProcessorIndex < dwGroupProcessorCount; + ProcessorIndex++) { PROCESSOR_NUMBER *pProcessorNumber = &(pMPI_ProcessorInfo[i].ProcessorNumber); - GROUP_AFFINITY *pGroupAffinity = &(pMPI_ProcessorInfo[i].GroupAffinity); - USHORT *pNodeNumber = &(pMPI_ProcessorInfo[i].NumaNodeNumber); + GROUP_AFFINITY *pGroupAffinity = &(pMPI_ProcessorInfo[i].GroupAffinity); + USHORT *pNodeNumber = &(pMPI_ProcessorInfo[i].NumaNodeNumber); - pProcessorNumber->Group = GroupIndex; + pProcessorNumber->Group = GroupIndex; pProcessorNumber->Number = ProcessorIndex; /* save an index to the processor array entry for the current processor - this is used to enable subsequent threads to be created in a round + this is used to enable subsequent threads to be created in a round robin fashion starting at the next array entry - */ + */ - if( (CurrentProcessorNumber.Group == pProcessorNumber->Group ) && - (CurrentProcessorNumber.Number == pProcessorNumber->Number) ) + if ( (CurrentProcessorNumber.Group == pProcessorNumber->Group ) && + (CurrentProcessorNumber.Number == pProcessorNumber->Number) ) { /* set global: current thread index into processor array */ g_ulThreadIndex = i; } /* capture the node number and group affinity associated with processor entry - any failures here are assumed to be catastrophic and disable + any failures here are assumed to be catastrophic and disable the group & NUMA aware thread support - */ + */ - if(!func_GetNumaProcessorNodeEx(pProcessorNumber, pNodeNumber)) + if (!func_GetNumaProcessorNodeEx(pProcessorNumber, pNodeNumber)) { tMPI_Fatal_error(TMPI_FARGS, "Processor enumeration, GetNumaProcessorNodeEx failed, error code=%d", @@ -413,7 +413,7 @@ int tMPI_Init_NUMA(void) goto cleanup; } - if(!func_GetNumaNodeProcessorMaskEx(*pNodeNumber, pGroupAffinity)) + if (!func_GetNumaNodeProcessorMaskEx(*pNodeNumber, pGroupAffinity)) { tMPI_Fatal_error(TMPI_FARGS, "Processor enumeration, GetNumaNodeProcessorMaskEx failed, error code=%d", @@ -421,7 +421,7 @@ int tMPI_Init_NUMA(void) goto cleanup; } - /* future enhancement: construct GroupAffinity (single) processor + /* future enhancement: construct GroupAffinity (single) processor mask within NUMA node for this processor entry */ /* increment processor array index */ @@ -429,28 +429,28 @@ int tMPI_Init_NUMA(void) /* sanity check, should never happen */ - if(i > dwTotalProcessors) + if (i > dwTotalProcessors) { - tMPI_Fatal_error(TMPI_FARGS,"Processor enumeration exceeds allocated memory!"); + tMPI_Fatal_error(TMPI_FARGS, "Processor enumeration exceeds allocated memory!"); goto cleanup; } } } - /* capture number of processors, highest NUMA node number, and processor + /* capture number of processors, highest NUMA node number, and processor array */ - g_ulTotalProcessors = dwTotalProcessors; + g_ulTotalProcessors = dwTotalProcessors; g_ulHighestNumaNodeNumber = ulHighestNumaNodeNumber; - g_MPI_ProcessorInfo = pMPI_ProcessorInfo; + g_MPI_ProcessorInfo = pMPI_ProcessorInfo; - iRet = 0 ; + iRet = 0; cleanup: - if( iRet != 0 ) + if (iRet != 0) { - if( pMPI_ProcessorInfo ) + if (pMPI_ProcessorInfo) { tMPI_Free( pMPI_ProcessorInfo ); } @@ -462,42 +462,42 @@ cleanup: static void tMPI_Thread_id_list_init(void) { EnterCriticalSection( &thread_id_list_lock ); - - N_thread_id_list=0; - Nalloc_thread_id_list=4; /* number of initial allocation*/ - thread_id_list=(thread_id_list_t*)tMPI_Malloc( - sizeof(thread_id_list_t)* - Nalloc_thread_id_list); + + N_thread_id_list = 0; + Nalloc_thread_id_list = 4; /* number of initial allocation*/ + thread_id_list = (thread_id_list_t*)tMPI_Malloc( + sizeof(thread_id_list_t)* + Nalloc_thread_id_list); LeaveCriticalSection( &thread_id_list_lock ); } /* add an entry to the thread ID list, assuming it's locked */ -static void tMPI_Thread_id_list_add_locked(DWORD thread_id, - struct tMPI_Thread *th) +static void tMPI_Thread_id_list_add_locked(DWORD thread_id, + struct tMPI_Thread *th) { if (Nalloc_thread_id_list < N_thread_id_list + 1) { thread_id_list_t* new_list; - int i; + int i; /* double the size */ - Nalloc_thread_id_list*=2; - new_list=(thread_id_list_t*)tMPI_Malloc( - sizeof(thread_id_list_t)* - Nalloc_thread_id_list); + Nalloc_thread_id_list *= 2; + new_list = (thread_id_list_t*)tMPI_Malloc( + sizeof(thread_id_list_t)* + Nalloc_thread_id_list); /* and copy over all elements */ - for (i=0;ith, + &th->th, 0, FALSE, DUPLICATE_SAME_ACCESS); - /* This causes a small memory leak that is hard to fix. */ - th->started_by_tmpi=0; + /* This causes a small memory leak that is hard to fix. */ + th->started_by_tmpi = 0; tMPI_Thread_id_list_add_locked(thread_id, th); } LeaveCriticalSection( &thread_id_list_lock ); @@ -624,7 +626,7 @@ static void tMPI_Init_initers(void) /* this can be a spinlock because the chances of collision are low. */ tMPI_Spinlock_lock( &init_init ); - state=tMPI_Atomic_get(&init_inited); + state = tMPI_Atomic_get(&init_inited); tMPI_Atomic_memory_barrier_acq(); if (state == 0) { @@ -634,7 +636,7 @@ static void tMPI_Init_initers(void) InitializeCriticalSection(&barrier_init); InitializeCriticalSection(&thread_id_list_lock); - /* fatal errors are handled by the routine by calling + /* fatal errors are handled by the routine by calling tMPI_Fatal_error() */ tMPI_Init_NUMA(); @@ -660,7 +662,7 @@ void tMPI_Fatal_error(const char *file, int line, const char *message, ...) va_start(ap, message); vfprintf(stderr, message, ap); va_end(ap); - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); abort(); } @@ -673,15 +675,15 @@ enum tMPI_Thread_support tMPI_Thread_support(void) struct tMPI_Thread_starter_param { - void *(*start_routine)(void*); /* the function */ - void *param; /* its parameter */ + void *(*start_routine)(void*); /* the function */ + void *param; /* its parameter */ struct tMPI_Thread *thread; }; -static DWORD WINAPI tMPI_Win32_thread_starter( LPVOID lpParam ) +static DWORD WINAPI tMPI_Win32_thread_starter( LPVOID lpParam ) { - struct tMPI_Thread_starter_param *prm= - (struct tMPI_Thread_starter_param*)lpParam; + struct tMPI_Thread_starter_param *prm = + (struct tMPI_Thread_starter_param*)lpParam; (prm->start_routine)(prm->param); return 0; @@ -690,12 +692,12 @@ static DWORD WINAPI tMPI_Win32_thread_starter( LPVOID lpParam ) int tMPI_Thread_get_hw_number(void) { - int ret; + int ret; SYSTEM_INFO sysinfo; GetSystemInfo( &sysinfo ); - ret=sysinfo.dwNumberOfProcessors; + ret = sysinfo.dwNumberOfProcessors; return ret; } @@ -710,37 +712,37 @@ int tMPI_Thread_create(tMPI_Thread_t *thread, tMPI_Init_initers(); - /* a small memory leak to be sure that it doesn't get deallocated + /* a small memory leak to be sure that it doesn't get deallocated once this function ends, before the newly created thread uses it. */ - prm=(struct tMPI_Thread_starter_param*) - tMPI_Malloc(sizeof(struct tMPI_Thread_starter_param)); - prm->start_routine= start_routine; - prm->param=arg; + prm = (struct tMPI_Thread_starter_param*) + tMPI_Malloc(sizeof(struct tMPI_Thread_starter_param)); + prm->start_routine = start_routine; + prm->param = arg; - *thread=(struct tMPI_Thread*)tMPI_Malloc(sizeof(struct tMPI_Thread)*1); + *thread = (struct tMPI_Thread*)tMPI_Malloc(sizeof(struct tMPI_Thread)*1); - if(thread==NULL) + if (thread == NULL) { - tMPI_Fatal_error(TMPI_FARGS,"Invalid thread pointer."); + tMPI_Fatal_error(TMPI_FARGS, "Invalid thread pointer."); return EINVAL; } - /* this must be locked before the thread is created to prevent a race + /* this must be locked before the thread is created to prevent a race condition if the thread immediately wants to create its own entry */ EnterCriticalSection( &thread_id_list_lock ); /* just create a plain thread. */ - (*thread)->started_by_tmpi=1; - (*thread)->th = CreateThread(NULL, - 0, - tMPI_Win32_thread_starter, - prm, - 0, - &thread_id); - (*thread)->id=thread_id; - - if((*thread)->th==NULL) + (*thread)->started_by_tmpi = 1; + (*thread)->th = CreateThread(NULL, + 0, + tMPI_Win32_thread_starter, + prm, + 0, + &thread_id); + (*thread)->id = thread_id; + + if ((*thread)->th == NULL) { tMPI_Free(thread); - tMPI_Fatal_error(TMPI_FARGS,"Failed to create thread, error code=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed to create thread, error code=%d", GetLastError()); return -1; } @@ -748,8 +750,8 @@ int tMPI_Thread_create(tMPI_Thread_t *thread, LeaveCriticalSection( &thread_id_list_lock ); /* inherit the thread priority from the parent thread. */ - /* TODO: is there value in setting this, vs. just allowing it to default - from the process? currently, this limits the effectivenes of changing + /* TODO: is there value in setting this, vs. just allowing it to default + from the process? currently, this limits the effectivenes of changing the priority in eg: TaskManager. */ SetThreadPriority(((*thread)->th), GetThreadPriority(GetCurrentThread())); @@ -764,13 +766,13 @@ int tMPI_Thread_create(tMPI_Thread_t *thread, int tMPI_Thread_join(tMPI_Thread_t thread, void **value_ptr) { - DWORD ret,retval; + DWORD ret, retval; ret = WaitForSingleObject(thread->th, INFINITE); if (ret != 0) { - tMPI_Fatal_error(TMPI_FARGS,"Failed to join thread. error code=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed to join thread. error code=%d", GetLastError()); return -1; } @@ -808,7 +810,7 @@ int tMPI_Thread_cancel(tMPI_Thread_t thread) { if (!TerminateThread( thread, -1) ) { - tMPI_Fatal_error(TMPI_FARGS,"Failed thread_cancel, error code=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed thread_cancel, error code=%d", GetLastError()); return -1; } @@ -822,7 +824,7 @@ tMPI_Thread_t tMPI_Thread_self(void) tMPI_Thread_t th; tMPI_Init_initers(); - th=tMPI_Thread_id_list_add_self(); + th = tMPI_Thread_id_list_add_self(); return th; } @@ -842,52 +844,52 @@ enum tMPI_Thread_setaffinity_support tMPI_Thread_setaffinity_support(void) int tMPI_Thread_setaffinity_single(tMPI_Thread_t thread, unsigned int nr) { - GROUP_AFFINITY GroupAffinity; + GROUP_AFFINITY GroupAffinity; PROCESSOR_NUMBER IdealProcessorNumber; /* thread NUMA node */ - USHORT NumaNodeNumber; + USHORT NumaNodeNumber; - /* check for a processor info array. This exists if NUMA + /* check for a processor info array. This exists if NUMA style calls have been succesfully initialized. */ - if( g_MPI_ProcessorInfo != NULL ) + if (g_MPI_ProcessorInfo != NULL) { /*func_GetCurrentProcessorNumberEx(&CurrentProcessorNumber);*/ /* group, mask. */ - memcpy(&GroupAffinity, - &(g_MPI_ProcessorInfo[nr].GroupAffinity), + memcpy(&GroupAffinity, + &(g_MPI_ProcessorInfo[nr].GroupAffinity), sizeof(GROUP_AFFINITY)); /* group, processor number */ - memcpy(&IdealProcessorNumber, - &(g_MPI_ProcessorInfo[nr].ProcessorNumber), - sizeof(PROCESSOR_NUMBER)); + memcpy(&IdealProcessorNumber, + &(g_MPI_ProcessorInfo[nr].ProcessorNumber), + sizeof(PROCESSOR_NUMBER)); /* set the NUMA node affinity for the current thread - failures to set the current thread affinity are ignored, - as a fringe case can arise on >32 processor systems with a 32bit + failures to set the current thread affinity are ignored, + as a fringe case can arise on >32 processor systems with a 32bit build/code. - */ + */ func_SetThreadIdealProcessorEx(thread->th, &IdealProcessorNumber, NULL); - if(func_GetNumaProcessorNodeEx(&IdealProcessorNumber, - &NumaNodeNumber)) + if (func_GetNumaProcessorNodeEx(&IdealProcessorNumber, + &NumaNodeNumber)) { - /* for the NUMA node number associated with the current processor + /* for the NUMA node number associated with the current processor number, get the group affinity mask */ - if(func_GetNumaNodeProcessorMaskEx(NumaNodeNumber, - &GroupAffinity)) + if (func_GetNumaNodeProcessorMaskEx(NumaNodeNumber, + &GroupAffinity)) { /* set the current thread affinity to prevent it from running on other NUMA nodes */ func_SetThreadGroupAffinity(thread->th, &GroupAffinity, NULL); - return 0; + return 0; } } return 1; @@ -905,23 +907,23 @@ int tMPI_Thread_setaffinity_single(tMPI_Thread_t thread, unsigned int nr) -int tMPI_Thread_mutex_init(tMPI_Thread_mutex_t *mtx) +int tMPI_Thread_mutex_init(tMPI_Thread_mutex_t *mtx) { - if(mtx==NULL) + if (mtx == NULL) { return EINVAL; } - mtx->mutex=(struct tMPI_Mutex*)tMPI_Malloc(sizeof(struct tMPI_Mutex)*1); + mtx->mutex = (struct tMPI_Mutex*)tMPI_Malloc(sizeof(struct tMPI_Mutex)*1); InitializeCriticalSection(&(mtx->mutex->cs)); return 0; } -int tMPI_Thread_mutex_destroy(tMPI_Thread_mutex_t *mtx) +int tMPI_Thread_mutex_destroy(tMPI_Thread_mutex_t *mtx) { - if(mtx == NULL) + if (mtx == NULL) { return EINVAL; } @@ -937,14 +939,14 @@ int tMPI_Thread_mutex_destroy(tMPI_Thread_mutex_t *mtx) static int tMPI_Thread_mutex_init_once(tMPI_Thread_mutex_t *mtx) { - int ret=0; + int ret = 0; /* This is essentially a copy of the code from the one-time * initialization, but with a call to the mutex init routine instead. * It might seem like overkill, but it will only be executed the first - * time you call a static mutex, and it is important to get all the + * time you call a static mutex, and it is important to get all the * memory barriers right. Trust me, you don't want a deadlock here... - */ + */ /* initialize the initializers */ tMPI_Init_initers(); @@ -957,7 +959,7 @@ static int tMPI_Thread_mutex_init_once(tMPI_Thread_mutex_t *mtx) /* No need to keep the lock during execution - * Only one thread can do it anyway. */ - ret=tMPI_Thread_mutex_init(mtx); + ret = tMPI_Thread_mutex_init(mtx); } LeaveCriticalSection( &mutex_init ); @@ -994,7 +996,7 @@ int tMPI_Thread_mutex_trylock(tMPI_Thread_mutex_t *mtx) } /* The mutex is now guaranteed to be valid. */ - ret=TryEnterCriticalSection( &(mtx->mutex->cs) ); + ret = TryEnterCriticalSection( &(mtx->mutex->cs) ); return (ret != 0); } @@ -1013,20 +1015,20 @@ int tMPI_Thread_mutex_unlock(tMPI_Thread_mutex_t *mtx) int tMPI_Thread_key_create(tMPI_Thread_key_t *key, void (*destructor)(void *)) { - if(key==NULL) + if (key == NULL) { - tMPI_Fatal_error(TMPI_FARGS,"Invalid key pointer."); + tMPI_Fatal_error(TMPI_FARGS, "Invalid key pointer."); return EINVAL; } /* TODO: make list of destructors for thread-local storage */ - key->key=(struct tMPI_Thread_key*)tMPI_Malloc(sizeof(struct - tMPI_Thread_key)*1); - - (key)->key->wkey=TlsAlloc(); + key->key = (struct tMPI_Thread_key*)tMPI_Malloc(sizeof(struct + tMPI_Thread_key)*1); - if ( (key)->key->wkey == TLS_OUT_OF_INDEXES ) + (key)->key->wkey = TlsAlloc(); + + if ( (key)->key->wkey == TLS_OUT_OF_INDEXES) { tMPI_Fatal_error(TMPI_FARGS, "Failed to create thread key, error code=%d.", @@ -1052,7 +1054,7 @@ void * tMPI_Thread_getspecific(tMPI_Thread_key_t key) { void *p = NULL; - p=TlsGetValue(key.key->wkey); + p = TlsGetValue(key.key->wkey); return p; } @@ -1064,16 +1066,16 @@ int tMPI_Thread_setspecific(tMPI_Thread_key_t key, void *value) ret = TlsSetValue(key.key->wkey, value); - return ret==0; + return ret == 0; } #if 0 /* use once Vista is minimum required version */ static BOOL CALLBACK InitHandleWrapperFunction(PINIT_ONCE InitOnce, - PVOID Parameter, - PVOID *lpContext) + PVOID Parameter, + PVOID *lpContext) { - void (*fn)(void)=(void (*)(void))Parameter; + void (*fn)(void) = (void (*)(void))Parameter; fn(); @@ -1081,22 +1083,22 @@ static BOOL CALLBACK InitHandleWrapperFunction(PINIT_ONCE InitOnce, } CRITICAL_SECTION tMPI_Once_cs; -tMPI_Spinlock_t tMPI_Once_cs_lock=TMPI_SPINLOCK_INITIALIZER; -volatile int tMPI_Once_init=0; +tMPI_Spinlock_t tMPI_Once_cs_lock = TMPI_SPINLOCK_INITIALIZER; +volatile int tMPI_Once_init = 0; #endif -int tMPI_Thread_once(tMPI_Thread_once_t *once_control, - void (*init_routine)(void)) +int tMPI_Thread_once(tMPI_Thread_once_t *once_control, + void (*init_routine)(void)) { #if 0 /* use once Vista is minimum required version */ BOOL bStatus; - bStatus = InitOnceExecuteOnce(once_control, InitHandleWrapperFunction, + bStatus = InitOnceExecuteOnce(once_control, InitHandleWrapperFunction, init_routine, NULL); if (!bStatus) { - tMPI_Fatal_error(TMPI_FARGS,"Failed to run thread_once routine"); + tMPI_Fatal_error(TMPI_FARGS, "Failed to run thread_once routine"); return -1; } #else @@ -1117,31 +1119,31 @@ int tMPI_Thread_once(tMPI_Thread_once_t *once_control, -int tMPI_Thread_cond_init(tMPI_Thread_cond_t *cond) +int tMPI_Thread_cond_init(tMPI_Thread_cond_t *cond) { - if(cond==NULL) + if (cond == NULL) { return EINVAL; } - cond->condp=(struct tMPI_Thread_cond*) - tMPI_Malloc(sizeof(struct tMPI_Thread_cond)*1); + cond->condp = (struct tMPI_Thread_cond*) + tMPI_Malloc(sizeof(struct tMPI_Thread_cond)*1); #if 0 /* use this code once Vista is the minimum version required */ InitializeConditionVariable( &(cond->cv) ); #else - cond->condp->Nwaiters=0; + cond->condp->Nwaiters = 0; InitializeCriticalSection(&(cond->condp->wtr_lock)); - cond->condp->Nrelease=0; - cond->condp->cycle=0; + cond->condp->Nrelease = 0; + cond->condp->cycle = 0; /* a manual reset, unsignalled event */ - cond->condp->ev = CreateEvent(NULL, TRUE, FALSE, NULL); + cond->condp->ev = CreateEvent(NULL, TRUE, FALSE, NULL); #endif return 0; } -int tMPI_Thread_cond_destroy(tMPI_Thread_cond_t *cond) +int tMPI_Thread_cond_destroy(tMPI_Thread_cond_t *cond) { #if 0 /* use this code once Vista is the minimum version required */ @@ -1155,27 +1157,27 @@ int tMPI_Thread_cond_destroy(tMPI_Thread_cond_t *cond) -/*! \brief Static init routine for pthread barrier +/*! \brief Static init routine for pthread barrier * * \internal * * This is only used as a wrapper to enable static initialization * of posix thread types together with out abstraction layer for tMPI_Thread.h - * + * * \param cond Condition variable, must be statically initialized - * + * * \return status - 0 on success, or a standard error code. */ static int tMPI_Thread_cond_init_once(tMPI_Thread_cond_t *cond) { - int ret=0; + int ret = 0; /* This is essentially a copy of the code from the one-time * initialization, but with a call to the cond init routine instead. * It might seem like overkill, but it will only be executed the first - * time you call a static condition variable, and it is important to get + * time you call a static condition variable, and it is important to get * the memory barriers right. Trust me, you don't want a deadlock here... - */ + */ /* initialize the initializers */ tMPI_Init_initers(); @@ -1187,7 +1189,7 @@ static int tMPI_Thread_cond_init_once(tMPI_Thread_cond_t *cond) { /* No need to keep the lock during execution - * Only one thread can do it anyway. */ - ret=tMPI_Thread_cond_init(cond); + ret = tMPI_Thread_cond_init(cond); } LeaveCriticalSection( &cond_init ); @@ -1199,9 +1201,9 @@ static int tMPI_Thread_cond_init_once(tMPI_Thread_cond_t *cond) int tMPI_Thread_cond_wait(tMPI_Thread_cond_t *cond, tMPI_Thread_mutex_t *mtx) { - BOOL wait_done=FALSE; - BOOL last_waiter=FALSE; - int my_cycle; + BOOL wait_done = FALSE; + BOOL last_waiter = FALSE; + int my_cycle; /* check whether the condition is initialized */ if (tMPI_Atomic_get( &(cond->initialized) ) == 0) @@ -1212,11 +1214,11 @@ int tMPI_Thread_cond_wait(tMPI_Thread_cond_t *cond, tMPI_Thread_mutex_t *mtx) #if 0 /* use this code once Vista is the minimum version required */ - ret=SleepConditionVariableCS (&(cond->cv), &(mtx->cs), INFINITE); + ret = SleepConditionVariableCS (&(cond->cv), &(mtx->cs), INFINITE); if (!ret) { - tMPI_Fatal_error(TMPI_FARGS,"Failed wait for condition, error code=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed wait for condition, error code=%d", GetLastError()); return -1; } @@ -1236,20 +1238,20 @@ int tMPI_Thread_cond_wait(tMPI_Thread_cond_t *cond, tMPI_Thread_mutex_t *mtx) do { /* do the actual waiting */ - if (WaitForSingleObject( cond->condp->ev, INFINITE )== WAIT_FAILED) + if (WaitForSingleObject( cond->condp->ev, INFINITE ) == WAIT_FAILED) { - tMPI_Fatal_error(TMPI_FARGS,"Failed event reset, error code=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed event reset, error code=%d", GetLastError()); return -1; } /* serially check whether we got the right event. */ EnterCriticalSection(&(cond->condp->wtr_lock)); - wait_done = (cond->condp->Nrelease > 0) && - (cond->condp->cycle!=my_cycle); + wait_done = (cond->condp->Nrelease > 0) && + (cond->condp->cycle != my_cycle); LeaveCriticalSection(&(cond->condp->wtr_lock)); } - while(!wait_done); + while (!wait_done); /* We obtain the mutex from the function call */ EnterCriticalSection(&(mtx->mutex->cs)); @@ -1258,7 +1260,7 @@ int tMPI_Thread_cond_wait(tMPI_Thread_cond_t *cond, tMPI_Thread_mutex_t *mtx) EnterCriticalSection(&(cond->condp->wtr_lock)); cond->condp->Nwaiters--; cond->condp->Nrelease--; - last_waiter=(cond->condp->Nrelease==0); + last_waiter = (cond->condp->Nrelease == 0); LeaveCriticalSection(&(cond->condp->wtr_lock)); /* manually release the event if everybody's done with it */ @@ -1266,7 +1268,7 @@ int tMPI_Thread_cond_wait(tMPI_Thread_cond_t *cond, tMPI_Thread_mutex_t *mtx) { if (!ResetEvent( cond->condp->ev )) { - tMPI_Fatal_error(TMPI_FARGS,"Failed event reset, error code=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed event reset, error code=%d", GetLastError()); return -1; } @@ -1297,10 +1299,10 @@ int tMPI_Thread_cond_signal(tMPI_Thread_cond_t *cond) { cond->condp->Nrelease++; cond->condp->cycle++; - if (!SetEvent(cond->condp->ev)) /* actually release the + if (!SetEvent(cond->condp->ev)) /* actually release the waiting threads */ { - tMPI_Fatal_error(TMPI_FARGS,"Failed SetEvent, error code=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed SetEvent, error code=%d", GetLastError()); return -1; } @@ -1329,12 +1331,12 @@ int tMPI_Thread_cond_broadcast(tMPI_Thread_cond_t *cond) /* check whether there are any waiters */ if (cond->condp->Nwaiters > 0) { - cond->condp->Nrelease=cond->condp->Nwaiters; + cond->condp->Nrelease = cond->condp->Nwaiters; cond->condp->cycle++; - if (!SetEvent(cond->condp->ev)) /* actually release the + if (!SetEvent(cond->condp->ev)) /* actually release the waiting threads */ { - tMPI_Fatal_error(TMPI_FARGS,"Failed SetEvent, error code=%d", + tMPI_Fatal_error(TMPI_FARGS, "Failed SetEvent, error code=%d", GetLastError()); return -1; } @@ -1349,16 +1351,16 @@ int tMPI_Thread_cond_broadcast(tMPI_Thread_cond_t *cond) int tMPI_Thread_barrier_init(tMPI_Thread_barrier_t *barrier, int n) { - if(barrier==NULL) + if (barrier == NULL) { return EINVAL; } - barrier->barrierp=(struct tMPI_Thread_barrier*) - tMPI_Malloc(sizeof(struct tMPI_Thread_barrier)*1); + barrier->barrierp = (struct tMPI_Thread_barrier*) + tMPI_Malloc(sizeof(struct tMPI_Thread_barrier)*1); #if 0 - /* use this once Vista is the oldest supported windows version: */ + /* use this once Vista is the oldest supported windows version: */ InitializeCriticalSection(&(barrier->barrierp->cs)); InitializeConditionVariable(&(barrier->barrierp->cv)); #else @@ -1376,8 +1378,8 @@ int tMPI_Thread_barrier_init(tMPI_Thread_barrier_t *barrier, int n) int tMPI_Thread_barrier_destroy(tMPI_Thread_barrier_t *barrier) -{ - if(barrier==NULL) +{ + if (barrier == NULL) { return EINVAL; } @@ -1397,7 +1399,7 @@ int tMPI_Thread_barrier_destroy(tMPI_Thread_barrier_t *barrier) -/*! \brief Static init routine for pthread barrier +/*! \brief Static init routine for pthread barrier * * \internal * @@ -1406,7 +1408,7 @@ int tMPI_Thread_barrier_destroy(tMPI_Thread_barrier_t *barrier) * * \param barrier Statically initialized barrier type * \param n Number of members in barrier - * + * * \return status - 0 on success, or a standard error code. */ static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier, int n) @@ -1416,9 +1418,9 @@ static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier, int n) /* This is essentially a copy of the code from the one-time * initialization, but with a call to the cond init routine instead. * It might seem like overkill, but it will only be executed the first - * time you call a static condition variable, and it is important to get + * time you call a static condition variable, and it is important to get * the memory barriers right. Trust me, you don't want a deadlock here... - */ + */ /* initialize the initializers */ @@ -1432,7 +1434,7 @@ static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier, int n) { /* No need to keep the lock during execution - * Only one thread can do it anyway. */ - ret=tMPI_Thread_barrier_init(barrier, n); + ret = tMPI_Thread_barrier_init(barrier, n); } LeaveCriticalSection( &barrier_init ); @@ -1443,15 +1445,15 @@ static int tMPI_Thread_barrier_init_once(tMPI_Thread_barrier_t *barrier, int n) int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t *barrier) { - int cycle; - BOOL rc=FALSE; - int ret=0; + int cycle; + BOOL rc = FALSE; + int ret = 0; /*tMPI_Thread_pthread_barrier_t *p;*/ /* check whether the barrier is initialized */ if (tMPI_Atomic_get( &(barrier->initialized) ) == 0) { - tMPI_Thread_barrier_init_once(barrier,barrier->threshold); + tMPI_Thread_barrier_init_once(barrier, barrier->threshold); } #if 0 @@ -1467,8 +1469,8 @@ int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t *barrier) /* Decrement the count atomically and check if it is zero. * This will only be true for the last thread calling us. */ - if( --(barrier->count) <= 0 ) - { + if (--(barrier->count) <= 0) + { barrier->cycle = !barrier->cycle; barrier->count = barrier->threshold; #if 0 @@ -1479,21 +1481,24 @@ int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t *barrier) } else { - while(cycle == barrier->cycle) + while (cycle == barrier->cycle) { #if 0 - rc=SleepConditionVariableCS (&(barrier->barrierp->cv), - &(barrier->barrierp->cs), - INFINITE); - if(!rc) + rc = SleepConditionVariableCS (&(barrier->barrierp->cv), + &(barrier->barrierp->cs), + INFINITE); + if (!rc) { - ret=-1; + ret = -1; break; } #else rc = tMPI_Thread_cond_wait(&barrier->barrierp->cv, &barrier->barrierp->cs); - if(rc != 0) break; + if (rc != 0) + { + break; + } #endif } } @@ -1508,7 +1513,6 @@ int tMPI_Thread_barrier_wait(tMPI_Thread_barrier_t *barrier) #else /* just to have some symbols */ -int tMPI_Thread_winthreads=0; +int tMPI_Thread_winthreads = 0; #endif /* THREAD_WINDOWS */ - diff --git a/src/gromacs/gmxlib/thread_mpi/winthreads.h b/src/gromacs/gmxlib/thread_mpi/winthreads.h index cdd5dca418..ba97d7e15a 100644 --- a/src/gromacs/gmxlib/thread_mpi/winthreads.h +++ b/src/gromacs/gmxlib/thread_mpi/winthreads.h @@ -1,48 +1,48 @@ /* -This source code file is part of thread_mpi. -Written by Sander Pronk, Erik Lindahl, and possibly others. + This source code file is part of thread_mpi. + Written by Sander Pronk, Erik Lindahl, and possibly others. -Copyright (c) 2009, Sander Pronk, Erik Lindahl. -All rights reserved. + Copyright (c) 2009, Sander Pronk, Erik Lindahl. + All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: -1) Redistributions of source code must retain the above copyright + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2) Redistributions in binary form must reproduce the above copyright + 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3) Neither the name of the copyright holders nor the + 3) Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -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 should not -be called official thread_mpi. Details are found in the README & COPYING -files. -*/ + THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + 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 should not + be called official thread_mpi. Details are found in the README & COPYING + files. + */ /* the types that were defined in include/thread_mpi/threads.h */ struct tMPI_Thread { - HANDLE th; /* the thread handle */ - DWORD id; /* the thread ID */ - int started_by_tmpi; /* whether this thread was started by tmpi */ + HANDLE th; /* the thread handle */ + DWORD id; /* the thread ID */ + int started_by_tmpi; /* whether this thread was started by tmpi */ }; struct tMPI_Thread_key @@ -66,19 +66,19 @@ struct tMPI_Thread_cond /* this works since Windows Vista: */ CONDITION_VARIABLE cv; #else - /* this data structure and its algorithms are based on + /* this data structure and its algorithms are based on 'Strategies for Implementing POSIX Condition Variables on Win32' by Douglas C. Schmidt and Irfan Pyarali Department of Computer Science Washington University, St. Louis, Missouri http://www.cs.wustl.edu/~schmidt/win32-cv-1.html */ - int Nwaiters; /* number of waiting threads */ + int Nwaiters; /* number of waiting threads */ CRITICAL_SECTION wtr_lock; /* lock for Nwaiters */ - int Nrelease; /* number of threads to release in broadcast/signal */ - int cycle; /* cycle number so threads can't steal signals */ - HANDLE ev; /* the event used to trigger WaitForSingleObject. - Is a manual reset event. */ + int Nrelease; /* number of threads to release in broadcast/signal */ + int cycle; /* cycle number so threads can't steal signals */ + HANDLE ev; /* the event used to trigger WaitForSingleObject. + Is a manual reset event. */ #endif }; @@ -86,17 +86,12 @@ struct tMPI_Thread_barrier { #if 0 /* use this once Vista is the oldest supported windows version: */ - CRITICAL_SECTION cs; /*!< Lock for the barrier - contents */ - CONDITION_VARIABLE cv; /*!< Condition to signal barrier - completion */ + CRITICAL_SECTION cs; /*!< Lock for the barrier + contents */ + CONDITION_VARIABLE cv; /*!< Condition to signal barrier + completion */ #else tMPI_Thread_mutex_t cs; /*!< Lock for the barrier contents */ - tMPI_Thread_cond_t cv; /*!< Condition to signal barrier completion */ + tMPI_Thread_cond_t cv; /*!< Condition to signal barrier completion */ #endif }; - - - - - diff --git a/src/gromacs/gmxlib/topsort.c b/src/gromacs/gmxlib/topsort.c index e79e2bd71f..2320022568 100644 --- a/src/gromacs/gmxlib/topsort.c +++ b/src/gromacs/gmxlib/topsort.c @@ -1,35 +1,35 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- */ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2008, 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 - * + * * And Hey: * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon */ @@ -43,10 +43,10 @@ #include "smalloc.h" #include "gmx_fatal.h" -static gmx_bool ip_pert(int ftype,const t_iparams *ip) +static gmx_bool ip_pert(int ftype, const t_iparams *ip) { gmx_bool bPert; - int i; + int i; if (NRFPB(ftype) == 0) { @@ -55,88 +55,88 @@ static gmx_bool ip_pert(int ftype,const t_iparams *ip) switch (ftype) { - case F_BONDS: - case F_G96BONDS: - case F_HARMONIC: - case F_ANGLES: - case F_G96ANGLES: - case F_IDIHS: - bPert = (ip->harmonic.rA != ip->harmonic.rB || - ip->harmonic.krA != ip->harmonic.krB); - break; - case F_MORSE: - bPert = (ip->morse.b0A != ip->morse.b0B || - ip->morse.cbA != ip->morse.cbB || - ip->morse.betaA != ip->morse.betaB); - break; - case F_RESTRBONDS: - bPert = (ip->restraint.lowA != ip->restraint.lowB || - ip->restraint.up1A != ip->restraint.up1B || - ip->restraint.up2A != ip->restraint.up2B || - ip->restraint.kA != ip->restraint.kB); - break; - case F_PDIHS: - case F_PIDIHS: - case F_ANGRES: - case F_ANGRESZ: - bPert = (ip->pdihs.phiA != ip->pdihs.phiB || - ip->pdihs.cpA != ip->pdihs.cpB); - break; - case F_RBDIHS: - bPert = FALSE; - for(i=0; irbdihs.rbcA[i] != ip->rbdihs.rbcB[i]) + case F_BONDS: + case F_G96BONDS: + case F_HARMONIC: + case F_ANGLES: + case F_G96ANGLES: + case F_IDIHS: + bPert = (ip->harmonic.rA != ip->harmonic.rB || + ip->harmonic.krA != ip->harmonic.krB); + break; + case F_MORSE: + bPert = (ip->morse.b0A != ip->morse.b0B || + ip->morse.cbA != ip->morse.cbB || + ip->morse.betaA != ip->morse.betaB); + break; + case F_RESTRBONDS: + bPert = (ip->restraint.lowA != ip->restraint.lowB || + ip->restraint.up1A != ip->restraint.up1B || + ip->restraint.up2A != ip->restraint.up2B || + ip->restraint.kA != ip->restraint.kB); + break; + case F_PDIHS: + case F_PIDIHS: + case F_ANGRES: + case F_ANGRESZ: + bPert = (ip->pdihs.phiA != ip->pdihs.phiB || + ip->pdihs.cpA != ip->pdihs.cpB); + break; + case F_RBDIHS: + bPert = FALSE; + for (i = 0; i < NR_RBDIHS; i++) { - bPert = TRUE; + if (ip->rbdihs.rbcA[i] != ip->rbdihs.rbcB[i]) + { + bPert = TRUE; + } } - } - break; - case F_TABBONDS: - case F_TABBONDSNC: - case F_TABANGLES: - case F_TABDIHS: - bPert = (ip->tab.kA != ip->tab.kB); - break; - case F_POSRES: - bPert = FALSE; - for(i=0; iposres.pos0A[i] != ip->posres.pos0B[i] || - ip->posres.fcA[i] != ip->posres.fcB[i]) + break; + case F_TABBONDS: + case F_TABBONDSNC: + case F_TABANGLES: + case F_TABDIHS: + bPert = (ip->tab.kA != ip->tab.kB); + break; + case F_POSRES: + bPert = FALSE; + for (i = 0; i < DIM; i++) { - bPert = TRUE; + if (ip->posres.pos0A[i] != ip->posres.pos0B[i] || + ip->posres.fcA[i] != ip->posres.fcB[i]) + { + bPert = TRUE; + } } - } - break; - case F_DIHRES: - bPert = ((ip->dihres.phiA != ip->dihres.phiB) || - (ip->dihres.dphiA != ip->dihres.dphiB) || - (ip->dihres.kfacA != ip->dihres.kfacB)); - break; - case F_LJ14: - bPert = (ip->lj14.c6A != ip->lj14.c6B || - ip->lj14.c12A != ip->lj14.c12B); - break; - case F_CMAP: - bPert = FALSE; - break; - default: - bPert = FALSE; - gmx_fatal(FARGS,"Function type %s not implemented in ip_pert", - interaction_function[ftype].longname); + break; + case F_DIHRES: + bPert = ((ip->dihres.phiA != ip->dihres.phiB) || + (ip->dihres.dphiA != ip->dihres.dphiB) || + (ip->dihres.kfacA != ip->dihres.kfacB)); + break; + case F_LJ14: + bPert = (ip->lj14.c6A != ip->lj14.c6B || + ip->lj14.c12A != ip->lj14.c12B); + break; + case F_CMAP: + bPert = FALSE; + break; + default: + bPert = FALSE; + gmx_fatal(FARGS, "Function type %s not implemented in ip_pert", + interaction_function[ftype].longname); } return bPert; } -static gmx_bool ip_q_pert(int ftype,const t_iatom *ia, - const t_iparams *ip,const real *qA,const real *qB) +static gmx_bool ip_q_pert(int ftype, const t_iatom *ia, + const t_iparams *ip, const real *qA, const real *qB) { /* 1-4 interactions do not have the charges stored in the iparams list, * so we need a separate check for those. */ - return (ip_pert(ftype,ip+ia[0]) || + return (ip_pert(ftype, ip+ia[0]) || (ftype == F_LJ14 && (qA[ia[1]] != qB[ia[1]] || qA[ia[2]] != qB[ia[2]]))); } @@ -144,23 +144,23 @@ static gmx_bool ip_q_pert(int ftype,const t_iatom *ia, gmx_bool gmx_mtop_bondeds_free_energy(const gmx_mtop_t *mtop) { const gmx_ffparams_t *ffparams; - int i,ftype; - int mb; - t_atom *atom; - t_ilist *il; - t_iatom *ia; - gmx_bool bPert; + int i, ftype; + int mb; + t_atom *atom; + t_ilist *il; + t_iatom *ia; + gmx_bool bPert; ffparams = &mtop->ffparams; - + /* Loop over all the function types and compare the A/B parameters */ bPert = FALSE; - for(i=0; intypes; i++) + for (i = 0; i < ffparams->ntypes; i++) { ftype = ffparams->functype[i]; if (interaction_function[ftype].flags & IF_BOND) { - if (ip_pert(ftype,&ffparams->iparams[i])) + if (ip_pert(ftype, &ffparams->iparams[i])) { bPert = TRUE; } @@ -168,12 +168,12 @@ gmx_bool gmx_mtop_bondeds_free_energy(const gmx_mtop_t *mtop) } /* Check perturbed charges for 1-4 interactions */ - for(mb=0; mbnmolblock; mb++) + for (mb = 0; mb < mtop->nmolblock; mb++) { atom = mtop->moltype[mtop->molblock[mb].type].atoms.atom; il = &mtop->moltype[mtop->molblock[mb].type].ilist[F_LJ14]; ia = il->iatoms; - for(i=0; inr; i+=3) + for (i = 0; i < il->nr; i += 3) { if (atom[ia[i+1]].q != atom[ia[i+1]].qB || atom[ia[i+2]].q != atom[ia[i+2]].qB) @@ -186,15 +186,15 @@ gmx_bool gmx_mtop_bondeds_free_energy(const gmx_mtop_t *mtop) return (bPert ? ilsortFE_UNSORTED : ilsortNO_FE); } -void gmx_sort_ilist_fe(t_idef *idef,const real *qA,const real *qB) +void gmx_sort_ilist_fe(t_idef *idef, const real *qA, const real *qB) { - int ftype,nral,i,ic,ib,a; + int ftype, nral, i, ic, ib, a; t_iparams *iparams; - t_ilist *ilist; - t_iatom *iatoms; - gmx_bool bPert; - t_iatom *iabuf; - int iabuf_nalloc; + t_ilist *ilist; + t_iatom *iatoms; + gmx_bool bPert; + t_iatom *iabuf; + int iabuf_nalloc; if (qB == NULL) { @@ -203,31 +203,31 @@ void gmx_sort_ilist_fe(t_idef *idef,const real *qA,const real *qB) iabuf_nalloc = 0; iabuf = NULL; - + iparams = idef->iparams; - for(ftype=0; ftypeil[ftype]; + ilist = &idef->il[ftype]; iatoms = ilist->iatoms; - nral = NRAL(ftype); - ic = 0; - ib = 0; - i = 0; + nral = NRAL(ftype); + ic = 0; + ib = 0; + i = 0; while (i < ilist->nr) { /* Check if this interaction is perturbed */ - if (ip_q_pert(ftype,iatoms+i,iparams,qA,qB)) + if (ip_q_pert(ftype, iatoms+i, iparams, qA, qB)) { /* Copy to the perturbed buffer */ if (ib + 1 + nral > iabuf_nalloc) { iabuf_nalloc = over_alloc_large(ib+1+nral); - srenew(iabuf,iabuf_nalloc); + srenew(iabuf, iabuf_nalloc); } - for(a=0; a<1+nral; a++) + for (a = 0; a < 1+nral; a++) { iabuf[ib++] = iatoms[i++]; } @@ -235,7 +235,7 @@ void gmx_sort_ilist_fe(t_idef *idef,const real *qA,const real *qB) else { /* Copy in place */ - for(a=0; a<1+nral; a++) + for (a = 0; a < 1+nral; a++) { iatoms[ic++] = iatoms[i++]; } @@ -243,16 +243,16 @@ void gmx_sort_ilist_fe(t_idef *idef,const real *qA,const real *qB) } /* Now we now the number of non-perturbed interactions */ ilist->nr_nonperturbed = ic; - + /* Copy the buffer with perturbed interactions to the ilist */ - for(a=0; anr_nonperturbed, ilist->nr-ilist->nr_nonperturbed); diff --git a/src/gromacs/gmxlib/tpxio.c b/src/gromacs/gmxlib/tpxio.c index bd7a9698af..7d283f7df7 100644 --- a/src/gromacs/gmxlib/tpxio.c +++ b/src/gromacs/gmxlib/tpxio.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -80,14 +80,14 @@ static const int tpx_version = 92; * This way we can maintain forward compatibility too for all analysis tools * and/or external programs that only need to know the atom/residue names, * charges, and bond connectivity. - * + * * It first appeared in tpx version 26, when I also moved the inputrecord * to the end of the tpx file, so we can just skip it if we only * want the topology. */ static const int tpx_generation = 25; -/* This number should be the most recent backwards incompatible version +/* This number should be the most recent backwards incompatible version * I.e., if this number is 9, we cannot read tpx version 9 with this code. */ static const int tpx_incompatible_version = 9; @@ -96,2407 +96,2856 @@ static const int tpx_incompatible_version = 9; /* Struct used to maintain tpx compatibility when function types are added */ typedef struct { - int fvnr; /* file version number in which the function type first appeared */ - int ftype; /* function type */ + int fvnr; /* file version number in which the function type first appeared */ + int ftype; /* function type */ } t_ftupd; -/* - *The entries should be ordered in: +/* + * The entries should be ordered in: * 1. ascending file version number * 2. ascending function type number */ /*static const t_ftupd ftupd[] = { - { 20, F_CUBICBONDS }, - { 20, F_CONNBONDS }, - { 20, F_HARMONIC }, - { 20, F_EQM, }, - { 22, F_DISRESVIOL }, - { 22, F_ORIRES }, - { 22, F_ORIRESDEV }, - { 26, F_FOURDIHS }, - { 26, F_PIDIHS }, - { 26, F_DIHRES }, - { 26, F_DIHRESVIOL }, - { 30, F_CROSS_BOND_BONDS }, - { 30, F_CROSS_BOND_ANGLES }, - { 30, F_UREY_BRADLEY }, - { 30, F_POLARIZATION }, - { 54, F_DHDL_CON }, - };*/ -/* - *The entries should be ordered in: + { 20, F_CUBICBONDS }, + { 20, F_CONNBONDS }, + { 20, F_HARMONIC }, + { 20, F_EQM, }, + { 22, F_DISRESVIOL }, + { 22, F_ORIRES }, + { 22, F_ORIRESDEV }, + { 26, F_FOURDIHS }, + { 26, F_PIDIHS }, + { 26, F_DIHRES }, + { 26, F_DIHRESVIOL }, + { 30, F_CROSS_BOND_BONDS }, + { 30, F_CROSS_BOND_ANGLES }, + { 30, F_UREY_BRADLEY }, + { 30, F_POLARIZATION }, + { 54, F_DHDL_CON }, + };*/ +/* + * The entries should be ordered in: * 1. ascending function type number * 2. ascending file version number */ /* question; what is the purpose of the commented code above? */ static const t_ftupd ftupd[] = { - { 20, F_CUBICBONDS }, - { 20, F_CONNBONDS }, - { 20, F_HARMONIC }, - { 34, F_FENEBONDS }, - { 43, F_TABBONDS }, - { 43, F_TABBONDSNC }, - { 70, F_RESTRBONDS }, - { 76, F_LINEAR_ANGLES }, - { 30, F_CROSS_BOND_BONDS }, - { 30, F_CROSS_BOND_ANGLES }, - { 30, F_UREY_BRADLEY }, - { 34, F_QUARTIC_ANGLES }, - { 43, F_TABANGLES }, - { 26, F_FOURDIHS }, - { 26, F_PIDIHS }, - { 43, F_TABDIHS }, - { 65, F_CMAP }, - { 60, F_GB12 }, - { 61, F_GB13 }, - { 61, F_GB14 }, - { 72, F_GBPOL }, - { 72, F_NPSOLVATION }, - { 41, F_LJC14_Q }, - { 41, F_LJC_PAIRS_NB }, - { 32, F_BHAM_LR }, - { 32, F_RF_EXCL }, - { 32, F_COUL_RECIP }, - { 46, F_DPD }, - { 30, F_POLARIZATION }, - { 36, F_THOLE_POL }, - { 80, F_FBPOSRES }, - { 22, F_DISRESVIOL }, - { 22, F_ORIRES }, - { 22, F_ORIRESDEV }, - { 26, F_DIHRES }, - { 26, F_DIHRESVIOL }, - { 49, F_VSITE4FDN }, - { 50, F_VSITEN }, - { 46, F_COM_PULL }, - { 20, F_EQM }, - { 46, F_ECONSERVED }, - { 69, F_VTEMP_NOLONGERUSED}, - { 66, F_PDISPCORR }, - { 54, F_DHDL_CON }, - { 76, F_ANHARM_POL }, - { 79, F_DVDL_COUL }, - { 79, F_DVDL_VDW, }, - { 79, F_DVDL_BONDED, }, - { 79, F_DVDL_RESTRAINT }, - { 79, F_DVDL_TEMPERATURE }, - { 54, F_DHDL_CON } + { 20, F_CUBICBONDS }, + { 20, F_CONNBONDS }, + { 20, F_HARMONIC }, + { 34, F_FENEBONDS }, + { 43, F_TABBONDS }, + { 43, F_TABBONDSNC }, + { 70, F_RESTRBONDS }, + { 76, F_LINEAR_ANGLES }, + { 30, F_CROSS_BOND_BONDS }, + { 30, F_CROSS_BOND_ANGLES }, + { 30, F_UREY_BRADLEY }, + { 34, F_QUARTIC_ANGLES }, + { 43, F_TABANGLES }, + { 26, F_FOURDIHS }, + { 26, F_PIDIHS }, + { 43, F_TABDIHS }, + { 65, F_CMAP }, + { 60, F_GB12 }, + { 61, F_GB13 }, + { 61, F_GB14 }, + { 72, F_GBPOL }, + { 72, F_NPSOLVATION }, + { 41, F_LJC14_Q }, + { 41, F_LJC_PAIRS_NB }, + { 32, F_BHAM_LR }, + { 32, F_RF_EXCL }, + { 32, F_COUL_RECIP }, + { 46, F_DPD }, + { 30, F_POLARIZATION }, + { 36, F_THOLE_POL }, + { 80, F_FBPOSRES }, + { 22, F_DISRESVIOL }, + { 22, F_ORIRES }, + { 22, F_ORIRESDEV }, + { 26, F_DIHRES }, + { 26, F_DIHRESVIOL }, + { 49, F_VSITE4FDN }, + { 50, F_VSITEN }, + { 46, F_COM_PULL }, + { 20, F_EQM }, + { 46, F_ECONSERVED }, + { 69, F_VTEMP_NOLONGERUSED}, + { 66, F_PDISPCORR }, + { 54, F_DHDL_CON }, + { 76, F_ANHARM_POL }, + { 79, F_DVDL_COUL }, + { 79, F_DVDL_VDW, }, + { 79, F_DVDL_BONDED, }, + { 79, F_DVDL_RESTRAINT }, + { 79, F_DVDL_TEMPERATURE }, + { 54, F_DHDL_CON } }; #define NFTUPD asize(ftupd) /* Needed for backward compatibility */ #define MAXNODES 256 -static void _do_section(t_fileio *fio,int key,gmx_bool bRead,const char *src, +static void _do_section(t_fileio *fio, int key, gmx_bool bRead, const char *src, int line) { - char buf[STRLEN]; - gmx_bool bDbg; - - if (gmx_fio_getftp(fio) == efTPA) { - if (!bRead) { - gmx_fio_write_string(fio,itemstr[key]); - bDbg = gmx_fio_getdebug(fio); - gmx_fio_setdebug(fio,FALSE); - gmx_fio_write_string(fio,comment_str[key]); - gmx_fio_setdebug(fio,bDbg); - } - else { - if (gmx_fio_getdebug(fio)) - fprintf(stderr,"Looking for section %s (%s, %d)", - itemstr[key],src,line); - - do { - gmx_fio_do_string(fio,buf); - } while ((gmx_strcasecmp(buf,itemstr[key]) != 0)); - - if (gmx_strcasecmp(buf,itemstr[key]) != 0) - gmx_fatal(FARGS,"\nCould not find section heading %s",itemstr[key]); - else if (gmx_fio_getdebug(fio)) - fprintf(stderr," and found it\n"); - } - } + char buf[STRLEN]; + gmx_bool bDbg; + + if (gmx_fio_getftp(fio) == efTPA) + { + if (!bRead) + { + gmx_fio_write_string(fio, itemstr[key]); + bDbg = gmx_fio_getdebug(fio); + gmx_fio_setdebug(fio, FALSE); + gmx_fio_write_string(fio, comment_str[key]); + gmx_fio_setdebug(fio, bDbg); + } + else + { + if (gmx_fio_getdebug(fio)) + { + fprintf(stderr, "Looking for section %s (%s, %d)", + itemstr[key], src, line); + } + + do + { + gmx_fio_do_string(fio, buf); + } + while ((gmx_strcasecmp(buf, itemstr[key]) != 0)); + + if (gmx_strcasecmp(buf, itemstr[key]) != 0) + { + gmx_fatal(FARGS, "\nCould not find section heading %s", itemstr[key]); + } + else if (gmx_fio_getdebug(fio)) + { + fprintf(stderr, " and found it\n"); + } + } + } } -#define do_section(fio,key,bRead) _do_section(fio,key,bRead,__FILE__,__LINE__) +#define do_section(fio, key, bRead) _do_section(fio, key, bRead, __FILE__, __LINE__) /************************************************************** * * Now the higer level routines that do io of the structures and arrays * **************************************************************/ -static void do_pullgrp(t_fileio *fio, t_pullgrp *pgrp, gmx_bool bRead, +static void do_pullgrp(t_fileio *fio, t_pullgrp *pgrp, gmx_bool bRead, int file_version) { - gmx_bool bDum=TRUE; - int i; - - gmx_fio_do_int(fio,pgrp->nat); - if (bRead) - snew(pgrp->ind,pgrp->nat); - bDum=gmx_fio_ndo_int(fio,pgrp->ind,pgrp->nat); - gmx_fio_do_int(fio,pgrp->nweight); - if (bRead) - snew(pgrp->weight,pgrp->nweight); - bDum=gmx_fio_ndo_real(fio,pgrp->weight,pgrp->nweight); - gmx_fio_do_int(fio,pgrp->pbcatom); - gmx_fio_do_rvec(fio,pgrp->vec); - gmx_fio_do_rvec(fio,pgrp->init); - gmx_fio_do_real(fio,pgrp->rate); - gmx_fio_do_real(fio,pgrp->k); - if (file_version >= 56) { - gmx_fio_do_real(fio,pgrp->kB); - } else { - pgrp->kB = pgrp->k; - } -} + gmx_bool bDum = TRUE; + int i; -static void do_expandedvals(t_fileio *fio,t_expanded *expand,t_lambda *fepvals, gmx_bool bRead, int file_version) -{ - /* i is used in the ndo_double macro*/ - int i; - real fv; - gmx_bool bDum=TRUE; - real rdum; - int n_lambda=fepvals->n_lambda; - - /* reset the lambda calculation window */ - fepvals->lambda_start_n = 0; - fepvals->lambda_stop_n = n_lambda; - if (file_version >= 79) - { - if (n_lambda>0) - { - if (bRead) - { - snew(expand->init_lambda_weights,n_lambda); - } - bDum=gmx_fio_ndo_real(fio,expand->init_lambda_weights,n_lambda); - gmx_fio_do_gmx_bool(fio,expand->bInit_weights); - } - - gmx_fio_do_int(fio,expand->nstexpanded); - gmx_fio_do_int(fio,expand->elmcmove); - gmx_fio_do_int(fio,expand->elamstats); - gmx_fio_do_int(fio,expand->lmc_repeats); - gmx_fio_do_int(fio,expand->gibbsdeltalam); - gmx_fio_do_int(fio,expand->lmc_forced_nstart); - gmx_fio_do_int(fio,expand->lmc_seed); - gmx_fio_do_real(fio,expand->mc_temp); - gmx_fio_do_int(fio,expand->bSymmetrizedTMatrix); - gmx_fio_do_int(fio,expand->nstTij); - gmx_fio_do_int(fio,expand->minvarmin); - gmx_fio_do_int(fio,expand->c_range); - gmx_fio_do_real(fio,expand->wl_scale); - gmx_fio_do_real(fio,expand->wl_ratio); - gmx_fio_do_real(fio,expand->init_wl_delta); - gmx_fio_do_gmx_bool(fio,expand->bWLoneovert); - gmx_fio_do_int(fio,expand->elmceq); - gmx_fio_do_int(fio,expand->equil_steps); - gmx_fio_do_int(fio,expand->equil_samples); - gmx_fio_do_int(fio,expand->equil_n_at_lam); - gmx_fio_do_real(fio,expand->equil_wl_delta); - gmx_fio_do_real(fio,expand->equil_ratio); - } + gmx_fio_do_int(fio, pgrp->nat); + if (bRead) + { + snew(pgrp->ind, pgrp->nat); + } + bDum = gmx_fio_ndo_int(fio, pgrp->ind, pgrp->nat); + gmx_fio_do_int(fio, pgrp->nweight); + if (bRead) + { + snew(pgrp->weight, pgrp->nweight); + } + bDum = gmx_fio_ndo_real(fio, pgrp->weight, pgrp->nweight); + gmx_fio_do_int(fio, pgrp->pbcatom); + gmx_fio_do_rvec(fio, pgrp->vec); + gmx_fio_do_rvec(fio, pgrp->init); + gmx_fio_do_real(fio, pgrp->rate); + gmx_fio_do_real(fio, pgrp->k); + if (file_version >= 56) + { + gmx_fio_do_real(fio, pgrp->kB); + } + else + { + pgrp->kB = pgrp->k; + } } -static void do_simtempvals(t_fileio *fio,t_simtemp *simtemp, int n_lambda, gmx_bool bRead, - int file_version) +static void do_expandedvals(t_fileio *fio, t_expanded *expand, t_lambda *fepvals, gmx_bool bRead, int file_version) { - gmx_bool bDum=TRUE; - - if (file_version >= 79) - { - gmx_fio_do_int(fio,simtemp->eSimTempScale); - gmx_fio_do_real(fio,simtemp->simtemp_high); - gmx_fio_do_real(fio,simtemp->simtemp_low); - if (n_lambda>0) - { - if (bRead) - { - snew(simtemp->temperatures,n_lambda); - } - bDum=gmx_fio_ndo_real(fio,simtemp->temperatures,n_lambda); - } - } -} + /* i is used in the ndo_double macro*/ + int i; + real fv; + gmx_bool bDum = TRUE; + real rdum; + int n_lambda = fepvals->n_lambda; + + /* reset the lambda calculation window */ + fepvals->lambda_start_n = 0; + fepvals->lambda_stop_n = n_lambda; + if (file_version >= 79) + { + if (n_lambda > 0) + { + if (bRead) + { + snew(expand->init_lambda_weights, n_lambda); + } + bDum = gmx_fio_ndo_real(fio, expand->init_lambda_weights, n_lambda); + gmx_fio_do_gmx_bool(fio, expand->bInit_weights); + } -static void do_fepvals(t_fileio *fio,t_lambda *fepvals,gmx_bool bRead, int file_version) -{ - /* i is defined in the ndo_double macro; use g to iterate. */ - int i,g; - real fv; - gmx_bool bDum=TRUE; - real rdum; - - /* free energy values */ - - if (file_version >= 79) - { - gmx_fio_do_int(fio,fepvals->init_fep_state); - gmx_fio_do_double(fio,fepvals->init_lambda); - gmx_fio_do_double(fio,fepvals->delta_lambda); - } - else if (file_version >= 59) { - gmx_fio_do_double(fio,fepvals->init_lambda); - gmx_fio_do_double(fio,fepvals->delta_lambda); - } else { - gmx_fio_do_real(fio,rdum); - fepvals->init_lambda = rdum; - gmx_fio_do_real(fio,rdum); - fepvals->delta_lambda = rdum; - } - if (file_version >= 79) - { - gmx_fio_do_int(fio,fepvals->n_lambda); - if (bRead) - { - snew(fepvals->all_lambda,efptNR); - } - for (g=0;gn_lambda > 0) { - if (bRead) - { - snew(fepvals->all_lambda[g],fepvals->n_lambda); - } - bDum=gmx_fio_ndo_double(fio,fepvals->all_lambda[g],fepvals->n_lambda); - bDum=gmx_fio_ndo_int(fio,fepvals->separate_dvdl,efptNR); - } - else if (fepvals->init_lambda >= 0) - { - fepvals->separate_dvdl[efptFEP] = TRUE; - } - } - } - else if (file_version >= 64) - { - gmx_fio_do_int(fio,fepvals->n_lambda); - if (bRead) - { - int g; - - snew(fepvals->all_lambda,efptNR); - /* still allocate the all_lambda array's contents. */ - for(g=0;gn_lambda > 0) { - snew(fepvals->all_lambda[g],fepvals->n_lambda); - } - } - } - bDum=gmx_fio_ndo_double(fio,fepvals->all_lambda[efptFEP], - fepvals->n_lambda); - if (fepvals->init_lambda >= 0) - { - int g,h; - - fepvals->separate_dvdl[efptFEP] = TRUE; - - if (bRead) - { - /* copy the contents of the efptFEP lambda component to all - the other components */ - for(g=0;gn_lambda;h++) - { - if (g!=efptFEP) - { - fepvals->all_lambda[g][h] = - fepvals->all_lambda[efptFEP][h]; - } - } - } - } - } - } - else - { - fepvals->n_lambda = 0; - fepvals->all_lambda = NULL; - if (fepvals->init_lambda >= 0) - { - fepvals->separate_dvdl[efptFEP] = TRUE; - } - } - if (file_version >= 13) - { - gmx_fio_do_real(fio,fepvals->sc_alpha); - } - else - { - fepvals->sc_alpha = 0; - } - if (file_version >= 38) - { - gmx_fio_do_int(fio,fepvals->sc_power); - } - else - { - fepvals->sc_power = 2; - } - if (file_version >= 79) - { - gmx_fio_do_real(fio,fepvals->sc_r_power); - } - else - { - fepvals->sc_r_power = 6.0; - } - if (file_version >= 15) - { - gmx_fio_do_real(fio,fepvals->sc_sigma); - } - else - { - fepvals->sc_sigma = 0.3; - } - if (bRead) - { - if (file_version >= 71) - { - fepvals->sc_sigma_min = fepvals->sc_sigma; - } - else - { - fepvals->sc_sigma_min = 0; - } - } - if (file_version >= 79) - { - gmx_fio_do_int(fio,fepvals->bScCoul); - } - else - { - fepvals->bScCoul = TRUE; - } - if (file_version >= 64) { - gmx_fio_do_int(fio,fepvals->nstdhdl); - } else { - fepvals->nstdhdl = 1; - } - - if (file_version >= 73) - { - gmx_fio_do_int(fio, fepvals->separate_dhdl_file); - gmx_fio_do_int(fio, fepvals->dhdl_derivatives); - } - else - { - fepvals->separate_dhdl_file = esepdhdlfileYES; - fepvals->dhdl_derivatives = edhdlderivativesYES; - } - if (file_version >= 71) - { - gmx_fio_do_int(fio,fepvals->dh_hist_size); - gmx_fio_do_double(fio,fepvals->dh_hist_spacing); - } - else - { - fepvals->dh_hist_size = 0; - fepvals->dh_hist_spacing = 0.1; - } - if (file_version >= 79) - { - gmx_fio_do_int(fio,fepvals->bPrintEnergy); - } - else - { - fepvals->bPrintEnergy = FALSE; - } - - /* handle lambda_neighbors */ - if ((file_version >= 83 && file_version < 90) || file_version >= 92 ) - { - gmx_fio_do_int(fio,fepvals->lambda_neighbors); - if ( (fepvals->lambda_neighbors >= 0) && (fepvals->init_fep_state>=0) && - (fepvals->init_lambda < 0) ) - { - fepvals->lambda_start_n = (fepvals->init_fep_state - - fepvals->lambda_neighbors); - fepvals->lambda_stop_n = (fepvals->init_fep_state + - fepvals->lambda_neighbors + 1); - if (fepvals->lambda_start_n < 0) - { - fepvals->lambda_start_n = 0;; - } - if (fepvals->lambda_stop_n >= fepvals->n_lambda) - { - fepvals->lambda_stop_n = fepvals->n_lambda; - } - } - else - { - fepvals->lambda_start_n = 0; - fepvals->lambda_stop_n = fepvals->n_lambda; - } - } - else - { - fepvals->lambda_start_n = 0; - fepvals->lambda_stop_n = fepvals->n_lambda; - } + gmx_fio_do_int(fio, expand->nstexpanded); + gmx_fio_do_int(fio, expand->elmcmove); + gmx_fio_do_int(fio, expand->elamstats); + gmx_fio_do_int(fio, expand->lmc_repeats); + gmx_fio_do_int(fio, expand->gibbsdeltalam); + gmx_fio_do_int(fio, expand->lmc_forced_nstart); + gmx_fio_do_int(fio, expand->lmc_seed); + gmx_fio_do_real(fio, expand->mc_temp); + gmx_fio_do_int(fio, expand->bSymmetrizedTMatrix); + gmx_fio_do_int(fio, expand->nstTij); + gmx_fio_do_int(fio, expand->minvarmin); + gmx_fio_do_int(fio, expand->c_range); + gmx_fio_do_real(fio, expand->wl_scale); + gmx_fio_do_real(fio, expand->wl_ratio); + gmx_fio_do_real(fio, expand->init_wl_delta); + gmx_fio_do_gmx_bool(fio, expand->bWLoneovert); + gmx_fio_do_int(fio, expand->elmceq); + gmx_fio_do_int(fio, expand->equil_steps); + gmx_fio_do_int(fio, expand->equil_samples); + gmx_fio_do_int(fio, expand->equil_n_at_lam); + gmx_fio_do_real(fio, expand->equil_wl_delta); + gmx_fio_do_real(fio, expand->equil_ratio); + } } -static void do_pull(t_fileio *fio, t_pull *pull,gmx_bool bRead, int file_version) +static void do_simtempvals(t_fileio *fio, t_simtemp *simtemp, int n_lambda, gmx_bool bRead, + int file_version) { - int g; - - gmx_fio_do_int(fio,pull->ngrp); - gmx_fio_do_int(fio,pull->eGeom); - gmx_fio_do_ivec(fio,pull->dim); - gmx_fio_do_real(fio,pull->cyl_r1); - gmx_fio_do_real(fio,pull->cyl_r0); - gmx_fio_do_real(fio,pull->constr_tol); - gmx_fio_do_int(fio,pull->nstxout); - gmx_fio_do_int(fio,pull->nstfout); - if (bRead) - snew(pull->grp,pull->ngrp+1); - for(g=0; gngrp+1; g++) - do_pullgrp(fio,&pull->grp[g],bRead,file_version); -} + gmx_bool bDum = TRUE; - -static void do_rotgrp(t_fileio *fio, t_rotgrp *rotg,gmx_bool bRead, int file_version) -{ - gmx_bool bDum=TRUE; - int i; - - gmx_fio_do_int(fio,rotg->eType); - gmx_fio_do_int(fio,rotg->bMassW); - gmx_fio_do_int(fio,rotg->nat); - if (bRead) - snew(rotg->ind,rotg->nat); - gmx_fio_ndo_int(fio,rotg->ind,rotg->nat); - if (bRead) - snew(rotg->x_ref,rotg->nat); - gmx_fio_ndo_rvec(fio,rotg->x_ref,rotg->nat); - gmx_fio_do_rvec(fio,rotg->vec); - gmx_fio_do_rvec(fio,rotg->pivot); - gmx_fio_do_real(fio,rotg->rate); - gmx_fio_do_real(fio,rotg->k); - gmx_fio_do_real(fio,rotg->slab_dist); - gmx_fio_do_real(fio,rotg->min_gaussian); - gmx_fio_do_real(fio,rotg->eps); - gmx_fio_do_int(fio,rotg->eFittype); - gmx_fio_do_int(fio,rotg->PotAngle_nstep); - gmx_fio_do_real(fio,rotg->PotAngle_step); + if (file_version >= 79) + { + gmx_fio_do_int(fio, simtemp->eSimTempScale); + gmx_fio_do_real(fio, simtemp->simtemp_high); + gmx_fio_do_real(fio, simtemp->simtemp_low); + if (n_lambda > 0) + { + if (bRead) + { + snew(simtemp->temperatures, n_lambda); + } + bDum = gmx_fio_ndo_real(fio, simtemp->temperatures, n_lambda); + } + } } -static void do_rot(t_fileio *fio, t_rot *rot,gmx_bool bRead, int file_version) +static void do_fepvals(t_fileio *fio, t_lambda *fepvals, gmx_bool bRead, int file_version) { - int g; - - gmx_fio_do_int(fio,rot->ngrp); - gmx_fio_do_int(fio,rot->nstrout); - gmx_fio_do_int(fio,rot->nstsout); - if (bRead) - snew(rot->grp,rot->ngrp); - for(g=0; gngrp; g++) - do_rotgrp(fio, &rot->grp[g],bRead,file_version); -} + /* i is defined in the ndo_double macro; use g to iterate. */ + int i, g; + real fv; + gmx_bool bDum = TRUE; + real rdum; + /* free energy values */ -static void do_inputrec(t_fileio *fio, t_inputrec *ir,gmx_bool bRead, - int file_version, real *fudgeQQ) -{ - int i,j,k,*tmp,idum=0; - gmx_bool bDum=TRUE; - real rdum,bd_temp; - rvec vdum; - gmx_bool bSimAnn; - real zerotemptime,finish_t,init_temp,finish_temp; - - if (file_version != tpx_version) + if (file_version >= 79) { - /* Give a warning about features that are not accessible */ - fprintf(stderr,"Note: file tpx version %d, software tpx version %d\n", - file_version,tpx_version); + gmx_fio_do_int(fio, fepvals->init_fep_state); + gmx_fio_do_double(fio, fepvals->init_lambda); + gmx_fio_do_double(fio, fepvals->delta_lambda); } - - if (bRead) + else if (file_version >= 59) { - init_inputrec(ir); + gmx_fio_do_double(fio, fepvals->init_lambda); + gmx_fio_do_double(fio, fepvals->delta_lambda); } - - if (file_version == 0) + else { - return; + gmx_fio_do_real(fio, rdum); + fepvals->init_lambda = rdum; + gmx_fio_do_real(fio, rdum); + fepvals->delta_lambda = rdum; } - - /* Basic inputrec stuff */ - gmx_fio_do_int(fio,ir->eI); - if (file_version >= 62) { - gmx_fio_do_gmx_large_int(fio, ir->nsteps); - } else { - gmx_fio_do_int(fio,idum); - ir->nsteps = idum; - } - if(file_version > 25) { - if (file_version >= 62) { - gmx_fio_do_gmx_large_int(fio, ir->init_step); - } else { - gmx_fio_do_int(fio,idum); - ir->init_step = idum; - } - } else { - ir->init_step=0; - } - - if(file_version >= 58) - gmx_fio_do_int(fio,ir->simulation_part); - else - ir->simulation_part=1; - - if (file_version >= 67) { - gmx_fio_do_int(fio,ir->nstcalcenergy); - } else { - ir->nstcalcenergy = 1; - } - if (file_version < 53) { - /* The pbc info has been moved out of do_inputrec, - * since we always want it, also without reading the inputrec. - */ - gmx_fio_do_int(fio,ir->ePBC); - if ((file_version <= 15) && (ir->ePBC == 2)) - ir->ePBC = epbcNONE; - if (file_version >= 45) { - gmx_fio_do_int(fio,ir->bPeriodicMols); - } else { - if (ir->ePBC == 2) { - ir->ePBC = epbcXYZ; - ir->bPeriodicMols = TRUE; - } else { - ir->bPeriodicMols = FALSE; - } - } - } - if (file_version >= 81) + if (file_version >= 79) { - gmx_fio_do_int(fio,ir->cutoff_scheme); + gmx_fio_do_int(fio, fepvals->n_lambda); + if (bRead) + { + snew(fepvals->all_lambda, efptNR); + } + for (g = 0; g < efptNR; g++) + { + if (fepvals->n_lambda > 0) + { + if (bRead) + { + snew(fepvals->all_lambda[g], fepvals->n_lambda); + } + bDum = gmx_fio_ndo_double(fio, fepvals->all_lambda[g], fepvals->n_lambda); + bDum = gmx_fio_ndo_int(fio, fepvals->separate_dvdl, efptNR); + } + else if (fepvals->init_lambda >= 0) + { + fepvals->separate_dvdl[efptFEP] = TRUE; + } + } } - else + else if (file_version >= 64) { - ir->cutoff_scheme = ecutsGROUP; - } - gmx_fio_do_int(fio,ir->ns_type); - gmx_fio_do_int(fio,ir->nstlist); - gmx_fio_do_int(fio,ir->ndelta); - if (file_version < 41) { - gmx_fio_do_int(fio,idum); - gmx_fio_do_int(fio,idum); - } - if (file_version >= 45) - gmx_fio_do_real(fio,ir->rtpi); - else - ir->rtpi = 0.05; - gmx_fio_do_int(fio,ir->nstcomm); - if (file_version > 34) - gmx_fio_do_int(fio,ir->comm_mode); - else if (ir->nstcomm < 0) - ir->comm_mode = ecmANGULAR; - else - ir->comm_mode = ecmLINEAR; - ir->nstcomm = abs(ir->nstcomm); - - if(file_version > 25) - gmx_fio_do_int(fio,ir->nstcheckpoint); - else - ir->nstcheckpoint=0; - - gmx_fio_do_int(fio,ir->nstcgsteep); + gmx_fio_do_int(fio, fepvals->n_lambda); + if (bRead) + { + int g; - if(file_version>=30) - gmx_fio_do_int(fio,ir->nbfgscorr); - else if (bRead) - ir->nbfgscorr = 10; + snew(fepvals->all_lambda, efptNR); + /* still allocate the all_lambda array's contents. */ + for (g = 0; g < efptNR; g++) + { + if (fepvals->n_lambda > 0) + { + snew(fepvals->all_lambda[g], fepvals->n_lambda); + } + } + } + bDum = gmx_fio_ndo_double(fio, fepvals->all_lambda[efptFEP], + fepvals->n_lambda); + if (fepvals->init_lambda >= 0) + { + int g, h; - gmx_fio_do_int(fio,ir->nstlog); - gmx_fio_do_int(fio,ir->nstxout); - gmx_fio_do_int(fio,ir->nstvout); - gmx_fio_do_int(fio,ir->nstfout); - gmx_fio_do_int(fio,ir->nstenergy); - gmx_fio_do_int(fio,ir->nstxtcout); - if (file_version >= 59) { - gmx_fio_do_double(fio,ir->init_t); - gmx_fio_do_double(fio,ir->delta_t); - } else { - gmx_fio_do_real(fio,rdum); - ir->init_t = rdum; - gmx_fio_do_real(fio,rdum); - ir->delta_t = rdum; - } - gmx_fio_do_real(fio,ir->xtcprec); - if (file_version < 19) { - gmx_fio_do_int(fio,idum); - gmx_fio_do_int(fio,idum); - } - if(file_version < 18) - gmx_fio_do_int(fio,idum); - if (file_version >= 81) { - gmx_fio_do_real(fio,ir->verletbuf_drift); - } else { - ir->verletbuf_drift = 0; - } - gmx_fio_do_real(fio,ir->rlist); - if (file_version >= 67) { - gmx_fio_do_real(fio,ir->rlistlong); - } - if(file_version >= 82 && file_version != 90) - { - gmx_fio_do_int(fio,ir->nstcalclr); + fepvals->separate_dvdl[efptFEP] = TRUE; + + if (bRead) + { + /* copy the contents of the efptFEP lambda component to all + the other components */ + for (g = 0; g < efptNR; g++) + { + for (h = 0; h < fepvals->n_lambda; h++) + { + if (g != efptFEP) + { + fepvals->all_lambda[g][h] = + fepvals->all_lambda[efptFEP][h]; + } + } + } + } + } } else { - /* Calculate at NS steps */ - ir->nstcalclr = ir->nstlist; + fepvals->n_lambda = 0; + fepvals->all_lambda = NULL; + if (fepvals->init_lambda >= 0) + { + fepvals->separate_dvdl[efptFEP] = TRUE; + } } - gmx_fio_do_int(fio,ir->coulombtype); - if (file_version < 32 && ir->coulombtype == eelRF) - ir->coulombtype = eelRF_NEC; - if (file_version >= 81) + if (file_version >= 13) { - gmx_fio_do_int(fio,ir->coulomb_modifier); + gmx_fio_do_real(fio, fepvals->sc_alpha); } else { - ir->coulomb_modifier = (ir->cutoff_scheme == ecutsVERLET ? eintmodPOTSHIFT : eintmodNONE); + fepvals->sc_alpha = 0; } - gmx_fio_do_real(fio,ir->rcoulomb_switch); - gmx_fio_do_real(fio,ir->rcoulomb); - gmx_fio_do_int(fio,ir->vdwtype); - if (file_version >= 81) + if (file_version >= 38) { - gmx_fio_do_int(fio,ir->vdw_modifier); + gmx_fio_do_int(fio, fepvals->sc_power); } else { - ir->vdw_modifier = (ir->cutoff_scheme == ecutsVERLET ? eintmodPOTSHIFT : eintmodNONE); - } - gmx_fio_do_real(fio,ir->rvdw_switch); - gmx_fio_do_real(fio,ir->rvdw); - if (file_version < 67) { - ir->rlistlong = max_cutoff(ir->rlist,max_cutoff(ir->rvdw,ir->rcoulomb)); - } - gmx_fio_do_int(fio,ir->eDispCorr); - gmx_fio_do_real(fio,ir->epsilon_r); - if (file_version >= 37) { - gmx_fio_do_real(fio,ir->epsilon_rf); - } else { - if (EEL_RF(ir->coulombtype)) { - ir->epsilon_rf = ir->epsilon_r; - ir->epsilon_r = 1.0; - } else { - ir->epsilon_rf = 1.0; - } + fepvals->sc_power = 2; } - if (file_version >= 29) - gmx_fio_do_real(fio,ir->tabext); - else - ir->tabext=1.0; - - if(file_version > 25) { - gmx_fio_do_int(fio,ir->gb_algorithm); - gmx_fio_do_int(fio,ir->nstgbradii); - gmx_fio_do_real(fio,ir->rgbradii); - gmx_fio_do_real(fio,ir->gb_saltconc); - gmx_fio_do_int(fio,ir->implicit_solvent); - } else { - ir->gb_algorithm=egbSTILL; - ir->nstgbradii=1; - ir->rgbradii=1.0; - ir->gb_saltconc=0; - ir->implicit_solvent=eisNO; - } - if(file_version>=55) - { - gmx_fio_do_real(fio,ir->gb_epsilon_solvent); - gmx_fio_do_real(fio,ir->gb_obc_alpha); - gmx_fio_do_real(fio,ir->gb_obc_beta); - gmx_fio_do_real(fio,ir->gb_obc_gamma); - if(file_version>=60) - { - gmx_fio_do_real(fio,ir->gb_dielectric_offset); - gmx_fio_do_int(fio,ir->sa_algorithm); - } - else - { - ir->gb_dielectric_offset = 0.009; - 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 - { - /* Better use sensible values than insane (0.0) ones... */ - ir->gb_epsilon_solvent = 80; - ir->gb_obc_alpha = 1.0; - ir->gb_obc_beta = 0.8; - ir->gb_obc_gamma = 4.85; - ir->sa_surface_tension = 2.092; - } - - - if (file_version >= 81) + if (file_version >= 79) { - gmx_fio_do_real(fio,ir->fourier_spacing); + gmx_fio_do_real(fio, fepvals->sc_r_power); } else { - ir->fourier_spacing = 0.0; - } - gmx_fio_do_int(fio,ir->nkx); - gmx_fio_do_int(fio,ir->nky); - gmx_fio_do_int(fio,ir->nkz); - gmx_fio_do_int(fio,ir->pme_order); - gmx_fio_do_real(fio,ir->ewald_rtol); - - if (file_version >=24) - gmx_fio_do_int(fio,ir->ewald_geometry); - else - ir->ewald_geometry=eewg3D; - - if (file_version <=17) { - ir->epsilon_surface=0; - if (file_version==17) - gmx_fio_do_int(fio,idum); - } - else - gmx_fio_do_real(fio,ir->epsilon_surface); - - gmx_fio_do_gmx_bool(fio,ir->bOptFFT); - - gmx_fio_do_gmx_bool(fio,ir->bContinuation); - gmx_fio_do_int(fio,ir->etc); - /* before version 18, ir->etc was a gmx_bool (ir->btc), - * but the values 0 and 1 still mean no and - * berendsen temperature coupling, respectively. - */ - if (file_version >= 79) { - gmx_fio_do_gmx_bool(fio,ir->bPrintNHChains); + fepvals->sc_r_power = 6.0; } - if (file_version >= 71) + if (file_version >= 15) { - gmx_fio_do_int(fio,ir->nsttcouple); + gmx_fio_do_real(fio, fepvals->sc_sigma); } else { - ir->nsttcouple = ir->nstcalcenergy; - } - if (file_version <= 15) - { - gmx_fio_do_int(fio,idum); + fepvals->sc_sigma = 0.3; } - if (file_version <=17) + if (bRead) { - gmx_fio_do_int(fio,ir->epct); - if (file_version <= 15) + if (file_version >= 71) { - if (ir->epct == 5) - { - ir->epct = epctSURFACETENSION; - } - gmx_fio_do_int(fio,idum); + fepvals->sc_sigma_min = fepvals->sc_sigma; } - ir->epct -= 1; - /* we have removed the NO alternative at the beginning */ - if(ir->epct==-1) - { - ir->epc=epcNO; - ir->epct=epctISOTROPIC; - } else { - ir->epc=epcBERENDSEN; + fepvals->sc_sigma_min = 0; } - } + } + if (file_version >= 79) + { + gmx_fio_do_int(fio, fepvals->bScCoul); + } else { - gmx_fio_do_int(fio,ir->epc); - gmx_fio_do_int(fio,ir->epct); + fepvals->bScCoul = TRUE; } - if (file_version >= 71) + if (file_version >= 64) { - gmx_fio_do_int(fio,ir->nstpcouple); + gmx_fio_do_int(fio, fepvals->nstdhdl); } else { - ir->nstpcouple = ir->nstcalcenergy; + fepvals->nstdhdl = 1; } - gmx_fio_do_real(fio,ir->tau_p); - if (file_version <= 15) { - gmx_fio_do_rvec(fio,vdum); - clear_mat(ir->ref_p); - for(i=0; iref_p[i][i] = vdum[i]; - } else { - gmx_fio_do_rvec(fio,ir->ref_p[XX]); - gmx_fio_do_rvec(fio,ir->ref_p[YY]); - gmx_fio_do_rvec(fio,ir->ref_p[ZZ]); - } - if (file_version <= 15) { - gmx_fio_do_rvec(fio,vdum); - clear_mat(ir->compress); - for(i=0; icompress[i][i] = vdum[i]; - } - else { - gmx_fio_do_rvec(fio,ir->compress[XX]); - gmx_fio_do_rvec(fio,ir->compress[YY]); - gmx_fio_do_rvec(fio,ir->compress[ZZ]); - } - if (file_version >= 47) { - gmx_fio_do_int(fio,ir->refcoord_scaling); - gmx_fio_do_rvec(fio,ir->posres_com); - gmx_fio_do_rvec(fio,ir->posres_comB); - } else { - ir->refcoord_scaling = erscNO; - clear_rvec(ir->posres_com); - clear_rvec(ir->posres_comB); - } - if((file_version > 25) && (file_version < 79)) - gmx_fio_do_int(fio,ir->andersen_seed); - else - ir->andersen_seed=0; - if(file_version < 26) { - gmx_fio_do_gmx_bool(fio,bSimAnn); - gmx_fio_do_real(fio,zerotemptime); - } - - if (file_version < 37) - gmx_fio_do_real(fio,rdum); - - gmx_fio_do_real(fio,ir->shake_tol); - if (file_version < 54) - gmx_fio_do_real(fio,*fudgeQQ); - gmx_fio_do_int(fio,ir->efep); - if (file_version <= 14 && ir->efep != efepNO) + if (file_version >= 73) { - ir->efep = efepYES; + gmx_fio_do_int(fio, fepvals->separate_dhdl_file); + gmx_fio_do_int(fio, fepvals->dhdl_derivatives); } - do_fepvals(fio,ir->fepvals,bRead,file_version); - - if (file_version >= 79) + else { - gmx_fio_do_gmx_bool(fio,ir->bSimTemp); - if (ir->bSimTemp) - { - ir->bSimTemp = TRUE; - } + fepvals->separate_dhdl_file = esepdhdlfileYES; + fepvals->dhdl_derivatives = edhdlderivativesYES; + } + if (file_version >= 71) + { + gmx_fio_do_int(fio, fepvals->dh_hist_size); + gmx_fio_do_double(fio, fepvals->dh_hist_spacing); } else { - ir->bSimTemp = FALSE; + fepvals->dh_hist_size = 0; + fepvals->dh_hist_spacing = 0.1; } - if (ir->bSimTemp) + if (file_version >= 79) + { + gmx_fio_do_int(fio, fepvals->bPrintEnergy); + } + else { - do_simtempvals(fio,ir->simtempvals,ir->fepvals->n_lambda,bRead,file_version); + fepvals->bPrintEnergy = FALSE; } - if (file_version >= 79) + /* handle lambda_neighbors */ + if ((file_version >= 83 && file_version < 90) || file_version >= 92) { - gmx_fio_do_gmx_bool(fio,ir->bExpanded); - if (ir->bExpanded) + gmx_fio_do_int(fio, fepvals->lambda_neighbors); + if ( (fepvals->lambda_neighbors >= 0) && (fepvals->init_fep_state >= 0) && + (fepvals->init_lambda < 0) ) { - ir->bExpanded = TRUE; + fepvals->lambda_start_n = (fepvals->init_fep_state - + fepvals->lambda_neighbors); + fepvals->lambda_stop_n = (fepvals->init_fep_state + + fepvals->lambda_neighbors + 1); + if (fepvals->lambda_start_n < 0) + { + fepvals->lambda_start_n = 0;; + } + if (fepvals->lambda_stop_n >= fepvals->n_lambda) + { + fepvals->lambda_stop_n = fepvals->n_lambda; + } } else { - ir->bExpanded = FALSE; + fepvals->lambda_start_n = 0; + fepvals->lambda_stop_n = fepvals->n_lambda; } } - if (ir->bExpanded) - { - do_expandedvals(fio,ir->expandedvals,ir->fepvals,bRead,file_version); - } - if (file_version >= 57) { - gmx_fio_do_int(fio,ir->eDisre); - } - gmx_fio_do_int(fio,ir->eDisreWeighting); - if (file_version < 22) { - if (ir->eDisreWeighting == 0) - ir->eDisreWeighting = edrwEqual; - else - ir->eDisreWeighting = edrwConservative; - } - gmx_fio_do_gmx_bool(fio,ir->bDisreMixed); - gmx_fio_do_real(fio,ir->dr_fc); - gmx_fio_do_real(fio,ir->dr_tau); - gmx_fio_do_int(fio,ir->nstdisreout); - if (file_version >= 22) { - gmx_fio_do_real(fio,ir->orires_fc); - gmx_fio_do_real(fio,ir->orires_tau); - gmx_fio_do_int(fio,ir->nstorireout); - } else { - ir->orires_fc = 0; - ir->orires_tau = 0; - ir->nstorireout = 0; - } - if(file_version >= 26 && file_version < 79) { - gmx_fio_do_real(fio,ir->dihre_fc); - if (file_version < 56) - { - gmx_fio_do_real(fio,rdum); - gmx_fio_do_int(fio,idum); - } - } else { - ir->dihre_fc=0; - } - - gmx_fio_do_real(fio,ir->em_stepsize); - gmx_fio_do_real(fio,ir->em_tol); - if (file_version >= 22) - gmx_fio_do_gmx_bool(fio,ir->bShakeSOR); - else if (bRead) - ir->bShakeSOR = TRUE; - if (file_version >= 11) - gmx_fio_do_int(fio,ir->niter); - else if (bRead) { - ir->niter = 25; - fprintf(stderr,"Note: niter not in run input file, setting it to %d\n", - ir->niter); - } - if (file_version >= 21) - gmx_fio_do_real(fio,ir->fc_stepsize); else - ir->fc_stepsize = 0; - gmx_fio_do_int(fio,ir->eConstrAlg); - gmx_fio_do_int(fio,ir->nProjOrder); - gmx_fio_do_real(fio,ir->LincsWarnAngle); - if (file_version <= 14) - gmx_fio_do_int(fio,idum); - if (file_version >=26) - gmx_fio_do_int(fio,ir->nLincsIter); - else if (bRead) { - ir->nLincsIter = 1; - fprintf(stderr,"Note: nLincsIter not in run input file, setting it to %d\n", - ir->nLincsIter); - } - if (file_version < 33) - gmx_fio_do_real(fio,bd_temp); - gmx_fio_do_real(fio,ir->bd_fric); - gmx_fio_do_int(fio,ir->ld_seed); - if (file_version >= 33) { - for(i=0; ideform[i]); - } else { - for(i=0; ideform[i]); - } - if (file_version >= 14) - gmx_fio_do_real(fio,ir->cos_accel); - else if (bRead) - ir->cos_accel = 0; - gmx_fio_do_int(fio,ir->userint1); - gmx_fio_do_int(fio,ir->userint2); - gmx_fio_do_int(fio,ir->userint3); - gmx_fio_do_int(fio,ir->userint4); - gmx_fio_do_real(fio,ir->userreal1); - gmx_fio_do_real(fio,ir->userreal2); - gmx_fio_do_real(fio,ir->userreal3); - gmx_fio_do_real(fio,ir->userreal4); - - /* AdResS stuff */ - if (file_version >= 77) { - gmx_fio_do_gmx_bool(fio,ir->bAdress); - if(ir->bAdress){ - if (bRead) snew(ir->adress, 1); - gmx_fio_do_int(fio,ir->adress->type); - gmx_fio_do_real(fio,ir->adress->const_wf); - gmx_fio_do_real(fio,ir->adress->ex_width); - gmx_fio_do_real(fio,ir->adress->hy_width); - gmx_fio_do_int(fio,ir->adress->icor); - gmx_fio_do_int(fio,ir->adress->site); - gmx_fio_do_rvec(fio,ir->adress->refs); - gmx_fio_do_int(fio,ir->adress->n_tf_grps); - gmx_fio_do_real(fio, ir->adress->ex_forcecap); - gmx_fio_do_int(fio, ir->adress->n_energy_grps); - gmx_fio_do_int(fio,ir->adress->do_hybridpairs); - - if (bRead)snew(ir->adress->tf_table_index,ir->adress->n_tf_grps); - if (ir->adress->n_tf_grps > 0) { - bDum=gmx_fio_ndo_int(fio,ir->adress->tf_table_index,ir->adress->n_tf_grps); - } - if (bRead)snew(ir->adress->group_explicit,ir->adress->n_energy_grps); - if (ir->adress->n_energy_grps > 0) { - bDum=gmx_fio_ndo_int(fio, ir->adress->group_explicit,ir->adress->n_energy_grps); - } - } - } else { - ir->bAdress = FALSE; + { + fepvals->lambda_start_n = 0; + fepvals->lambda_stop_n = fepvals->n_lambda; } +} - /* pull stuff */ - if (file_version >= 48) { - gmx_fio_do_int(fio,ir->ePull); - if (ir->ePull != epullNO) { - if (bRead) - snew(ir->pull,1); - do_pull(fio, ir->pull,bRead,file_version); - } - } else { - ir->ePull = epullNO; - } - - /* Enforced rotation */ - if (file_version >= 74) { - gmx_fio_do_int(fio,ir->bRot); - if (ir->bRot == TRUE) { - if (bRead) - snew(ir->rot,1); - do_rot(fio, ir->rot,bRead,file_version); - } - } else { - ir->bRot = FALSE; - } - - /* grpopts stuff */ - gmx_fio_do_int(fio,ir->opts.ngtc); - if (file_version >= 69) { - gmx_fio_do_int(fio,ir->opts.nhchainlength); - } else { - ir->opts.nhchainlength = 1; - } - gmx_fio_do_int(fio,ir->opts.ngacc); - gmx_fio_do_int(fio,ir->opts.ngfrz); - gmx_fio_do_int(fio,ir->opts.ngener); - - if (bRead) { - snew(ir->opts.nrdf, ir->opts.ngtc); - snew(ir->opts.ref_t, ir->opts.ngtc); - snew(ir->opts.annealing, ir->opts.ngtc); - snew(ir->opts.anneal_npoints, ir->opts.ngtc); - snew(ir->opts.anneal_time, ir->opts.ngtc); - snew(ir->opts.anneal_temp, ir->opts.ngtc); - snew(ir->opts.tau_t, ir->opts.ngtc); - snew(ir->opts.nFreeze,ir->opts.ngfrz); - snew(ir->opts.acc, ir->opts.ngacc); - snew(ir->opts.egp_flags,ir->opts.ngener*ir->opts.ngener); - } - if (ir->opts.ngtc > 0) { - if (bRead && file_version<13) { - snew(tmp,ir->opts.ngtc); - bDum=gmx_fio_ndo_int(fio,tmp, ir->opts.ngtc); - for(i=0; iopts.ngtc; i++) - ir->opts.nrdf[i] = tmp[i]; - sfree(tmp); - } else { - bDum=gmx_fio_ndo_real(fio,ir->opts.nrdf, ir->opts.ngtc); - } - bDum=gmx_fio_ndo_real(fio,ir->opts.ref_t,ir->opts.ngtc); - bDum=gmx_fio_ndo_real(fio,ir->opts.tau_t,ir->opts.ngtc); - if (file_version<33 && ir->eI==eiBD) { - for(i=0; iopts.ngtc; i++) - ir->opts.tau_t[i] = bd_temp; - } - } - if (ir->opts.ngfrz > 0) - bDum=gmx_fio_ndo_ivec(fio,ir->opts.nFreeze,ir->opts.ngfrz); - if (ir->opts.ngacc > 0) - gmx_fio_ndo_rvec(fio,ir->opts.acc,ir->opts.ngacc); - if (file_version >= 12) - bDum=gmx_fio_ndo_int(fio,ir->opts.egp_flags, - ir->opts.ngener*ir->opts.ngener); - - if(bRead && file_version < 26) { - for(i=0;iopts.ngtc;i++) { - if(bSimAnn) { - ir->opts.annealing[i] = eannSINGLE; - ir->opts.anneal_npoints[i] = 2; - snew(ir->opts.anneal_time[i],2); - snew(ir->opts.anneal_temp[i],2); - /* calculate the starting/ending temperatures from reft, zerotemptime, and nsteps */ - finish_t = ir->init_t + ir->nsteps * ir->delta_t; - init_temp = ir->opts.ref_t[i]*(1-ir->init_t/zerotemptime); - finish_temp = ir->opts.ref_t[i]*(1-finish_t/zerotemptime); - ir->opts.anneal_time[i][0] = ir->init_t; - ir->opts.anneal_time[i][1] = finish_t; - ir->opts.anneal_temp[i][0] = init_temp; - ir->opts.anneal_temp[i][1] = finish_temp; - } else { - ir->opts.annealing[i] = eannNO; - ir->opts.anneal_npoints[i] = 0; - } - } - } else { - /* file version 26 or later */ - /* First read the lists with annealing and npoints for each group */ - bDum=gmx_fio_ndo_int(fio,ir->opts.annealing,ir->opts.ngtc); - bDum=gmx_fio_ndo_int(fio,ir->opts.anneal_npoints,ir->opts.ngtc); - for(j=0;j<(ir->opts.ngtc);j++) { - k=ir->opts.anneal_npoints[j]; - if(bRead) { - snew(ir->opts.anneal_time[j],k); - snew(ir->opts.anneal_temp[j],k); - } - bDum=gmx_fio_ndo_real(fio,ir->opts.anneal_time[j],k); - bDum=gmx_fio_ndo_real(fio,ir->opts.anneal_temp[j],k); - } +static void do_pull(t_fileio *fio, t_pull *pull, gmx_bool bRead, int file_version) +{ + int g; + + gmx_fio_do_int(fio, pull->ngrp); + gmx_fio_do_int(fio, pull->eGeom); + gmx_fio_do_ivec(fio, pull->dim); + gmx_fio_do_real(fio, pull->cyl_r1); + gmx_fio_do_real(fio, pull->cyl_r0); + gmx_fio_do_real(fio, pull->constr_tol); + gmx_fio_do_int(fio, pull->nstxout); + gmx_fio_do_int(fio, pull->nstfout); + if (bRead) + { + snew(pull->grp, pull->ngrp+1); } - /* Walls */ - if (file_version >= 45) { - gmx_fio_do_int(fio,ir->nwall); - gmx_fio_do_int(fio,ir->wall_type); - if (file_version >= 50) - gmx_fio_do_real(fio,ir->wall_r_linpot); - else - ir->wall_r_linpot = -1; - gmx_fio_do_int(fio,ir->wall_atomtype[0]); - gmx_fio_do_int(fio,ir->wall_atomtype[1]); - gmx_fio_do_real(fio,ir->wall_density[0]); - gmx_fio_do_real(fio,ir->wall_density[1]); - gmx_fio_do_real(fio,ir->wall_ewald_zfac); - } else { - ir->nwall = 0; - ir->wall_type = 0; - ir->wall_atomtype[0] = -1; - ir->wall_atomtype[1] = -1; - ir->wall_density[0] = 0; - ir->wall_density[1] = 0; - ir->wall_ewald_zfac = 3; + for (g = 0; g < pull->ngrp+1; g++) + { + do_pullgrp(fio, &pull->grp[g], bRead, file_version); } - /* Cosine stuff for electric fields */ - for(j=0; (jex[j].n); - gmx_fio_do_int(fio,ir->et[j].n); - if (bRead) { - snew(ir->ex[j].a, ir->ex[j].n); - snew(ir->ex[j].phi,ir->ex[j].n); - snew(ir->et[j].a, ir->et[j].n); - snew(ir->et[j].phi,ir->et[j].n); - } - bDum=gmx_fio_ndo_real(fio,ir->ex[j].a, ir->ex[j].n); - bDum=gmx_fio_ndo_real(fio,ir->ex[j].phi,ir->ex[j].n); - bDum=gmx_fio_ndo_real(fio,ir->et[j].a, ir->et[j].n); - bDum=gmx_fio_ndo_real(fio,ir->et[j].phi,ir->et[j].n); - } - - /* QMMM stuff */ - if(file_version>=39){ - gmx_fio_do_gmx_bool(fio,ir->bQMMM); - gmx_fio_do_int(fio,ir->QMMMscheme); - gmx_fio_do_real(fio,ir->scalefactor); - gmx_fio_do_int(fio,ir->opts.ngQM); - if (bRead) { - snew(ir->opts.QMmethod, ir->opts.ngQM); - snew(ir->opts.QMbasis, ir->opts.ngQM); - snew(ir->opts.QMcharge, ir->opts.ngQM); - snew(ir->opts.QMmult, ir->opts.ngQM); - snew(ir->opts.bSH, ir->opts.ngQM); - snew(ir->opts.CASorbitals, ir->opts.ngQM); - snew(ir->opts.CASelectrons,ir->opts.ngQM); - snew(ir->opts.SAon, ir->opts.ngQM); - snew(ir->opts.SAoff, ir->opts.ngQM); - snew(ir->opts.SAsteps, ir->opts.ngQM); - snew(ir->opts.bOPT, ir->opts.ngQM); - snew(ir->opts.bTS, ir->opts.ngQM); - } - if (ir->opts.ngQM > 0) { - bDum=gmx_fio_ndo_int(fio,ir->opts.QMmethod,ir->opts.ngQM); - bDum=gmx_fio_ndo_int(fio,ir->opts.QMbasis,ir->opts.ngQM); - bDum=gmx_fio_ndo_int(fio,ir->opts.QMcharge,ir->opts.ngQM); - bDum=gmx_fio_ndo_int(fio,ir->opts.QMmult,ir->opts.ngQM); - bDum=gmx_fio_ndo_gmx_bool(fio,ir->opts.bSH,ir->opts.ngQM); - bDum=gmx_fio_ndo_int(fio,ir->opts.CASorbitals,ir->opts.ngQM); - bDum=gmx_fio_ndo_int(fio,ir->opts.CASelectrons,ir->opts.ngQM); - bDum=gmx_fio_ndo_real(fio,ir->opts.SAon,ir->opts.ngQM); - bDum=gmx_fio_ndo_real(fio,ir->opts.SAoff,ir->opts.ngQM); - bDum=gmx_fio_ndo_int(fio,ir->opts.SAsteps,ir->opts.ngQM); - bDum=gmx_fio_ndo_gmx_bool(fio,ir->opts.bOPT,ir->opts.ngQM); - bDum=gmx_fio_ndo_gmx_bool(fio,ir->opts.bTS,ir->opts.ngQM); - } - /* end of QMMM stuff */ - } } -static void do_harm(t_fileio *fio, t_iparams *iparams,gmx_bool bRead) +static void do_rotgrp(t_fileio *fio, t_rotgrp *rotg, gmx_bool bRead, int file_version) { - gmx_fio_do_real(fio,iparams->harmonic.rA); - gmx_fio_do_real(fio,iparams->harmonic.krA); - gmx_fio_do_real(fio,iparams->harmonic.rB); - gmx_fio_do_real(fio,iparams->harmonic.krB); -} + gmx_bool bDum = TRUE; + int i; -void do_iparams(t_fileio *fio, t_functype ftype,t_iparams *iparams, - gmx_bool bRead, int file_version) -{ - int idum; - gmx_bool bDum; - real rdum; - - if (!bRead) - gmx_fio_set_comment(fio, interaction_function[ftype].name); - switch (ftype) { - case F_ANGLES: - case F_G96ANGLES: - case F_BONDS: - case F_G96BONDS: - case F_HARMONIC: - case F_IDIHS: - do_harm(fio, iparams,bRead); - if ((ftype == F_ANGRES || ftype == F_ANGRESZ) && bRead) { - /* Correct incorrect storage of parameters */ - iparams->pdihs.phiB = iparams->pdihs.phiA; - iparams->pdihs.cpB = iparams->pdihs.cpA; - } - break; - case F_LINEAR_ANGLES: - gmx_fio_do_real(fio,iparams->linangle.klinA); - gmx_fio_do_real(fio,iparams->linangle.aA); - gmx_fio_do_real(fio,iparams->linangle.klinB); - gmx_fio_do_real(fio,iparams->linangle.aB); - break; - case F_FENEBONDS: - gmx_fio_do_real(fio,iparams->fene.bm); - gmx_fio_do_real(fio,iparams->fene.kb); - break; - case F_RESTRBONDS: - gmx_fio_do_real(fio,iparams->restraint.lowA); - gmx_fio_do_real(fio,iparams->restraint.up1A); - gmx_fio_do_real(fio,iparams->restraint.up2A); - gmx_fio_do_real(fio,iparams->restraint.kA); - gmx_fio_do_real(fio,iparams->restraint.lowB); - gmx_fio_do_real(fio,iparams->restraint.up1B); - gmx_fio_do_real(fio,iparams->restraint.up2B); - gmx_fio_do_real(fio,iparams->restraint.kB); - break; - case F_TABBONDS: - case F_TABBONDSNC: - case F_TABANGLES: - case F_TABDIHS: - gmx_fio_do_real(fio,iparams->tab.kA); - gmx_fio_do_int(fio,iparams->tab.table); - gmx_fio_do_real(fio,iparams->tab.kB); - break; - case F_CROSS_BOND_BONDS: - gmx_fio_do_real(fio,iparams->cross_bb.r1e); - gmx_fio_do_real(fio,iparams->cross_bb.r2e); - gmx_fio_do_real(fio,iparams->cross_bb.krr); - break; - case F_CROSS_BOND_ANGLES: - gmx_fio_do_real(fio,iparams->cross_ba.r1e); - gmx_fio_do_real(fio,iparams->cross_ba.r2e); - gmx_fio_do_real(fio,iparams->cross_ba.r3e); - gmx_fio_do_real(fio,iparams->cross_ba.krt); - break; - case F_UREY_BRADLEY: - gmx_fio_do_real(fio,iparams->u_b.thetaA); - gmx_fio_do_real(fio,iparams->u_b.kthetaA); - gmx_fio_do_real(fio,iparams->u_b.r13A); - gmx_fio_do_real(fio,iparams->u_b.kUBA); - if (file_version >= 79) { - gmx_fio_do_real(fio,iparams->u_b.thetaB); - gmx_fio_do_real(fio,iparams->u_b.kthetaB); - gmx_fio_do_real(fio,iparams->u_b.r13B); - gmx_fio_do_real(fio,iparams->u_b.kUBB); - } else { - iparams->u_b.thetaB=iparams->u_b.thetaA; - iparams->u_b.kthetaB=iparams->u_b.kthetaA; - iparams->u_b.r13B=iparams->u_b.r13A; - iparams->u_b.kUBB=iparams->u_b.kUBA; - } - break; - case F_QUARTIC_ANGLES: - gmx_fio_do_real(fio,iparams->qangle.theta); - bDum=gmx_fio_ndo_real(fio,iparams->qangle.c,5); - break; - case F_BHAM: - gmx_fio_do_real(fio,iparams->bham.a); - gmx_fio_do_real(fio,iparams->bham.b); - gmx_fio_do_real(fio,iparams->bham.c); - break; - case F_MORSE: - gmx_fio_do_real(fio,iparams->morse.b0A); - gmx_fio_do_real(fio,iparams->morse.cbA); - gmx_fio_do_real(fio,iparams->morse.betaA); - if (file_version >= 79) { - gmx_fio_do_real(fio,iparams->morse.b0B); - gmx_fio_do_real(fio,iparams->morse.cbB); - gmx_fio_do_real(fio,iparams->morse.betaB); - } else { - iparams->morse.b0B = iparams->morse.b0A; - iparams->morse.cbB = iparams->morse.cbA; - iparams->morse.betaB = iparams->morse.betaA; - } - break; - case F_CUBICBONDS: - gmx_fio_do_real(fio,iparams->cubic.b0); - gmx_fio_do_real(fio,iparams->cubic.kb); - gmx_fio_do_real(fio,iparams->cubic.kcub); - break; - case F_CONNBONDS: - break; - case F_POLARIZATION: - gmx_fio_do_real(fio,iparams->polarize.alpha); - break; - case F_ANHARM_POL: - gmx_fio_do_real(fio,iparams->anharm_polarize.alpha); - gmx_fio_do_real(fio,iparams->anharm_polarize.drcut); - gmx_fio_do_real(fio,iparams->anharm_polarize.khyp); - break; - case F_WATER_POL: - if (file_version < 31) - gmx_fatal(FARGS,"Old tpr files with water_polarization not supported. Make a new."); - gmx_fio_do_real(fio,iparams->wpol.al_x); - gmx_fio_do_real(fio,iparams->wpol.al_y); - gmx_fio_do_real(fio,iparams->wpol.al_z); - gmx_fio_do_real(fio,iparams->wpol.rOH); - gmx_fio_do_real(fio,iparams->wpol.rHH); - gmx_fio_do_real(fio,iparams->wpol.rOD); - break; - case F_THOLE_POL: - gmx_fio_do_real(fio,iparams->thole.a); - gmx_fio_do_real(fio,iparams->thole.alpha1); - gmx_fio_do_real(fio,iparams->thole.alpha2); - gmx_fio_do_real(fio,iparams->thole.rfac); - break; - case F_LJ: - gmx_fio_do_real(fio,iparams->lj.c6); - gmx_fio_do_real(fio,iparams->lj.c12); - break; - case F_LJ14: - gmx_fio_do_real(fio,iparams->lj14.c6A); - gmx_fio_do_real(fio,iparams->lj14.c12A); - gmx_fio_do_real(fio,iparams->lj14.c6B); - gmx_fio_do_real(fio,iparams->lj14.c12B); - break; - case F_LJC14_Q: - gmx_fio_do_real(fio,iparams->ljc14.fqq); - gmx_fio_do_real(fio,iparams->ljc14.qi); - gmx_fio_do_real(fio,iparams->ljc14.qj); - gmx_fio_do_real(fio,iparams->ljc14.c6); - gmx_fio_do_real(fio,iparams->ljc14.c12); - break; - case F_LJC_PAIRS_NB: - gmx_fio_do_real(fio,iparams->ljcnb.qi); - gmx_fio_do_real(fio,iparams->ljcnb.qj); - gmx_fio_do_real(fio,iparams->ljcnb.c6); - gmx_fio_do_real(fio,iparams->ljcnb.c12); - break; - case F_PDIHS: - case F_PIDIHS: - case F_ANGRES: - case F_ANGRESZ: - gmx_fio_do_real(fio,iparams->pdihs.phiA); - gmx_fio_do_real(fio,iparams->pdihs.cpA); - if ((ftype == F_ANGRES || ftype == F_ANGRESZ) && file_version < 42) { - /* Read the incorrectly stored multiplicity */ - gmx_fio_do_real(fio,iparams->harmonic.rB); - gmx_fio_do_real(fio,iparams->harmonic.krB); - iparams->pdihs.phiB = iparams->pdihs.phiA; - iparams->pdihs.cpB = iparams->pdihs.cpA; - } else { - gmx_fio_do_real(fio,iparams->pdihs.phiB); - gmx_fio_do_real(fio,iparams->pdihs.cpB); - gmx_fio_do_int(fio,iparams->pdihs.mult); - } - break; - case F_DISRES: - gmx_fio_do_int(fio,iparams->disres.label); - gmx_fio_do_int(fio,iparams->disres.type); - gmx_fio_do_real(fio,iparams->disres.low); - gmx_fio_do_real(fio,iparams->disres.up1); - gmx_fio_do_real(fio,iparams->disres.up2); - gmx_fio_do_real(fio,iparams->disres.kfac); - break; - case F_ORIRES: - gmx_fio_do_int(fio,iparams->orires.ex); - gmx_fio_do_int(fio,iparams->orires.label); - gmx_fio_do_int(fio,iparams->orires.power); - gmx_fio_do_real(fio,iparams->orires.c); - gmx_fio_do_real(fio,iparams->orires.obs); - gmx_fio_do_real(fio,iparams->orires.kfac); - break; - case F_DIHRES: - if ( file_version < 72) { - gmx_fio_do_int(fio,idum); - gmx_fio_do_int(fio,idum); - } - gmx_fio_do_real(fio,iparams->dihres.phiA); - gmx_fio_do_real(fio,iparams->dihres.dphiA); - gmx_fio_do_real(fio,iparams->dihres.kfacA); - if (file_version >= 72) { - gmx_fio_do_real(fio,iparams->dihres.phiB); - gmx_fio_do_real(fio,iparams->dihres.dphiB); - gmx_fio_do_real(fio,iparams->dihres.kfacB); - } else { - iparams->dihres.phiB=iparams->dihres.phiA; - iparams->dihres.dphiB=iparams->dihres.dphiA; - iparams->dihres.kfacB=iparams->dihres.kfacA; - } - break; - case F_POSRES: - gmx_fio_do_rvec(fio,iparams->posres.pos0A); - gmx_fio_do_rvec(fio,iparams->posres.fcA); - if (bRead && file_version < 27) { - copy_rvec(iparams->posres.pos0A,iparams->posres.pos0B); - copy_rvec(iparams->posres.fcA,iparams->posres.fcB); - } else { - gmx_fio_do_rvec(fio,iparams->posres.pos0B); - gmx_fio_do_rvec(fio,iparams->posres.fcB); - } - break; - case F_FBPOSRES: - gmx_fio_do_int(fio,iparams->fbposres.geom); - gmx_fio_do_rvec(fio,iparams->fbposres.pos0); - gmx_fio_do_real(fio,iparams->fbposres.r); - gmx_fio_do_real(fio,iparams->fbposres.k); - break; - case F_RBDIHS: - bDum=gmx_fio_ndo_real(fio,iparams->rbdihs.rbcA,NR_RBDIHS); - if(file_version>=25) - bDum=gmx_fio_ndo_real(fio,iparams->rbdihs.rbcB,NR_RBDIHS); - break; - case F_FOURDIHS: - /* Fourier dihedrals are internally represented - * as Ryckaert-Bellemans since those are faster to compute. - */ - bDum=gmx_fio_ndo_real(fio,iparams->rbdihs.rbcA, NR_RBDIHS); - bDum=gmx_fio_ndo_real(fio,iparams->rbdihs.rbcB, NR_RBDIHS); - break; - case F_CONSTR: - case F_CONSTRNC: - gmx_fio_do_real(fio,iparams->constr.dA); - gmx_fio_do_real(fio,iparams->constr.dB); - break; - case F_SETTLE: - gmx_fio_do_real(fio,iparams->settle.doh); - gmx_fio_do_real(fio,iparams->settle.dhh); - break; - case F_VSITE2: - gmx_fio_do_real(fio,iparams->vsite.a); - break; - case F_VSITE3: - case F_VSITE3FD: - case F_VSITE3FAD: - gmx_fio_do_real(fio,iparams->vsite.a); - gmx_fio_do_real(fio,iparams->vsite.b); - break; - case F_VSITE3OUT: - case F_VSITE4FD: - case F_VSITE4FDN: - gmx_fio_do_real(fio,iparams->vsite.a); - gmx_fio_do_real(fio,iparams->vsite.b); - gmx_fio_do_real(fio,iparams->vsite.c); - break; - case F_VSITEN: - gmx_fio_do_int(fio,iparams->vsiten.n); - gmx_fio_do_real(fio,iparams->vsiten.a); - break; - case F_GB12: - case F_GB13: - case F_GB14: - /* We got rid of some parameters in version 68 */ - if(bRead && file_version<68) - { - gmx_fio_do_real(fio,rdum); - gmx_fio_do_real(fio,rdum); - gmx_fio_do_real(fio,rdum); - gmx_fio_do_real(fio,rdum); - } - gmx_fio_do_real(fio,iparams->gb.sar); - gmx_fio_do_real(fio,iparams->gb.st); - gmx_fio_do_real(fio,iparams->gb.pi); - gmx_fio_do_real(fio,iparams->gb.gbr); - gmx_fio_do_real(fio,iparams->gb.bmlt); - break; - case F_CMAP: - gmx_fio_do_int(fio,iparams->cmap.cmapA); - gmx_fio_do_int(fio,iparams->cmap.cmapB); - break; - default: - gmx_fatal(FARGS,"unknown function type %d (%s) in %s line %d", - ftype,interaction_function[ftype].name,__FILE__,__LINE__); - } - if (!bRead) - gmx_fio_unset_comment(fio); + gmx_fio_do_int(fio, rotg->eType); + gmx_fio_do_int(fio, rotg->bMassW); + gmx_fio_do_int(fio, rotg->nat); + if (bRead) + { + snew(rotg->ind, rotg->nat); + } + gmx_fio_ndo_int(fio, rotg->ind, rotg->nat); + if (bRead) + { + snew(rotg->x_ref, rotg->nat); + } + gmx_fio_ndo_rvec(fio, rotg->x_ref, rotg->nat); + gmx_fio_do_rvec(fio, rotg->vec); + gmx_fio_do_rvec(fio, rotg->pivot); + gmx_fio_do_real(fio, rotg->rate); + gmx_fio_do_real(fio, rotg->k); + gmx_fio_do_real(fio, rotg->slab_dist); + gmx_fio_do_real(fio, rotg->min_gaussian); + gmx_fio_do_real(fio, rotg->eps); + gmx_fio_do_int(fio, rotg->eFittype); + gmx_fio_do_int(fio, rotg->PotAngle_nstep); + gmx_fio_do_real(fio, rotg->PotAngle_step); } -static void do_ilist(t_fileio *fio, t_ilist *ilist,gmx_bool bRead,int file_version, - int ftype) +static void do_rot(t_fileio *fio, t_rot *rot, gmx_bool bRead, int file_version) { - int i,k,idum; - gmx_bool bDum=TRUE; - - if (!bRead) { - gmx_fio_set_comment(fio, interaction_function[ftype].name); - } - if (file_version < 44) { - for(i=0; inr); - if (bRead) - snew(ilist->iatoms,ilist->nr); - bDum=gmx_fio_ndo_int(fio,ilist->iatoms,ilist->nr); - if (!bRead) - gmx_fio_unset_comment(fio); -} + int g; -static void do_ffparams(t_fileio *fio, gmx_ffparams_t *ffparams, - gmx_bool bRead, int file_version) -{ - int idum,i,j; - gmx_bool bDum=TRUE; - unsigned int k; - - gmx_fio_do_int(fio,ffparams->atnr); - if (file_version < 57) { - gmx_fio_do_int(fio,idum); - } - gmx_fio_do_int(fio,ffparams->ntypes); - if (bRead && debug) - fprintf(debug,"ffparams->atnr = %d, ntypes = %d\n", - ffparams->atnr,ffparams->ntypes); - if (bRead) { - snew(ffparams->functype,ffparams->ntypes); - snew(ffparams->iparams,ffparams->ntypes); - } - /* Read/write all the function types */ - bDum=gmx_fio_ndo_int(fio,ffparams->functype,ffparams->ntypes); - if (bRead && debug) - pr_ivec(debug,0,"functype",ffparams->functype,ffparams->ntypes,TRUE); - - if (file_version >= 66) { - gmx_fio_do_double(fio,ffparams->reppow); - } else { - ffparams->reppow = 12.0; - } - - if (file_version >= 57) { - gmx_fio_do_real(fio,ffparams->fudgeQQ); - } - - /* Check whether all these function types are supported by the code. - * In practice the code is backwards compatible, which means that the - * numbering may have to be altered from old numbering to new numbering - */ - for (i=0; (intypes); i++) { + gmx_fio_do_int(fio, rot->ngrp); + gmx_fio_do_int(fio, rot->nstrout); + gmx_fio_do_int(fio, rot->nstsout); if (bRead) - /* Loop over file versions */ - for (k=0; (kfunctype[i] >= ftupd[k].ftype)) { - ffparams->functype[i] += 1; - if (debug) { - fprintf(debug,"Incrementing function type %d to %d (due to %s)\n", - i,ffparams->functype[i], - interaction_function[ftupd[k].ftype].longname); - fflush(debug); - } - } - - do_iparams(fio, ffparams->functype[i],&ffparams->iparams[i],bRead, - file_version); - if (bRead && debug) - pr_iparams(debug,ffparams->functype[i],&ffparams->iparams[i]); - } + { + snew(rot->grp, rot->ngrp); + } + for (g = 0; g < rot->ngrp; g++) + { + do_rotgrp(fio, &rot->grp[g], bRead, file_version); + } } -static void add_settle_atoms(t_ilist *ilist) + +static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead, + int file_version, real *fudgeQQ) { - int i; + int i, j, k, *tmp, idum = 0; + gmx_bool bDum = TRUE; + real rdum, bd_temp; + rvec vdum; + gmx_bool bSimAnn; + real zerotemptime, finish_t, init_temp, finish_temp; - /* Settle used to only store the first atom: add the other two */ - srenew(ilist->iatoms,2*ilist->nr); - for(i=ilist->nr/2-1; i>=0; i--) + if (file_version != tpx_version) { - ilist->iatoms[4*i+0] = ilist->iatoms[2*i+0]; - ilist->iatoms[4*i+1] = ilist->iatoms[2*i+1]; - ilist->iatoms[4*i+2] = ilist->iatoms[2*i+1] + 1; - ilist->iatoms[4*i+3] = ilist->iatoms[2*i+1] + 2; + /* Give a warning about features that are not accessible */ + fprintf(stderr, "Note: file tpx version %d, software tpx version %d\n", + file_version, tpx_version); } - ilist->nr = 2*ilist->nr; -} -static void do_ilists(t_fileio *fio, t_ilist *ilist,gmx_bool bRead, - int file_version) + if (bRead) + { + init_inputrec(ir); + } + + if (file_version == 0) + { + return; + } + + /* Basic inputrec stuff */ + gmx_fio_do_int(fio, ir->eI); + if (file_version >= 62) + { + gmx_fio_do_gmx_large_int(fio, ir->nsteps); + } + else + { + gmx_fio_do_int(fio, idum); + ir->nsteps = idum; + } + if (file_version > 25) + { + if (file_version >= 62) + { + gmx_fio_do_gmx_large_int(fio, ir->init_step); + } + else + { + gmx_fio_do_int(fio, idum); + ir->init_step = idum; + } + } + else + { + ir->init_step = 0; + } + + if (file_version >= 58) + { + gmx_fio_do_int(fio, ir->simulation_part); + } + else + { + ir->simulation_part = 1; + } + + if (file_version >= 67) + { + gmx_fio_do_int(fio, ir->nstcalcenergy); + } + else + { + ir->nstcalcenergy = 1; + } + if (file_version < 53) + { + /* The pbc info has been moved out of do_inputrec, + * since we always want it, also without reading the inputrec. + */ + gmx_fio_do_int(fio, ir->ePBC); + if ((file_version <= 15) && (ir->ePBC == 2)) + { + ir->ePBC = epbcNONE; + } + if (file_version >= 45) + { + gmx_fio_do_int(fio, ir->bPeriodicMols); + } + else + { + if (ir->ePBC == 2) + { + ir->ePBC = epbcXYZ; + ir->bPeriodicMols = TRUE; + } + else + { + ir->bPeriodicMols = FALSE; + } + } + } + if (file_version >= 81) + { + gmx_fio_do_int(fio, ir->cutoff_scheme); + } + else + { + ir->cutoff_scheme = ecutsGROUP; + } + gmx_fio_do_int(fio, ir->ns_type); + gmx_fio_do_int(fio, ir->nstlist); + gmx_fio_do_int(fio, ir->ndelta); + if (file_version < 41) + { + gmx_fio_do_int(fio, idum); + gmx_fio_do_int(fio, idum); + } + if (file_version >= 45) + { + gmx_fio_do_real(fio, ir->rtpi); + } + else + { + ir->rtpi = 0.05; + } + gmx_fio_do_int(fio, ir->nstcomm); + if (file_version > 34) + { + gmx_fio_do_int(fio, ir->comm_mode); + } + else if (ir->nstcomm < 0) + { + ir->comm_mode = ecmANGULAR; + } + else + { + ir->comm_mode = ecmLINEAR; + } + ir->nstcomm = abs(ir->nstcomm); + + if (file_version > 25) + { + gmx_fio_do_int(fio, ir->nstcheckpoint); + } + else + { + ir->nstcheckpoint = 0; + } + + gmx_fio_do_int(fio, ir->nstcgsteep); + + if (file_version >= 30) + { + gmx_fio_do_int(fio, ir->nbfgscorr); + } + else if (bRead) + { + ir->nbfgscorr = 10; + } + + gmx_fio_do_int(fio, ir->nstlog); + gmx_fio_do_int(fio, ir->nstxout); + gmx_fio_do_int(fio, ir->nstvout); + gmx_fio_do_int(fio, ir->nstfout); + gmx_fio_do_int(fio, ir->nstenergy); + gmx_fio_do_int(fio, ir->nstxtcout); + if (file_version >= 59) + { + gmx_fio_do_double(fio, ir->init_t); + gmx_fio_do_double(fio, ir->delta_t); + } + else + { + gmx_fio_do_real(fio, rdum); + ir->init_t = rdum; + gmx_fio_do_real(fio, rdum); + ir->delta_t = rdum; + } + gmx_fio_do_real(fio, ir->xtcprec); + if (file_version < 19) + { + gmx_fio_do_int(fio, idum); + gmx_fio_do_int(fio, idum); + } + if (file_version < 18) + { + gmx_fio_do_int(fio, idum); + } + if (file_version >= 81) + { + gmx_fio_do_real(fio, ir->verletbuf_drift); + } + else + { + ir->verletbuf_drift = 0; + } + gmx_fio_do_real(fio, ir->rlist); + if (file_version >= 67) + { + gmx_fio_do_real(fio, ir->rlistlong); + } + if (file_version >= 82 && file_version != 90) + { + gmx_fio_do_int(fio, ir->nstcalclr); + } + else + { + /* Calculate at NS steps */ + ir->nstcalclr = ir->nstlist; + } + gmx_fio_do_int(fio, ir->coulombtype); + if (file_version < 32 && ir->coulombtype == eelRF) + { + ir->coulombtype = eelRF_NEC; + } + if (file_version >= 81) + { + gmx_fio_do_int(fio, ir->coulomb_modifier); + } + else + { + ir->coulomb_modifier = (ir->cutoff_scheme == ecutsVERLET ? eintmodPOTSHIFT : eintmodNONE); + } + gmx_fio_do_real(fio, ir->rcoulomb_switch); + gmx_fio_do_real(fio, ir->rcoulomb); + gmx_fio_do_int(fio, ir->vdwtype); + if (file_version >= 81) + { + gmx_fio_do_int(fio, ir->vdw_modifier); + } + else + { + ir->vdw_modifier = (ir->cutoff_scheme == ecutsVERLET ? eintmodPOTSHIFT : eintmodNONE); + } + gmx_fio_do_real(fio, ir->rvdw_switch); + gmx_fio_do_real(fio, ir->rvdw); + if (file_version < 67) + { + ir->rlistlong = max_cutoff(ir->rlist, max_cutoff(ir->rvdw, ir->rcoulomb)); + } + gmx_fio_do_int(fio, ir->eDispCorr); + gmx_fio_do_real(fio, ir->epsilon_r); + if (file_version >= 37) + { + gmx_fio_do_real(fio, ir->epsilon_rf); + } + else + { + if (EEL_RF(ir->coulombtype)) + { + ir->epsilon_rf = ir->epsilon_r; + ir->epsilon_r = 1.0; + } + else + { + ir->epsilon_rf = 1.0; + } + } + if (file_version >= 29) + { + gmx_fio_do_real(fio, ir->tabext); + } + else + { + ir->tabext = 1.0; + } + + if (file_version > 25) + { + gmx_fio_do_int(fio, ir->gb_algorithm); + gmx_fio_do_int(fio, ir->nstgbradii); + gmx_fio_do_real(fio, ir->rgbradii); + gmx_fio_do_real(fio, ir->gb_saltconc); + gmx_fio_do_int(fio, ir->implicit_solvent); + } + else + { + ir->gb_algorithm = egbSTILL; + ir->nstgbradii = 1; + ir->rgbradii = 1.0; + ir->gb_saltconc = 0; + ir->implicit_solvent = eisNO; + } + if (file_version >= 55) + { + gmx_fio_do_real(fio, ir->gb_epsilon_solvent); + gmx_fio_do_real(fio, ir->gb_obc_alpha); + gmx_fio_do_real(fio, ir->gb_obc_beta); + gmx_fio_do_real(fio, ir->gb_obc_gamma); + if (file_version >= 60) + { + gmx_fio_do_real(fio, ir->gb_dielectric_offset); + gmx_fio_do_int(fio, ir->sa_algorithm); + } + else + { + ir->gb_dielectric_offset = 0.009; + 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 + { + /* Better use sensible values than insane (0.0) ones... */ + ir->gb_epsilon_solvent = 80; + ir->gb_obc_alpha = 1.0; + ir->gb_obc_beta = 0.8; + ir->gb_obc_gamma = 4.85; + ir->sa_surface_tension = 2.092; + } + + + if (file_version >= 81) + { + gmx_fio_do_real(fio, ir->fourier_spacing); + } + else + { + ir->fourier_spacing = 0.0; + } + gmx_fio_do_int(fio, ir->nkx); + gmx_fio_do_int(fio, ir->nky); + gmx_fio_do_int(fio, ir->nkz); + gmx_fio_do_int(fio, ir->pme_order); + gmx_fio_do_real(fio, ir->ewald_rtol); + + if (file_version >= 24) + { + gmx_fio_do_int(fio, ir->ewald_geometry); + } + else + { + ir->ewald_geometry = eewg3D; + } + + if (file_version <= 17) + { + ir->epsilon_surface = 0; + if (file_version == 17) + { + gmx_fio_do_int(fio, idum); + } + } + else + { + gmx_fio_do_real(fio, ir->epsilon_surface); + } + + gmx_fio_do_gmx_bool(fio, ir->bOptFFT); + + gmx_fio_do_gmx_bool(fio, ir->bContinuation); + gmx_fio_do_int(fio, ir->etc); + /* before version 18, ir->etc was a gmx_bool (ir->btc), + * but the values 0 and 1 still mean no and + * berendsen temperature coupling, respectively. + */ + if (file_version >= 79) + { + gmx_fio_do_gmx_bool(fio, ir->bPrintNHChains); + } + if (file_version >= 71) + { + gmx_fio_do_int(fio, ir->nsttcouple); + } + else + { + ir->nsttcouple = ir->nstcalcenergy; + } + if (file_version <= 15) + { + gmx_fio_do_int(fio, idum); + } + if (file_version <= 17) + { + gmx_fio_do_int(fio, ir->epct); + if (file_version <= 15) + { + if (ir->epct == 5) + { + ir->epct = epctSURFACETENSION; + } + gmx_fio_do_int(fio, idum); + } + ir->epct -= 1; + /* we have removed the NO alternative at the beginning */ + if (ir->epct == -1) + { + ir->epc = epcNO; + ir->epct = epctISOTROPIC; + } + else + { + ir->epc = epcBERENDSEN; + } + } + else + { + gmx_fio_do_int(fio, ir->epc); + gmx_fio_do_int(fio, ir->epct); + } + if (file_version >= 71) + { + gmx_fio_do_int(fio, ir->nstpcouple); + } + else + { + ir->nstpcouple = ir->nstcalcenergy; + } + gmx_fio_do_real(fio, ir->tau_p); + if (file_version <= 15) + { + gmx_fio_do_rvec(fio, vdum); + clear_mat(ir->ref_p); + for (i = 0; i < DIM; i++) + { + ir->ref_p[i][i] = vdum[i]; + } + } + else + { + gmx_fio_do_rvec(fio, ir->ref_p[XX]); + gmx_fio_do_rvec(fio, ir->ref_p[YY]); + gmx_fio_do_rvec(fio, ir->ref_p[ZZ]); + } + if (file_version <= 15) + { + gmx_fio_do_rvec(fio, vdum); + clear_mat(ir->compress); + for (i = 0; i < DIM; i++) + { + ir->compress[i][i] = vdum[i]; + } + } + else + { + gmx_fio_do_rvec(fio, ir->compress[XX]); + gmx_fio_do_rvec(fio, ir->compress[YY]); + gmx_fio_do_rvec(fio, ir->compress[ZZ]); + } + if (file_version >= 47) + { + gmx_fio_do_int(fio, ir->refcoord_scaling); + gmx_fio_do_rvec(fio, ir->posres_com); + gmx_fio_do_rvec(fio, ir->posres_comB); + } + else + { + ir->refcoord_scaling = erscNO; + clear_rvec(ir->posres_com); + clear_rvec(ir->posres_comB); + } + if ((file_version > 25) && (file_version < 79)) + { + gmx_fio_do_int(fio, ir->andersen_seed); + } + else + { + ir->andersen_seed = 0; + } + if (file_version < 26) + { + gmx_fio_do_gmx_bool(fio, bSimAnn); + gmx_fio_do_real(fio, zerotemptime); + } + + if (file_version < 37) + { + gmx_fio_do_real(fio, rdum); + } + + gmx_fio_do_real(fio, ir->shake_tol); + if (file_version < 54) + { + gmx_fio_do_real(fio, *fudgeQQ); + } + + gmx_fio_do_int(fio, ir->efep); + if (file_version <= 14 && ir->efep != efepNO) + { + ir->efep = efepYES; + } + do_fepvals(fio, ir->fepvals, bRead, file_version); + + if (file_version >= 79) + { + gmx_fio_do_gmx_bool(fio, ir->bSimTemp); + if (ir->bSimTemp) + { + ir->bSimTemp = TRUE; + } + } + else + { + ir->bSimTemp = FALSE; + } + if (ir->bSimTemp) + { + do_simtempvals(fio, ir->simtempvals, ir->fepvals->n_lambda, bRead, file_version); + } + + if (file_version >= 79) + { + gmx_fio_do_gmx_bool(fio, ir->bExpanded); + if (ir->bExpanded) + { + ir->bExpanded = TRUE; + } + else + { + ir->bExpanded = FALSE; + } + } + if (ir->bExpanded) + { + do_expandedvals(fio, ir->expandedvals, ir->fepvals, bRead, file_version); + } + if (file_version >= 57) + { + gmx_fio_do_int(fio, ir->eDisre); + } + gmx_fio_do_int(fio, ir->eDisreWeighting); + if (file_version < 22) + { + if (ir->eDisreWeighting == 0) + { + ir->eDisreWeighting = edrwEqual; + } + else + { + ir->eDisreWeighting = edrwConservative; + } + } + gmx_fio_do_gmx_bool(fio, ir->bDisreMixed); + gmx_fio_do_real(fio, ir->dr_fc); + gmx_fio_do_real(fio, ir->dr_tau); + gmx_fio_do_int(fio, ir->nstdisreout); + if (file_version >= 22) + { + gmx_fio_do_real(fio, ir->orires_fc); + gmx_fio_do_real(fio, ir->orires_tau); + gmx_fio_do_int(fio, ir->nstorireout); + } + else + { + ir->orires_fc = 0; + ir->orires_tau = 0; + ir->nstorireout = 0; + } + if (file_version >= 26 && file_version < 79) + { + gmx_fio_do_real(fio, ir->dihre_fc); + if (file_version < 56) + { + gmx_fio_do_real(fio, rdum); + gmx_fio_do_int(fio, idum); + } + } + else + { + ir->dihre_fc = 0; + } + + gmx_fio_do_real(fio, ir->em_stepsize); + gmx_fio_do_real(fio, ir->em_tol); + if (file_version >= 22) + { + gmx_fio_do_gmx_bool(fio, ir->bShakeSOR); + } + else if (bRead) + { + ir->bShakeSOR = TRUE; + } + if (file_version >= 11) + { + gmx_fio_do_int(fio, ir->niter); + } + else if (bRead) + { + ir->niter = 25; + fprintf(stderr, "Note: niter not in run input file, setting it to %d\n", + ir->niter); + } + if (file_version >= 21) + { + gmx_fio_do_real(fio, ir->fc_stepsize); + } + else + { + ir->fc_stepsize = 0; + } + gmx_fio_do_int(fio, ir->eConstrAlg); + gmx_fio_do_int(fio, ir->nProjOrder); + gmx_fio_do_real(fio, ir->LincsWarnAngle); + if (file_version <= 14) + { + gmx_fio_do_int(fio, idum); + } + if (file_version >= 26) + { + gmx_fio_do_int(fio, ir->nLincsIter); + } + else if (bRead) + { + ir->nLincsIter = 1; + fprintf(stderr, "Note: nLincsIter not in run input file, setting it to %d\n", + ir->nLincsIter); + } + if (file_version < 33) + { + gmx_fio_do_real(fio, bd_temp); + } + gmx_fio_do_real(fio, ir->bd_fric); + gmx_fio_do_int(fio, ir->ld_seed); + if (file_version >= 33) + { + for (i = 0; i < DIM; i++) + { + gmx_fio_do_rvec(fio, ir->deform[i]); + } + } + else + { + for (i = 0; i < DIM; i++) + { + clear_rvec(ir->deform[i]); + } + } + if (file_version >= 14) + { + gmx_fio_do_real(fio, ir->cos_accel); + } + else if (bRead) + { + ir->cos_accel = 0; + } + gmx_fio_do_int(fio, ir->userint1); + gmx_fio_do_int(fio, ir->userint2); + gmx_fio_do_int(fio, ir->userint3); + gmx_fio_do_int(fio, ir->userint4); + gmx_fio_do_real(fio, ir->userreal1); + gmx_fio_do_real(fio, ir->userreal2); + gmx_fio_do_real(fio, ir->userreal3); + gmx_fio_do_real(fio, ir->userreal4); + + /* AdResS stuff */ + if (file_version >= 77) + { + gmx_fio_do_gmx_bool(fio, ir->bAdress); + if (ir->bAdress) + { + if (bRead) + { + snew(ir->adress, 1); + } + gmx_fio_do_int(fio, ir->adress->type); + gmx_fio_do_real(fio, ir->adress->const_wf); + gmx_fio_do_real(fio, ir->adress->ex_width); + gmx_fio_do_real(fio, ir->adress->hy_width); + gmx_fio_do_int(fio, ir->adress->icor); + gmx_fio_do_int(fio, ir->adress->site); + gmx_fio_do_rvec(fio, ir->adress->refs); + gmx_fio_do_int(fio, ir->adress->n_tf_grps); + gmx_fio_do_real(fio, ir->adress->ex_forcecap); + gmx_fio_do_int(fio, ir->adress->n_energy_grps); + gmx_fio_do_int(fio, ir->adress->do_hybridpairs); + + if (bRead) + { + snew(ir->adress->tf_table_index, ir->adress->n_tf_grps); + } + if (ir->adress->n_tf_grps > 0) + { + bDum = gmx_fio_ndo_int(fio, ir->adress->tf_table_index, ir->adress->n_tf_grps); + } + if (bRead) + { + snew(ir->adress->group_explicit, ir->adress->n_energy_grps); + } + if (ir->adress->n_energy_grps > 0) + { + bDum = gmx_fio_ndo_int(fio, ir->adress->group_explicit, ir->adress->n_energy_grps); + } + } + } + else + { + ir->bAdress = FALSE; + } + + /* pull stuff */ + if (file_version >= 48) + { + gmx_fio_do_int(fio, ir->ePull); + if (ir->ePull != epullNO) + { + if (bRead) + { + snew(ir->pull, 1); + } + do_pull(fio, ir->pull, bRead, file_version); + } + } + else + { + ir->ePull = epullNO; + } + + /* Enforced rotation */ + if (file_version >= 74) + { + gmx_fio_do_int(fio, ir->bRot); + if (ir->bRot == TRUE) + { + if (bRead) + { + snew(ir->rot, 1); + } + do_rot(fio, ir->rot, bRead, file_version); + } + } + else + { + ir->bRot = FALSE; + } + + /* grpopts stuff */ + gmx_fio_do_int(fio, ir->opts.ngtc); + if (file_version >= 69) + { + gmx_fio_do_int(fio, ir->opts.nhchainlength); + } + else + { + ir->opts.nhchainlength = 1; + } + gmx_fio_do_int(fio, ir->opts.ngacc); + gmx_fio_do_int(fio, ir->opts.ngfrz); + gmx_fio_do_int(fio, ir->opts.ngener); + + if (bRead) + { + snew(ir->opts.nrdf, ir->opts.ngtc); + snew(ir->opts.ref_t, ir->opts.ngtc); + snew(ir->opts.annealing, ir->opts.ngtc); + snew(ir->opts.anneal_npoints, ir->opts.ngtc); + snew(ir->opts.anneal_time, ir->opts.ngtc); + snew(ir->opts.anneal_temp, ir->opts.ngtc); + snew(ir->opts.tau_t, ir->opts.ngtc); + snew(ir->opts.nFreeze, ir->opts.ngfrz); + snew(ir->opts.acc, ir->opts.ngacc); + snew(ir->opts.egp_flags, ir->opts.ngener*ir->opts.ngener); + } + if (ir->opts.ngtc > 0) + { + if (bRead && file_version < 13) + { + snew(tmp, ir->opts.ngtc); + bDum = gmx_fio_ndo_int(fio, tmp, ir->opts.ngtc); + for (i = 0; i < ir->opts.ngtc; i++) + { + ir->opts.nrdf[i] = tmp[i]; + } + sfree(tmp); + } + else + { + bDum = gmx_fio_ndo_real(fio, ir->opts.nrdf, ir->opts.ngtc); + } + bDum = gmx_fio_ndo_real(fio, ir->opts.ref_t, ir->opts.ngtc); + bDum = gmx_fio_ndo_real(fio, ir->opts.tau_t, ir->opts.ngtc); + if (file_version < 33 && ir->eI == eiBD) + { + for (i = 0; i < ir->opts.ngtc; i++) + { + ir->opts.tau_t[i] = bd_temp; + } + } + } + if (ir->opts.ngfrz > 0) + { + bDum = gmx_fio_ndo_ivec(fio, ir->opts.nFreeze, ir->opts.ngfrz); + } + if (ir->opts.ngacc > 0) + { + gmx_fio_ndo_rvec(fio, ir->opts.acc, ir->opts.ngacc); + } + if (file_version >= 12) + { + bDum = gmx_fio_ndo_int(fio, ir->opts.egp_flags, + ir->opts.ngener*ir->opts.ngener); + } + + if (bRead && file_version < 26) + { + for (i = 0; i < ir->opts.ngtc; i++) + { + if (bSimAnn) + { + ir->opts.annealing[i] = eannSINGLE; + ir->opts.anneal_npoints[i] = 2; + snew(ir->opts.anneal_time[i], 2); + snew(ir->opts.anneal_temp[i], 2); + /* calculate the starting/ending temperatures from reft, zerotemptime, and nsteps */ + finish_t = ir->init_t + ir->nsteps * ir->delta_t; + init_temp = ir->opts.ref_t[i]*(1-ir->init_t/zerotemptime); + finish_temp = ir->opts.ref_t[i]*(1-finish_t/zerotemptime); + ir->opts.anneal_time[i][0] = ir->init_t; + ir->opts.anneal_time[i][1] = finish_t; + ir->opts.anneal_temp[i][0] = init_temp; + ir->opts.anneal_temp[i][1] = finish_temp; + } + else + { + ir->opts.annealing[i] = eannNO; + ir->opts.anneal_npoints[i] = 0; + } + } + } + else + { + /* file version 26 or later */ + /* First read the lists with annealing and npoints for each group */ + bDum = gmx_fio_ndo_int(fio, ir->opts.annealing, ir->opts.ngtc); + bDum = gmx_fio_ndo_int(fio, ir->opts.anneal_npoints, ir->opts.ngtc); + for (j = 0; j < (ir->opts.ngtc); j++) + { + k = ir->opts.anneal_npoints[j]; + if (bRead) + { + snew(ir->opts.anneal_time[j], k); + snew(ir->opts.anneal_temp[j], k); + } + bDum = gmx_fio_ndo_real(fio, ir->opts.anneal_time[j], k); + bDum = gmx_fio_ndo_real(fio, ir->opts.anneal_temp[j], k); + } + } + /* Walls */ + if (file_version >= 45) + { + gmx_fio_do_int(fio, ir->nwall); + gmx_fio_do_int(fio, ir->wall_type); + if (file_version >= 50) + { + gmx_fio_do_real(fio, ir->wall_r_linpot); + } + else + { + ir->wall_r_linpot = -1; + } + gmx_fio_do_int(fio, ir->wall_atomtype[0]); + gmx_fio_do_int(fio, ir->wall_atomtype[1]); + gmx_fio_do_real(fio, ir->wall_density[0]); + gmx_fio_do_real(fio, ir->wall_density[1]); + gmx_fio_do_real(fio, ir->wall_ewald_zfac); + } + else + { + ir->nwall = 0; + ir->wall_type = 0; + ir->wall_atomtype[0] = -1; + ir->wall_atomtype[1] = -1; + ir->wall_density[0] = 0; + ir->wall_density[1] = 0; + ir->wall_ewald_zfac = 3; + } + /* Cosine stuff for electric fields */ + for (j = 0; (j < DIM); j++) + { + gmx_fio_do_int(fio, ir->ex[j].n); + gmx_fio_do_int(fio, ir->et[j].n); + if (bRead) + { + snew(ir->ex[j].a, ir->ex[j].n); + snew(ir->ex[j].phi, ir->ex[j].n); + snew(ir->et[j].a, ir->et[j].n); + snew(ir->et[j].phi, ir->et[j].n); + } + bDum = gmx_fio_ndo_real(fio, ir->ex[j].a, ir->ex[j].n); + bDum = gmx_fio_ndo_real(fio, ir->ex[j].phi, ir->ex[j].n); + bDum = gmx_fio_ndo_real(fio, ir->et[j].a, ir->et[j].n); + bDum = gmx_fio_ndo_real(fio, ir->et[j].phi, ir->et[j].n); + } + + /* QMMM stuff */ + if (file_version >= 39) + { + gmx_fio_do_gmx_bool(fio, ir->bQMMM); + gmx_fio_do_int(fio, ir->QMMMscheme); + gmx_fio_do_real(fio, ir->scalefactor); + gmx_fio_do_int(fio, ir->opts.ngQM); + if (bRead) + { + snew(ir->opts.QMmethod, ir->opts.ngQM); + snew(ir->opts.QMbasis, ir->opts.ngQM); + snew(ir->opts.QMcharge, ir->opts.ngQM); + snew(ir->opts.QMmult, ir->opts.ngQM); + snew(ir->opts.bSH, ir->opts.ngQM); + snew(ir->opts.CASorbitals, ir->opts.ngQM); + snew(ir->opts.CASelectrons, ir->opts.ngQM); + snew(ir->opts.SAon, ir->opts.ngQM); + snew(ir->opts.SAoff, ir->opts.ngQM); + snew(ir->opts.SAsteps, ir->opts.ngQM); + snew(ir->opts.bOPT, ir->opts.ngQM); + snew(ir->opts.bTS, ir->opts.ngQM); + } + if (ir->opts.ngQM > 0) + { + bDum = gmx_fio_ndo_int(fio, ir->opts.QMmethod, ir->opts.ngQM); + bDum = gmx_fio_ndo_int(fio, ir->opts.QMbasis, ir->opts.ngQM); + bDum = gmx_fio_ndo_int(fio, ir->opts.QMcharge, ir->opts.ngQM); + bDum = gmx_fio_ndo_int(fio, ir->opts.QMmult, ir->opts.ngQM); + bDum = gmx_fio_ndo_gmx_bool(fio, ir->opts.bSH, ir->opts.ngQM); + bDum = gmx_fio_ndo_int(fio, ir->opts.CASorbitals, ir->opts.ngQM); + bDum = gmx_fio_ndo_int(fio, ir->opts.CASelectrons, ir->opts.ngQM); + bDum = gmx_fio_ndo_real(fio, ir->opts.SAon, ir->opts.ngQM); + bDum = gmx_fio_ndo_real(fio, ir->opts.SAoff, ir->opts.ngQM); + bDum = gmx_fio_ndo_int(fio, ir->opts.SAsteps, ir->opts.ngQM); + bDum = gmx_fio_ndo_gmx_bool(fio, ir->opts.bOPT, ir->opts.ngQM); + bDum = gmx_fio_ndo_gmx_bool(fio, ir->opts.bTS, ir->opts.ngQM); + } + /* end of QMMM stuff */ + } +} + + +static void do_harm(t_fileio *fio, t_iparams *iparams, gmx_bool bRead) +{ + gmx_fio_do_real(fio, iparams->harmonic.rA); + gmx_fio_do_real(fio, iparams->harmonic.krA); + gmx_fio_do_real(fio, iparams->harmonic.rB); + gmx_fio_do_real(fio, iparams->harmonic.krB); +} + +void do_iparams(t_fileio *fio, t_functype ftype, t_iparams *iparams, + gmx_bool bRead, int file_version) +{ + int idum; + gmx_bool bDum; + real rdum; + + if (!bRead) + { + gmx_fio_set_comment(fio, interaction_function[ftype].name); + } + switch (ftype) + { + case F_ANGLES: + case F_G96ANGLES: + case F_BONDS: + case F_G96BONDS: + case F_HARMONIC: + case F_IDIHS: + do_harm(fio, iparams, bRead); + if ((ftype == F_ANGRES || ftype == F_ANGRESZ) && bRead) + { + /* Correct incorrect storage of parameters */ + iparams->pdihs.phiB = iparams->pdihs.phiA; + iparams->pdihs.cpB = iparams->pdihs.cpA; + } + break; + case F_LINEAR_ANGLES: + gmx_fio_do_real(fio, iparams->linangle.klinA); + gmx_fio_do_real(fio, iparams->linangle.aA); + gmx_fio_do_real(fio, iparams->linangle.klinB); + gmx_fio_do_real(fio, iparams->linangle.aB); + break; + case F_FENEBONDS: + gmx_fio_do_real(fio, iparams->fene.bm); + gmx_fio_do_real(fio, iparams->fene.kb); + break; + case F_RESTRBONDS: + gmx_fio_do_real(fio, iparams->restraint.lowA); + gmx_fio_do_real(fio, iparams->restraint.up1A); + gmx_fio_do_real(fio, iparams->restraint.up2A); + gmx_fio_do_real(fio, iparams->restraint.kA); + gmx_fio_do_real(fio, iparams->restraint.lowB); + gmx_fio_do_real(fio, iparams->restraint.up1B); + gmx_fio_do_real(fio, iparams->restraint.up2B); + gmx_fio_do_real(fio, iparams->restraint.kB); + break; + case F_TABBONDS: + case F_TABBONDSNC: + case F_TABANGLES: + case F_TABDIHS: + gmx_fio_do_real(fio, iparams->tab.kA); + gmx_fio_do_int(fio, iparams->tab.table); + gmx_fio_do_real(fio, iparams->tab.kB); + break; + case F_CROSS_BOND_BONDS: + gmx_fio_do_real(fio, iparams->cross_bb.r1e); + gmx_fio_do_real(fio, iparams->cross_bb.r2e); + gmx_fio_do_real(fio, iparams->cross_bb.krr); + break; + case F_CROSS_BOND_ANGLES: + gmx_fio_do_real(fio, iparams->cross_ba.r1e); + gmx_fio_do_real(fio, iparams->cross_ba.r2e); + gmx_fio_do_real(fio, iparams->cross_ba.r3e); + gmx_fio_do_real(fio, iparams->cross_ba.krt); + break; + case F_UREY_BRADLEY: + gmx_fio_do_real(fio, iparams->u_b.thetaA); + gmx_fio_do_real(fio, iparams->u_b.kthetaA); + gmx_fio_do_real(fio, iparams->u_b.r13A); + gmx_fio_do_real(fio, iparams->u_b.kUBA); + if (file_version >= 79) + { + gmx_fio_do_real(fio, iparams->u_b.thetaB); + gmx_fio_do_real(fio, iparams->u_b.kthetaB); + gmx_fio_do_real(fio, iparams->u_b.r13B); + gmx_fio_do_real(fio, iparams->u_b.kUBB); + } + else + { + iparams->u_b.thetaB = iparams->u_b.thetaA; + iparams->u_b.kthetaB = iparams->u_b.kthetaA; + iparams->u_b.r13B = iparams->u_b.r13A; + iparams->u_b.kUBB = iparams->u_b.kUBA; + } + break; + case F_QUARTIC_ANGLES: + gmx_fio_do_real(fio, iparams->qangle.theta); + bDum = gmx_fio_ndo_real(fio, iparams->qangle.c, 5); + break; + case F_BHAM: + gmx_fio_do_real(fio, iparams->bham.a); + gmx_fio_do_real(fio, iparams->bham.b); + gmx_fio_do_real(fio, iparams->bham.c); + break; + case F_MORSE: + gmx_fio_do_real(fio, iparams->morse.b0A); + gmx_fio_do_real(fio, iparams->morse.cbA); + gmx_fio_do_real(fio, iparams->morse.betaA); + if (file_version >= 79) + { + gmx_fio_do_real(fio, iparams->morse.b0B); + gmx_fio_do_real(fio, iparams->morse.cbB); + gmx_fio_do_real(fio, iparams->morse.betaB); + } + else + { + iparams->morse.b0B = iparams->morse.b0A; + iparams->morse.cbB = iparams->morse.cbA; + iparams->morse.betaB = iparams->morse.betaA; + } + break; + case F_CUBICBONDS: + gmx_fio_do_real(fio, iparams->cubic.b0); + gmx_fio_do_real(fio, iparams->cubic.kb); + gmx_fio_do_real(fio, iparams->cubic.kcub); + break; + case F_CONNBONDS: + break; + case F_POLARIZATION: + gmx_fio_do_real(fio, iparams->polarize.alpha); + break; + case F_ANHARM_POL: + gmx_fio_do_real(fio, iparams->anharm_polarize.alpha); + gmx_fio_do_real(fio, iparams->anharm_polarize.drcut); + gmx_fio_do_real(fio, iparams->anharm_polarize.khyp); + break; + case F_WATER_POL: + if (file_version < 31) + { + gmx_fatal(FARGS, "Old tpr files with water_polarization not supported. Make a new."); + } + gmx_fio_do_real(fio, iparams->wpol.al_x); + gmx_fio_do_real(fio, iparams->wpol.al_y); + gmx_fio_do_real(fio, iparams->wpol.al_z); + gmx_fio_do_real(fio, iparams->wpol.rOH); + gmx_fio_do_real(fio, iparams->wpol.rHH); + gmx_fio_do_real(fio, iparams->wpol.rOD); + break; + case F_THOLE_POL: + gmx_fio_do_real(fio, iparams->thole.a); + gmx_fio_do_real(fio, iparams->thole.alpha1); + gmx_fio_do_real(fio, iparams->thole.alpha2); + gmx_fio_do_real(fio, iparams->thole.rfac); + break; + case F_LJ: + gmx_fio_do_real(fio, iparams->lj.c6); + gmx_fio_do_real(fio, iparams->lj.c12); + break; + case F_LJ14: + gmx_fio_do_real(fio, iparams->lj14.c6A); + gmx_fio_do_real(fio, iparams->lj14.c12A); + gmx_fio_do_real(fio, iparams->lj14.c6B); + gmx_fio_do_real(fio, iparams->lj14.c12B); + break; + case F_LJC14_Q: + gmx_fio_do_real(fio, iparams->ljc14.fqq); + gmx_fio_do_real(fio, iparams->ljc14.qi); + gmx_fio_do_real(fio, iparams->ljc14.qj); + gmx_fio_do_real(fio, iparams->ljc14.c6); + gmx_fio_do_real(fio, iparams->ljc14.c12); + break; + case F_LJC_PAIRS_NB: + gmx_fio_do_real(fio, iparams->ljcnb.qi); + gmx_fio_do_real(fio, iparams->ljcnb.qj); + gmx_fio_do_real(fio, iparams->ljcnb.c6); + gmx_fio_do_real(fio, iparams->ljcnb.c12); + break; + case F_PDIHS: + case F_PIDIHS: + case F_ANGRES: + case F_ANGRESZ: + gmx_fio_do_real(fio, iparams->pdihs.phiA); + gmx_fio_do_real(fio, iparams->pdihs.cpA); + if ((ftype == F_ANGRES || ftype == F_ANGRESZ) && file_version < 42) + { + /* Read the incorrectly stored multiplicity */ + gmx_fio_do_real(fio, iparams->harmonic.rB); + gmx_fio_do_real(fio, iparams->harmonic.krB); + iparams->pdihs.phiB = iparams->pdihs.phiA; + iparams->pdihs.cpB = iparams->pdihs.cpA; + } + else + { + gmx_fio_do_real(fio, iparams->pdihs.phiB); + gmx_fio_do_real(fio, iparams->pdihs.cpB); + gmx_fio_do_int(fio, iparams->pdihs.mult); + } + break; + case F_DISRES: + gmx_fio_do_int(fio, iparams->disres.label); + gmx_fio_do_int(fio, iparams->disres.type); + gmx_fio_do_real(fio, iparams->disres.low); + gmx_fio_do_real(fio, iparams->disres.up1); + gmx_fio_do_real(fio, iparams->disres.up2); + gmx_fio_do_real(fio, iparams->disres.kfac); + break; + case F_ORIRES: + gmx_fio_do_int(fio, iparams->orires.ex); + gmx_fio_do_int(fio, iparams->orires.label); + gmx_fio_do_int(fio, iparams->orires.power); + gmx_fio_do_real(fio, iparams->orires.c); + gmx_fio_do_real(fio, iparams->orires.obs); + gmx_fio_do_real(fio, iparams->orires.kfac); + break; + case F_DIHRES: + if (file_version < 72) + { + gmx_fio_do_int(fio, idum); + gmx_fio_do_int(fio, idum); + } + gmx_fio_do_real(fio, iparams->dihres.phiA); + gmx_fio_do_real(fio, iparams->dihres.dphiA); + gmx_fio_do_real(fio, iparams->dihres.kfacA); + if (file_version >= 72) + { + gmx_fio_do_real(fio, iparams->dihres.phiB); + gmx_fio_do_real(fio, iparams->dihres.dphiB); + gmx_fio_do_real(fio, iparams->dihres.kfacB); + } + else + { + iparams->dihres.phiB = iparams->dihres.phiA; + iparams->dihres.dphiB = iparams->dihres.dphiA; + iparams->dihres.kfacB = iparams->dihres.kfacA; + } + break; + case F_POSRES: + gmx_fio_do_rvec(fio, iparams->posres.pos0A); + gmx_fio_do_rvec(fio, iparams->posres.fcA); + if (bRead && file_version < 27) + { + copy_rvec(iparams->posres.pos0A, iparams->posres.pos0B); + copy_rvec(iparams->posres.fcA, iparams->posres.fcB); + } + else + { + gmx_fio_do_rvec(fio, iparams->posres.pos0B); + gmx_fio_do_rvec(fio, iparams->posres.fcB); + } + break; + case F_FBPOSRES: + gmx_fio_do_int(fio, iparams->fbposres.geom); + gmx_fio_do_rvec(fio, iparams->fbposres.pos0); + gmx_fio_do_real(fio, iparams->fbposres.r); + gmx_fio_do_real(fio, iparams->fbposres.k); + break; + case F_RBDIHS: + bDum = gmx_fio_ndo_real(fio, iparams->rbdihs.rbcA, NR_RBDIHS); + if (file_version >= 25) + { + bDum = gmx_fio_ndo_real(fio, iparams->rbdihs.rbcB, NR_RBDIHS); + } + break; + case F_FOURDIHS: + /* Fourier dihedrals are internally represented + * as Ryckaert-Bellemans since those are faster to compute. + */ + bDum = gmx_fio_ndo_real(fio, iparams->rbdihs.rbcA, NR_RBDIHS); + bDum = gmx_fio_ndo_real(fio, iparams->rbdihs.rbcB, NR_RBDIHS); + break; + case F_CONSTR: + case F_CONSTRNC: + gmx_fio_do_real(fio, iparams->constr.dA); + gmx_fio_do_real(fio, iparams->constr.dB); + break; + case F_SETTLE: + gmx_fio_do_real(fio, iparams->settle.doh); + gmx_fio_do_real(fio, iparams->settle.dhh); + break; + case F_VSITE2: + gmx_fio_do_real(fio, iparams->vsite.a); + break; + case F_VSITE3: + case F_VSITE3FD: + case F_VSITE3FAD: + gmx_fio_do_real(fio, iparams->vsite.a); + gmx_fio_do_real(fio, iparams->vsite.b); + break; + case F_VSITE3OUT: + case F_VSITE4FD: + case F_VSITE4FDN: + gmx_fio_do_real(fio, iparams->vsite.a); + gmx_fio_do_real(fio, iparams->vsite.b); + gmx_fio_do_real(fio, iparams->vsite.c); + break; + case F_VSITEN: + gmx_fio_do_int(fio, iparams->vsiten.n); + gmx_fio_do_real(fio, iparams->vsiten.a); + break; + case F_GB12: + case F_GB13: + case F_GB14: + /* We got rid of some parameters in version 68 */ + if (bRead && file_version < 68) + { + gmx_fio_do_real(fio, rdum); + gmx_fio_do_real(fio, rdum); + gmx_fio_do_real(fio, rdum); + gmx_fio_do_real(fio, rdum); + } + gmx_fio_do_real(fio, iparams->gb.sar); + gmx_fio_do_real(fio, iparams->gb.st); + gmx_fio_do_real(fio, iparams->gb.pi); + gmx_fio_do_real(fio, iparams->gb.gbr); + gmx_fio_do_real(fio, iparams->gb.bmlt); + break; + case F_CMAP: + gmx_fio_do_int(fio, iparams->cmap.cmapA); + gmx_fio_do_int(fio, iparams->cmap.cmapB); + break; + default: + gmx_fatal(FARGS, "unknown function type %d (%s) in %s line %d", + ftype, interaction_function[ftype].name, __FILE__, __LINE__); + } + if (!bRead) + { + gmx_fio_unset_comment(fio); + } +} + +static void do_ilist(t_fileio *fio, t_ilist *ilist, gmx_bool bRead, int file_version, + int ftype) { - int i,j,renum[F_NRE]; - gmx_bool bDum=TRUE,bClear; - unsigned int k; - - for(j=0; (jnr); if (bRead) - for (k=0; k 0) - { - add_settle_atoms(&ilist[j]); - } - } - /* - if (bRead && gmx_debug_at) - pr_ilist(debug,0,interaction_function[j].longname, - functype,&ilist[j],TRUE); - */ - } + { + snew(ilist->iatoms, ilist->nr); + } + bDum = gmx_fio_ndo_int(fio, ilist->iatoms, ilist->nr); + if (!bRead) + { + gmx_fio_unset_comment(fio); + } +} + +static void do_ffparams(t_fileio *fio, gmx_ffparams_t *ffparams, + gmx_bool bRead, int file_version) +{ + int idum, i, j; + gmx_bool bDum = TRUE; + unsigned int k; + + gmx_fio_do_int(fio, ffparams->atnr); + if (file_version < 57) + { + gmx_fio_do_int(fio, idum); + } + gmx_fio_do_int(fio, ffparams->ntypes); + if (bRead && debug) + { + fprintf(debug, "ffparams->atnr = %d, ntypes = %d\n", + ffparams->atnr, ffparams->ntypes); + } + if (bRead) + { + snew(ffparams->functype, ffparams->ntypes); + snew(ffparams->iparams, ffparams->ntypes); + } + /* Read/write all the function types */ + bDum = gmx_fio_ndo_int(fio, ffparams->functype, ffparams->ntypes); + if (bRead && debug) + { + pr_ivec(debug, 0, "functype", ffparams->functype, ffparams->ntypes, TRUE); + } + + if (file_version >= 66) + { + gmx_fio_do_double(fio, ffparams->reppow); + } + else + { + ffparams->reppow = 12.0; + } + + if (file_version >= 57) + { + gmx_fio_do_real(fio, ffparams->fudgeQQ); + } + + /* Check whether all these function types are supported by the code. + * In practice the code is backwards compatible, which means that the + * numbering may have to be altered from old numbering to new numbering + */ + for (i = 0; (i < ffparams->ntypes); i++) + { + if (bRead) + { + /* Loop over file versions */ + for (k = 0; (k < NFTUPD); k++) + { + /* Compare the read file_version to the update table */ + if ((file_version < ftupd[k].fvnr) && + (ffparams->functype[i] >= ftupd[k].ftype)) + { + ffparams->functype[i] += 1; + if (debug) + { + fprintf(debug, "Incrementing function type %d to %d (due to %s)\n", + i, ffparams->functype[i], + interaction_function[ftupd[k].ftype].longname); + fflush(debug); + } + } + } + } + + do_iparams(fio, ffparams->functype[i], &ffparams->iparams[i], bRead, + file_version); + if (bRead && debug) + { + pr_iparams(debug, ffparams->functype[i], &ffparams->iparams[i]); + } + } +} + +static void add_settle_atoms(t_ilist *ilist) +{ + int i; + + /* Settle used to only store the first atom: add the other two */ + srenew(ilist->iatoms, 2*ilist->nr); + for (i = ilist->nr/2-1; i >= 0; i--) + { + ilist->iatoms[4*i+0] = ilist->iatoms[2*i+0]; + ilist->iatoms[4*i+1] = ilist->iatoms[2*i+1]; + ilist->iatoms[4*i+2] = ilist->iatoms[2*i+1] + 1; + ilist->iatoms[4*i+3] = ilist->iatoms[2*i+1] + 2; + } + ilist->nr = 2*ilist->nr; +} + +static void do_ilists(t_fileio *fio, t_ilist *ilist, gmx_bool bRead, + int file_version) +{ + int i, j, renum[F_NRE]; + gmx_bool bDum = TRUE, bClear; + unsigned int k; + + for (j = 0; (j < F_NRE); j++) + { + bClear = FALSE; + if (bRead) + { + for (k = 0; k < NFTUPD; k++) + { + if ((file_version < ftupd[k].fvnr) && (j == ftupd[k].ftype)) + { + bClear = TRUE; + } + } + } + if (bClear) + { + ilist[j].nr = 0; + ilist[j].iatoms = NULL; + } + else + { + do_ilist(fio, &ilist[j], bRead, file_version, j); + if (file_version < 78 && j == F_SETTLE && ilist[j].nr > 0) + { + add_settle_atoms(&ilist[j]); + } + } + /* + if (bRead && gmx_debug_at) + pr_ilist(debug,0,interaction_function[j].longname, + functype,&ilist[j],TRUE); + */ + } } -static void do_idef(t_fileio *fio, gmx_ffparams_t *ffparams,gmx_moltype_t *molt, - gmx_bool bRead, int file_version) +static void do_idef(t_fileio *fio, gmx_ffparams_t *ffparams, gmx_moltype_t *molt, + gmx_bool bRead, int file_version) { - do_ffparams(fio, ffparams,bRead,file_version); - - if (file_version >= 54) { - gmx_fio_do_real(fio,ffparams->fudgeQQ); - } + do_ffparams(fio, ffparams, bRead, file_version); + + if (file_version >= 54) + { + gmx_fio_do_real(fio, ffparams->fudgeQQ); + } - do_ilists(fio, molt->ilist,bRead,file_version); + do_ilists(fio, molt->ilist, bRead, file_version); } -static void do_block(t_fileio *fio, t_block *block,gmx_bool bRead,int file_version) +static void do_block(t_fileio *fio, t_block *block, gmx_bool bRead, int file_version) { - int i,idum,dum_nra,*dum_a; - gmx_bool bDum=TRUE; - - if (file_version < 44) - for(i=0; inr); - if (file_version < 51) - gmx_fio_do_int(fio,dum_nra); - if (bRead) { - block->nalloc_index = block->nr+1; - snew(block->index,block->nalloc_index); - } - bDum=gmx_fio_ndo_int(fio,block->index,block->nr+1); - - if (file_version < 51 && dum_nra > 0) { - snew(dum_a,dum_nra); - bDum=gmx_fio_ndo_int(fio,dum_a,dum_nra); - sfree(dum_a); - } + int i, idum, dum_nra, *dum_a; + gmx_bool bDum = TRUE; + + if (file_version < 44) + { + for (i = 0; i < MAXNODES; i++) + { + gmx_fio_do_int(fio, idum); + } + } + gmx_fio_do_int(fio, block->nr); + if (file_version < 51) + { + gmx_fio_do_int(fio, dum_nra); + } + if (bRead) + { + block->nalloc_index = block->nr+1; + snew(block->index, block->nalloc_index); + } + bDum = gmx_fio_ndo_int(fio, block->index, block->nr+1); + + if (file_version < 51 && dum_nra > 0) + { + snew(dum_a, dum_nra); + bDum = gmx_fio_ndo_int(fio, dum_a, dum_nra); + sfree(dum_a); + } } -static void do_blocka(t_fileio *fio, t_blocka *block,gmx_bool bRead, +static void do_blocka(t_fileio *fio, t_blocka *block, gmx_bool bRead, int file_version) { - int i,idum; - gmx_bool bDum=TRUE; - - if (file_version < 44) - for(i=0; inr); - gmx_fio_do_int(fio,block->nra); - if (bRead) { - block->nalloc_index = block->nr+1; - snew(block->index,block->nalloc_index); - block->nalloc_a = block->nra; - snew(block->a,block->nalloc_a); - } - bDum=gmx_fio_ndo_int(fio,block->index,block->nr+1); - bDum=gmx_fio_ndo_int(fio,block->a,block->nra); + int i, idum; + gmx_bool bDum = TRUE; + + if (file_version < 44) + { + for (i = 0; i < MAXNODES; i++) + { + gmx_fio_do_int(fio, idum); + } + } + gmx_fio_do_int(fio, block->nr); + gmx_fio_do_int(fio, block->nra); + if (bRead) + { + block->nalloc_index = block->nr+1; + snew(block->index, block->nalloc_index); + block->nalloc_a = block->nra; + snew(block->a, block->nalloc_a); + } + bDum = gmx_fio_ndo_int(fio, block->index, block->nr+1); + bDum = gmx_fio_ndo_int(fio, block->a, block->nra); } -static void do_atom(t_fileio *fio, t_atom *atom,int ngrp,gmx_bool bRead, - int file_version, gmx_groups_t *groups,int atnr) -{ - int i,myngrp; - - gmx_fio_do_real(fio,atom->m); - gmx_fio_do_real(fio,atom->q); - gmx_fio_do_real(fio,atom->mB); - gmx_fio_do_real(fio,atom->qB); - gmx_fio_do_ushort(fio, atom->type); - gmx_fio_do_ushort(fio, atom->typeB); - gmx_fio_do_int(fio,atom->ptype); - gmx_fio_do_int(fio,atom->resind); - if (file_version >= 52) - gmx_fio_do_int(fio,atom->atomnumber); - else if (bRead) - atom->atomnumber = NOTSET; - if (file_version < 23) - myngrp = 8; - else if (file_version < 39) - myngrp = 9; - else - myngrp = ngrp; - - if (file_version < 57) { - unsigned char uchar[egcNR]; - gmx_fio_ndo_uchar(fio,uchar,myngrp); - for(i=myngrp; (igrpnr[i][atnr] = uchar[i]; - } - } +static void do_atom(t_fileio *fio, t_atom *atom, int ngrp, gmx_bool bRead, + int file_version, gmx_groups_t *groups, int atnr) +{ + int i, myngrp; + + gmx_fio_do_real(fio, atom->m); + gmx_fio_do_real(fio, atom->q); + gmx_fio_do_real(fio, atom->mB); + gmx_fio_do_real(fio, atom->qB); + gmx_fio_do_ushort(fio, atom->type); + gmx_fio_do_ushort(fio, atom->typeB); + gmx_fio_do_int(fio, atom->ptype); + gmx_fio_do_int(fio, atom->resind); + if (file_version >= 52) + { + gmx_fio_do_int(fio, atom->atomnumber); + } + else if (bRead) + { + atom->atomnumber = NOTSET; + } + if (file_version < 23) + { + myngrp = 8; + } + else if (file_version < 39) + { + myngrp = 9; + } + else + { + myngrp = ngrp; + } + + if (file_version < 57) + { + unsigned char uchar[egcNR]; + gmx_fio_ndo_uchar(fio, uchar, myngrp); + for (i = myngrp; (i < ngrp); i++) + { + uchar[i] = 0; + } + /* Copy the old data format to the groups struct */ + for (i = 0; i < ngrp; i++) + { + groups->grpnr[i][atnr] = uchar[i]; + } + } } -static void do_grps(t_fileio *fio, int ngrp,t_grps grps[],gmx_bool bRead, +static void do_grps(t_fileio *fio, int ngrp, t_grps grps[], gmx_bool bRead, int file_version) { - int i,j,myngrp; - gmx_bool bDum=TRUE; - - if (file_version < 23) - myngrp = 8; - else if (file_version < 39) - myngrp = 9; - else - myngrp = ngrp; - - for(j=0; (j= 63) { - gmx_fio_do_int(fio,ri[j].nr); - gmx_fio_do_uchar(fio, ri[j].ic); - } else { - ri[j].nr = j + 1; - ri[j].ic = ' '; - } - } + int j; + + for (j = 0; (j < n); j++) + { + do_symstr(fio, &(ri[j].name), bRead, symtab); + if (file_version >= 63) + { + gmx_fio_do_int(fio, ri[j].nr); + gmx_fio_do_uchar(fio, ri[j].ic); + } + else + { + ri[j].nr = j + 1; + ri[j].ic = ' '; + } + } } -static void do_atoms(t_fileio *fio, t_atoms *atoms,gmx_bool bRead,t_symtab *symtab, - int file_version, - gmx_groups_t *groups) +static void do_atoms(t_fileio *fio, t_atoms *atoms, gmx_bool bRead, t_symtab *symtab, + int file_version, + gmx_groups_t *groups) { - int i; - - gmx_fio_do_int(fio,atoms->nr); - gmx_fio_do_int(fio,atoms->nres); - if (file_version < 57) { - gmx_fio_do_int(fio,groups->ngrpname); - for(i=0; ingrpnr[i] = atoms->nr; - snew(groups->grpnr[i],groups->ngrpnr[i]); - } - } - if (bRead) { - snew(atoms->atom,atoms->nr); - snew(atoms->atomname,atoms->nr); - snew(atoms->atomtype,atoms->nr); - snew(atoms->atomtypeB,atoms->nr); - snew(atoms->resinfo,atoms->nres); - if (file_version < 57) { - snew(groups->grpname,groups->ngrpname); - } - atoms->pdbinfo = NULL; - } - for(i=0; (inr); i++) { - do_atom(fio, &atoms->atom[i],egcNR,bRead, file_version,groups,i); - } - do_strstr(fio, atoms->nr,atoms->atomname,bRead,symtab); - if (bRead && (file_version <= 20)) { - for(i=0; inr; i++) { - atoms->atomtype[i] = put_symtab(symtab,"?"); - atoms->atomtypeB[i] = put_symtab(symtab,"?"); - } - } else { - do_strstr(fio, atoms->nr,atoms->atomtype,bRead,symtab); - do_strstr(fio, atoms->nr,atoms->atomtypeB,bRead,symtab); - } - do_resinfo(fio, atoms->nres,atoms->resinfo,bRead,symtab,file_version); - - if (file_version < 57) { - do_strstr(fio, groups->ngrpname,groups->grpname,bRead,symtab); - - do_grps(fio, egcNR,groups->grps,bRead,file_version); - } + int i; + + gmx_fio_do_int(fio, atoms->nr); + gmx_fio_do_int(fio, atoms->nres); + if (file_version < 57) + { + gmx_fio_do_int(fio, groups->ngrpname); + for (i = 0; i < egcNR; i++) + { + groups->ngrpnr[i] = atoms->nr; + snew(groups->grpnr[i], groups->ngrpnr[i]); + } + } + if (bRead) + { + snew(atoms->atom, atoms->nr); + snew(atoms->atomname, atoms->nr); + snew(atoms->atomtype, atoms->nr); + snew(atoms->atomtypeB, atoms->nr); + snew(atoms->resinfo, atoms->nres); + if (file_version < 57) + { + snew(groups->grpname, groups->ngrpname); + } + atoms->pdbinfo = NULL; + } + for (i = 0; (i < atoms->nr); i++) + { + do_atom(fio, &atoms->atom[i], egcNR, bRead, file_version, groups, i); + } + do_strstr(fio, atoms->nr, atoms->atomname, bRead, symtab); + if (bRead && (file_version <= 20)) + { + for (i = 0; i < atoms->nr; i++) + { + atoms->atomtype[i] = put_symtab(symtab, "?"); + atoms->atomtypeB[i] = put_symtab(symtab, "?"); + } + } + else + { + do_strstr(fio, atoms->nr, atoms->atomtype, bRead, symtab); + do_strstr(fio, atoms->nr, atoms->atomtypeB, bRead, symtab); + } + do_resinfo(fio, atoms->nres, atoms->resinfo, bRead, symtab, file_version); + + if (file_version < 57) + { + do_strstr(fio, groups->ngrpname, groups->grpname, bRead, symtab); + + do_grps(fio, egcNR, groups->grps, bRead, file_version); + } } static void do_groups(t_fileio *fio, gmx_groups_t *groups, - gmx_bool bRead,t_symtab *symtab, - int file_version) + gmx_bool bRead, t_symtab *symtab, + int file_version) { - int g,n,i; - gmx_bool bDum=TRUE; - - do_grps(fio, egcNR,groups->grps,bRead,file_version); - gmx_fio_do_int(fio,groups->ngrpname); - if (bRead) { - snew(groups->grpname,groups->ngrpname); - } - do_strstr(fio, groups->ngrpname,groups->grpname,bRead,symtab); - for(g=0; gngrpnr[g]); - if (groups->ngrpnr[g] == 0) { - if (bRead) { - groups->grpnr[g] = NULL; - } - } else { - if (bRead) { - snew(groups->grpnr[g],groups->ngrpnr[g]); - } - bDum=gmx_fio_ndo_uchar(fio, groups->grpnr[g],groups->ngrpnr[g]); - } - } + int g, n, i; + gmx_bool bDum = TRUE; + + do_grps(fio, egcNR, groups->grps, bRead, file_version); + gmx_fio_do_int(fio, groups->ngrpname); + if (bRead) + { + snew(groups->grpname, groups->ngrpname); + } + do_strstr(fio, groups->ngrpname, groups->grpname, bRead, symtab); + for (g = 0; g < egcNR; g++) + { + gmx_fio_do_int(fio, groups->ngrpnr[g]); + if (groups->ngrpnr[g] == 0) + { + if (bRead) + { + groups->grpnr[g] = NULL; + } + } + else + { + if (bRead) + { + snew(groups->grpnr[g], groups->ngrpnr[g]); + } + bDum = gmx_fio_ndo_uchar(fio, groups->grpnr[g], groups->ngrpnr[g]); + } + } } -static void do_atomtypes(t_fileio *fio, t_atomtypes *atomtypes,gmx_bool bRead, - t_symtab *symtab,int file_version) +static void do_atomtypes(t_fileio *fio, t_atomtypes *atomtypes, gmx_bool bRead, + t_symtab *symtab, int file_version) { - int i,j; - gmx_bool bDum = TRUE; - - if (file_version > 25) { - gmx_fio_do_int(fio,atomtypes->nr); - j=atomtypes->nr; - if (bRead) { - snew(atomtypes->radius,j); - snew(atomtypes->vol,j); - snew(atomtypes->surftens,j); - snew(atomtypes->atomnumber,j); - snew(atomtypes->gb_radius,j); - snew(atomtypes->S_hct,j); - } - bDum=gmx_fio_ndo_real(fio,atomtypes->radius,j); - bDum=gmx_fio_ndo_real(fio,atomtypes->vol,j); - bDum=gmx_fio_ndo_real(fio,atomtypes->surftens,j); - if(file_version >= 40) - { - bDum=gmx_fio_ndo_int(fio,atomtypes->atomnumber,j); - } - if(file_version >= 60) - { - bDum=gmx_fio_ndo_real(fio,atomtypes->gb_radius,j); - bDum=gmx_fio_ndo_real(fio,atomtypes->S_hct,j); - } - } else { - /* File versions prior to 26 cannot do GBSA, - * so they dont use this structure - */ - atomtypes->nr = 0; - atomtypes->radius = NULL; - atomtypes->vol = NULL; - atomtypes->surftens = NULL; - atomtypes->atomnumber = NULL; - atomtypes->gb_radius = NULL; - atomtypes->S_hct = NULL; - } + int i, j; + gmx_bool bDum = TRUE; + + if (file_version > 25) + { + gmx_fio_do_int(fio, atomtypes->nr); + j = atomtypes->nr; + if (bRead) + { + snew(atomtypes->radius, j); + snew(atomtypes->vol, j); + snew(atomtypes->surftens, j); + snew(atomtypes->atomnumber, j); + snew(atomtypes->gb_radius, j); + snew(atomtypes->S_hct, j); + } + bDum = gmx_fio_ndo_real(fio, atomtypes->radius, j); + bDum = gmx_fio_ndo_real(fio, atomtypes->vol, j); + bDum = gmx_fio_ndo_real(fio, atomtypes->surftens, j); + if (file_version >= 40) + { + bDum = gmx_fio_ndo_int(fio, atomtypes->atomnumber, j); + } + if (file_version >= 60) + { + bDum = gmx_fio_ndo_real(fio, atomtypes->gb_radius, j); + bDum = gmx_fio_ndo_real(fio, atomtypes->S_hct, j); + } + } + else + { + /* File versions prior to 26 cannot do GBSA, + * so they dont use this structure + */ + atomtypes->nr = 0; + atomtypes->radius = NULL; + atomtypes->vol = NULL; + atomtypes->surftens = NULL; + atomtypes->atomnumber = NULL; + atomtypes->gb_radius = NULL; + atomtypes->S_hct = NULL; + } } -static void do_symtab(t_fileio *fio, t_symtab *symtab,gmx_bool bRead) +static void do_symtab(t_fileio *fio, t_symtab *symtab, gmx_bool bRead) { - int i,nr; - t_symbuf *symbuf; - char buf[STRLEN]; - - gmx_fio_do_int(fio,symtab->nr); - nr = symtab->nr; - if (bRead) { - snew(symtab->symbuf,1); - symbuf = symtab->symbuf; - symbuf->bufsize = nr; - snew(symbuf->buf,nr); - for (i=0; (ibuf[i]=strdup(buf); - } - } - else { - symbuf = symtab->symbuf; - while (symbuf!=NULL) { - for (i=0; (ibufsize) && (ibuf[i]); - nr-=i; - symbuf=symbuf->next; - } - if (nr != 0) - gmx_fatal(FARGS,"nr of symtab strings left: %d",nr); - } + int i, nr; + t_symbuf *symbuf; + char buf[STRLEN]; + + gmx_fio_do_int(fio, symtab->nr); + nr = symtab->nr; + if (bRead) + { + snew(symtab->symbuf, 1); + symbuf = symtab->symbuf; + symbuf->bufsize = nr; + snew(symbuf->buf, nr); + for (i = 0; (i < nr); i++) + { + gmx_fio_do_string(fio, buf); + symbuf->buf[i] = strdup(buf); + } + } + else + { + symbuf = symtab->symbuf; + while (symbuf != NULL) + { + for (i = 0; (i < symbuf->bufsize) && (i < nr); i++) + { + gmx_fio_do_string(fio, symbuf->buf[i]); + } + nr -= i; + symbuf = symbuf->next; + } + if (nr != 0) + { + gmx_fatal(FARGS, "nr of symtab strings left: %d", nr); + } + } } static void do_cmap(t_fileio *fio, gmx_cmap_t *cmap_grid, gmx_bool bRead) { - int i,j,ngrid,gs,nelem; - - gmx_fio_do_int(fio,cmap_grid->ngrid); - gmx_fio_do_int(fio,cmap_grid->grid_spacing); - - ngrid = cmap_grid->ngrid; - gs = cmap_grid->grid_spacing; - nelem = gs * gs; - - if(bRead) - { - snew(cmap_grid->cmapdata,ngrid); - - for(i=0;ingrid;i++) - { - snew(cmap_grid->cmapdata[i].cmap,4*nelem); - } - } - - for(i=0;ingrid;i++) - { - for(j=0;jcmapdata[i].cmap[j*4]); - gmx_fio_do_real(fio,cmap_grid->cmapdata[i].cmap[j*4+1]); - gmx_fio_do_real(fio,cmap_grid->cmapdata[i].cmap[j*4+2]); - gmx_fio_do_real(fio,cmap_grid->cmapdata[i].cmap[j*4+3]); - } - } + int i, j, ngrid, gs, nelem; + + gmx_fio_do_int(fio, cmap_grid->ngrid); + gmx_fio_do_int(fio, cmap_grid->grid_spacing); + + ngrid = cmap_grid->ngrid; + gs = cmap_grid->grid_spacing; + nelem = gs * gs; + + if (bRead) + { + snew(cmap_grid->cmapdata, ngrid); + + for (i = 0; i < cmap_grid->ngrid; i++) + { + snew(cmap_grid->cmapdata[i].cmap, 4*nelem); + } + } + + for (i = 0; i < cmap_grid->ngrid; i++) + { + for (j = 0; j < nelem; j++) + { + gmx_fio_do_real(fio, cmap_grid->cmapdata[i].cmap[j*4]); + gmx_fio_do_real(fio, cmap_grid->cmapdata[i].cmap[j*4+1]); + gmx_fio_do_real(fio, cmap_grid->cmapdata[i].cmap[j*4+2]); + gmx_fio_do_real(fio, cmap_grid->cmapdata[i].cmap[j*4+3]); + } + } } -void tpx_make_chain_identifiers(t_atoms *atoms,t_block *mols) +void tpx_make_chain_identifiers(t_atoms *atoms, t_block *mols) { - int m,a,a0,a1,r; - char c,chainid; + int m, a, a0, a1, r; + char c, chainid; int chainnum; - - /* We always assign a new chain number, but save the chain id characters + + /* We always assign a new chain number, but save the chain id characters * for larger molecules. */ #define CHAIN_MIN_ATOMS 15 - - chainnum=0; - chainid='A'; - for(m=0; mnr; m++) + + chainnum = 0; + chainid = 'A'; + for (m = 0; m < mols->nr; m++) { - a0=mols->index[m]; - a1=mols->index[m+1]; - if ((a1-a0 >= CHAIN_MIN_ATOMS) && (chainid <= 'Z')) + a0 = mols->index[m]; + a1 = mols->index[m+1]; + if ((a1-a0 >= CHAIN_MIN_ATOMS) && (chainid <= 'Z')) { - c=chainid; + c = chainid; chainid++; - } + } else { - c=' '; + c = ' '; + } + for (a = a0; a < a1; a++) + { + atoms->resinfo[atoms->atom[a].resind].chainnum = chainnum; + atoms->resinfo[atoms->atom[a].resind].chainid = c; + } + chainnum++; + } + + /* Blank out the chain id if there was only one chain */ + if (chainid == 'B') + { + for (r = 0; r < atoms->nres; r++) + { + atoms->resinfo[r].chainid = ' '; + } + } +} + +static void do_moltype(t_fileio *fio, gmx_moltype_t *molt, gmx_bool bRead, + t_symtab *symtab, int file_version, + gmx_groups_t *groups) +{ + int i; + + if (file_version >= 57) + { + do_symstr(fio, &(molt->name), bRead, symtab); + } + + do_atoms(fio, &molt->atoms, bRead, symtab, file_version, groups); + + if (bRead && gmx_debug_at) + { + pr_atoms(debug, 0, "atoms", &molt->atoms, TRUE); + } + + if (file_version >= 57) + { + do_ilists(fio, molt->ilist, bRead, file_version); + + do_block(fio, &molt->cgs, bRead, file_version); + if (bRead && gmx_debug_at) + { + pr_block(debug, 0, "cgs", &molt->cgs, TRUE); + } + } + + /* This used to be in the atoms struct */ + do_blocka(fio, &molt->excls, bRead, file_version); +} + +static void do_molblock(t_fileio *fio, gmx_molblock_t *molb, gmx_bool bRead, + int file_version) +{ + int i; + + gmx_fio_do_int(fio, molb->type); + gmx_fio_do_int(fio, molb->nmol); + gmx_fio_do_int(fio, molb->natoms_mol); + /* Position restraint coordinates */ + gmx_fio_do_int(fio, molb->nposres_xA); + if (molb->nposres_xA > 0) + { + if (bRead) + { + snew(molb->posres_xA, molb->nposres_xA); + } + gmx_fio_ndo_rvec(fio, molb->posres_xA, molb->nposres_xA); + } + gmx_fio_do_int(fio, molb->nposres_xB); + if (molb->nposres_xB > 0) + { + if (bRead) + { + snew(molb->posres_xB, molb->nposres_xB); + } + gmx_fio_ndo_rvec(fio, molb->posres_xB, molb->nposres_xB); + } + +} + +static t_block mtop_mols(gmx_mtop_t *mtop) +{ + int mb, m, a, mol; + t_block mols; + + mols.nr = 0; + for (mb = 0; mb < mtop->nmolblock; mb++) + { + mols.nr += mtop->molblock[mb].nmol; + } + mols.nalloc_index = mols.nr + 1; + snew(mols.index, mols.nalloc_index); + + a = 0; + m = 0; + mols.index[m] = a; + for (mb = 0; mb < mtop->nmolblock; mb++) + { + for (mol = 0; mol < mtop->molblock[mb].nmol; mol++) + { + a += mtop->molblock[mb].natoms_mol; + m++; + mols.index[m] = a; + } + } + + return mols; +} + +static void add_posres_molblock(gmx_mtop_t *mtop) +{ + t_ilist *il, *ilfb; + int am, i, mol, a; + gmx_bool bFE; + gmx_molblock_t *molb; + t_iparams *ip; + + /* posres reference positions are stored in ip->posres (if present) and + in ip->fbposres (if present). If normal and flat-bottomed posres are present, + posres.pos0A are identical to fbposres.pos0. */ + il = &mtop->moltype[0].ilist[F_POSRES]; + ilfb = &mtop->moltype[0].ilist[F_FBPOSRES]; + if (il->nr == 0 && ilfb->nr == 0) + { + return; + } + am = 0; + bFE = FALSE; + for (i = 0; i < il->nr; i += 2) + { + ip = &mtop->ffparams.iparams[il->iatoms[i]]; + am = max(am, il->iatoms[i+1]); + if (ip->posres.pos0B[XX] != ip->posres.pos0A[XX] || + ip->posres.pos0B[YY] != ip->posres.pos0A[YY] || + ip->posres.pos0B[ZZ] != ip->posres.pos0A[ZZ]) + { + bFE = TRUE; + } + } + /* This loop is required if we have only flat-bottomed posres: + - set am + - bFE == FALSE (no B-state for flat-bottomed posres) */ + if (il->nr == 0) + { + for (i = 0; i < ilfb->nr; i += 2) + { + ip = &mtop->ffparams.iparams[ilfb->iatoms[i]]; + am = max(am, ilfb->iatoms[i+1]); + } + } + /* Make the posres coordinate block end at a molecule end */ + mol = 0; + while (am >= mtop->mols.index[mol+1]) + { + mol++; + } + molb = &mtop->molblock[0]; + molb->nposres_xA = mtop->mols.index[mol+1]; + snew(molb->posres_xA, molb->nposres_xA); + if (bFE) + { + molb->nposres_xB = molb->nposres_xA; + snew(molb->posres_xB, molb->nposres_xB); + } + else + { + molb->nposres_xB = 0; + } + for (i = 0; i < il->nr; i += 2) + { + ip = &mtop->ffparams.iparams[il->iatoms[i]]; + a = il->iatoms[i+1]; + molb->posres_xA[a][XX] = ip->posres.pos0A[XX]; + molb->posres_xA[a][YY] = ip->posres.pos0A[YY]; + molb->posres_xA[a][ZZ] = ip->posres.pos0A[ZZ]; + if (bFE) + { + molb->posres_xB[a][XX] = ip->posres.pos0B[XX]; + molb->posres_xB[a][YY] = ip->posres.pos0B[YY]; + molb->posres_xB[a][ZZ] = ip->posres.pos0B[ZZ]; } - for(a=a0; anr == 0) + { + /* If only flat-bottomed posres are present, take reference pos from them. + Here: bFE == FALSE */ + for (i = 0; i < ilfb->nr; i += 2) { - atoms->resinfo[atoms->atom[a].resind].chainnum = chainnum; - atoms->resinfo[atoms->atom[a].resind].chainid = c; + ip = &mtop->ffparams.iparams[ilfb->iatoms[i]]; + a = ilfb->iatoms[i+1]; + molb->posres_xA[a][XX] = ip->fbposres.pos0[XX]; + molb->posres_xA[a][YY] = ip->fbposres.pos0[YY]; + molb->posres_xA[a][ZZ] = ip->fbposres.pos0[ZZ]; } - chainnum++; } - - /* Blank out the chain id if there was only one chain */ - if (chainid == 'B') +} + +static void set_disres_npair(gmx_mtop_t *mtop) +{ + int mt, i, npair; + t_iparams *ip; + t_ilist *il; + t_iatom *a; + + ip = mtop->ffparams.iparams; + + for (mt = 0; mt < mtop->nmoltype; mt++) { - for(r=0; rnres; r++) + il = &mtop->moltype[mt].ilist[F_DISRES]; + if (il->nr > 0) { - atoms->resinfo[r].chainid = ' '; + a = il->iatoms; + npair = 0; + for (i = 0; i < il->nr; i += 3) + { + npair++; + if (i+3 == il->nr || ip[a[i]].disres.label != ip[a[i+3]].disres.label) + { + ip[a[i]].disres.npair = npair; + npair = 0; + } + } } } } - -static void do_moltype(t_fileio *fio, gmx_moltype_t *molt,gmx_bool bRead, - t_symtab *symtab, int file_version, - gmx_groups_t *groups) + +static void do_mtop(t_fileio *fio, gmx_mtop_t *mtop, gmx_bool bRead, + int file_version) { - int i; + int mt, mb, i; + t_blocka dumb; - if (file_version >= 57) { - do_symstr(fio, &(molt->name),bRead,symtab); - } + if (bRead) + { + init_mtop(mtop); + } + do_symtab(fio, &(mtop->symtab), bRead); + if (bRead && debug) + { + pr_symtab(debug, 0, "symtab", &mtop->symtab); + } - do_atoms(fio, &molt->atoms, bRead, symtab, file_version, groups); + do_symstr(fio, &(mtop->name), bRead, &(mtop->symtab)); - if (bRead && gmx_debug_at) { - pr_atoms(debug,0,"atoms",&molt->atoms,TRUE); - } - - if (file_version >= 57) { - do_ilists(fio, molt->ilist,bRead,file_version); + if (file_version >= 57) + { + do_ffparams(fio, &mtop->ffparams, bRead, file_version); - do_block(fio, &molt->cgs,bRead,file_version); - if (bRead && gmx_debug_at) { - pr_block(debug,0,"cgs",&molt->cgs,TRUE); + gmx_fio_do_int(fio, mtop->nmoltype); + } + else + { + mtop->nmoltype = 1; + } + if (bRead) + { + snew(mtop->moltype, mtop->nmoltype); + if (file_version < 57) + { + mtop->moltype[0].name = mtop->name; + } + } + for (mt = 0; mt < mtop->nmoltype; mt++) + { + do_moltype(fio, &mtop->moltype[mt], bRead, &mtop->symtab, file_version, + &mtop->groups); } - } - /* This used to be in the atoms struct */ - do_blocka(fio, &molt->excls, bRead, file_version); -} + if (file_version >= 57) + { + gmx_fio_do_int(fio, mtop->nmolblock); + } + else + { + mtop->nmolblock = 1; + } + if (bRead) + { + snew(mtop->molblock, mtop->nmolblock); + } + if (file_version >= 57) + { + for (mb = 0; mb < mtop->nmolblock; mb++) + { + do_molblock(fio, &mtop->molblock[mb], bRead, file_version); + } + gmx_fio_do_int(fio, mtop->natoms); + } + else + { + mtop->molblock[0].type = 0; + mtop->molblock[0].nmol = 1; + mtop->molblock[0].natoms_mol = mtop->moltype[0].atoms.nr; + mtop->molblock[0].nposres_xA = 0; + mtop->molblock[0].nposres_xB = 0; + } -static void do_molblock(t_fileio *fio, gmx_molblock_t *molb,gmx_bool bRead, - int file_version) -{ - int i; - - gmx_fio_do_int(fio,molb->type); - gmx_fio_do_int(fio,molb->nmol); - gmx_fio_do_int(fio,molb->natoms_mol); - /* Position restraint coordinates */ - gmx_fio_do_int(fio,molb->nposres_xA); - if (molb->nposres_xA > 0) { - if (bRead) { - snew(molb->posres_xA,molb->nposres_xA); - } - gmx_fio_ndo_rvec(fio,molb->posres_xA,molb->nposres_xA); - } - gmx_fio_do_int(fio,molb->nposres_xB); - if (molb->nposres_xB > 0) { - if (bRead) { - snew(molb->posres_xB,molb->nposres_xB); - } - gmx_fio_ndo_rvec(fio,molb->posres_xB,molb->nposres_xB); - } + do_atomtypes (fio, &(mtop->atomtypes), bRead, &(mtop->symtab), file_version); + if (bRead && debug) + { + pr_atomtypes(debug, 0, "atomtypes", &mtop->atomtypes, TRUE); + } -} + if (file_version < 57) + { + /* Debug statements are inside do_idef */ + do_idef (fio, &mtop->ffparams, &mtop->moltype[0], bRead, file_version); + mtop->natoms = mtop->moltype[0].atoms.nr; + } -static t_block mtop_mols(gmx_mtop_t *mtop) -{ - int mb,m,a,mol; - t_block mols; - - mols.nr = 0; - for(mb=0; mbnmolblock; mb++) { - mols.nr += mtop->molblock[mb].nmol; - } - mols.nalloc_index = mols.nr + 1; - snew(mols.index,mols.nalloc_index); - - a = 0; - m = 0; - mols.index[m] = a; - for(mb=0; mbnmolblock; mb++) { - for(mol=0; molmolblock[mb].nmol; mol++) { - a += mtop->molblock[mb].natoms_mol; - m++; - mols.index[m] = a; - } - } - - return mols; -} + if (file_version >= 65) + { + do_cmap(fio, &mtop->ffparams.cmap_grid, bRead); + } + else + { + mtop->ffparams.cmap_grid.ngrid = 0; + mtop->ffparams.cmap_grid.grid_spacing = 0; + mtop->ffparams.cmap_grid.cmapdata = NULL; + } -static void add_posres_molblock(gmx_mtop_t *mtop) -{ - t_ilist *il,*ilfb; - int am,i,mol,a; - gmx_bool bFE; - gmx_molblock_t *molb; - t_iparams *ip; - - /* posres reference positions are stored in ip->posres (if present) and - in ip->fbposres (if present). If normal and flat-bottomed posres are present, - posres.pos0A are identical to fbposres.pos0. */ - il = &mtop->moltype[0].ilist[F_POSRES]; - ilfb = &mtop->moltype[0].ilist[F_FBPOSRES]; - if (il->nr == 0 && ilfb->nr == 0) { - return; - } - am = 0; - bFE = FALSE; - for(i=0; inr; i+=2) { - ip = &mtop->ffparams.iparams[il->iatoms[i]]; - am = max(am,il->iatoms[i+1]); - if (ip->posres.pos0B[XX] != ip->posres.pos0A[XX] || - ip->posres.pos0B[YY] != ip->posres.pos0A[YY] || - ip->posres.pos0B[ZZ] != ip->posres.pos0A[ZZ]) { - bFE = TRUE; - } - } - /* This loop is required if we have only flat-bottomed posres: - - set am - - bFE == FALSE (no B-state for flat-bottomed posres) */ - if (il->nr == 0) - { - for(i=0; inr; i+=2) { - ip = &mtop->ffparams.iparams[ilfb->iatoms[i]]; - am = max(am,ilfb->iatoms[i+1]); - } - } - /* Make the posres coordinate block end at a molecule end */ - mol = 0; - while(am >= mtop->mols.index[mol+1]) { - mol++; - } - molb = &mtop->molblock[0]; - molb->nposres_xA = mtop->mols.index[mol+1]; - snew(molb->posres_xA,molb->nposres_xA); - if (bFE) { - molb->nposres_xB = molb->nposres_xA; - snew(molb->posres_xB,molb->nposres_xB); - } else { - molb->nposres_xB = 0; - } - for(i=0; inr; i+=2) { - ip = &mtop->ffparams.iparams[il->iatoms[i]]; - a = il->iatoms[i+1]; - molb->posres_xA[a][XX] = ip->posres.pos0A[XX]; - molb->posres_xA[a][YY] = ip->posres.pos0A[YY]; - molb->posres_xA[a][ZZ] = ip->posres.pos0A[ZZ]; - if (bFE) { - molb->posres_xB[a][XX] = ip->posres.pos0B[XX]; - molb->posres_xB[a][YY] = ip->posres.pos0B[YY]; - molb->posres_xB[a][ZZ] = ip->posres.pos0B[ZZ]; - } - } - if (il->nr == 0) - { - /* If only flat-bottomed posres are present, take reference pos from them. - Here: bFE == FALSE */ - for(i=0; inr; i+=2) - { - ip = &mtop->ffparams.iparams[ilfb->iatoms[i]]; - a = ilfb->iatoms[i+1]; - molb->posres_xA[a][XX] = ip->fbposres.pos0[XX]; - molb->posres_xA[a][YY] = ip->fbposres.pos0[YY]; - molb->posres_xA[a][ZZ] = ip->fbposres.pos0[ZZ]; - } - } -} + if (file_version >= 57) + { + do_groups(fio, &mtop->groups, bRead, &(mtop->symtab), file_version); + } -static void set_disres_npair(gmx_mtop_t *mtop) -{ - int mt,i,npair; - t_iparams *ip; - t_ilist *il; - t_iatom *a; - - ip = mtop->ffparams.iparams; - - for(mt=0; mtnmoltype; mt++) { - il = &mtop->moltype[mt].ilist[F_DISRES]; - if (il->nr > 0) { - a = il->iatoms; - npair = 0; - for(i=0; inr; i+=3) { - npair++; - if (i+3 == il->nr || ip[a[i]].disres.label != ip[a[i+3]].disres.label) { - ip[a[i]].disres.npair = npair; - npair = 0; - } - } - } - } -} + if (file_version < 57) + { + do_block(fio, &mtop->moltype[0].cgs, bRead, file_version); + if (bRead && gmx_debug_at) + { + pr_block(debug, 0, "cgs", &mtop->moltype[0].cgs, TRUE); + } + do_block(fio, &mtop->mols, bRead, file_version); + /* Add the posres coordinates to the molblock */ + add_posres_molblock(mtop); + } + if (bRead) + { + if (file_version >= 57) + { + mtop->mols = mtop_mols(mtop); + } + if (gmx_debug_at) + { + pr_block(debug, 0, "mols", &mtop->mols, TRUE); + } + } -static void do_mtop(t_fileio *fio, gmx_mtop_t *mtop,gmx_bool bRead, - int file_version) -{ - int mt,mb,i; - t_blocka dumb; - - if (bRead) - init_mtop(mtop); - do_symtab(fio, &(mtop->symtab),bRead); - if (bRead && debug) - pr_symtab(debug,0,"symtab",&mtop->symtab); - - do_symstr(fio, &(mtop->name),bRead,&(mtop->symtab)); - - if (file_version >= 57) { - do_ffparams(fio, &mtop->ffparams,bRead,file_version); - - gmx_fio_do_int(fio,mtop->nmoltype); - } else { - mtop->nmoltype = 1; - } - if (bRead) { - snew(mtop->moltype,mtop->nmoltype); - if (file_version < 57) { - mtop->moltype[0].name = mtop->name; - } - } - for(mt=0; mtnmoltype; mt++) { - do_moltype(fio, &mtop->moltype[mt],bRead,&mtop->symtab,file_version, - &mtop->groups); - } - - if (file_version >= 57) { - gmx_fio_do_int(fio,mtop->nmolblock); - } else { - mtop->nmolblock = 1; - } - if (bRead) { - snew(mtop->molblock,mtop->nmolblock); - } - if (file_version >= 57) { - for(mb=0; mbnmolblock; mb++) { - do_molblock(fio, &mtop->molblock[mb],bRead,file_version); - } - gmx_fio_do_int(fio,mtop->natoms); - } else { - mtop->molblock[0].type = 0; - mtop->molblock[0].nmol = 1; - mtop->molblock[0].natoms_mol = mtop->moltype[0].atoms.nr; - mtop->molblock[0].nposres_xA = 0; - mtop->molblock[0].nposres_xB = 0; - } - - do_atomtypes (fio, &(mtop->atomtypes),bRead,&(mtop->symtab), file_version); - if (bRead && debug) - pr_atomtypes(debug,0,"atomtypes",&mtop->atomtypes,TRUE); - - if (file_version < 57) { - /* Debug statements are inside do_idef */ - do_idef (fio, &mtop->ffparams,&mtop->moltype[0],bRead,file_version); - mtop->natoms = mtop->moltype[0].atoms.nr; - } - - if(file_version >= 65) - { - do_cmap(fio, &mtop->ffparams.cmap_grid,bRead); - } - else - { - mtop->ffparams.cmap_grid.ngrid = 0; - mtop->ffparams.cmap_grid.grid_spacing = 0; - mtop->ffparams.cmap_grid.cmapdata = NULL; - } - - if (file_version >= 57) { - do_groups(fio, &mtop->groups,bRead,&(mtop->symtab),file_version); - } - - if (file_version < 57) { - do_block(fio, &mtop->moltype[0].cgs,bRead,file_version); - if (bRead && gmx_debug_at) { - pr_block(debug,0,"cgs",&mtop->moltype[0].cgs,TRUE); - } - do_block(fio, &mtop->mols,bRead,file_version); - /* Add the posres coordinates to the molblock */ - add_posres_molblock(mtop); - } - if (bRead) { - if (file_version >= 57) { - mtop->mols = mtop_mols(mtop); - } - if (gmx_debug_at) { - pr_block(debug,0,"mols",&mtop->mols,TRUE); - } - } - - if (file_version < 51) { - /* Here used to be the shake blocks */ - do_blocka(fio, &dumb,bRead,file_version); - if (dumb.nr > 0) - sfree(dumb.index); - if (dumb.nra > 0) - sfree(dumb.a); - } - - if (bRead) { - close_symtab(&(mtop->symtab)); - } + if (file_version < 51) + { + /* Here used to be the shake blocks */ + do_blocka(fio, &dumb, bRead, file_version); + if (dumb.nr > 0) + { + sfree(dumb.index); + } + if (dumb.nra > 0) + { + sfree(dumb.a); + } + } + + if (bRead) + { + close_symtab(&(mtop->symtab)); + } } /* If TopOnlyOK is TRUE then we can read even future versions * of tpx files, provided the file_generation hasn't changed. * If it is FALSE, we need the inputrecord too, and bail out * if the file is newer than the program. - * + * * The version and generation if the topology (see top of this file) * are returned in the two last arguments. - * + * * If possible, we will read the inputrec even when TopOnlyOK is TRUE. */ -static void do_tpxheader(t_fileio *fio,gmx_bool bRead,t_tpxheader *tpx, - gmx_bool TopOnlyOK, int *file_version, +static void do_tpxheader(t_fileio *fio, gmx_bool bRead, t_tpxheader *tpx, + gmx_bool TopOnlyOK, int *file_version, int *file_generation) { - char buf[STRLEN]; - char file_tag[STRLEN]; - gmx_bool bDouble; - int precision; - int fver,fgen; - int idum=0; - real rdum=0; - - gmx_fio_checktype(fio); - gmx_fio_setdebug(fio,bDebugMode()); - - /* NEW! XDR tpb file */ - precision = sizeof(real); - if (bRead) { - 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"); - } - else { - gmx_fio_write_string(fio,GromacsVersion()); - bDouble = (precision == sizeof(double)); - gmx_fio_setprecision(fio,bDouble); - gmx_fio_do_int(fio,precision); - fver = tpx_version; - sprintf(file_tag,"%s",tpx_tag); - fgen = tpx_generation; - } - + char buf[STRLEN]; + char file_tag[STRLEN]; + gmx_bool bDouble; + int precision; + int fver, fgen; + int idum = 0; + real rdum = 0; + + gmx_fio_checktype(fio); + gmx_fio_setdebug(fio, bDebugMode()); + + /* NEW! XDR tpb file */ + precision = sizeof(real); + if (bRead) + { + 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"); + } + else + { + gmx_fio_write_string(fio, GromacsVersion()); + bDouble = (precision == sizeof(double)); + gmx_fio_setprecision(fio, bDouble); + gmx_fio_do_int(fio, precision); + fver = tpx_version; + sprintf(file_tag, "%s", tpx_tag); + fgen = tpx_generation; + } + /* Check versions! */ - gmx_fio_do_int(fio,fver); + gmx_fio_do_int(fio, fver); /* This is for backward compatibility with development versions 77-79 * where the tag was, mistakenly, placed before the generation, @@ -2505,43 +2954,43 @@ static void do_tpxheader(t_fileio *fio,gmx_bool bRead,t_tpxheader *tpx, */ if (fver >= 77 && fver <= 79) { - gmx_fio_do_string(fio,file_tag); + gmx_fio_do_string(fio, file_tag); } - + if (fver >= 26) { - gmx_fio_do_int(fio,fgen); + gmx_fio_do_int(fio, fgen); } else { fgen = 0; } - + if (fver >= 81) { - gmx_fio_do_string(fio,file_tag); + gmx_fio_do_string(fio, file_tag); } if (bRead) { if (fver < 77) { /* Versions before 77 don't have the tag, set it to release */ - sprintf(file_tag,"%s",TPX_TAG_RELEASE); + sprintf(file_tag, "%s", TPX_TAG_RELEASE); } - if (strcmp(file_tag,tpx_tag) != 0) + if (strcmp(file_tag, tpx_tag) != 0) { - fprintf(stderr,"Note: file tpx tag '%s', software tpx tag '%s'\n", - file_tag,tpx_tag); + fprintf(stderr, "Note: file tpx tag '%s', software tpx tag '%s'\n", + file_tag, tpx_tag); /* We only support reading tpx files with the same tag as the code * or tpx files with the release tag and with lower version number. */ - if (!strcmp(file_tag,TPX_TAG_RELEASE) == 0 && fver < tpx_version) + if (!strcmp(file_tag, TPX_TAG_RELEASE) == 0 && fver < tpx_version) { - gmx_fatal(FARGS,"tpx tag/version mismatch: reading tpx file (%s) version %d, tag '%s' with program for tpx version %d, tag '%s'", - gmx_fio_getname(fio),fver,file_tag, - tpx_version,tpx_tag); + gmx_fatal(FARGS, "tpx tag/version mismatch: reading tpx file (%s) version %d, tag '%s' with program for tpx version %d, tag '%s'", + gmx_fio_getname(fio), fver, file_tag, + tpx_version, tpx_tag); } } } @@ -2554,233 +3003,284 @@ static void do_tpxheader(t_fileio *fio,gmx_bool bRead,t_tpxheader *tpx, { *file_generation = fgen; } - - - if ((fver <= tpx_incompatible_version) || - ((fver > tpx_version) && !TopOnlyOK) || - (fgen > tpx_generation)) - gmx_fatal(FARGS,"reading tpx file (%s) version %d with version %d program", - gmx_fio_getname(fio),fver,tpx_version); - - do_section(fio,eitemHEADER,bRead); - gmx_fio_do_int(fio,tpx->natoms); - if (fver >= 28) - gmx_fio_do_int(fio,tpx->ngtc); - else - tpx->ngtc = 0; - if (fver < 62) { - gmx_fio_do_int(fio,idum); - gmx_fio_do_real(fio,rdum); - } - /*a better decision will eventually (5.0 or later) need to be made - on how to treat the alchemical state of the system, which can now - vary through a simulation, and cannot be completely described - though a single lambda variable, or even a single state - index. Eventually, should probably be a vector. MRS*/ - if (fver >= 79) - { - gmx_fio_do_int(fio,tpx->fep_state); - } - gmx_fio_do_real(fio,tpx->lambda); - gmx_fio_do_int(fio,tpx->bIr); - gmx_fio_do_int(fio,tpx->bTop); - gmx_fio_do_int(fio,tpx->bX); - gmx_fio_do_int(fio,tpx->bV); - gmx_fio_do_int(fio,tpx->bF); - gmx_fio_do_int(fio,tpx->bBox); - - if((fgen > tpx_generation)) { - /* This can only happen if TopOnlyOK=TRUE */ - tpx->bIr=FALSE; - } + + + if ((fver <= tpx_incompatible_version) || + ((fver > tpx_version) && !TopOnlyOK) || + (fgen > tpx_generation)) + { + gmx_fatal(FARGS, "reading tpx file (%s) version %d with version %d program", + gmx_fio_getname(fio), fver, tpx_version); + } + + do_section(fio, eitemHEADER, bRead); + gmx_fio_do_int(fio, tpx->natoms); + if (fver >= 28) + { + gmx_fio_do_int(fio, tpx->ngtc); + } + else + { + tpx->ngtc = 0; + } + if (fver < 62) + { + gmx_fio_do_int(fio, idum); + gmx_fio_do_real(fio, rdum); + } + /*a better decision will eventually (5.0 or later) need to be made + on how to treat the alchemical state of the system, which can now + vary through a simulation, and cannot be completely described + though a single lambda variable, or even a single state + index. Eventually, should probably be a vector. MRS*/ + if (fver >= 79) + { + gmx_fio_do_int(fio, tpx->fep_state); + } + gmx_fio_do_real(fio, tpx->lambda); + gmx_fio_do_int(fio, tpx->bIr); + gmx_fio_do_int(fio, tpx->bTop); + gmx_fio_do_int(fio, tpx->bX); + gmx_fio_do_int(fio, tpx->bV); + gmx_fio_do_int(fio, tpx->bF); + gmx_fio_do_int(fio, tpx->bBox); + + if ((fgen > tpx_generation)) + { + /* This can only happen if TopOnlyOK=TRUE */ + tpx->bIr = FALSE; + } } static int do_tpx(t_fileio *fio, gmx_bool bRead, - t_inputrec *ir,t_state *state,rvec *f,gmx_mtop_t *mtop, - gmx_bool bXVallocated) + t_inputrec *ir, t_state *state, rvec *f, gmx_mtop_t *mtop, + gmx_bool bXVallocated) { - t_tpxheader tpx; - t_inputrec dum_ir; - gmx_mtop_t dum_top; - gmx_bool TopOnlyOK,bDum=TRUE; - int file_version,file_generation; - int i; - rvec *xptr,*vptr; - int ePBC; - gmx_bool bPeriodicMols; - - if (!bRead) { - tpx.natoms = state->natoms; - tpx.ngtc = state->ngtc; /* need to add nnhpres here? */ - tpx.fep_state = state->fep_state; - tpx.lambda = state->lambda[efptFEP]; - tpx.bIr = (ir != NULL); - tpx.bTop = (mtop != NULL); - tpx.bX = (state->x != NULL); - tpx.bV = (state->v != NULL); - tpx.bF = (f != NULL); - tpx.bBox = TRUE; - } - - TopOnlyOK = (ir==NULL); - - do_tpxheader(fio,bRead,&tpx,TopOnlyOK,&file_version,&file_generation); - - if (bRead) { - state->flags = 0; - /* state->lambda = tpx.lambda;*/ /*remove this eventually? */ - /* The init_state calls initialize the Nose-Hoover xi integrals to zero */ - if (bXVallocated) { - xptr = state->x; - vptr = state->v; - init_state(state,0,tpx.ngtc,0,0,0); /* nose-hoover chains */ /* eventually, need to add nnhpres here? */ - state->natoms = tpx.natoms; - state->nalloc = tpx.natoms; - state->x = xptr; - state->v = vptr; - } else { - init_state(state,tpx.natoms,tpx.ngtc,0,0,0); /* nose-hoover chains */ - } - } - -#define do_test(fio,b,p) if (bRead && (p!=NULL) && !b) gmx_fatal(FARGS,"No %s in %s",#p,gmx_fio_getname(fio)) - - do_test(fio,tpx.bBox,state->box); - do_section(fio,eitemBOX,bRead); - if (tpx.bBox) { - gmx_fio_ndo_rvec(fio,state->box,DIM); - if (file_version >= 51) { - gmx_fio_ndo_rvec(fio,state->box_rel,DIM); - } else { - /* We initialize box_rel after reading the inputrec */ - clear_mat(state->box_rel); - } - if (file_version >= 28) { - gmx_fio_ndo_rvec(fio,state->boxv,DIM); - if (file_version < 56) { - matrix mdum; - gmx_fio_ndo_rvec(fio,mdum,DIM); - } - } - } - - if (state->ngtc > 0 && file_version >= 28) { - real *dumv; - /*ndo_double(state->nosehoover_xi,state->ngtc,bDum);*/ - /*ndo_double(state->nosehoover_vxi,state->ngtc,bDum);*/ - /*ndo_double(state->therm_integral,state->ngtc,bDum);*/ - snew(dumv,state->ngtc); - if (file_version < 69) { - bDum=gmx_fio_ndo_real(fio,dumv,state->ngtc); - } - /* These used to be the Berendsen tcoupl_lambda's */ - bDum=gmx_fio_ndo_real(fio,dumv,state->ngtc); - sfree(dumv); - } - - /* Prior to tpx version 26, the inputrec was here. - * I moved it to enable partial forward-compatibility - * for analysis/viewer programs. - */ - if(file_version<26) { - do_test(fio,tpx.bIr,ir); - do_section(fio,eitemIR,bRead); - if (tpx.bIr) { - if (ir) { - do_inputrec(fio, ir,bRead,file_version, - mtop ? &mtop->ffparams.fudgeQQ : NULL); - if (bRead && debug) - pr_inputrec(debug,0,"inputrec",ir,FALSE); - } - else { - do_inputrec(fio, &dum_ir,bRead,file_version, - mtop ? &mtop->ffparams.fudgeQQ :NULL); - if (bRead && debug) - pr_inputrec(debug,0,"inputrec",&dum_ir,FALSE); - done_inputrec(&dum_ir); - } - - } - } - - do_test(fio,tpx.bTop,mtop); - do_section(fio,eitemTOP,bRead); - if (tpx.bTop) { - int mtop_file_version = file_version; - /*allow reading of Gromacs 4.6 files*/ - if (mtop_file_version>80 && mtop_file_version<90) - { - mtop_file_version = 79; - } - if (mtop) { - do_mtop(fio,mtop,bRead, mtop_file_version); - } else { - do_mtop(fio,&dum_top,bRead,mtop_file_version); - done_mtop(&dum_top,TRUE); - } - } - do_test(fio,tpx.bX,state->x); - do_section(fio,eitemX,bRead); - if (tpx.bX) { - if (bRead) { - state->flags |= (1<x,state->natoms); - } - - do_test(fio,tpx.bV,state->v); - do_section(fio,eitemV,bRead); - if (tpx.bV) { - if (bRead) { - state->flags |= (1<v,state->natoms); - } - - do_test(fio,tpx.bF,f); - do_section(fio,eitemF,bRead); - if (tpx.bF) gmx_fio_ndo_rvec(fio,f,state->natoms); - - /* Starting with tpx version 26, we have the inputrec - * at the end of the file, so we can ignore it - * if the file is never than the software (but still the - * same generation - see comments at the top of this file. - * - * - */ - ePBC = -1; - bPeriodicMols = FALSE; - if (file_version >= 26) { - do_test(fio,tpx.bIr,ir); - do_section(fio,eitemIR,bRead); - if (tpx.bIr) { - if (file_version >= 53) { - /* Removed the pbc info from do_inputrec, since we always want it */ - if (!bRead) { - ePBC = ir->ePBC; - bPeriodicMols = ir->bPeriodicMols; - } - gmx_fio_do_int(fio,ePBC); - gmx_fio_do_gmx_bool(fio,bPeriodicMols); - } - if (file_generation <= tpx_generation && ir) { - do_inputrec(fio, ir,bRead,file_version,mtop ? &mtop->ffparams.fudgeQQ : NULL); - if (bRead && debug) - pr_inputrec(debug,0,"inputrec",ir,FALSE); - if (file_version < 51) - set_box_rel(ir,state); - if (file_version < 53) { - ePBC = ir->ePBC; - bPeriodicMols = ir->bPeriodicMols; - } - } - if (bRead && ir && file_version >= 53) { - /* We need to do this after do_inputrec, since that initializes ir */ - ir->ePBC = ePBC; - ir->bPeriodicMols = bPeriodicMols; - } - } - } + t_tpxheader tpx; + t_inputrec dum_ir; + gmx_mtop_t dum_top; + gmx_bool TopOnlyOK, bDum = TRUE; + int file_version, file_generation; + int i; + rvec *xptr, *vptr; + int ePBC; + gmx_bool bPeriodicMols; + + if (!bRead) + { + tpx.natoms = state->natoms; + tpx.ngtc = state->ngtc; /* need to add nnhpres here? */ + tpx.fep_state = state->fep_state; + tpx.lambda = state->lambda[efptFEP]; + tpx.bIr = (ir != NULL); + tpx.bTop = (mtop != NULL); + tpx.bX = (state->x != NULL); + tpx.bV = (state->v != NULL); + tpx.bF = (f != NULL); + tpx.bBox = TRUE; + } + + TopOnlyOK = (ir == NULL); + + do_tpxheader(fio, bRead, &tpx, TopOnlyOK, &file_version, &file_generation); + + if (bRead) + { + state->flags = 0; + /* state->lambda = tpx.lambda;*/ /*remove this eventually? */ + /* The init_state calls initialize the Nose-Hoover xi integrals to zero */ + if (bXVallocated) + { + xptr = state->x; + vptr = state->v; + init_state(state, 0, tpx.ngtc, 0, 0, 0); /* nose-hoover chains */ /* eventually, need to add nnhpres here? */ + state->natoms = tpx.natoms; + state->nalloc = tpx.natoms; + state->x = xptr; + state->v = vptr; + } + else + { + init_state(state, tpx.natoms, tpx.ngtc, 0, 0, 0); /* nose-hoover chains */ + } + } + +#define do_test(fio, b, p) if (bRead && (p != NULL) && !b) gmx_fatal(FARGS, "No %s in %s",#p, gmx_fio_getname(fio)) + + do_test(fio, tpx.bBox, state->box); + do_section(fio, eitemBOX, bRead); + if (tpx.bBox) + { + gmx_fio_ndo_rvec(fio, state->box, DIM); + if (file_version >= 51) + { + gmx_fio_ndo_rvec(fio, state->box_rel, DIM); + } + else + { + /* We initialize box_rel after reading the inputrec */ + clear_mat(state->box_rel); + } + if (file_version >= 28) + { + gmx_fio_ndo_rvec(fio, state->boxv, DIM); + if (file_version < 56) + { + matrix mdum; + gmx_fio_ndo_rvec(fio, mdum, DIM); + } + } + } + + if (state->ngtc > 0 && file_version >= 28) + { + real *dumv; + /*ndo_double(state->nosehoover_xi,state->ngtc,bDum);*/ + /*ndo_double(state->nosehoover_vxi,state->ngtc,bDum);*/ + /*ndo_double(state->therm_integral,state->ngtc,bDum);*/ + snew(dumv, state->ngtc); + if (file_version < 69) + { + bDum = gmx_fio_ndo_real(fio, dumv, state->ngtc); + } + /* These used to be the Berendsen tcoupl_lambda's */ + bDum = gmx_fio_ndo_real(fio, dumv, state->ngtc); + sfree(dumv); + } + + /* Prior to tpx version 26, the inputrec was here. + * I moved it to enable partial forward-compatibility + * for analysis/viewer programs. + */ + if (file_version < 26) + { + do_test(fio, tpx.bIr, ir); + do_section(fio, eitemIR, bRead); + if (tpx.bIr) + { + if (ir) + { + do_inputrec(fio, ir, bRead, file_version, + mtop ? &mtop->ffparams.fudgeQQ : NULL); + if (bRead && debug) + { + pr_inputrec(debug, 0, "inputrec", ir, FALSE); + } + } + else + { + do_inputrec(fio, &dum_ir, bRead, file_version, + mtop ? &mtop->ffparams.fudgeQQ : NULL); + if (bRead && debug) + { + pr_inputrec(debug, 0, "inputrec", &dum_ir, FALSE); + } + done_inputrec(&dum_ir); + } + + } + } + + do_test(fio, tpx.bTop, mtop); + do_section(fio, eitemTOP, bRead); + if (tpx.bTop) + { + int mtop_file_version = file_version; + /*allow reading of Gromacs 4.6 files*/ + if (mtop_file_version > 80 && mtop_file_version < 90) + { + mtop_file_version = 79; + } + if (mtop) + { + do_mtop(fio, mtop, bRead, mtop_file_version); + } + else + { + do_mtop(fio, &dum_top, bRead, mtop_file_version); + done_mtop(&dum_top, TRUE); + } + } + do_test(fio, tpx.bX, state->x); + do_section(fio, eitemX, bRead); + if (tpx.bX) + { + if (bRead) + { + state->flags |= (1<x, state->natoms); + } + + do_test(fio, tpx.bV, state->v); + do_section(fio, eitemV, bRead); + if (tpx.bV) + { + if (bRead) + { + state->flags |= (1<v, state->natoms); + } + + do_test(fio, tpx.bF, f); + do_section(fio, eitemF, bRead); + if (tpx.bF) + { + gmx_fio_ndo_rvec(fio, f, state->natoms); + } + + /* Starting with tpx version 26, we have the inputrec + * at the end of the file, so we can ignore it + * if the file is never than the software (but still the + * same generation - see comments at the top of this file. + * + * + */ + ePBC = -1; + bPeriodicMols = FALSE; + if (file_version >= 26) + { + do_test(fio, tpx.bIr, ir); + do_section(fio, eitemIR, bRead); + if (tpx.bIr) + { + if (file_version >= 53) + { + /* Removed the pbc info from do_inputrec, since we always want it */ + if (!bRead) + { + ePBC = ir->ePBC; + bPeriodicMols = ir->bPeriodicMols; + } + gmx_fio_do_int(fio, ePBC); + gmx_fio_do_gmx_bool(fio, bPeriodicMols); + } + if (file_generation <= tpx_generation && ir) + { + do_inputrec(fio, ir, bRead, file_version, mtop ? &mtop->ffparams.fudgeQQ : NULL); + if (bRead && debug) + { + pr_inputrec(debug, 0, "inputrec", ir, FALSE); + } + if (file_version < 51) + { + set_box_rel(ir, state); + } + if (file_version < 53) + { + ePBC = ir->ePBC; + bPeriodicMols = ir->bPeriodicMols; + } + } + if (bRead && ir && file_version >= 53) + { + /* We need to do this after do_inputrec, since that initializes ir */ + ir->ePBC = ePBC; + ir->bPeriodicMols = bPeriodicMols; + } + } + } if (bRead) { @@ -2789,7 +3289,7 @@ static int do_tpx(t_fileio *fio, gmx_bool bRead, if (state->ngtc == 0) { /* Reading old version without tcoupl state data: set it */ - init_gtc_state(state,ir->opts.ngtc,0,ir->opts.nhchainlength); + init_gtc_state(state, ir->opts.ngtc, 0, ir->opts.nhchainlength); } if (tpx.bTop && mtop) { @@ -2816,21 +3316,21 @@ static int do_tpx(t_fileio *fio, gmx_bool bRead, if (file_version >= 57) { char *env; - int ienv; + int ienv; env = getenv("GMX_NOCHARGEGROUPS"); if (env != NULL) { - sscanf(env,"%d",&ienv); - fprintf(stderr,"\nFound env.var. GMX_NOCHARGEGROUPS = %d\n", + sscanf(env, "%d", &ienv); + fprintf(stderr, "\nFound env.var. GMX_NOCHARGEGROUPS = %d\n", ienv); if (ienv > 0) { fprintf(stderr, "Will make single atomic charge groups in non-solvent%s\n", ienv > 1 ? " and solvent" : ""); - gmx_mtop_make_atomic_charge_groups(mtop,ienv==1); + gmx_mtop_make_atomic_charge_groups(mtop, ienv == 1); } - fprintf(stderr,"\n"); + fprintf(stderr, "\n"); } } } @@ -2844,156 +3344,173 @@ static int do_tpx(t_fileio *fio, gmx_bool bRead, * ************************************************************/ -t_fileio *open_tpx(const char *fn,const char *mode) +t_fileio *open_tpx(const char *fn, const char *mode) { - return gmx_fio_open(fn,mode); -} - + return gmx_fio_open(fn, mode); +} + void close_tpx(t_fileio *fio) { - gmx_fio_close(fio); + gmx_fio_close(fio); } void read_tpxheader(const char *fn, t_tpxheader *tpx, gmx_bool TopOnlyOK, int *file_version, int *file_generation) { - t_fileio *fio; + t_fileio *fio; - fio = open_tpx(fn,"r"); - do_tpxheader(fio,TRUE,tpx,TopOnlyOK,file_version,file_generation); - close_tpx(fio); + fio = open_tpx(fn, "r"); + do_tpxheader(fio, TRUE, tpx, TopOnlyOK, file_version, file_generation); + close_tpx(fio); } void write_tpx_state(const char *fn, - t_inputrec *ir,t_state *state,gmx_mtop_t *mtop) + t_inputrec *ir, t_state *state, gmx_mtop_t *mtop) { - t_fileio *fio; + t_fileio *fio; - fio = open_tpx(fn,"w"); - do_tpx(fio,FALSE,ir,state,NULL,mtop,FALSE); - close_tpx(fio); + fio = open_tpx(fn, "w"); + do_tpx(fio, FALSE, ir, state, NULL, mtop, FALSE); + close_tpx(fio); } void read_tpx_state(const char *fn, - t_inputrec *ir,t_state *state,rvec *f,gmx_mtop_t *mtop) + t_inputrec *ir, t_state *state, rvec *f, gmx_mtop_t *mtop) { - t_fileio *fio; - - fio = open_tpx(fn,"r"); - do_tpx(fio,TRUE,ir,state,f,mtop,FALSE); - close_tpx(fio); + t_fileio *fio; + + fio = open_tpx(fn, "r"); + do_tpx(fio, TRUE, ir, state, f, mtop, FALSE); + close_tpx(fio); } int read_tpx(const char *fn, - t_inputrec *ir, matrix box,int *natoms, - rvec *x,rvec *v,rvec *f,gmx_mtop_t *mtop) + t_inputrec *ir, matrix box, int *natoms, + rvec *x, rvec *v, rvec *f, gmx_mtop_t *mtop) { - t_fileio *fio; - t_state state; - int ePBC; - - state.x = x; - state.v = v; - fio = open_tpx(fn,"r"); - ePBC = do_tpx(fio,TRUE,ir,&state,f,mtop,TRUE); - close_tpx(fio); - *natoms = state.natoms; - if (box) - copy_mat(state.box,box); - state.x = NULL; - state.v = NULL; - done_state(&state); - - return ePBC; + t_fileio *fio; + t_state state; + int ePBC; + + state.x = x; + state.v = v; + fio = open_tpx(fn, "r"); + ePBC = do_tpx(fio, TRUE, ir, &state, f, mtop, TRUE); + close_tpx(fio); + *natoms = state.natoms; + if (box) + { + copy_mat(state.box, box); + } + state.x = NULL; + state.v = NULL; + done_state(&state); + + return ePBC; } int read_tpx_top(const char *fn, - t_inputrec *ir, matrix box,int *natoms, - rvec *x,rvec *v,rvec *f,t_topology *top) + t_inputrec *ir, matrix box, int *natoms, + rvec *x, rvec *v, rvec *f, t_topology *top) { - gmx_mtop_t mtop; - t_topology *ltop; - int ePBC; + gmx_mtop_t mtop; + t_topology *ltop; + int ePBC; - ePBC = read_tpx(fn,ir,box,natoms,x,v,f,&mtop); - - *top = gmx_mtop_t_to_t_topology(&mtop); + ePBC = read_tpx(fn, ir, box, natoms, x, v, f, &mtop); - return ePBC; + *top = gmx_mtop_t_to_t_topology(&mtop); + + return ePBC; } gmx_bool fn2bTPX(const char *file) { - switch (fn2ftp(file)) { - case efTPR: - case efTPB: - case efTPA: - return TRUE; - default: - return FALSE; - } + switch (fn2ftp(file)) + { + case efTPR: + case efTPB: + case efTPA: + return TRUE; + default: + return FALSE; + } } -gmx_bool read_tps_conf(const char *infile,char *title,t_topology *top,int *ePBC, - rvec **x,rvec **v,matrix box,gmx_bool bMass) +gmx_bool read_tps_conf(const char *infile, char *title, t_topology *top, int *ePBC, + rvec **x, rvec **v, matrix box, gmx_bool bMass) { - t_tpxheader header; - int natoms,i,version,generation; - gmx_bool bTop,bXNULL=FALSE; - gmx_mtop_t *mtop; - t_topology *topconv; - gmx_atomprop_t aps; - - bTop = fn2bTPX(infile); - *ePBC = -1; - if (bTop) { - read_tpxheader(infile,&header,TRUE,&version,&generation); - if (x) - snew(*x,header.natoms); - if (v) - snew(*v,header.natoms); - snew(mtop,1); - *ePBC = read_tpx(infile,NULL,box,&natoms, - (x==NULL) ? NULL : *x,(v==NULL) ? NULL : *v,NULL,mtop); - *top = gmx_mtop_t_to_t_topology(mtop); - sfree(mtop); - strcpy(title,*top->name); - tpx_make_chain_identifiers(&top->atoms,&top->mols); - } - else { - get_stx_coordnum(infile,&natoms); - init_t_atoms(&top->atoms,natoms,(fn2ftp(infile) == efPDB)); - if (x == NULL) - { - snew(x,1); - bXNULL = TRUE; - } - snew(*x,natoms); - if (v) - snew(*v,natoms); - read_stx_conf(infile,title,&top->atoms,*x,(v==NULL) ? NULL : *v,ePBC,box); - if (bXNULL) - { - sfree(*x); - sfree(x); - } - if (bMass) { - aps = gmx_atomprop_init(); - for(i=0; (iatoms.resinfo[top->atoms.atom[i].resind].name, - *top->atoms.atomname[i], - &(top->atoms.atom[i].m))) { - if (debug) - fprintf(debug,"Can not find mass for atom %s %d %s, setting to 1\n", - *top->atoms.resinfo[top->atoms.atom[i].resind].name, - top->atoms.resinfo[top->atoms.atom[i].resind].nr, - *top->atoms.atomname[i]); - } - gmx_atomprop_destroy(aps); - } - top->idef.ntypes=-1; - } - - return bTop; + t_tpxheader header; + int natoms, i, version, generation; + gmx_bool bTop, bXNULL = FALSE; + gmx_mtop_t *mtop; + t_topology *topconv; + gmx_atomprop_t aps; + + bTop = fn2bTPX(infile); + *ePBC = -1; + if (bTop) + { + read_tpxheader(infile, &header, TRUE, &version, &generation); + if (x) + { + snew(*x, header.natoms); + } + if (v) + { + snew(*v, header.natoms); + } + snew(mtop, 1); + *ePBC = read_tpx(infile, NULL, box, &natoms, + (x == NULL) ? NULL : *x, (v == NULL) ? NULL : *v, NULL, mtop); + *top = gmx_mtop_t_to_t_topology(mtop); + sfree(mtop); + strcpy(title, *top->name); + tpx_make_chain_identifiers(&top->atoms, &top->mols); + } + else + { + get_stx_coordnum(infile, &natoms); + init_t_atoms(&top->atoms, natoms, (fn2ftp(infile) == efPDB)); + if (x == NULL) + { + snew(x, 1); + bXNULL = TRUE; + } + snew(*x, natoms); + if (v) + { + snew(*v, natoms); + } + read_stx_conf(infile, title, &top->atoms, *x, (v == NULL) ? NULL : *v, ePBC, box); + if (bXNULL) + { + sfree(*x); + sfree(x); + } + if (bMass) + { + aps = gmx_atomprop_init(); + for (i = 0; (i < natoms); i++) + { + if (!gmx_atomprop_query(aps, epropMass, + *top->atoms.resinfo[top->atoms.atom[i].resind].name, + *top->atoms.atomname[i], + &(top->atoms.atom[i].m))) + { + if (debug) + { + fprintf(debug, "Can not find mass for atom %s %d %s, setting to 1\n", + *top->atoms.resinfo[top->atoms.atom[i].resind].name, + top->atoms.resinfo[top->atoms.atom[i].resind].nr, + *top->atoms.atomname[i]); + } + } + } + gmx_atomprop_destroy(aps); + } + top->idef.ntypes = -1; + } + + return bTop; } diff --git a/src/gromacs/gmxlib/trajana/displacement.c b/src/gromacs/gmxlib/trajana/displacement.c index 5fca218897..c169677966 100644 --- a/src/gromacs/gmxlib/trajana/displacement.c +++ b/src/gromacs/gmxlib/trajana/displacement.c @@ -84,7 +84,7 @@ typedef struct gmx_ana_displpos_t { /** Stored position vector. */ - rvec x; + rvec x; /** TRUE if there is something stored. */ gmx_bool bPres; } gmx_ana_displpos_t; @@ -105,13 +105,13 @@ struct gmx_ana_displ_t /** TRUE if no frames have been read. */ gmx_bool bFirst; /** Stores the time of the first frame. */ - real t0; + real t0; /** Stores the time interval between frames. */ - real dt; + real dt; /** Stores the time of the current frame. */ - real t; + real t; /** Stores the index in the store for the current positions. */ - int ci; + int ci; /** Maximum number of positions to store for a particle. */ int max_store; diff --git a/src/gromacs/gmxlib/trnio.c b/src/gromacs/gmxlib/trnio.c index 3cc7ef1d47..90bb016eec 100644 --- a/src/gromacs/gmxlib/trnio.c +++ b/src/gromacs/gmxlib/trnio.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -46,161 +46,214 @@ #include "trnio.h" #include "gmxfio.h" -#define BUFSIZE 128 +#define BUFSIZE 128 #define GROMACS_MAGIC 1993 static int nFloatSize(t_trnheader *sh) { - int nflsize=0; - - if (sh->box_size) - nflsize = sh->box_size/(DIM*DIM); - else if (sh->x_size) - nflsize = sh->x_size/(sh->natoms*DIM); - else if (sh->v_size) - nflsize = sh->v_size/(sh->natoms*DIM); - else if (sh->f_size) - nflsize = sh->f_size/(sh->natoms*DIM); - else - gmx_file("Can not determine precision of trn file"); - - if (((nflsize != sizeof(float)) && (nflsize != sizeof(double)))) - gmx_fatal(FARGS,"Float size %d. Maybe different CPU?",nflsize); - - return nflsize; + int nflsize = 0; + + if (sh->box_size) + { + nflsize = sh->box_size/(DIM*DIM); + } + else if (sh->x_size) + { + nflsize = sh->x_size/(sh->natoms*DIM); + } + else if (sh->v_size) + { + nflsize = sh->v_size/(sh->natoms*DIM); + } + else if (sh->f_size) + { + nflsize = sh->f_size/(sh->natoms*DIM); + } + else + { + gmx_file("Can not determine precision of trn file"); + } + + if (((nflsize != sizeof(float)) && (nflsize != sizeof(double)))) + { + gmx_fatal(FARGS, "Float size %d. Maybe different CPU?", nflsize); + } + + return nflsize; } -static gmx_bool do_trnheader(t_fileio *fio,gmx_bool bRead,t_trnheader *sh, gmx_bool *bOK) +static gmx_bool do_trnheader(t_fileio *fio, gmx_bool bRead, t_trnheader *sh, gmx_bool *bOK) { - int magic=GROMACS_MAGIC; - static gmx_bool bFirst=TRUE; - char buf[256]; - - *bOK=TRUE; - - gmx_fio_checktype(fio); - - if (!gmx_fio_do_int(fio,magic) || magic!=GROMACS_MAGIC) - return FALSE; - - if (bRead) { - *bOK = *bOK && gmx_fio_do_string(fio,buf); - if (bFirst) - fprintf(stderr,"trn version: %s ",buf); - } - else { - sprintf(buf,"GMX_trn_file"); - *bOK = *bOK && gmx_fio_do_string(fio,buf); - } - *bOK = *bOK && gmx_fio_do_int(fio,sh->ir_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->e_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->box_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->vir_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->pres_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->top_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->sym_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->x_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->v_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->f_size); - *bOK = *bOK && gmx_fio_do_int(fio,sh->natoms); - - if (!*bOK) return *bOK; - sh->bDouble = (nFloatSize(sh) == sizeof(double)); - gmx_fio_setprecision(fio,sh->bDouble); - - if (bRead && bFirst) { - fprintf(stderr,"(%s precision)\n",sh->bDouble ? "double" : "single"); - bFirst = FALSE; - } - - *bOK = *bOK && gmx_fio_do_int(fio,sh->step); - *bOK = *bOK && gmx_fio_do_int(fio,sh->nre); - *bOK = *bOK && gmx_fio_do_real(fio,sh->t); - *bOK = *bOK && gmx_fio_do_real(fio,sh->lambda); - - return *bOK; + int magic = GROMACS_MAGIC; + static gmx_bool bFirst = TRUE; + char buf[256]; + + *bOK = TRUE; + + gmx_fio_checktype(fio); + + if (!gmx_fio_do_int(fio, magic) || magic != GROMACS_MAGIC) + { + return FALSE; + } + + if (bRead) + { + *bOK = *bOK && gmx_fio_do_string(fio, buf); + if (bFirst) + { + fprintf(stderr, "trn version: %s ", buf); + } + } + else + { + sprintf(buf, "GMX_trn_file"); + *bOK = *bOK && gmx_fio_do_string(fio, buf); + } + *bOK = *bOK && gmx_fio_do_int(fio, sh->ir_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->e_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->box_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->vir_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->pres_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->top_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->sym_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->x_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->v_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->f_size); + *bOK = *bOK && gmx_fio_do_int(fio, sh->natoms); + + if (!*bOK) + { + return *bOK; + } + sh->bDouble = (nFloatSize(sh) == sizeof(double)); + gmx_fio_setprecision(fio, sh->bDouble); + + if (bRead && bFirst) + { + fprintf(stderr, "(%s precision)\n", sh->bDouble ? "double" : "single"); + bFirst = FALSE; + } + + *bOK = *bOK && gmx_fio_do_int(fio, sh->step); + *bOK = *bOK && gmx_fio_do_int(fio, sh->nre); + *bOK = *bOK && gmx_fio_do_real(fio, sh->t); + *bOK = *bOK && gmx_fio_do_real(fio, sh->lambda); + + return *bOK; } -void pr_trnheader(FILE *fp,int indent,char *title,t_trnheader *sh) +void pr_trnheader(FILE *fp, int indent, char *title, t_trnheader *sh) { - if (sh) { - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"box_size = %d\n",sh->box_size); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"x_size = %d\n",sh->x_size); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"v_size = %d\n",sh->v_size); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"f_size = %d\n",sh->f_size); - - (void) pr_indent(fp,indent); - (void) fprintf(fp,"natoms = %d\n",sh->natoms); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"step = %d\n",sh->step); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"t = %e\n",sh->t); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"lambda = %e\n",sh->lambda); - } + if (sh) + { + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "box_size = %d\n", sh->box_size); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "x_size = %d\n", sh->x_size); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "v_size = %d\n", sh->v_size); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "f_size = %d\n", sh->f_size); + + (void) pr_indent(fp, indent); + (void) fprintf(fp, "natoms = %d\n", sh->natoms); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "step = %d\n", sh->step); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "t = %e\n", sh->t); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "lambda = %e\n", sh->lambda); + } } -static gmx_bool do_htrn(t_fileio *fio,gmx_bool bRead,t_trnheader *sh, - rvec *box,rvec *x,rvec *v,rvec *f) +static gmx_bool do_htrn(t_fileio *fio, gmx_bool bRead, t_trnheader *sh, + rvec *box, rvec *x, rvec *v, rvec *f) { - matrix pv; - gmx_bool bOK; - - bOK = TRUE; - if (sh->box_size != 0) bOK = bOK && gmx_fio_ndo_rvec(fio,box,DIM); - if (sh->vir_size != 0) bOK = bOK && gmx_fio_ndo_rvec(fio,pv,DIM); - if (sh->pres_size!= 0) bOK = bOK && gmx_fio_ndo_rvec(fio,pv,DIM); - if (sh->x_size != 0) bOK = bOK && gmx_fio_ndo_rvec(fio,x,sh->natoms); - if (sh->v_size != 0) bOK = bOK && gmx_fio_ndo_rvec(fio,v,sh->natoms); - if (sh->f_size != 0) bOK = bOK && gmx_fio_ndo_rvec(fio,f,sh->natoms); - - return bOK; + matrix pv; + gmx_bool bOK; + + bOK = TRUE; + if (sh->box_size != 0) + { + bOK = bOK && gmx_fio_ndo_rvec(fio, box, DIM); + } + if (sh->vir_size != 0) + { + bOK = bOK && gmx_fio_ndo_rvec(fio, pv, DIM); + } + if (sh->pres_size != 0) + { + bOK = bOK && gmx_fio_ndo_rvec(fio, pv, DIM); + } + if (sh->x_size != 0) + { + bOK = bOK && gmx_fio_ndo_rvec(fio, x, sh->natoms); + } + if (sh->v_size != 0) + { + bOK = bOK && gmx_fio_ndo_rvec(fio, v, sh->natoms); + } + if (sh->f_size != 0) + { + bOK = bOK && gmx_fio_ndo_rvec(fio, f, sh->natoms); + } + + return bOK; } -static gmx_bool do_trn(t_fileio *fio,gmx_bool bRead,int *step,real *t,real *lambda, - rvec *box,int *natoms,rvec *x,rvec *v,rvec *f) +static gmx_bool do_trn(t_fileio *fio, gmx_bool bRead, int *step, real *t, real *lambda, + rvec *box, int *natoms, rvec *x, rvec *v, rvec *f) { - t_trnheader *sh; - gmx_bool bOK; - - snew(sh,1); - if (!bRead) { - sh->box_size=(box)?sizeof(matrix):0; - sh->x_size=((x)?(*natoms*sizeof(x[0])):0); - sh->v_size=((v)?(*natoms*sizeof(v[0])):0); - sh->f_size=((f)?(*natoms*sizeof(f[0])):0); - sh->natoms = *natoms; - sh->step = *step; - sh->nre = 0; - sh->t = *t; - sh->lambda = *lambda; - } - if (!do_trnheader(fio,bRead,sh,&bOK)) - return FALSE; - if (bRead) { - *natoms = sh->natoms; - *step = sh->step; - *t = sh->t; - *lambda = sh->lambda; - if (sh->ir_size) - gmx_file("inputrec in trn file"); - if (sh->e_size) - gmx_file("energies in trn file"); - if (sh->top_size) - gmx_file("topology in trn file"); - if (sh->sym_size) - gmx_file("symbol table in trn file"); - } - bOK = do_htrn(fio,bRead,sh,box,x,v,f); - - sfree(sh); - - return bOK; + t_trnheader *sh; + gmx_bool bOK; + + snew(sh, 1); + if (!bRead) + { + sh->box_size = (box) ? sizeof(matrix) : 0; + sh->x_size = ((x) ? (*natoms*sizeof(x[0])) : 0); + sh->v_size = ((v) ? (*natoms*sizeof(v[0])) : 0); + sh->f_size = ((f) ? (*natoms*sizeof(f[0])) : 0); + sh->natoms = *natoms; + sh->step = *step; + sh->nre = 0; + sh->t = *t; + sh->lambda = *lambda; + } + if (!do_trnheader(fio, bRead, sh, &bOK)) + { + return FALSE; + } + if (bRead) + { + *natoms = sh->natoms; + *step = sh->step; + *t = sh->t; + *lambda = sh->lambda; + if (sh->ir_size) + { + gmx_file("inputrec in trn file"); + } + if (sh->e_size) + { + gmx_file("energies in trn file"); + } + if (sh->top_size) + { + gmx_file("topology in trn file"); + } + if (sh->sym_size) + { + gmx_file("symbol table in trn file"); + } + } + bOK = do_htrn(fio, bRead, sh, box, x, v, f); + + sfree(sh); + + return bOK; } /************************************************************ @@ -208,71 +261,73 @@ static gmx_bool do_trn(t_fileio *fio,gmx_bool bRead,int *step,real *t,real *lamb * The following routines are the exported ones * ************************************************************/ - -void read_trnheader(const char *fn,t_trnheader *trn) + +void read_trnheader(const char *fn, t_trnheader *trn) { - t_fileio *fio; - gmx_bool bOK; - - fio = open_trn(fn,"r"); - if (!do_trnheader(fio,TRUE,trn,&bOK)) - gmx_fatal(FARGS,"Empty file %s",fn); - close_trn(fio); + t_fileio *fio; + gmx_bool bOK; + + fio = open_trn(fn, "r"); + if (!do_trnheader(fio, TRUE, trn, &bOK)) + { + gmx_fatal(FARGS, "Empty file %s", fn); + } + close_trn(fio); } -gmx_bool fread_trnheader(t_fileio *fio,t_trnheader *trn, gmx_bool *bOK) +gmx_bool fread_trnheader(t_fileio *fio, t_trnheader *trn, gmx_bool *bOK) { - return do_trnheader(fio,TRUE,trn,bOK); + return do_trnheader(fio, TRUE, trn, bOK); } -void write_trn(const char *fn,int step,real t,real lambda, - rvec *box,int natoms,rvec *x,rvec *v,rvec *f) +void write_trn(const char *fn, int step, real t, real lambda, + rvec *box, int natoms, rvec *x, rvec *v, rvec *f) { - t_fileio *fio; - - fio = open_trn(fn,"w"); - do_trn(fio,FALSE,&step,&t,&lambda,box,&natoms,x,v,f); - close_trn(fio); + t_fileio *fio; + + fio = open_trn(fn, "w"); + do_trn(fio, FALSE, &step, &t, &lambda, box, &natoms, x, v, f); + close_trn(fio); } -void read_trn(const char *fn,int *step,real *t,real *lambda, - rvec *box,int *natoms,rvec *x,rvec *v,rvec *f) +void read_trn(const char *fn, int *step, real *t, real *lambda, + rvec *box, int *natoms, rvec *x, rvec *v, rvec *f) { - t_fileio *fio; - - fio = open_trn(fn,"r"); - (void) do_trn(fio,TRUE,step,t,lambda,box,natoms,x,v,f); - close_trn(fio); + t_fileio *fio; + + fio = open_trn(fn, "r"); + (void) do_trn(fio, TRUE, step, t, lambda, box, natoms, x, v, f); + close_trn(fio); } -void fwrite_trn(t_fileio *fio,int step,real t,real lambda, - rvec *box,int natoms,rvec *x,rvec *v,rvec *f) +void fwrite_trn(t_fileio *fio, int step, real t, real lambda, + rvec *box, int natoms, rvec *x, rvec *v, rvec *f) { - if( do_trn(fio,FALSE,&step,&t,&lambda,box,&natoms,x,v,f) == FALSE) - { - gmx_file("Cannot write trajectory frame; maybe you are out of disk space?"); - } + if (do_trn(fio, FALSE, &step, &t, &lambda, box, &natoms, x, v, f) == FALSE) + { + gmx_file("Cannot write trajectory frame; maybe you are out of disk space?"); + } } -gmx_bool fread_trn(t_fileio *fio,int *step,real *t,real *lambda, - rvec *box,int *natoms,rvec *x,rvec *v,rvec *f) +gmx_bool fread_trn(t_fileio *fio, int *step, real *t, real *lambda, + rvec *box, int *natoms, rvec *x, rvec *v, rvec *f) { - return do_trn(fio,TRUE,step,t,lambda,box,natoms,x,v,f); + return do_trn(fio, TRUE, step, t, lambda, box, natoms, x, v, f); } -gmx_bool fread_htrn(t_fileio *fio,t_trnheader *trn,rvec *box,rvec *x,rvec *v, - rvec *f) +gmx_bool fread_htrn(t_fileio *fio, t_trnheader *trn, rvec *box, rvec *x, rvec *v, + rvec *f) { - return do_htrn(fio,TRUE,trn,box,x,v,f); + return do_htrn(fio, TRUE, trn, box, x, v, f); } -t_fileio *open_trn(const char *fn,const char *mode) +t_fileio *open_trn(const char *fn, const char *mode) { - return gmx_fio_open(fn,mode); + return gmx_fio_open(fn, mode); } void close_trn(t_fileio *fio) { - gmx_fio_close(fio); + gmx_fio_close(fio); } diff --git a/src/gromacs/gmxlib/trxio.c b/src/gromacs/gmxlib/trxio.c index 50d1ed0117..91ec7de1d5 100644 --- a/src/gromacs/gmxlib/trxio.c +++ b/src/gromacs/gmxlib/trxio.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 forxd * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -63,33 +63,35 @@ #define SKIP3 1000 /* Globals for gromos-87 input */ -typedef enum { effXYZ, effXYZBox, effG87, effG87Box, effNR } eFileFormat; +typedef enum { + effXYZ, effXYZBox, effG87, effG87Box, effNR +} eFileFormat; struct t_trxstatus { - int __frame; - t_trxframe *xframe; - int nxframe; - t_fileio *fio; - eFileFormat eFF; - int NATOMS; - double DT,BOX[3]; + int __frame; + t_trxframe *xframe; + int nxframe; + t_fileio *fio; + eFileFormat eFF; + int NATOMS; + double DT, BOX[3]; gmx_bool bReadBox; - char *persistent_line; /* Persistent line for reading g96 trajectories */ + char *persistent_line; /* Persistent line for reading g96 trajectories */ }; static void initcount(t_trxstatus *status) { - status->__frame=-1; + status->__frame = -1; } static void status_init(t_trxstatus *status) { - status->nxframe=0; - status->xframe=NULL; - status->fio=NULL; - status->__frame=-1; - status->persistent_line=NULL; + status->nxframe = 0; + status->xframe = NULL; + status->fio = NULL; + status->__frame = -1; + status->persistent_line = NULL; } @@ -99,44 +101,52 @@ int nframes_read(t_trxstatus *status) } static void printcount_(t_trxstatus *status, const output_env_t oenv, - const char *l,real t) + const char *l, real t) { - if ((status->__frame < 2*SKIP1 || status->__frame % SKIP1 == 0) && - (status->__frame < 2*SKIP2 || status->__frame % SKIP2 == 0) && - (status->__frame < 2*SKIP3 || status->__frame % SKIP3 == 0)) - fprintf(stderr,"\r%-14s %6d time %8.3f ",l,status->__frame, - output_env_conv_time(oenv,t)); + if ((status->__frame < 2*SKIP1 || status->__frame % SKIP1 == 0) && + (status->__frame < 2*SKIP2 || status->__frame % SKIP2 == 0) && + (status->__frame < 2*SKIP3 || status->__frame % SKIP3 == 0)) + { + fprintf(stderr, "\r%-14s %6d time %8.3f ", l, status->__frame, + output_env_conv_time(oenv, t)); + } } -static void printcount(t_trxstatus *status, const output_env_t oenv,real t, +static void printcount(t_trxstatus *status, const output_env_t oenv, real t, gmx_bool bSkip) { - status->__frame++; - printcount_(status, oenv,bSkip ? "Skipping frame" : "Reading frame",t); + status->__frame++; + printcount_(status, oenv, bSkip ? "Skipping frame" : "Reading frame", t); } -static void printlast(t_trxstatus *status, const output_env_t oenv,real t) +static void printlast(t_trxstatus *status, const output_env_t oenv, real t) { - printcount_(status, oenv,"Last frame",t); - fprintf(stderr,"\n"); + printcount_(status, oenv, "Last frame", t); + fprintf(stderr, "\n"); } static void printincomp(t_trxstatus *status, t_trxframe *fr) { - if (fr->not_ok & HEADER_NOT_OK) - fprintf(stderr,"WARNING: Incomplete header: nr %d time %g\n", - status->__frame+1,fr->time); - else if (fr->not_ok) - fprintf(stderr,"WARNING: Incomplete frame: nr %d time %g\n", - status->__frame+1,fr->time); + if (fr->not_ok & HEADER_NOT_OK) + { + fprintf(stderr, "WARNING: Incomplete header: nr %d time %g\n", + status->__frame+1, fr->time); + } + else if (fr->not_ok) + { + fprintf(stderr, "WARNING: Incomplete frame: nr %d time %g\n", + status->__frame+1, fr->time); + } } int prec2ndec(real prec) { - if (prec <= 0) - gmx_fatal(FARGS,"DEATH HORROR prec (%g) <= 0 in prec2ndec",prec); - - return (int)(log(prec)/log(10.0)+0.5); + if (prec <= 0) + { + gmx_fatal(FARGS, "DEATH HORROR prec (%g) <= 0 in prec2ndec", prec); + } + + return (int)(log(prec)/log(10.0)+0.5); } @@ -147,793 +157,940 @@ t_fileio *trx_get_fileio(t_trxstatus *status) -void clear_trxframe(t_trxframe *fr,gmx_bool bFirst) +void clear_trxframe(t_trxframe *fr, gmx_bool bFirst) { - fr->not_ok = 0; - fr->bTitle = FALSE; - fr->bStep = FALSE; - fr->bTime = FALSE; - fr->bLambda = FALSE; - fr->bAtoms = FALSE; - fr->bPrec = FALSE; - fr->bX = FALSE; - fr->bV = FALSE; - fr->bF = FALSE; - fr->bBox = FALSE; - if (bFirst) { - fr->flags = 0; - fr->bDouble= FALSE; - fr->natoms = -1; - fr->t0 = 0; - fr->tpf = 0; - fr->tppf = 0; - fr->title = NULL; - fr->step = 0; - fr->time = 0; - fr->lambda = 0; - fr->atoms = NULL; - fr->prec = 0; - fr->x = NULL; - fr->v = NULL; - fr->f = NULL; - clear_mat(fr->box); - fr->bPBC = FALSE; - fr->ePBC = -1; - } + fr->not_ok = 0; + fr->bTitle = FALSE; + fr->bStep = FALSE; + fr->bTime = FALSE; + fr->bLambda = FALSE; + fr->bAtoms = FALSE; + fr->bPrec = FALSE; + fr->bX = FALSE; + fr->bV = FALSE; + fr->bF = FALSE; + fr->bBox = FALSE; + if (bFirst) + { + fr->flags = 0; + fr->bDouble = FALSE; + fr->natoms = -1; + fr->t0 = 0; + fr->tpf = 0; + fr->tppf = 0; + fr->title = NULL; + fr->step = 0; + fr->time = 0; + fr->lambda = 0; + fr->atoms = NULL; + fr->prec = 0; + fr->x = NULL; + fr->v = NULL; + fr->f = NULL; + clear_mat(fr->box); + fr->bPBC = FALSE; + fr->ePBC = -1; + } } -void set_trxframe_ePBC(t_trxframe *fr,int ePBC) +void set_trxframe_ePBC(t_trxframe *fr, int ePBC) { - fr->bPBC = (ePBC == -1); - fr->ePBC = ePBC; + fr->bPBC = (ePBC == -1); + fr->ePBC = ePBC; } -int write_trxframe_indexed(t_trxstatus *status,t_trxframe *fr,int nind, +int write_trxframe_indexed(t_trxstatus *status, t_trxframe *fr, int nind, const atom_id *ind, gmx_conect gc) { - char title[STRLEN]; - rvec *xout=NULL,*vout=NULL,*fout=NULL; - int i; - real prec; - - if (fr->bPrec) - prec = fr->prec; - else - prec = 1000.0; - - switch (gmx_fio_getftp(status->fio)) { - case efTRJ: - case efTRR: - break; - default: - if (!fr->bX) - gmx_fatal(FARGS,"Need coordinates to write a %s trajectory", - ftp2ext(gmx_fio_getftp(status->fio))); - break; - } - - switch (gmx_fio_getftp(status->fio)) { - case efTRJ: - case efTRR: - if (fr->bV) { - snew(vout,nind); - for(i=0; iv[ind[i]],vout[i]); - } - if (fr->bF) { - snew(fout,nind); - for(i=0; if[ind[i]],fout[i]); - } - /* no break */ - case efXTC: - case efG87: - if (fr->bX) { - snew(xout,nind); - for(i=0; ix[ind[i]],xout[i]); - } - break; - default: - break; - } - - switch (gmx_fio_getftp(status->fio)) { - case efXTC: - write_xtc(status->fio,nind,fr->step,fr->time,fr->box,xout,prec); - break; - case efTRJ: - case efTRR: - fwrite_trn(status->fio,nframes_read(status), - fr->time,fr->step,fr->box,nind,xout,vout,fout); - break; - case efGRO: - case efPDB: - case efBRK: - case efENT: - if (!fr->bAtoms) - gmx_fatal(FARGS,"Can not write a %s file without atom names", - ftp2ext(gmx_fio_getftp(status->fio))); - sprintf(title,"frame t= %.3f",fr->time); - if (gmx_fio_getftp(status->fio) == efGRO) - write_hconf_indexed_p(gmx_fio_getfp(status->fio),title,fr->atoms,nind,ind, - prec2ndec(prec), - fr->x,fr->bV ? fr->v : NULL,fr->box); + char title[STRLEN]; + rvec *xout = NULL, *vout = NULL, *fout = NULL; + int i; + real prec; + + if (fr->bPrec) + { + prec = fr->prec; + } else - write_pdbfile_indexed(gmx_fio_getfp(status->fio),title,fr->atoms, - fr->x,-1,fr->box,' ',fr->step,nind,ind,gc,TRUE); - break; - case efG87: - write_gms(gmx_fio_getfp(status->fio),nind,xout,fr->box); - break; - case efG96: - write_g96_conf(gmx_fio_getfp(status->fio),fr,nind,ind); - break; - default: - gmx_fatal(FARGS,"Sorry, write_trxframe_indexed can not write %s", - ftp2ext(gmx_fio_getftp(status->fio))); - break; - } - - switch (gmx_fio_getftp(status->fio)) { - case efTRN: - case efTRJ: - case efTRR: - if (vout) sfree(vout); - if (fout) sfree(fout); - /* no break */ - case efXTC: - case efG87: - sfree(xout); - break; - default: - break; - } - - return 0; + { + prec = 1000.0; + } + + switch (gmx_fio_getftp(status->fio)) + { + case efTRJ: + case efTRR: + break; + default: + if (!fr->bX) + { + gmx_fatal(FARGS, "Need coordinates to write a %s trajectory", + ftp2ext(gmx_fio_getftp(status->fio))); + } + break; + } + + switch (gmx_fio_getftp(status->fio)) + { + case efTRJ: + case efTRR: + if (fr->bV) + { + snew(vout, nind); + for (i = 0; i < nind; i++) + { + copy_rvec(fr->v[ind[i]], vout[i]); + } + } + if (fr->bF) + { + snew(fout, nind); + for (i = 0; i < nind; i++) + { + copy_rvec(fr->f[ind[i]], fout[i]); + } + } + /* no break */ + case efXTC: + case efG87: + if (fr->bX) + { + snew(xout, nind); + for (i = 0; i < nind; i++) + { + copy_rvec(fr->x[ind[i]], xout[i]); + } + } + break; + default: + break; + } + + switch (gmx_fio_getftp(status->fio)) + { + case efXTC: + write_xtc(status->fio, nind, fr->step, fr->time, fr->box, xout, prec); + break; + case efTRJ: + case efTRR: + fwrite_trn(status->fio, nframes_read(status), + fr->time, fr->step, fr->box, nind, xout, vout, fout); + break; + case efGRO: + case efPDB: + case efBRK: + case efENT: + if (!fr->bAtoms) + { + gmx_fatal(FARGS, "Can not write a %s file without atom names", + ftp2ext(gmx_fio_getftp(status->fio))); + } + sprintf(title, "frame t= %.3f", fr->time); + if (gmx_fio_getftp(status->fio) == efGRO) + { + write_hconf_indexed_p(gmx_fio_getfp(status->fio), title, fr->atoms, nind, ind, + prec2ndec(prec), + fr->x, fr->bV ? fr->v : NULL, fr->box); + } + else + { + write_pdbfile_indexed(gmx_fio_getfp(status->fio), title, fr->atoms, + fr->x, -1, fr->box, ' ', fr->step, nind, ind, gc, TRUE); + } + break; + case efG87: + write_gms(gmx_fio_getfp(status->fio), nind, xout, fr->box); + break; + case efG96: + write_g96_conf(gmx_fio_getfp(status->fio), fr, nind, ind); + break; + default: + gmx_fatal(FARGS, "Sorry, write_trxframe_indexed can not write %s", + ftp2ext(gmx_fio_getftp(status->fio))); + break; + } + + switch (gmx_fio_getftp(status->fio)) + { + case efTRN: + case efTRJ: + case efTRR: + if (vout) + { + sfree(vout); + } + if (fout) + { + sfree(fout); + } + /* no break */ + case efXTC: + case efG87: + sfree(xout); + break; + default: + break; + } + + return 0; } -int write_trxframe(t_trxstatus *status,t_trxframe *fr,gmx_conect gc) +int write_trxframe(t_trxstatus *status, t_trxframe *fr, gmx_conect gc) { - char title[STRLEN]; - real prec; - - if (fr->bPrec) - prec = fr->prec; - else - prec = 1000.0; - - switch (gmx_fio_getftp(status->fio)) { - case efTRJ: - case efTRR: - break; - default: - if (!fr->bX) - gmx_fatal(FARGS,"Need coordinates to write a %s trajectory", - ftp2ext(gmx_fio_getftp(status->fio))); - break; - } - - switch (gmx_fio_getftp(status->fio)) { - case efXTC: - write_xtc(status->fio,fr->natoms,fr->step,fr->time,fr->box,fr->x,prec); - break; - case efTRJ: - case efTRR: - fwrite_trn(status->fio,fr->step,fr->time,fr->lambda,fr->box,fr->natoms, - fr->bX ? fr->x:NULL,fr->bV ? fr->v:NULL ,fr->bF ? fr->f:NULL); - break; - case efGRO: - case efPDB: - case efBRK: - case efENT: - if (!fr->bAtoms) - gmx_fatal(FARGS,"Can not write a %s file without atom names", - ftp2ext(gmx_fio_getftp(status->fio))); - sprintf(title,"frame t= %.3f",fr->time); - if (gmx_fio_getftp(status->fio) == efGRO) - write_hconf_p(gmx_fio_getfp(status->fio),title,fr->atoms, - prec2ndec(prec),fr->x,fr->bV ? fr->v : NULL,fr->box); + char title[STRLEN]; + real prec; + + if (fr->bPrec) + { + prec = fr->prec; + } else - write_pdbfile(gmx_fio_getfp(status->fio),title, - fr->atoms,fr->x,fr->bPBC ? fr->ePBC : -1,fr->box, - ' ',fr->step,gc,TRUE); - break; - case efG87: - write_gms(gmx_fio_getfp(status->fio),fr->natoms,fr->x,fr->box); - break; - case efG96: - write_g96_conf(gmx_fio_getfp(status->fio),fr,-1,NULL); - break; - default: - gmx_fatal(FARGS,"Sorry, write_trxframe can not write %s", - ftp2ext(gmx_fio_getftp(status->fio))); - break; - } - - return 0; + { + prec = 1000.0; + } + + switch (gmx_fio_getftp(status->fio)) + { + case efTRJ: + case efTRR: + break; + default: + if (!fr->bX) + { + gmx_fatal(FARGS, "Need coordinates to write a %s trajectory", + ftp2ext(gmx_fio_getftp(status->fio))); + } + break; + } + + switch (gmx_fio_getftp(status->fio)) + { + case efXTC: + write_xtc(status->fio, fr->natoms, fr->step, fr->time, fr->box, fr->x, prec); + break; + case efTRJ: + case efTRR: + fwrite_trn(status->fio, fr->step, fr->time, fr->lambda, fr->box, fr->natoms, + fr->bX ? fr->x : NULL, fr->bV ? fr->v : NULL, fr->bF ? fr->f : NULL); + break; + case efGRO: + case efPDB: + case efBRK: + case efENT: + if (!fr->bAtoms) + { + gmx_fatal(FARGS, "Can not write a %s file without atom names", + ftp2ext(gmx_fio_getftp(status->fio))); + } + sprintf(title, "frame t= %.3f", fr->time); + if (gmx_fio_getftp(status->fio) == efGRO) + { + write_hconf_p(gmx_fio_getfp(status->fio), title, fr->atoms, + prec2ndec(prec), fr->x, fr->bV ? fr->v : NULL, fr->box); + } + else + { + write_pdbfile(gmx_fio_getfp(status->fio), title, + fr->atoms, fr->x, fr->bPBC ? fr->ePBC : -1, fr->box, + ' ', fr->step, gc, TRUE); + } + break; + case efG87: + write_gms(gmx_fio_getfp(status->fio), fr->natoms, fr->x, fr->box); + break; + case efG96: + write_g96_conf(gmx_fio_getfp(status->fio), fr, -1, NULL); + break; + default: + gmx_fatal(FARGS, "Sorry, write_trxframe can not write %s", + ftp2ext(gmx_fio_getftp(status->fio))); + break; + } + + return 0; } -int write_trx(t_trxstatus *status,int nind,const atom_id *ind,t_atoms *atoms, - int step,real time,matrix box,rvec x[],rvec *v, - gmx_conect gc) +int write_trx(t_trxstatus *status, int nind, const atom_id *ind, t_atoms *atoms, + int step, real time, matrix box, rvec x[], rvec *v, + gmx_conect gc) { - t_trxframe fr; - - clear_trxframe(&fr,TRUE); - fr.bStep = TRUE; - fr.step = step; - fr.bTime = TRUE; - fr.time = time; - fr.bAtoms = atoms!=NULL; - fr.atoms = atoms; - fr.bX = TRUE; - fr.x = x; - fr.bV = v!=NULL; - fr.v = v; - fr.bBox = TRUE; - copy_mat(box,fr.box); - - return write_trxframe_indexed(status,&fr,nind,ind,gc); + t_trxframe fr; + + clear_trxframe(&fr, TRUE); + fr.bStep = TRUE; + fr.step = step; + fr.bTime = TRUE; + fr.time = time; + fr.bAtoms = atoms != NULL; + fr.atoms = atoms; + fr.bX = TRUE; + fr.x = x; + fr.bV = v != NULL; + fr.v = v; + fr.bBox = TRUE; + copy_mat(box, fr.box); + + return write_trxframe_indexed(status, &fr, nind, ind, gc); } void close_trx(t_trxstatus *status) { - gmx_fio_close(status->fio); - sfree(status); + gmx_fio_close(status->fio); + sfree(status); } -t_trxstatus *open_trx(const char *outfile,const char *filemode) +t_trxstatus *open_trx(const char *outfile, const char *filemode) { t_trxstatus *stat; - if (filemode[0]!='w' && filemode[0]!='a' && filemode[1]!='+') - gmx_fatal(FARGS,"Sorry, write_trx can only write"); + if (filemode[0] != 'w' && filemode[0] != 'a' && filemode[1] != '+') + { + gmx_fatal(FARGS, "Sorry, write_trx can only write"); + } - snew(stat,1); + snew(stat, 1); status_init(stat); - stat->fio=gmx_fio_open(outfile,filemode); + stat->fio = gmx_fio_open(outfile, filemode); return stat; } -static gmx_bool gmx_next_frame(t_trxstatus *status,t_trxframe *fr) +static gmx_bool gmx_next_frame(t_trxstatus *status, t_trxframe *fr) { - t_trnheader sh; - gmx_bool bOK,bRet; - - bRet = FALSE; - - if (fread_trnheader(status->fio,&sh,&bOK)) { - fr->bDouble=sh.bDouble; - fr->natoms=sh.natoms; - fr->bStep=TRUE; - fr->step=sh.step; - fr->bTime=TRUE; - fr->time=sh.t; - fr->bLambda = TRUE; - fr->bFepState = TRUE; - fr->lambda = sh.lambda; - fr->bBox = sh.box_size>0; - if (fr->flags & (TRX_READ_X | TRX_NEED_X)) { - if (fr->x==NULL) - snew(fr->x,sh.natoms); - fr->bX = sh.x_size>0; - } - if (fr->flags & (TRX_READ_V | TRX_NEED_V)) { - if (fr->v==NULL) - snew(fr->v,sh.natoms); - fr->bV = sh.v_size>0; - } - if (fr->flags & (TRX_READ_F | TRX_NEED_F)) { - if (fr->f==NULL) - snew(fr->f,sh.natoms); - fr->bF = sh.f_size>0; - } - if (fread_htrn(status->fio,&sh,fr->box,fr->x,fr->v,fr->f)) - bRet = TRUE; + t_trnheader sh; + gmx_bool bOK, bRet; + + bRet = FALSE; + + if (fread_trnheader(status->fio, &sh, &bOK)) + { + fr->bDouble = sh.bDouble; + fr->natoms = sh.natoms; + fr->bStep = TRUE; + fr->step = sh.step; + fr->bTime = TRUE; + fr->time = sh.t; + fr->bLambda = TRUE; + fr->bFepState = TRUE; + fr->lambda = sh.lambda; + fr->bBox = sh.box_size > 0; + if (fr->flags & (TRX_READ_X | TRX_NEED_X)) + { + if (fr->x == NULL) + { + snew(fr->x, sh.natoms); + } + fr->bX = sh.x_size > 0; + } + if (fr->flags & (TRX_READ_V | TRX_NEED_V)) + { + if (fr->v == NULL) + { + snew(fr->v, sh.natoms); + } + fr->bV = sh.v_size > 0; + } + if (fr->flags & (TRX_READ_F | TRX_NEED_F)) + { + if (fr->f == NULL) + { + snew(fr->f, sh.natoms); + } + fr->bF = sh.f_size > 0; + } + if (fread_htrn(status->fio, &sh, fr->box, fr->x, fr->v, fr->f)) + { + bRet = TRUE; + } + else + { + fr->not_ok = DATA_NOT_OK; + } + } else - fr->not_ok = DATA_NOT_OK; - } else if (!bOK) - fr->not_ok = HEADER_NOT_OK; + { + fr->not_ok = HEADER_NOT_OK; + } - return bRet; + return bRet; } static void choose_file_format(FILE *fp) { - int i,m,c; - int rc; - eFileFormat eFF; - t_trxstatus *stat; - - printf("\n\n"); - printf(" Select File Format\n"); - printf("---------------------------\n"); - printf("1. XYZ File\n"); - printf("2. XYZ File with Box\n"); - printf("3. Gromos-87 Ascii Trajectory\n"); - printf("4. Gromos-87 Ascii Trajectory with Box\n"); - - snew(stat,1); - status_init(stat); - - do { - printf("\nChoice: "); - fflush(stdout); + int i, m, c; + int rc; + eFileFormat eFF; + t_trxstatus *stat; + + printf("\n\n"); + printf(" Select File Format\n"); + printf("---------------------------\n"); + printf("1. XYZ File\n"); + printf("2. XYZ File with Box\n"); + printf("3. Gromos-87 Ascii Trajectory\n"); + printf("4. Gromos-87 Ascii Trajectory with Box\n"); + + snew(stat, 1); + status_init(stat); + do { - rc = scanf("%d",&i); + printf("\nChoice: "); + fflush(stdout); + do + { + rc = scanf("%d", &i); + } + while (rc != 1); + i--; } - while (rc!=1); - i--; - } while ((i < 0) || (i >= effNR)); - printf("\n"); - - stat->eFF = (eFileFormat) i; + while ((i < 0) || (i >= effNR)); + printf("\n"); - for(m=0; (mBOX[m]=0; - - stat->bReadBox = (stat->eFF == effG87Box) || (stat->eFF == effXYZBox); - - switch (stat->eFF) { - case effXYZ: - case effXYZBox: - if( 5 != fscanf(fp,"%d%lf%lf%lf%lf",&stat->NATOMS,&stat->BOX[XX],&stat->BOX[YY],&stat->BOX[ZZ],&stat->DT)) - { - gmx_fatal(FARGS,"Error reading natoms/box in file"); - } - break; - case effG87: - case effG87Box: - printf("GROMOS! OH DEAR...\n\n"); - printf("Number of atoms ? "); - fflush(stdout); - if (1 != scanf("%d",&stat->NATOMS)) + stat->eFF = (eFileFormat) i; + + for (m = 0; (m < DIM); m++) { - gmx_fatal(FARGS,"Error reading natoms in file"); + stat->BOX[m] = 0; } - printf("Time between timeframes ? "); - fflush(stdout); - if( 1 != scanf("%lf",&stat->DT)) + stat->bReadBox = (stat->eFF == effG87Box) || (stat->eFF == effXYZBox); + + switch (stat->eFF) { - gmx_fatal(FARGS,"Error reading dt from file"); - } + case effXYZ: + case effXYZBox: + if (5 != fscanf(fp, "%d%lf%lf%lf%lf", &stat->NATOMS, &stat->BOX[XX], &stat->BOX[YY], &stat->BOX[ZZ], &stat->DT)) + { + gmx_fatal(FARGS, "Error reading natoms/box in file"); + } + break; + case effG87: + case effG87Box: + printf("GROMOS! OH DEAR...\n\n"); + printf("Number of atoms ? "); + fflush(stdout); + if (1 != scanf("%d", &stat->NATOMS)) + { + gmx_fatal(FARGS, "Error reading natoms in file"); + } + + printf("Time between timeframes ? "); + fflush(stdout); + if (1 != scanf("%lf", &stat->DT)) + { + gmx_fatal(FARGS, "Error reading dt from file"); + } - if (stat->eFF == effG87) { - printf("Box X Y Z ? "); - fflush(stdout); - if(3 != scanf("%lf%lf%lf",&stat->BOX[XX],&stat->BOX[YY],&stat->BOX[ZZ])) - { - gmx_fatal(FARGS,"Error reading box in file"); - } + if (stat->eFF == effG87) + { + printf("Box X Y Z ? "); + fflush(stdout); + if (3 != scanf("%lf%lf%lf", &stat->BOX[XX], &stat->BOX[YY], &stat->BOX[ZZ])) + { + gmx_fatal(FARGS, "Error reading box in file"); + } + } + do + { + c = fgetc(fp); + printf("%c", c); + } + while (c != '\n'); + printf("\n"); + fflush(stdout); + break; + default: + printf("Hellow World\n"); } - do { - c=fgetc(fp); - printf("%c",c); - } while (c != '\n'); - printf("\n"); - fflush(stdout); - break; - default: - printf("Hellow World\n"); - } } -static gmx_bool do_read_xyz(t_trxstatus *status, FILE *fp,int natoms, - rvec x[],matrix box) +static gmx_bool do_read_xyz(t_trxstatus *status, FILE *fp, int natoms, + rvec x[], matrix box) { - int i,m; - double x0; - - for(i=0; (ibReadBox) { - for(m=0; (mbReadBox) + { + for (m = 0; (m < DIM); m++) + { + if (fscanf(fp, "%lf", &x0) != 1) + { + return FALSE; + } + box[m][m] = x0; + } + } + return TRUE; } static gmx_bool xyz_next_x(t_trxstatus *status, FILE *fp, const output_env_t oenv, - real *t, int natoms, rvec x[], matrix box) - /* Reads until a new x can be found (return TRUE) - * or eof (return FALSE) - */ + real *t, int natoms, rvec x[], matrix box) +/* Reads until a new x can be found (return TRUE) + * or eof (return FALSE) + */ { - real pt; - - pt=*t; - while (!bTimeSet(TBEGIN) || (*t < rTimeValue(TBEGIN))) { - if (!do_read_xyz(status,fp,natoms,x,box)) - return FALSE; - printcount(status,oenv,*t,FALSE); - *t+=status->DT; - pt=*t; - } - if (!bTimeSet(TEND) || (*t <= rTimeValue(TEND))) { - if (!do_read_xyz(status,fp,natoms,x,box)) { - printlast(status, oenv,*t); - return FALSE; - } - printcount(status,oenv,*t,FALSE); - pt=*t; - *t+=status->DT; - return TRUE; - } - printlast(status,oenv,pt); - return FALSE; + real pt; + + pt = *t; + while (!bTimeSet(TBEGIN) || (*t < rTimeValue(TBEGIN))) + { + if (!do_read_xyz(status, fp, natoms, x, box)) + { + return FALSE; + } + printcount(status, oenv, *t, FALSE); + *t += status->DT; + pt = *t; + } + if (!bTimeSet(TEND) || (*t <= rTimeValue(TEND))) + { + if (!do_read_xyz(status, fp, natoms, x, box)) + { + printlast(status, oenv, *t); + return FALSE; + } + printcount(status, oenv, *t, FALSE); + pt = *t; + *t += status->DT; + return TRUE; + } + printlast(status, oenv, pt); + return FALSE; } -static int xyz_first_x(t_trxstatus *status, FILE *fp, const output_env_t oenv, +static int xyz_first_x(t_trxstatus *status, FILE *fp, const output_env_t oenv, real *t, rvec **x, matrix box) /* Reads fp, mallocs x, and returns x and box * Returns natoms when successful, FALSE otherwise */ { - int m; - - initcount(status); + int m; - clear_mat(box); - choose_file_format(fp); + initcount(status); - for(m=0; (mBOX[m]; + clear_mat(box); + choose_file_format(fp); - snew(*x,status->NATOMS); - *t=status->DT; - if (!xyz_next_x(status, fp,oenv,t,status->NATOMS,*x,box)) - return 0; - *t=0.0; - - return status->NATOMS; + for (m = 0; (m < DIM); m++) + { + box[m][m] = status->BOX[m]; + } + + snew(*x, status->NATOMS); + *t = status->DT; + if (!xyz_next_x(status, fp, oenv, t, status->NATOMS, *x, box)) + { + return 0; + } + *t = 0.0; + + return status->NATOMS; } -static gmx_bool pdb_next_x(t_trxstatus *status, FILE *fp,t_trxframe *fr) +static gmx_bool pdb_next_x(t_trxstatus *status, FILE *fp, t_trxframe *fr) { - t_atoms atoms; - matrix boxpdb; - int ePBC,model_nr,na; - char title[STRLEN],*time; - double dbl; - - atoms.nr = fr->natoms; - atoms.atom=NULL; - atoms.pdbinfo=NULL; - /* the other pointers in atoms should not be accessed if these are NULL */ - model_nr=NOTSET; - na=read_pdbfile(fp,title,&model_nr,&atoms,fr->x,&ePBC,boxpdb,TRUE,NULL); - set_trxframe_ePBC(fr,ePBC); - if (nframes_read(status)==0) - fprintf(stderr," '%s', %d atoms\n",title, fr->natoms); - fr->bPrec = TRUE; - fr->prec = 10000; - fr->bX = TRUE; - fr->bBox = (boxpdb[XX][XX] != 0.0); - if (fr->bBox) { - copy_mat(boxpdb,fr->box); - } - - if (model_nr!=NOTSET) { - fr->bStep = TRUE; - fr->step = model_nr; - } - time=strstr(title," t= "); - if (time) { - fr->bTime = TRUE; - sscanf(time+4,"%lf",&dbl); - fr->time=(real)dbl; - } else { - fr->bTime = FALSE; - /* this is a bit dirty, but it will work: if no time is read from - comment line in pdb file, set time to current frame number */ - if (fr->bStep) - fr->time=(real)fr->step; + t_atoms atoms; + matrix boxpdb; + int ePBC, model_nr, na; + char title[STRLEN], *time; + double dbl; + + atoms.nr = fr->natoms; + atoms.atom = NULL; + atoms.pdbinfo = NULL; + /* the other pointers in atoms should not be accessed if these are NULL */ + model_nr = NOTSET; + na = read_pdbfile(fp, title, &model_nr, &atoms, fr->x, &ePBC, boxpdb, TRUE, NULL); + set_trxframe_ePBC(fr, ePBC); + if (nframes_read(status) == 0) + { + fprintf(stderr, " '%s', %d atoms\n", title, fr->natoms); + } + fr->bPrec = TRUE; + fr->prec = 10000; + fr->bX = TRUE; + fr->bBox = (boxpdb[XX][XX] != 0.0); + if (fr->bBox) + { + copy_mat(boxpdb, fr->box); + } + + if (model_nr != NOTSET) + { + fr->bStep = TRUE; + fr->step = model_nr; + } + time = strstr(title, " t= "); + if (time) + { + fr->bTime = TRUE; + sscanf(time+4, "%lf", &dbl); + fr->time = (real)dbl; + } else - fr->time=(real)nframes_read(status); - } - if (na == 0) { - return FALSE; - } else { - if (na != fr->natoms) - gmx_fatal(FARGS,"Number of atoms in pdb frame %d is %d instead of %d", - nframes_read(status),na,fr->natoms); - return TRUE; - } + { + fr->bTime = FALSE; + /* this is a bit dirty, but it will work: if no time is read from + comment line in pdb file, set time to current frame number */ + if (fr->bStep) + { + fr->time = (real)fr->step; + } + else + { + fr->time = (real)nframes_read(status); + } + } + if (na == 0) + { + return FALSE; + } + else + { + if (na != fr->natoms) + { + gmx_fatal(FARGS, "Number of atoms in pdb frame %d is %d instead of %d", + nframes_read(status), na, fr->natoms); + } + return TRUE; + } } static int pdb_first_x(t_trxstatus *status, FILE *fp, t_trxframe *fr) { - initcount(status); - - fprintf(stderr,"Reading frames from pdb file"); - frewind(fp); - get_pdb_coordnum(fp, &fr->natoms); - if (fr->natoms==0) - gmx_fatal(FARGS,"\nNo coordinates in pdb file\n"); - frewind(fp); - snew(fr->x,fr->natoms); - pdb_next_x(status, fp, fr); - - return fr->natoms; + initcount(status); + + fprintf(stderr, "Reading frames from pdb file"); + frewind(fp); + get_pdb_coordnum(fp, &fr->natoms); + if (fr->natoms == 0) + { + gmx_fatal(FARGS, "\nNo coordinates in pdb file\n"); + } + frewind(fp); + snew(fr->x, fr->natoms); + pdb_next_x(status, fp, fr); + + return fr->natoms; } -gmx_bool read_next_frame(const output_env_t oenv,t_trxstatus *status,t_trxframe *fr) +gmx_bool read_next_frame(const output_env_t oenv, t_trxstatus *status, t_trxframe *fr) { - real pt; - int ct; - gmx_bool bOK,bRet,bMissingData=FALSE,bSkip=FALSE; - int dummy=0; - - bRet = FALSE; - pt=fr->time; - - do { - clear_trxframe(fr,FALSE); - fr->tppf = fr->tpf; - fr->tpf = fr->time; - - switch (gmx_fio_getftp(status->fio)) { - case efTRJ: - case efTRR: - bRet = gmx_next_frame(status,fr); - break; - case efCPT: - /* Checkpoint files can not contain mulitple frames */ - break; - case efG96: - read_g96_conf(gmx_fio_getfp(status->fio),NULL,fr, - status->persistent_line); - bRet = (fr->natoms > 0); - break; - case efG87: - bRet = xyz_next_x(status, gmx_fio_getfp(status->fio),oenv,&fr->time, - fr->natoms, fr->x,fr->box); - fr->bTime = bRet; - fr->bX = bRet; - fr->bBox = bRet; - break; - case efXTC: - /* B. Hess 2005-4-20 - * Sometimes is off by one frame - * and sometimes reports frame not present/file not seekable - */ - /* DvdS 2005-05-31: this has been fixed along with the increased - * accuracy of the control over -b and -e options. - */ - if (bTimeSet(TBEGIN) && (fr->time < rTimeValue(TBEGIN))) { - if (xtc_seek_time(status->fio, rTimeValue(TBEGIN),fr->natoms,TRUE)) { - gmx_fatal(FARGS,"Specified frame (time %f) doesn't exist or file corrupt/inconsistent.", - rTimeValue(TBEGIN)); - } - initcount(status); - } - bRet = read_next_xtc(status->fio,fr->natoms,&fr->step,&fr->time,fr->box, - fr->x,&fr->prec,&bOK); - fr->bPrec = (bRet && fr->prec > 0); - fr->bStep = bRet; - fr->bTime = bRet; - fr->bX = bRet; - fr->bBox = bRet; - if (!bOK) { - /* Actually the header could also be not ok, - but from bOK from read_next_xtc this can't be distinguished */ - fr->not_ok = DATA_NOT_OK; - } - break; - case efPDB: - bRet = pdb_next_x(status, gmx_fio_getfp(status->fio),fr); - break; - case efGRO: - bRet = gro_next_x_or_v(gmx_fio_getfp(status->fio),fr); - break; - default: + real pt; + int ct; + gmx_bool bOK, bRet, bMissingData = FALSE, bSkip = FALSE; + int dummy = 0; + + bRet = FALSE; + pt = fr->time; + + do + { + clear_trxframe(fr, FALSE); + fr->tppf = fr->tpf; + fr->tpf = fr->time; + + switch (gmx_fio_getftp(status->fio)) + { + case efTRJ: + case efTRR: + bRet = gmx_next_frame(status, fr); + break; + case efCPT: + /* Checkpoint files can not contain mulitple frames */ + break; + case efG96: + read_g96_conf(gmx_fio_getfp(status->fio), NULL, fr, + status->persistent_line); + bRet = (fr->natoms > 0); + break; + case efG87: + bRet = xyz_next_x(status, gmx_fio_getfp(status->fio), oenv, &fr->time, + fr->natoms, fr->x, fr->box); + fr->bTime = bRet; + fr->bX = bRet; + fr->bBox = bRet; + break; + case efXTC: + /* B. Hess 2005-4-20 + * Sometimes is off by one frame + * and sometimes reports frame not present/file not seekable + */ + /* DvdS 2005-05-31: this has been fixed along with the increased + * accuracy of the control over -b and -e options. + */ + if (bTimeSet(TBEGIN) && (fr->time < rTimeValue(TBEGIN))) + { + if (xtc_seek_time(status->fio, rTimeValue(TBEGIN), fr->natoms, TRUE)) + { + gmx_fatal(FARGS, "Specified frame (time %f) doesn't exist or file corrupt/inconsistent.", + rTimeValue(TBEGIN)); + } + initcount(status); + } + bRet = read_next_xtc(status->fio, fr->natoms, &fr->step, &fr->time, fr->box, + fr->x, &fr->prec, &bOK); + fr->bPrec = (bRet && fr->prec > 0); + fr->bStep = bRet; + fr->bTime = bRet; + fr->bX = bRet; + fr->bBox = bRet; + if (!bOK) + { + /* Actually the header could also be not ok, + but from bOK from read_next_xtc this can't be distinguished */ + fr->not_ok = DATA_NOT_OK; + } + break; + case efPDB: + bRet = pdb_next_x(status, gmx_fio_getfp(status->fio), fr); + break; + case efGRO: + bRet = gro_next_x_or_v(gmx_fio_getfp(status->fio), fr); + break; + default: #ifdef GMX_USE_PLUGINS - bRet = read_next_vmd_frame(dummy,fr); + bRet = read_next_vmd_frame(dummy, fr); #else - gmx_fatal(FARGS,"DEATH HORROR in read_next_frame ftp=%s,status=%s", - ftp2ext(gmx_fio_getftp(status->fio)), - gmx_fio_getname(status->fio)); + gmx_fatal(FARGS, "DEATH HORROR in read_next_frame ftp=%s,status=%s", + ftp2ext(gmx_fio_getftp(status->fio)), + gmx_fio_getname(status->fio)); #endif + } + + if (bRet) + { + bMissingData = (((fr->flags & TRX_NEED_X) && !fr->bX) || + ((fr->flags & TRX_NEED_V) && !fr->bV) || + ((fr->flags & TRX_NEED_F) && !fr->bF)); + bSkip = FALSE; + if (!bMissingData) + { + ct = check_times2(fr->time, fr->t0, fr->tpf, fr->tppf, fr->bDouble); + if (ct == 0 || ((fr->flags & TRX_DONT_SKIP) && ct < 0)) + { + printcount(status, oenv, fr->time, FALSE); + } + else if (ct > 0) + { + bRet = FALSE; + } + else + { + printcount(status, oenv, fr->time, TRUE); + bSkip = TRUE; + } + } + } + + } + while (bRet && (bMissingData || bSkip)); + + if (!bRet) + { + printlast(status, oenv, pt); + if (fr->not_ok) + { + printincomp(status, fr); + } } - - if (bRet) { - bMissingData = (((fr->flags & TRX_NEED_X) && !fr->bX) || - ((fr->flags & TRX_NEED_V) && !fr->bV) || - ((fr->flags & TRX_NEED_F) && !fr->bF)); - bSkip = FALSE; - if (!bMissingData) { - ct=check_times2(fr->time,fr->t0,fr->tpf,fr->tppf,fr->bDouble); - if (ct == 0 || ((fr->flags & TRX_DONT_SKIP) && ct<0)) { - printcount(status, oenv,fr->time,FALSE); - } else if (ct > 0) - bRet = FALSE; - else { - printcount(status, oenv,fr->time,TRUE); - bSkip = TRUE; - } - } - } - - } while (bRet && (bMissingData || bSkip)); - - if (!bRet) { - printlast(status, oenv,pt); - if (fr->not_ok) - printincomp(status, fr); - } - - return bRet; + + return bRet; } -int read_first_frame(const output_env_t oenv,t_trxstatus **status, - const char *fn,t_trxframe *fr,int flags) +int read_first_frame(const output_env_t oenv, t_trxstatus **status, + const char *fn, t_trxframe *fr, int flags) { - t_fileio *fio; - gmx_bool bFirst,bOK; - int dummy=0; - - clear_trxframe(fr,TRUE); - fr->flags = flags; - - bFirst = TRUE; - - snew((*status), 1); - - status_init( *status ); - (*status)->nxframe=1; - initcount(*status); - - fio = (*status)->fio =gmx_fio_open(fn,"r"); - switch (gmx_fio_getftp(fio)) - { - case efTRJ: - case efTRR: - break; - case efCPT: - read_checkpoint_trxframe(fio,fr); - bFirst = FALSE; - break; - case efG96: - /* Can not rewind a compressed file, so open it twice */ - if (!(*status)->persistent_line) - { - /* allocate the persistent line */ - snew((*status)->persistent_line, STRLEN+1); - } - read_g96_conf(gmx_fio_getfp(fio),fn,fr, (*status)->persistent_line); - gmx_fio_close(fio); - clear_trxframe(fr,FALSE); - if (flags & (TRX_READ_X | TRX_NEED_X)) - snew(fr->x,fr->natoms); - if (flags & (TRX_READ_V | TRX_NEED_V)) - snew(fr->v,fr->natoms); - fio = (*status)->fio =gmx_fio_open(fn,"r"); - break; - case efG87: - fr->natoms=xyz_first_x(*status, gmx_fio_getfp(fio),oenv,&fr->time, - &fr->x,fr->box); - if (fr->natoms) { - fr->bTime = TRUE; - fr->bX = TRUE; - fr->bBox = TRUE; - printcount(*status,oenv,fr->time,FALSE); - } - bFirst = FALSE; - break; - case efXTC: - if (read_first_xtc(fio,&fr->natoms,&fr->step,&fr->time,fr->box,&fr->x, - &fr->prec,&bOK) == 0) { - if (bOK) { - gmx_fatal(FARGS,"No XTC!\n"); - } else { - fr->not_ok = DATA_NOT_OK; - } - } - if (fr->not_ok) { - fr->natoms = 0; - printincomp(*status,fr); - } else { - fr->bPrec = (fr->prec > 0); - fr->bStep = TRUE; - fr->bTime = TRUE; - fr->bX = TRUE; - fr->bBox = TRUE; - printcount(*status,oenv,fr->time,FALSE); - } - bFirst = FALSE; - break; - case efPDB: - pdb_first_x(*status, gmx_fio_getfp(fio),fr); - if (fr->natoms) - printcount(*status,oenv,fr->time,FALSE); - bFirst = FALSE; - break; - case efGRO: - if (gro_first_x_or_v(gmx_fio_getfp(fio),fr)) - printcount(*status,oenv,fr->time,FALSE); - bFirst = FALSE; - break; - default: + t_fileio *fio; + gmx_bool bFirst, bOK; + int dummy = 0; + + clear_trxframe(fr, TRUE); + fr->flags = flags; + + bFirst = TRUE; + + snew((*status), 1); + + status_init( *status ); + (*status)->nxframe = 1; + initcount(*status); + + fio = (*status)->fio = gmx_fio_open(fn, "r"); + switch (gmx_fio_getftp(fio)) + { + case efTRJ: + case efTRR: + break; + case efCPT: + read_checkpoint_trxframe(fio, fr); + bFirst = FALSE; + break; + case efG96: + /* Can not rewind a compressed file, so open it twice */ + if (!(*status)->persistent_line) + { + /* allocate the persistent line */ + snew((*status)->persistent_line, STRLEN+1); + } + read_g96_conf(gmx_fio_getfp(fio), fn, fr, (*status)->persistent_line); + gmx_fio_close(fio); + clear_trxframe(fr, FALSE); + if (flags & (TRX_READ_X | TRX_NEED_X)) + { + snew(fr->x, fr->natoms); + } + if (flags & (TRX_READ_V | TRX_NEED_V)) + { + snew(fr->v, fr->natoms); + } + fio = (*status)->fio = gmx_fio_open(fn, "r"); + break; + case efG87: + fr->natoms = xyz_first_x(*status, gmx_fio_getfp(fio), oenv, &fr->time, + &fr->x, fr->box); + if (fr->natoms) + { + fr->bTime = TRUE; + fr->bX = TRUE; + fr->bBox = TRUE; + printcount(*status, oenv, fr->time, FALSE); + } + bFirst = FALSE; + break; + case efXTC: + if (read_first_xtc(fio, &fr->natoms, &fr->step, &fr->time, fr->box, &fr->x, + &fr->prec, &bOK) == 0) + { + if (bOK) + { + gmx_fatal(FARGS, "No XTC!\n"); + } + else + { + fr->not_ok = DATA_NOT_OK; + } + } + if (fr->not_ok) + { + fr->natoms = 0; + printincomp(*status, fr); + } + else + { + fr->bPrec = (fr->prec > 0); + fr->bStep = TRUE; + fr->bTime = TRUE; + fr->bX = TRUE; + fr->bBox = TRUE; + printcount(*status, oenv, fr->time, FALSE); + } + bFirst = FALSE; + break; + case efPDB: + pdb_first_x(*status, gmx_fio_getfp(fio), fr); + if (fr->natoms) + { + printcount(*status, oenv, fr->time, FALSE); + } + bFirst = FALSE; + break; + case efGRO: + if (gro_first_x_or_v(gmx_fio_getfp(fio), fr)) + { + printcount(*status, oenv, fr->time, FALSE); + } + bFirst = FALSE; + break; + default: #ifdef GMX_USE_PLUGINS - fprintf(stderr,"The file format of %s is not a known trajectory format to GROMACS.\n" - "Please make sure that the file is a trajectory!\n" - "GROMACS will now assume it to be a trajectory and will try to open it using the VMD plug-ins.\n" - "This will only work in case the VMD plugins are found and it is a trajectory format supported by VMD.\n",fn); - gmx_fio_fp_close(fio); /*only close the file without removing FIO entry*/ - if (!read_first_vmd_frame(&dummy,fn,fr,flags)) - { - gmx_fatal(FARGS,"Not supported in read_first_frame: %s",fn); - } + fprintf(stderr, "The file format of %s is not a known trajectory format to GROMACS.\n" + "Please make sure that the file is a trajectory!\n" + "GROMACS will now assume it to be a trajectory and will try to open it using the VMD plug-ins.\n" + "This will only work in case the VMD plugins are found and it is a trajectory format supported by VMD.\n", fn); + gmx_fio_fp_close(fio); /*only close the file without removing FIO entry*/ + if (!read_first_vmd_frame(&dummy, fn, fr, flags)) + { + gmx_fatal(FARGS, "Not supported in read_first_frame: %s", fn); + } #else - gmx_fatal(FARGS,"Not supported in read_first_frame: %s. Please make sure that the file is a trajectory.\n" - "GROMACS is not compiled with plug-in support. Thus it cannot read non-GROMACS trajectory formats using the VMD plug-ins.\n" - "Please compile with plug-in support if you want to read non-GROMACS trajectory formats.\n",fn); + gmx_fatal(FARGS, "Not supported in read_first_frame: %s. Please make sure that the file is a trajectory.\n" + "GROMACS is not compiled with plug-in support. Thus it cannot read non-GROMACS trajectory formats using the VMD plug-ins.\n" + "Please compile with plug-in support if you want to read non-GROMACS trajectory formats.\n", fn); #endif - break; - } + break; + } + + /* Return FALSE if we read a frame that's past the set ending time. */ + if (!bFirst && (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) > 0)) + { + fr->t0 = fr->time; + return FALSE; + } - /* Return FALSE if we read a frame that's past the set ending time. */ - if (!bFirst && (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) > 0)) { + if (bFirst || + (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) < 0)) + { + /* Read a frame when no frame was read or the first was skipped */ + if (!read_next_frame(oenv, *status, fr)) + { + return FALSE; + } + } fr->t0 = fr->time; - return FALSE; - } - - if (bFirst || - (!(fr->flags & TRX_DONT_SKIP) && check_times(fr->time) < 0)) - /* Read a frame when no frame was read or the first was skipped */ - if (!read_next_frame(oenv,*status,fr)) - return FALSE; - fr->t0 = fr->time; - - return (fr->natoms > 0); + + return (fr->natoms > 0); } /***** C O O R D I N A T E S T U F F *****/ -int read_first_x(const output_env_t oenv,t_trxstatus **status,const char *fn, - real *t,rvec **x,matrix box) +int read_first_x(const output_env_t oenv, t_trxstatus **status, const char *fn, + real *t, rvec **x, matrix box) { - t_trxframe fr; - - read_first_frame(oenv,status,fn,&fr,TRX_NEED_X); - - snew((*status)->xframe, 1); - (*status)->nxframe=1; - (*(*status)->xframe) = fr; - *t = (*status)->xframe->time; - *x = (*status)->xframe->x; - copy_mat((*status)->xframe->box,box); - - return (*status)->xframe->natoms; + t_trxframe fr; + + read_first_frame(oenv, status, fn, &fr, TRX_NEED_X); + + snew((*status)->xframe, 1); + (*status)->nxframe = 1; + (*(*status)->xframe) = fr; + *t = (*status)->xframe->time; + *x = (*status)->xframe->x; + copy_mat((*status)->xframe->box, box); + + return (*status)->xframe->natoms; } -gmx_bool read_next_x(const output_env_t oenv, t_trxstatus *status,real *t, - int natoms, rvec x[], matrix box) +gmx_bool read_next_x(const output_env_t oenv, t_trxstatus *status, real *t, + int natoms, rvec x[], matrix box) { - gmx_bool bRet; - - status->xframe->x= x; - /*xframe[status].x = x;*/ - bRet = read_next_frame(oenv,status,status->xframe); - *t = status->xframe->time; - copy_mat(status->xframe->box,box); - - return bRet; + gmx_bool bRet; + + status->xframe->x = x; + /*xframe[status].x = x;*/ + bRet = read_next_frame(oenv, status, status->xframe); + *t = status->xframe->time; + copy_mat(status->xframe->box, box); + + return bRet; } void close_trj(t_trxstatus *status) @@ -948,7 +1105,7 @@ void close_trj(t_trxstatus *status) void rewind_trj(t_trxstatus *status) { - initcount(status); - - gmx_fio_rewind(status->fio); + initcount(status); + + gmx_fio_rewind(status->fio); } diff --git a/src/gromacs/gmxlib/txtdump.c b/src/gromacs/gmxlib/txtdump.c index 82922dce52..f5c3966b5f 100644 --- a/src/gromacs/gmxlib/txtdump.c +++ b/src/gromacs/gmxlib/txtdump.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -53,68 +53,74 @@ #include "macros.h" -int pr_indent(FILE *fp,int n) +int pr_indent(FILE *fp, int n) { - int i; + int i; - for (i=0; i 0) - pr_indent(fp,indent); - (void) fprintf(fp,"%s: not available\n",title); - } - return (p!=NULL); + if (!p) + { + if (indent > 0) + { + pr_indent(fp, indent); + } + (void) fprintf(fp, "%s: not available\n", title); + } + return (p != NULL); } -int pr_title(FILE *fp,int indent,const char *title) +int pr_title(FILE *fp, int indent, const char *title) { - (void) pr_indent(fp,indent); - (void) fprintf(fp,"%s:\n",title); - return (indent+INDENT); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "%s:\n", title); + return (indent+INDENT); } -int pr_title_n(FILE *fp,int indent,const char *title,int n) +int pr_title_n(FILE *fp, int indent, const char *title, int n) { - (void) pr_indent(fp,indent); - (void) fprintf(fp,"%s (%d):\n",title,n); - return (indent+INDENT); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "%s (%d):\n", title, n); + return (indent+INDENT); } -int pr_title_nxn(FILE *fp,int indent,const char *title,int n1,int n2) +int pr_title_nxn(FILE *fp, int indent, const char *title, int n1, int n2) { - (void) pr_indent(fp,indent); - (void) fprintf(fp,"%s (%dx%d):\n",title,n1,n2); - return (indent+INDENT); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "%s (%dx%d):\n", title, n1, n2); + return (indent+INDENT); } -void pr_ivec(FILE *fp,int indent,const char *title,int vec[],int n, gmx_bool bShowNumbers) +void pr_ivec(FILE *fp, int indent, const char *title, int vec[], int n, gmx_bool bShowNumbers) { - int i; + int i; - if (available(fp,vec,indent,title)) + if (available(fp, vec, indent, title)) { - indent=pr_title_n(fp,indent,title,n); - for (i=0; ingQM); - if (opts->ngQM > 0) { - pr_ivec(fp,indent,"QMmethod",opts->QMmethod,opts->ngQM,FALSE); - pr_ivec(fp,indent,"QMbasis",opts->QMbasis,opts->ngQM,FALSE); - pr_ivec(fp,indent,"QMcharge",opts->QMcharge,opts->ngQM,FALSE); - pr_ivec(fp,indent,"QMmult",opts->QMmult,opts->ngQM,FALSE); - pr_bvec(fp,indent,"bSH",opts->bSH,opts->ngQM,FALSE); - pr_ivec(fp,indent,"CASorbitals",opts->CASorbitals,opts->ngQM,FALSE); - pr_ivec(fp,indent,"CASelectrons",opts->CASelectrons,opts->ngQM,FALSE); - pr_rvec(fp,indent,"SAon",opts->SAon,opts->ngQM,FALSE); - pr_rvec(fp,indent,"SAon",opts->SAon,opts->ngQM,FALSE); - pr_ivec(fp,indent,"SAsteps",opts->SAsteps,opts->ngQM,FALSE); - pr_bvec(fp,indent,"bOPT",opts->bOPT,opts->ngQM,FALSE); - pr_bvec(fp,indent,"bTS",opts->bTS,opts->ngQM,FALSE); - } + int i, m, j; + + fprintf(fp, "%s:\n", title); + + pr_int(fp, indent, "ngQM", opts->ngQM); + if (opts->ngQM > 0) + { + pr_ivec(fp, indent, "QMmethod", opts->QMmethod, opts->ngQM, FALSE); + pr_ivec(fp, indent, "QMbasis", opts->QMbasis, opts->ngQM, FALSE); + pr_ivec(fp, indent, "QMcharge", opts->QMcharge, opts->ngQM, FALSE); + pr_ivec(fp, indent, "QMmult", opts->QMmult, opts->ngQM, FALSE); + pr_bvec(fp, indent, "bSH", opts->bSH, opts->ngQM, FALSE); + pr_ivec(fp, indent, "CASorbitals", opts->CASorbitals, opts->ngQM, FALSE); + pr_ivec(fp, indent, "CASelectrons", opts->CASelectrons, opts->ngQM, FALSE); + pr_rvec(fp, indent, "SAon", opts->SAon, opts->ngQM, FALSE); + pr_rvec(fp, indent, "SAon", opts->SAon, opts->ngQM, FALSE); + pr_ivec(fp, indent, "SAsteps", opts->SAsteps, opts->ngQM, FALSE); + pr_bvec(fp, indent, "bOPT", opts->bOPT, opts->ngQM, FALSE); + pr_bvec(fp, indent, "bTS", opts->bTS, opts->ngQM, FALSE); + } } -static void pr_grp_opts(FILE *out,int indent,const char *title,t_grpopts *opts, - gmx_bool bMDPformat) +static void pr_grp_opts(FILE *out, int indent, const char *title, t_grpopts *opts, + gmx_bool bMDPformat) { - int i,m,j; - - if (!bMDPformat) - fprintf(out,"%s:\n",title); - - pr_indent(out,indent); - fprintf(out,"nrdf%s",bMDPformat ? " = " : ":"); - for(i=0; (ingtc); i++) - fprintf(out," %10g",opts->nrdf[i]); - fprintf(out,"\n"); - - pr_indent(out,indent); - fprintf(out,"ref-t%s",bMDPformat ? " = " : ":"); - for(i=0; (ingtc); i++) - fprintf(out," %10g",opts->ref_t[i]); - fprintf(out,"\n"); - - pr_indent(out,indent); - fprintf(out,"tau-t%s",bMDPformat ? " = " : ":"); - for(i=0; (ingtc); i++) - fprintf(out," %10g",opts->tau_t[i]); - fprintf(out,"\n"); - - /* Pretty-print the simulated annealing info */ - fprintf(out,"anneal%s",bMDPformat ? " = " : ":"); - for(i=0; (ingtc); i++) - fprintf(out," %10s",EANNEAL(opts->annealing[i])); - fprintf(out,"\n"); - - fprintf(out,"ann-npoints%s",bMDPformat ? " = " : ":"); - for(i=0; (ingtc); i++) - fprintf(out," %10d",opts->anneal_npoints[i]); - fprintf(out,"\n"); - - for(i=0; (ingtc); i++) { - if(opts->anneal_npoints[i]>0) { - fprintf(out,"ann. times [%d]:\t",i); - for(j=0; (janneal_npoints[i]); j++) - fprintf(out," %10.1f",opts->anneal_time[i][j]); - fprintf(out,"\n"); - fprintf(out,"ann. temps [%d]:\t",i); - for(j=0; (janneal_npoints[i]); j++) - fprintf(out," %10.1f",opts->anneal_temp[i][j]); - fprintf(out,"\n"); - } - } - - pr_indent(out,indent); - fprintf(out,"acc:\t"); - for(i=0; (ingacc); i++) - for(m=0; (macc[i][m]); - fprintf(out,"\n"); - - pr_indent(out,indent); - fprintf(out,"nfreeze:"); - for(i=0; (ingfrz); i++) - for(m=0; (mnFreeze[i][m] ? "Y" : "N"); - fprintf(out,"\n"); - - - for(i=0; (ingener); i++) { - pr_indent(out,indent); - fprintf(out,"energygrp-flags[%3d]:",i); - for(m=0; (mngener); m++) - fprintf(out," %d",opts->egp_flags[opts->ngener*i+m]); - fprintf(out,"\n"); - } - - fflush(out); + int i, m, j; + + if (!bMDPformat) + { + fprintf(out, "%s:\n", title); + } + + pr_indent(out, indent); + fprintf(out, "nrdf%s", bMDPformat ? " = " : ":"); + for (i = 0; (i < opts->ngtc); i++) + { + fprintf(out, " %10g", opts->nrdf[i]); + } + fprintf(out, "\n"); + + pr_indent(out, indent); + fprintf(out, "ref-t%s", bMDPformat ? " = " : ":"); + for (i = 0; (i < opts->ngtc); i++) + { + fprintf(out, " %10g", opts->ref_t[i]); + } + fprintf(out, "\n"); + + pr_indent(out, indent); + fprintf(out, "tau-t%s", bMDPformat ? " = " : ":"); + for (i = 0; (i < opts->ngtc); i++) + { + fprintf(out, " %10g", opts->tau_t[i]); + } + fprintf(out, "\n"); + + /* Pretty-print the simulated annealing info */ + fprintf(out, "anneal%s", bMDPformat ? " = " : ":"); + for (i = 0; (i < opts->ngtc); i++) + { + fprintf(out, " %10s", EANNEAL(opts->annealing[i])); + } + fprintf(out, "\n"); + + fprintf(out, "ann-npoints%s", bMDPformat ? " = " : ":"); + for (i = 0; (i < opts->ngtc); i++) + { + fprintf(out, " %10d", opts->anneal_npoints[i]); + } + fprintf(out, "\n"); + + for (i = 0; (i < opts->ngtc); i++) + { + if (opts->anneal_npoints[i] > 0) + { + fprintf(out, "ann. times [%d]:\t", i); + for (j = 0; (j < opts->anneal_npoints[i]); j++) + { + fprintf(out, " %10.1f", opts->anneal_time[i][j]); + } + fprintf(out, "\n"); + fprintf(out, "ann. temps [%d]:\t", i); + for (j = 0; (j < opts->anneal_npoints[i]); j++) + { + fprintf(out, " %10.1f", opts->anneal_temp[i][j]); + } + fprintf(out, "\n"); + } + } + + pr_indent(out, indent); + fprintf(out, "acc:\t"); + for (i = 0; (i < opts->ngacc); i++) + { + for (m = 0; (m < DIM); m++) + { + fprintf(out, " %10g", opts->acc[i][m]); + } + } + fprintf(out, "\n"); + + pr_indent(out, indent); + fprintf(out, "nfreeze:"); + for (i = 0; (i < opts->ngfrz); i++) + { + for (m = 0; (m < DIM); m++) + { + fprintf(out, " %10s", opts->nFreeze[i][m] ? "Y" : "N"); + } + } + fprintf(out, "\n"); + + + for (i = 0; (i < opts->ngener); i++) + { + pr_indent(out, indent); + fprintf(out, "energygrp-flags[%3d]:", i); + for (m = 0; (m < opts->ngener); m++) + { + fprintf(out, " %d", opts->egp_flags[opts->ngener*i+m]); + } + fprintf(out, "\n"); + } + + fflush(out); } -static void pr_matrix(FILE *fp,int indent,const char *title,rvec *m, - gmx_bool bMDPformat) +static void pr_matrix(FILE *fp, int indent, const char *title, rvec *m, + gmx_bool bMDPformat) { - if (bMDPformat) - fprintf(fp,"%-10s = %g %g %g %g %g %g\n",title, - m[XX][XX],m[YY][YY],m[ZZ][ZZ],m[XX][YY],m[XX][ZZ],m[YY][ZZ]); - else - pr_rvecs(fp,indent,title,m,DIM); + if (bMDPformat) + { + fprintf(fp, "%-10s = %g %g %g %g %g %g\n", title, + m[XX][XX], m[YY][YY], m[ZZ][ZZ], m[XX][YY], m[XX][ZZ], m[YY][ZZ]); + } + else + { + pr_rvecs(fp, indent, title, m, DIM); + } } -static void pr_cosine(FILE *fp,int indent,const char *title,t_cosines *cos, - gmx_bool bMDPformat) +static void pr_cosine(FILE *fp, int indent, const char *title, t_cosines *cos, + gmx_bool bMDPformat) { - int j; - - if (bMDPformat) { - fprintf(fp,"%s = %d\n",title,cos->n); - } - else { - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - fprintf(fp,"n = %d\n",cos->n); - if (cos->n > 0) { - (void) pr_indent(fp,indent+2); - fprintf(fp,"a ="); - for(j=0; (jn); j++) - fprintf(fp," %e",cos->a[j]); - fprintf(fp,"\n"); - (void) pr_indent(fp,indent+2); - fprintf(fp,"phi ="); - for(j=0; (jn); j++) - fprintf(fp," %e",cos->phi[j]); - fprintf(fp,"\n"); - } - } + int j; + + if (bMDPformat) + { + fprintf(fp, "%s = %d\n", title, cos->n); + } + else + { + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + fprintf(fp, "n = %d\n", cos->n); + if (cos->n > 0) + { + (void) pr_indent(fp, indent+2); + fprintf(fp, "a ="); + for (j = 0; (j < cos->n); j++) + { + fprintf(fp, " %e", cos->a[j]); + } + fprintf(fp, "\n"); + (void) pr_indent(fp, indent+2); + fprintf(fp, "phi ="); + for (j = 0; (j < cos->n); j++) + { + fprintf(fp, " %e", cos->phi[j]); + } + fprintf(fp, "\n"); + } + } } -#define PS(t,s) pr_str(fp,indent,t,s) -#define PI(t,s) pr_int(fp,indent,t,s) -#define PSTEP(t,s) pr_gmx_large_int(fp,indent,t,s) -#define PR(t,s) pr_real(fp,indent,t,s) -#define PD(t,s) pr_double(fp,indent,t,s) +#define PS(t, s) pr_str(fp, indent, t, s) +#define PI(t, s) pr_int(fp, indent, t, s) +#define PSTEP(t, s) pr_gmx_large_int(fp, indent, t, s) +#define PR(t, s) pr_real(fp, indent, t, s) +#define PD(t, s) pr_double(fp, indent, t, s) -static void pr_pullgrp(FILE *fp,int indent,int g,t_pullgrp *pg) +static void pr_pullgrp(FILE *fp, int indent, int g, t_pullgrp *pg) { - pr_indent(fp,indent); - fprintf(fp,"pull-group %d:\n",g); - indent += 2; - pr_ivec_block(fp,indent,"atom",pg->ind,pg->nat,TRUE); - pr_rvec(fp,indent,"weight",pg->weight,pg->nweight,TRUE); - PI("pbcatom",pg->pbcatom); - pr_rvec(fp,indent,"vec",pg->vec,DIM,TRUE); - pr_rvec(fp,indent,"init",pg->init,DIM,TRUE); - PR("rate",pg->rate); - PR("k",pg->k); - PR("kB",pg->kB); + pr_indent(fp, indent); + fprintf(fp, "pull-group %d:\n", g); + indent += 2; + pr_ivec_block(fp, indent, "atom", pg->ind, pg->nat, TRUE); + pr_rvec(fp, indent, "weight", pg->weight, pg->nweight, TRUE); + PI("pbcatom", pg->pbcatom); + pr_rvec(fp, indent, "vec", pg->vec, DIM, TRUE); + pr_rvec(fp, indent, "init", pg->init, DIM, TRUE); + PR("rate", pg->rate); + PR("k", pg->k); + PR("kB", pg->kB); } -static void pr_simtempvals(FILE *fp,int indent,t_simtemp *simtemp, int n_lambda, gmx_bool bMDPformat) +static void pr_simtempvals(FILE *fp, int indent, t_simtemp *simtemp, int n_lambda, gmx_bool bMDPformat) { - PR("simtemp_low",simtemp->simtemp_low); - PR("simtemp_high",simtemp->simtemp_high); - PS("simulated-tempering-scaling",ESIMTEMP(simtemp->eSimTempScale)); - pr_rvec(fp,indent,"simulated tempering temperatures",simtemp->temperatures,n_lambda,TRUE); + PR("simtemp_low", simtemp->simtemp_low); + PR("simtemp_high", simtemp->simtemp_high); + PS("simulated-tempering-scaling", ESIMTEMP(simtemp->eSimTempScale)); + pr_rvec(fp, indent, "simulated tempering temperatures", simtemp->temperatures, n_lambda, TRUE); } -static void pr_expandedvals(FILE *fp,int indent,t_expanded *expand, int n_lambda, gmx_bool bMDPformat) +static void pr_expandedvals(FILE *fp, int indent, t_expanded *expand, int n_lambda, gmx_bool bMDPformat) { PI("nstexpanded", expand->nstexpanded); PS("lambda-stats", elamstats_names[expand->elamstats]); PS("lambda-mc-move", elmcmove_names[expand->elmcmove]); - PI("lmc-repeats",expand->lmc_repeats); - PI("lmc-gibbsdelta",expand->gibbsdeltalam); - PI("lmc-nstart",expand->lmc_forced_nstart); + PI("lmc-repeats", expand->lmc_repeats); + PI("lmc-gibbsdelta", expand->gibbsdeltalam); + PI("lmc-nstart", expand->lmc_forced_nstart); PS("symmetrized-transition-matrix", EBOOL(expand->bSymmetrizedTMatrix)); - PI("nst-transition-matrix",expand->nstTij); - PI("mininum-var-min",expand->minvarmin); /*default is reasonable */ - PI("weight-c-range",expand->c_range); /* default is just C=0 */ - PR("wl-scale",expand->wl_scale); - PR("init-wl-delta",expand->init_wl_delta); - PR("wl-ratio",expand->wl_ratio); - PS("bWLoneovert",EBOOL(expand->bWLoneovert)); - PI("lmc-seed",expand->lmc_seed); - PR("mc-temperature",expand->mc_temp); - PS("lmc-weights-equil",elmceq_names[expand->elmceq]); + PI("nst-transition-matrix", expand->nstTij); + PI("mininum-var-min", expand->minvarmin); /*default is reasonable */ + PI("weight-c-range", expand->c_range); /* default is just C=0 */ + PR("wl-scale", expand->wl_scale); + PR("init-wl-delta", expand->init_wl_delta); + PR("wl-ratio", expand->wl_ratio); + PS("bWLoneovert", EBOOL(expand->bWLoneovert)); + PI("lmc-seed", expand->lmc_seed); + PR("mc-temperature", expand->mc_temp); + PS("lmc-weights-equil", elmceq_names[expand->elmceq]); if (expand->elmceq == elmceqNUMATLAM) { - PI("weight-equil-number-all-lambda",expand->equil_n_at_lam); + PI("weight-equil-number-all-lambda", expand->equil_n_at_lam); } if (expand->elmceq == elmceqSAMPLES) { - PI("weight-equil-number-samples",expand->equil_samples); + PI("weight-equil-number-samples", expand->equil_samples); } if (expand->elmceq == elmceqSTEPS) { - PI("weight-equil-number-steps",expand->equil_steps); + PI("weight-equil-number-steps", expand->equil_steps); } if (expand->elmceq == elmceqWLDELTA) { - PR("weight-equil-wl-delta",expand->equil_wl_delta); + PR("weight-equil-wl-delta", expand->equil_wl_delta); } if (expand->elmceq == elmceqRATIO) { - PR("weight-equil-count-ratio",expand->equil_ratio); + PR("weight-equil-count-ratio", expand->equil_ratio); } - pr_indent(fp,indent); - pr_rvec(fp,indent,"init-lambda-weights",expand->init_lambda_weights,n_lambda,TRUE); - PS("init-weights",EBOOL(expand->bInit_weights)); + pr_indent(fp, indent); + pr_rvec(fp, indent, "init-lambda-weights", expand->init_lambda_weights, n_lambda, TRUE); + PS("init-weights", EBOOL(expand->bInit_weights)); } -static void pr_fepvals(FILE *fp,int indent,t_lambda *fep, gmx_bool bMDPformat) +static void pr_fepvals(FILE *fp, int indent, t_lambda *fep, gmx_bool bMDPformat) { - int i,j; + int i, j; - PI("nstdhdl",fep->nstdhdl); - PI("init-lambda-state",fep->init_fep_state); - PR("init-lambda",fep->init_lambda); - PR("delta-lambda",fep->delta_lambda); + PI("nstdhdl", fep->nstdhdl); + PI("init-lambda-state", fep->init_fep_state); + PR("init-lambda", fep->init_lambda); + PR("delta-lambda", fep->delta_lambda); if (!bMDPformat) { - PI("n-lambdas",fep->n_lambda); + PI("n-lambdas", fep->n_lambda); } if (fep->n_lambda > 0) { - pr_indent(fp,indent); - fprintf(fp,"separate-dvdl%s\n",bMDPformat ? " = " : ":"); - for(i=0; iall_lambda[i][j]); + fprintf(fp, " %10g", fep->all_lambda[i][j]); } - fprintf(fp,"\n"); + fprintf(fp, "\n"); } } - PI("calc-lambda-neighbors",fep->lambda_neighbors); - - PR("sc-alpha",fep->sc_alpha); - PS("bScCoul",EBOOL(fep->bScCoul)); - PS("bScPrintEnergy",EBOOL(fep->bPrintEnergy)); - PI("sc-power",fep->sc_power); - PR("sc-r-power",fep->sc_r_power); - PR("sc-sigma",fep->sc_sigma); - PR("sc-sigma-min",fep->sc_sigma_min); + PI("calc-lambda-neighbors", fep->lambda_neighbors); + + PR("sc-alpha", fep->sc_alpha); + PS("bScCoul", EBOOL(fep->bScCoul)); + PS("bScPrintEnergy", EBOOL(fep->bPrintEnergy)); + PI("sc-power", fep->sc_power); + PR("sc-r-power", fep->sc_r_power); + PR("sc-sigma", fep->sc_sigma); + PR("sc-sigma-min", fep->sc_sigma_min); PS("separate-dhdl-file", SEPDHDLFILETYPE(fep->separate_dhdl_file)); PS("dhdl-derivatives", DHDLDERIVATIVESTYPE(fep->dhdl_derivatives)); PI("dh-hist-size", fep->dh_hist_size); PD("dh-hist-spacing", fep->dh_hist_spacing); }; -static void pr_pull(FILE *fp,int indent,t_pull *pull) +static void pr_pull(FILE *fp, int indent, t_pull *pull) { - int g; - - PS("pull-geometry",EPULLGEOM(pull->eGeom)); - pr_ivec(fp,indent,"pull-dim",pull->dim,DIM,TRUE); - PR("pull-r1",pull->cyl_r1); - PR("pull-r0",pull->cyl_r0); - PR("pull-constr-tol",pull->constr_tol); - PI("pull-nstxout",pull->nstxout); - PI("pull-nstfout",pull->nstfout); - PI("pull-ngrp",pull->ngrp); - for(g=0; gngrp+1; g++) - pr_pullgrp(fp,indent,g,&pull->grp[g]); + int g; + + PS("pull-geometry", EPULLGEOM(pull->eGeom)); + pr_ivec(fp, indent, "pull-dim", pull->dim, DIM, TRUE); + PR("pull-r1", pull->cyl_r1); + PR("pull-r0", pull->cyl_r0); + PR("pull-constr-tol", pull->constr_tol); + PI("pull-nstxout", pull->nstxout); + PI("pull-nstfout", pull->nstfout); + PI("pull-ngrp", pull->ngrp); + for (g = 0; g < pull->ngrp+1; g++) + { + pr_pullgrp(fp, indent, g, &pull->grp[g]); + } } -static void pr_rotgrp(FILE *fp,int indent,int g,t_rotgrp *rotg) +static void pr_rotgrp(FILE *fp, int indent, int g, t_rotgrp *rotg) { - pr_indent(fp,indent); - fprintf(fp,"rotation_group %d:\n",g); - indent += 2; - PS("type",EROTGEOM(rotg->eType)); - PS("massw",EBOOL(rotg->bMassW)); - pr_ivec_block(fp,indent,"atom",rotg->ind,rotg->nat,TRUE); - pr_rvecs(fp,indent,"x_ref",rotg->x_ref,rotg->nat); - pr_rvec(fp,indent,"vec",rotg->vec,DIM,TRUE); - pr_rvec(fp,indent,"pivot",rotg->pivot,DIM,TRUE); - PR("rate",rotg->rate); - PR("k",rotg->k); - PR("slab_dist",rotg->slab_dist); - PR("min_gaussian",rotg->min_gaussian); - PR("epsilon",rotg->eps); - PS("fit_method",EROTFIT(rotg->eFittype)); - PI("potfitangle_nstep",rotg->PotAngle_nstep); - PR("potfitangle_step",rotg->PotAngle_step); + pr_indent(fp, indent); + fprintf(fp, "rotation_group %d:\n", g); + indent += 2; + PS("type", EROTGEOM(rotg->eType)); + PS("massw", EBOOL(rotg->bMassW)); + pr_ivec_block(fp, indent, "atom", rotg->ind, rotg->nat, TRUE); + pr_rvecs(fp, indent, "x_ref", rotg->x_ref, rotg->nat); + pr_rvec(fp, indent, "vec", rotg->vec, DIM, TRUE); + pr_rvec(fp, indent, "pivot", rotg->pivot, DIM, TRUE); + PR("rate", rotg->rate); + PR("k", rotg->k); + PR("slab_dist", rotg->slab_dist); + PR("min_gaussian", rotg->min_gaussian); + PR("epsilon", rotg->eps); + PS("fit_method", EROTFIT(rotg->eFittype)); + PI("potfitangle_nstep", rotg->PotAngle_nstep); + PR("potfitangle_step", rotg->PotAngle_step); } -static void pr_rot(FILE *fp,int indent,t_rot *rot) +static void pr_rot(FILE *fp, int indent, t_rot *rot) { - int g; + int g; - PI("rot_nstrout",rot->nstrout); - PI("rot_nstsout",rot->nstsout); - PI("rot_ngrp",rot->ngrp); - for(g=0; gngrp; g++) - pr_rotgrp(fp,indent,g,&rot->grp[g]); + PI("rot_nstrout", rot->nstrout); + PI("rot_nstsout", rot->nstsout); + PI("rot_ngrp", rot->ngrp); + for (g = 0; g < rot->ngrp; g++) + { + pr_rotgrp(fp, indent, g, &rot->grp[g]); + } } -void pr_inputrec(FILE *fp,int indent,const char *title,t_inputrec *ir, +void pr_inputrec(FILE *fp, int indent, const char *title, t_inputrec *ir, gmx_bool bMDPformat) { - const char *infbuf="inf"; - int i; - - if (available(fp,ir,indent,title)) { - if (!bMDPformat) - indent=pr_title(fp,indent,title); - PS("integrator",EI(ir->eI)); - PSTEP("nsteps",ir->nsteps); - PSTEP("init-step",ir->init_step); - PS("cutoff-scheme",ECUTSCHEME(ir->cutoff_scheme)); - PS("ns_type",ENS(ir->ns_type)); - PI("nstlist",ir->nstlist); - PI("ndelta",ir->ndelta); - PI("nstcomm",ir->nstcomm); - PS("comm-mode",ECOM(ir->comm_mode)); - PI("nstlog",ir->nstlog); - PI("nstxout",ir->nstxout); - PI("nstvout",ir->nstvout); - PI("nstfout",ir->nstfout); - PI("nstcalcenergy",ir->nstcalcenergy); - PI("nstenergy",ir->nstenergy); - PI("nstxtcout",ir->nstxtcout); - PR("init-t",ir->init_t); - PR("delta-t",ir->delta_t); - - PR("xtcprec",ir->xtcprec); - PR("fourierspacing",ir->fourier_spacing); - PI("nkx",ir->nkx); - PI("nky",ir->nky); - PI("nkz",ir->nkz); - PI("pme-order",ir->pme_order); - PR("ewald-rtol",ir->ewald_rtol); - PR("ewald-geometry",ir->ewald_geometry); - PR("epsilon-surface",ir->epsilon_surface); - PS("optimize-fft",EBOOL(ir->bOptFFT)); - PS("ePBC",EPBC(ir->ePBC)); - PS("bPeriodicMols",EBOOL(ir->bPeriodicMols)); - PS("bContinuation",EBOOL(ir->bContinuation)); - PS("bShakeSOR",EBOOL(ir->bShakeSOR)); - PS("etc",ETCOUPLTYPE(ir->etc)); - PS("bPrintNHChains",EBOOL(ir->bPrintNHChains)); - PI("nsttcouple",ir->nsttcouple); - PS("epc",EPCOUPLTYPE(ir->epc)); - PS("epctype",EPCOUPLTYPETYPE(ir->epct)); - PI("nstpcouple",ir->nstpcouple); - PR("tau-p",ir->tau_p); - pr_matrix(fp,indent,"ref-p",ir->ref_p,bMDPformat); - pr_matrix(fp,indent,"compress",ir->compress,bMDPformat); - PS("refcoord-scaling",EREFSCALINGTYPE(ir->refcoord_scaling)); - if (bMDPformat) - fprintf(fp,"posres-com = %g %g %g\n",ir->posres_com[XX], - ir->posres_com[YY],ir->posres_com[ZZ]); - else - pr_rvec(fp,indent,"posres-com",ir->posres_com,DIM,TRUE); - if (bMDPformat) - fprintf(fp,"posres-comB = %g %g %g\n",ir->posres_comB[XX], - ir->posres_comB[YY],ir->posres_comB[ZZ]); - else - pr_rvec(fp,indent,"posres-comB",ir->posres_comB,DIM,TRUE); - PR("verlet-buffer-drift",ir->verletbuf_drift); - PR("rlist",ir->rlist); - PR("rlistlong",ir->rlistlong); - PR("nstcalclr",ir->nstcalclr); - PR("rtpi",ir->rtpi); - PS("coulombtype",EELTYPE(ir->coulombtype)); - PS("coulomb-modifier",INTMODIFIER(ir->coulomb_modifier)); - PR("rcoulomb-switch",ir->rcoulomb_switch); - PR("rcoulomb",ir->rcoulomb); - PS("vdwtype",EVDWTYPE(ir->vdwtype)); - PS("vdw-modifier",INTMODIFIER(ir->vdw_modifier)); - PR("rvdw-switch",ir->rvdw_switch); - PR("rvdw",ir->rvdw); - if (ir->epsilon_r != 0) - PR("epsilon-r",ir->epsilon_r); - else - PS("epsilon-r",infbuf); - if (ir->epsilon_rf != 0) - PR("epsilon-rf",ir->epsilon_rf); - else - PS("epsilon-rf",infbuf); - PR("tabext",ir->tabext); - PS("implicit-solvent",EIMPLICITSOL(ir->implicit_solvent)); - PS("gb-algorithm",EGBALGORITHM(ir->gb_algorithm)); - PR("gb-epsilon-solvent",ir->gb_epsilon_solvent); - PI("nstgbradii",ir->nstgbradii); - PR("rgbradii",ir->rgbradii); - PR("gb-saltconc",ir->gb_saltconc); - PR("gb-obc-alpha",ir->gb_obc_alpha); - PR("gb-obc-beta",ir->gb_obc_beta); - PR("gb-obc-gamma",ir->gb_obc_gamma); - PR("gb-dielectric-offset",ir->gb_dielectric_offset); - PS("sa-algorithm",ESAALGORITHM(ir->gb_algorithm)); - PR("sa-surface-tension",ir->sa_surface_tension); - PS("DispCorr",EDISPCORR(ir->eDispCorr)); - PS("bSimTemp",EBOOL(ir->bSimTemp)); - if (ir->bSimTemp) { - pr_simtempvals(fp,indent,ir->simtempvals,ir->fepvals->n_lambda,bMDPformat); - } - PS("free-energy",EFEPTYPE(ir->efep)); - if (ir->efep != efepNO || ir->bSimTemp) { - pr_fepvals(fp,indent,ir->fepvals,bMDPformat); - } - if (ir->bExpanded) { - pr_expandedvals(fp,indent,ir->expandedvals,ir->fepvals->n_lambda,bMDPformat); - } - - PI("nwall",ir->nwall); - PS("wall-type",EWALLTYPE(ir->wall_type)); - PI("wall-atomtype[0]",ir->wall_atomtype[0]); - PI("wall-atomtype[1]",ir->wall_atomtype[1]); - PR("wall-density[0]",ir->wall_density[0]); - PR("wall-density[1]",ir->wall_density[1]); - PR("wall-ewald-zfac",ir->wall_ewald_zfac); - - PS("pull",EPULLTYPE(ir->ePull)); - if (ir->ePull != epullNO) - pr_pull(fp,indent,ir->pull); - - PS("rotation",EBOOL(ir->bRot)); - if (ir->bRot) - pr_rot(fp,indent,ir->rot); - - PS("disre",EDISRETYPE(ir->eDisre)); - PS("disre-weighting",EDISREWEIGHTING(ir->eDisreWeighting)); - PS("disre-mixed",EBOOL(ir->bDisreMixed)); - PR("dr-fc",ir->dr_fc); - PR("dr-tau",ir->dr_tau); - PR("nstdisreout",ir->nstdisreout); - PR("orires-fc",ir->orires_fc); - PR("orires-tau",ir->orires_tau); - PR("nstorireout",ir->nstorireout); - - PR("dihre-fc",ir->dihre_fc); - - PR("em-stepsize",ir->em_stepsize); - PR("em-tol",ir->em_tol); - PI("niter",ir->niter); - PR("fc-stepsize",ir->fc_stepsize); - PI("nstcgsteep",ir->nstcgsteep); - PI("nbfgscorr",ir->nbfgscorr); - - PS("ConstAlg",ECONSTRTYPE(ir->eConstrAlg)); - PR("shake-tol",ir->shake_tol); - PI("lincs-order",ir->nProjOrder); - PR("lincs-warnangle",ir->LincsWarnAngle); - PI("lincs-iter",ir->nLincsIter); - PR("bd-fric",ir->bd_fric); - PI("ld-seed",ir->ld_seed); - PR("cos-accel",ir->cos_accel); - pr_matrix(fp,indent,"deform",ir->deform,bMDPformat); - - PS("adress",EBOOL(ir->bAdress)); - if (ir->bAdress){ - PS("adress_type",EADRESSTYPE(ir->adress->type)); - PR("adress_const_wf",ir->adress->const_wf); - PR("adress_ex_width",ir->adress->ex_width); - PR("adress_hy_width",ir->adress->hy_width); - PS("adress_interface_correction",EADRESSICTYPE(ir->adress->icor)); - PS("adress_site",EADRESSSITETYPE(ir->adress->site)); - PR("adress_ex_force_cap",ir->adress->ex_forcecap); - PS("adress_do_hybridpairs", EBOOL(ir->adress->do_hybridpairs)); - - pr_rvec(fp,indent,"adress_reference_coords",ir->adress->refs,DIM,TRUE); - } - PI("userint1",ir->userint1); - PI("userint2",ir->userint2); - PI("userint3",ir->userint3); - PI("userint4",ir->userint4); - PR("userreal1",ir->userreal1); - PR("userreal2",ir->userreal2); - PR("userreal3",ir->userreal3); - PR("userreal4",ir->userreal4); - pr_grp_opts(fp,indent,"grpopts",&(ir->opts),bMDPformat); - pr_cosine(fp,indent,"efield-x",&(ir->ex[XX]),bMDPformat); - pr_cosine(fp,indent,"efield-xt",&(ir->et[XX]),bMDPformat); - pr_cosine(fp,indent,"efield-y",&(ir->ex[YY]),bMDPformat); - pr_cosine(fp,indent,"efield-yt",&(ir->et[YY]),bMDPformat); - pr_cosine(fp,indent,"efield-z",&(ir->ex[ZZ]),bMDPformat); - pr_cosine(fp,indent,"efield-zt",&(ir->et[ZZ]),bMDPformat); - PS("bQMMM",EBOOL(ir->bQMMM)); - PI("QMconstraints",ir->QMconstraints); - PI("QMMMscheme",ir->QMMMscheme); - PR("scalefactor",ir->scalefactor); - pr_qm_opts(fp,indent,"qm-opts",&(ir->opts)); - } + const char *infbuf = "inf"; + int i; + + if (available(fp, ir, indent, title)) + { + if (!bMDPformat) + { + indent = pr_title(fp, indent, title); + } + PS("integrator", EI(ir->eI)); + PSTEP("nsteps", ir->nsteps); + PSTEP("init-step", ir->init_step); + PS("cutoff-scheme", ECUTSCHEME(ir->cutoff_scheme)); + PS("ns_type", ENS(ir->ns_type)); + PI("nstlist", ir->nstlist); + PI("ndelta", ir->ndelta); + PI("nstcomm", ir->nstcomm); + PS("comm-mode", ECOM(ir->comm_mode)); + PI("nstlog", ir->nstlog); + PI("nstxout", ir->nstxout); + PI("nstvout", ir->nstvout); + PI("nstfout", ir->nstfout); + PI("nstcalcenergy", ir->nstcalcenergy); + PI("nstenergy", ir->nstenergy); + PI("nstxtcout", ir->nstxtcout); + PR("init-t", ir->init_t); + PR("delta-t", ir->delta_t); + + PR("xtcprec", ir->xtcprec); + PR("fourierspacing", ir->fourier_spacing); + PI("nkx", ir->nkx); + PI("nky", ir->nky); + PI("nkz", ir->nkz); + PI("pme-order", ir->pme_order); + PR("ewald-rtol", ir->ewald_rtol); + PR("ewald-geometry", ir->ewald_geometry); + PR("epsilon-surface", ir->epsilon_surface); + PS("optimize-fft", EBOOL(ir->bOptFFT)); + PS("ePBC", EPBC(ir->ePBC)); + PS("bPeriodicMols", EBOOL(ir->bPeriodicMols)); + PS("bContinuation", EBOOL(ir->bContinuation)); + PS("bShakeSOR", EBOOL(ir->bShakeSOR)); + PS("etc", ETCOUPLTYPE(ir->etc)); + PS("bPrintNHChains", EBOOL(ir->bPrintNHChains)); + PI("nsttcouple", ir->nsttcouple); + PS("epc", EPCOUPLTYPE(ir->epc)); + PS("epctype", EPCOUPLTYPETYPE(ir->epct)); + PI("nstpcouple", ir->nstpcouple); + PR("tau-p", ir->tau_p); + pr_matrix(fp, indent, "ref-p", ir->ref_p, bMDPformat); + pr_matrix(fp, indent, "compress", ir->compress, bMDPformat); + PS("refcoord-scaling", EREFSCALINGTYPE(ir->refcoord_scaling)); + if (bMDPformat) + { + fprintf(fp, "posres-com = %g %g %g\n", ir->posres_com[XX], + ir->posres_com[YY], ir->posres_com[ZZ]); + } + else + { + pr_rvec(fp, indent, "posres-com", ir->posres_com, DIM, TRUE); + } + if (bMDPformat) + { + fprintf(fp, "posres-comB = %g %g %g\n", ir->posres_comB[XX], + ir->posres_comB[YY], ir->posres_comB[ZZ]); + } + else + { + pr_rvec(fp, indent, "posres-comB", ir->posres_comB, DIM, TRUE); + } + PR("verlet-buffer-drift", ir->verletbuf_drift); + PR("rlist", ir->rlist); + PR("rlistlong", ir->rlistlong); + PR("nstcalclr", ir->nstcalclr); + PR("rtpi", ir->rtpi); + PS("coulombtype", EELTYPE(ir->coulombtype)); + PS("coulomb-modifier", INTMODIFIER(ir->coulomb_modifier)); + PR("rcoulomb-switch", ir->rcoulomb_switch); + PR("rcoulomb", ir->rcoulomb); + PS("vdwtype", EVDWTYPE(ir->vdwtype)); + PS("vdw-modifier", INTMODIFIER(ir->vdw_modifier)); + PR("rvdw-switch", ir->rvdw_switch); + PR("rvdw", ir->rvdw); + if (ir->epsilon_r != 0) + { + PR("epsilon-r", ir->epsilon_r); + } + else + { + PS("epsilon-r", infbuf); + } + if (ir->epsilon_rf != 0) + { + PR("epsilon-rf", ir->epsilon_rf); + } + else + { + PS("epsilon-rf", infbuf); + } + PR("tabext", ir->tabext); + PS("implicit-solvent", EIMPLICITSOL(ir->implicit_solvent)); + PS("gb-algorithm", EGBALGORITHM(ir->gb_algorithm)); + PR("gb-epsilon-solvent", ir->gb_epsilon_solvent); + PI("nstgbradii", ir->nstgbradii); + PR("rgbradii", ir->rgbradii); + PR("gb-saltconc", ir->gb_saltconc); + PR("gb-obc-alpha", ir->gb_obc_alpha); + PR("gb-obc-beta", ir->gb_obc_beta); + PR("gb-obc-gamma", ir->gb_obc_gamma); + PR("gb-dielectric-offset", ir->gb_dielectric_offset); + PS("sa-algorithm", ESAALGORITHM(ir->gb_algorithm)); + PR("sa-surface-tension", ir->sa_surface_tension); + PS("DispCorr", EDISPCORR(ir->eDispCorr)); + PS("bSimTemp", EBOOL(ir->bSimTemp)); + if (ir->bSimTemp) + { + pr_simtempvals(fp, indent, ir->simtempvals, ir->fepvals->n_lambda, bMDPformat); + } + PS("free-energy", EFEPTYPE(ir->efep)); + if (ir->efep != efepNO || ir->bSimTemp) + { + pr_fepvals(fp, indent, ir->fepvals, bMDPformat); + } + if (ir->bExpanded) + { + pr_expandedvals(fp, indent, ir->expandedvals, ir->fepvals->n_lambda, bMDPformat); + } + + PI("nwall", ir->nwall); + PS("wall-type", EWALLTYPE(ir->wall_type)); + PI("wall-atomtype[0]", ir->wall_atomtype[0]); + PI("wall-atomtype[1]", ir->wall_atomtype[1]); + PR("wall-density[0]", ir->wall_density[0]); + PR("wall-density[1]", ir->wall_density[1]); + PR("wall-ewald-zfac", ir->wall_ewald_zfac); + + PS("pull", EPULLTYPE(ir->ePull)); + if (ir->ePull != epullNO) + { + pr_pull(fp, indent, ir->pull); + } + + PS("rotation", EBOOL(ir->bRot)); + if (ir->bRot) + { + pr_rot(fp, indent, ir->rot); + } + + PS("disre", EDISRETYPE(ir->eDisre)); + PS("disre-weighting", EDISREWEIGHTING(ir->eDisreWeighting)); + PS("disre-mixed", EBOOL(ir->bDisreMixed)); + PR("dr-fc", ir->dr_fc); + PR("dr-tau", ir->dr_tau); + PR("nstdisreout", ir->nstdisreout); + PR("orires-fc", ir->orires_fc); + PR("orires-tau", ir->orires_tau); + PR("nstorireout", ir->nstorireout); + + PR("dihre-fc", ir->dihre_fc); + + PR("em-stepsize", ir->em_stepsize); + PR("em-tol", ir->em_tol); + PI("niter", ir->niter); + PR("fc-stepsize", ir->fc_stepsize); + PI("nstcgsteep", ir->nstcgsteep); + PI("nbfgscorr", ir->nbfgscorr); + + PS("ConstAlg", ECONSTRTYPE(ir->eConstrAlg)); + PR("shake-tol", ir->shake_tol); + PI("lincs-order", ir->nProjOrder); + PR("lincs-warnangle", ir->LincsWarnAngle); + PI("lincs-iter", ir->nLincsIter); + PR("bd-fric", ir->bd_fric); + PI("ld-seed", ir->ld_seed); + PR("cos-accel", ir->cos_accel); + pr_matrix(fp, indent, "deform", ir->deform, bMDPformat); + + PS("adress", EBOOL(ir->bAdress)); + if (ir->bAdress) + { + PS("adress_type", EADRESSTYPE(ir->adress->type)); + PR("adress_const_wf", ir->adress->const_wf); + PR("adress_ex_width", ir->adress->ex_width); + PR("adress_hy_width", ir->adress->hy_width); + PS("adress_interface_correction", EADRESSICTYPE(ir->adress->icor)); + PS("adress_site", EADRESSSITETYPE(ir->adress->site)); + PR("adress_ex_force_cap", ir->adress->ex_forcecap); + PS("adress_do_hybridpairs", EBOOL(ir->adress->do_hybridpairs)); + + pr_rvec(fp, indent, "adress_reference_coords", ir->adress->refs, DIM, TRUE); + } + PI("userint1", ir->userint1); + PI("userint2", ir->userint2); + PI("userint3", ir->userint3); + PI("userint4", ir->userint4); + PR("userreal1", ir->userreal1); + PR("userreal2", ir->userreal2); + PR("userreal3", ir->userreal3); + PR("userreal4", ir->userreal4); + pr_grp_opts(fp, indent, "grpopts", &(ir->opts), bMDPformat); + pr_cosine(fp, indent, "efield-x", &(ir->ex[XX]), bMDPformat); + pr_cosine(fp, indent, "efield-xt", &(ir->et[XX]), bMDPformat); + pr_cosine(fp, indent, "efield-y", &(ir->ex[YY]), bMDPformat); + pr_cosine(fp, indent, "efield-yt", &(ir->et[YY]), bMDPformat); + pr_cosine(fp, indent, "efield-z", &(ir->ex[ZZ]), bMDPformat); + pr_cosine(fp, indent, "efield-zt", &(ir->et[ZZ]), bMDPformat); + PS("bQMMM", EBOOL(ir->bQMMM)); + PI("QMconstraints", ir->QMconstraints); + PI("QMMMscheme", ir->QMMMscheme); + PR("scalefactor", ir->scalefactor); + pr_qm_opts(fp, indent, "qm-opts", &(ir->opts)); + } } #undef PS #undef PR #undef PI -static void pr_harm(FILE *fp,t_iparams *iparams,const char *r,const char *kr) +static void pr_harm(FILE *fp, t_iparams *iparams, const char *r, const char *kr) { - fprintf(fp,"%sA=%12.5e, %sA=%12.5e, %sB=%12.5e, %sB=%12.5e\n", - r,iparams->harmonic.rA,kr,iparams->harmonic.krA, - r,iparams->harmonic.rB,kr,iparams->harmonic.krB); + fprintf(fp, "%sA=%12.5e, %sA=%12.5e, %sB=%12.5e, %sB=%12.5e\n", + r, iparams->harmonic.rA, kr, iparams->harmonic.krA, + r, iparams->harmonic.rB, kr, iparams->harmonic.krB); } -void pr_iparams(FILE *fp,t_functype ftype,t_iparams *iparams) +void pr_iparams(FILE *fp, t_functype ftype, t_iparams *iparams) { - int i; - real VA[4],VB[4],*rbcA,*rbcB; - - switch (ftype) { - case F_ANGLES: - case F_G96ANGLES: - pr_harm(fp,iparams,"th","ct"); - break; - case F_CROSS_BOND_BONDS: - fprintf(fp,"r1e=%15.8e, r2e=%15.8e, krr=%15.8e\n", - iparams->cross_bb.r1e,iparams->cross_bb.r2e, - iparams->cross_bb.krr); - break; - case F_CROSS_BOND_ANGLES: - fprintf(fp,"r1e=%15.8e, r1e=%15.8e, r3e=%15.8e, krt=%15.8e\n", - iparams->cross_ba.r1e,iparams->cross_ba.r2e, - iparams->cross_ba.r3e,iparams->cross_ba.krt); - break; - case F_LINEAR_ANGLES: - fprintf(fp,"klinA=%15.8e, aA=%15.8e, klinB=%15.8e, aB=%15.8e\n", - iparams->linangle.klinA,iparams->linangle.aA, - iparams->linangle.klinB,iparams->linangle.aB); - break; - case F_UREY_BRADLEY: - fprintf(fp,"thetaA=%15.8e, kthetaA=%15.8e, r13A=%15.8e, kUBA=%15.8e, thetaB=%15.8e, kthetaB=%15.8e, r13B=%15.8e, kUBB=%15.8e\n",iparams->u_b.thetaA,iparams->u_b.kthetaA,iparams->u_b.r13A,iparams->u_b.kUBA,iparams->u_b.thetaB,iparams->u_b.kthetaB,iparams->u_b.r13B,iparams->u_b.kUBB); - break; - case F_QUARTIC_ANGLES: - fprintf(fp,"theta=%15.8e",iparams->qangle.theta); - for(i=0; i<5; i++) - fprintf(fp,", c%c=%15.8e",'0'+i,iparams->qangle.c[i]); - fprintf(fp,"\n"); - break; - case F_BHAM: - fprintf(fp,"a=%15.8e, b=%15.8e, c=%15.8e\n", - iparams->bham.a,iparams->bham.b,iparams->bham.c); - break; - case F_BONDS: - case F_G96BONDS: - case F_HARMONIC: - pr_harm(fp,iparams,"b0","cb"); - break; - case F_IDIHS: - pr_harm(fp,iparams,"xi","cx"); - break; - case F_MORSE: - fprintf(fp,"b0A=%15.8e, cbA=%15.8e, betaA=%15.8e, b0B=%15.8e, cbB=%15.8e, betaB=%15.8e\n", - iparams->morse.b0A,iparams->morse.cbA,iparams->morse.betaA, - iparams->morse.b0B,iparams->morse.cbB,iparams->morse.betaB); - break; - case F_CUBICBONDS: - fprintf(fp,"b0=%15.8e, kb=%15.8e, kcub=%15.8e\n", - iparams->cubic.b0,iparams->cubic.kb,iparams->cubic.kcub); - break; - case F_CONNBONDS: - fprintf(fp,"\n"); - break; - case F_FENEBONDS: - fprintf(fp,"bm=%15.8e, kb=%15.8e\n",iparams->fene.bm,iparams->fene.kb); - break; - case F_RESTRBONDS: - fprintf(fp,"lowA=%15.8e, up1A=%15.8e, up2A=%15.8e, kA=%15.8e, lowB=%15.8e, up1B=%15.8e, up2B=%15.8e, kB=%15.8e,\n", - iparams->restraint.lowA,iparams->restraint.up1A, - iparams->restraint.up2A,iparams->restraint.kA, - iparams->restraint.lowB,iparams->restraint.up1B, - iparams->restraint.up2B,iparams->restraint.kB); - break; - case F_TABBONDS: - case F_TABBONDSNC: - case F_TABANGLES: - case F_TABDIHS: - fprintf(fp,"tab=%d, kA=%15.8e, kB=%15.8e\n", - iparams->tab.table,iparams->tab.kA,iparams->tab.kB); - break; - case F_POLARIZATION: - fprintf(fp,"alpha=%15.8e\n",iparams->polarize.alpha); - break; - case F_ANHARM_POL: - fprintf(fp,"alpha=%15.8e drcut=%15.8e khyp=%15.8e\n", - iparams->anharm_polarize.alpha, - iparams->anharm_polarize.drcut, - iparams->anharm_polarize.khyp); - break; - case F_THOLE_POL: - fprintf(fp,"a=%15.8e, alpha1=%15.8e, alpha2=%15.8e, rfac=%15.8e\n", - iparams->thole.a,iparams->thole.alpha1,iparams->thole.alpha2, - iparams->thole.rfac); - break; - case F_WATER_POL: - fprintf(fp,"al_x=%15.8e, al_y=%15.8e, al_z=%15.8e, rOH=%9.6f, rHH=%9.6f, rOD=%9.6f\n", - iparams->wpol.al_x,iparams->wpol.al_y,iparams->wpol.al_z, - iparams->wpol.rOH,iparams->wpol.rHH,iparams->wpol.rOD); - break; - case F_LJ: - fprintf(fp,"c6=%15.8e, c12=%15.8e\n",iparams->lj.c6,iparams->lj.c12); - break; - case F_LJ14: - fprintf(fp,"c6A=%15.8e, c12A=%15.8e, c6B=%15.8e, c12B=%15.8e\n", - iparams->lj14.c6A,iparams->lj14.c12A, - iparams->lj14.c6B,iparams->lj14.c12B); - break; - case F_LJC14_Q: - fprintf(fp,"fqq=%15.8e, qi=%15.8e, qj=%15.8e, c6=%15.8e, c12=%15.8e\n", - iparams->ljc14.fqq, - iparams->ljc14.qi,iparams->ljc14.qj, - iparams->ljc14.c6,iparams->ljc14.c12); - break; - case F_LJC_PAIRS_NB: - fprintf(fp,"qi=%15.8e, qj=%15.8e, c6=%15.8e, c12=%15.8e\n", - iparams->ljcnb.qi,iparams->ljcnb.qj, - iparams->ljcnb.c6,iparams->ljcnb.c12); - break; - case F_PDIHS: - case F_PIDIHS: - case F_ANGRES: - case F_ANGRESZ: - fprintf(fp,"phiA=%15.8e, cpA=%15.8e, phiB=%15.8e, cpB=%15.8e, mult=%d\n", - iparams->pdihs.phiA,iparams->pdihs.cpA, - iparams->pdihs.phiB,iparams->pdihs.cpB, - iparams->pdihs.mult); - break; - case F_DISRES: - fprintf(fp,"label=%4d, type=%1d, low=%15.8e, up1=%15.8e, up2=%15.8e, fac=%15.8e)\n", - iparams->disres.label,iparams->disres.type, - iparams->disres.low,iparams->disres.up1, - iparams->disres.up2,iparams->disres.kfac); - break; - case F_ORIRES: - fprintf(fp,"ex=%4d, label=%d, power=%4d, c=%15.8e, obs=%15.8e, kfac=%15.8e)\n", - iparams->orires.ex,iparams->orires.label,iparams->orires.power, - iparams->orires.c,iparams->orires.obs,iparams->orires.kfac); - break; - case F_DIHRES: - fprintf(fp,"phiA=%15.8e, dphiA=%15.8e, kfacA=%15.8e, phiB=%15.8e, dphiB=%15.8e, kfacB=%15.8e\n", - iparams->dihres.phiA,iparams->dihres.dphiA,iparams->dihres.kfacA, - iparams->dihres.phiB,iparams->dihres.dphiB,iparams->dihres.kfacB); - break; - case F_POSRES: - fprintf(fp,"pos0A=(%15.8e,%15.8e,%15.8e), fcA=(%15.8e,%15.8e,%15.8e), pos0B=(%15.8e,%15.8e,%15.8e), fcB=(%15.8e,%15.8e,%15.8e)\n", - iparams->posres.pos0A[XX],iparams->posres.pos0A[YY], - iparams->posres.pos0A[ZZ],iparams->posres.fcA[XX], - iparams->posres.fcA[YY],iparams->posres.fcA[ZZ], - iparams->posres.pos0B[XX],iparams->posres.pos0B[YY], - iparams->posres.pos0B[ZZ],iparams->posres.fcB[XX], - iparams->posres.fcB[YY],iparams->posres.fcB[ZZ]); - break; - case F_FBPOSRES: - fprintf(fp,"pos0=(%15.8e,%15.8e,%15.8e), geometry=%d, r=%15.8e, k=%15.8e\n", - iparams->fbposres.pos0[XX], iparams->fbposres.pos0[YY], - iparams->fbposres.pos0[ZZ], iparams->fbposres.geom, - iparams->fbposres.r, iparams->fbposres.k); - break; - case F_RBDIHS: - for (i=0; irbdihs.rbcA[i]); - fprintf(fp,"\n"); - for (i=0; irbdihs.rbcB[i]); - fprintf(fp,"\n"); - break; - case F_FOURDIHS: - /* Use the OPLS -> Ryckaert-Bellemans formula backwards to get the - * OPLS potential constants back. - */ - rbcA = iparams->rbdihs.rbcA; - rbcB = iparams->rbdihs.rbcB; - - VA[3] = -0.25*rbcA[4]; - VA[2] = -0.5*rbcA[3]; - VA[1] = 4.0*VA[3]-rbcA[2]; - VA[0] = 3.0*VA[2]-2.0*rbcA[1]; - - VB[3] = -0.25*rbcB[4]; - VB[2] = -0.5*rbcB[3]; - VB[1] = 4.0*VB[3]-rbcB[2]; - VB[0] = 3.0*VB[2]-2.0*rbcB[1]; - - for (i=0; iconstr.dA,iparams->constr.dB); - break; - case F_SETTLE: - fprintf(fp,"doh=%15.8e, dhh=%15.8e\n",iparams->settle.doh, - iparams->settle.dhh); - break; - case F_VSITE2: - fprintf(fp,"a=%15.8e\n",iparams->vsite.a); - break; - case F_VSITE3: - case F_VSITE3FD: - case F_VSITE3FAD: - fprintf(fp,"a=%15.8e, b=%15.8e\n",iparams->vsite.a,iparams->vsite.b); - break; - case F_VSITE3OUT: - case F_VSITE4FD: - case F_VSITE4FDN: - fprintf(fp,"a=%15.8e, b=%15.8e, c=%15.8e\n", - iparams->vsite.a,iparams->vsite.b,iparams->vsite.c); - break; - case F_VSITEN: - fprintf(fp,"n=%2d, a=%15.8e\n",iparams->vsiten.n,iparams->vsiten.a); - break; - case F_GB12: - case F_GB13: - case F_GB14: - fprintf(fp, "sar=%15.8e, st=%15.8e, pi=%15.8e, gbr=%15.8e, bmlt=%15.8e\n",iparams->gb.sar,iparams->gb.st,iparams->gb.pi,iparams->gb.gbr,iparams->gb.bmlt); - break; - case F_CMAP: - fprintf(fp, "cmapA=%1d, cmapB=%1d\n",iparams->cmap.cmapA, iparams->cmap.cmapB); - break; - default: - gmx_fatal(FARGS,"unknown function type %d (%s) in %s line %d", - ftype,interaction_function[ftype].name,__FILE__,__LINE__); - } + int i; + real VA[4], VB[4], *rbcA, *rbcB; + + switch (ftype) + { + case F_ANGLES: + case F_G96ANGLES: + pr_harm(fp, iparams, "th", "ct"); + break; + case F_CROSS_BOND_BONDS: + fprintf(fp, "r1e=%15.8e, r2e=%15.8e, krr=%15.8e\n", + iparams->cross_bb.r1e, iparams->cross_bb.r2e, + iparams->cross_bb.krr); + break; + case F_CROSS_BOND_ANGLES: + fprintf(fp, "r1e=%15.8e, r1e=%15.8e, r3e=%15.8e, krt=%15.8e\n", + iparams->cross_ba.r1e, iparams->cross_ba.r2e, + iparams->cross_ba.r3e, iparams->cross_ba.krt); + break; + case F_LINEAR_ANGLES: + fprintf(fp, "klinA=%15.8e, aA=%15.8e, klinB=%15.8e, aB=%15.8e\n", + iparams->linangle.klinA, iparams->linangle.aA, + iparams->linangle.klinB, iparams->linangle.aB); + break; + case F_UREY_BRADLEY: + fprintf(fp, "thetaA=%15.8e, kthetaA=%15.8e, r13A=%15.8e, kUBA=%15.8e, thetaB=%15.8e, kthetaB=%15.8e, r13B=%15.8e, kUBB=%15.8e\n", iparams->u_b.thetaA, iparams->u_b.kthetaA, iparams->u_b.r13A, iparams->u_b.kUBA, iparams->u_b.thetaB, iparams->u_b.kthetaB, iparams->u_b.r13B, iparams->u_b.kUBB); + break; + case F_QUARTIC_ANGLES: + fprintf(fp, "theta=%15.8e", iparams->qangle.theta); + for (i = 0; i < 5; i++) + { + fprintf(fp, ", c%c=%15.8e", '0'+i, iparams->qangle.c[i]); + } + fprintf(fp, "\n"); + break; + case F_BHAM: + fprintf(fp, "a=%15.8e, b=%15.8e, c=%15.8e\n", + iparams->bham.a, iparams->bham.b, iparams->bham.c); + break; + case F_BONDS: + case F_G96BONDS: + case F_HARMONIC: + pr_harm(fp, iparams, "b0", "cb"); + break; + case F_IDIHS: + pr_harm(fp, iparams, "xi", "cx"); + break; + case F_MORSE: + fprintf(fp, "b0A=%15.8e, cbA=%15.8e, betaA=%15.8e, b0B=%15.8e, cbB=%15.8e, betaB=%15.8e\n", + iparams->morse.b0A, iparams->morse.cbA, iparams->morse.betaA, + iparams->morse.b0B, iparams->morse.cbB, iparams->morse.betaB); + break; + case F_CUBICBONDS: + fprintf(fp, "b0=%15.8e, kb=%15.8e, kcub=%15.8e\n", + iparams->cubic.b0, iparams->cubic.kb, iparams->cubic.kcub); + break; + case F_CONNBONDS: + fprintf(fp, "\n"); + break; + case F_FENEBONDS: + fprintf(fp, "bm=%15.8e, kb=%15.8e\n", iparams->fene.bm, iparams->fene.kb); + break; + case F_RESTRBONDS: + fprintf(fp, "lowA=%15.8e, up1A=%15.8e, up2A=%15.8e, kA=%15.8e, lowB=%15.8e, up1B=%15.8e, up2B=%15.8e, kB=%15.8e,\n", + iparams->restraint.lowA, iparams->restraint.up1A, + iparams->restraint.up2A, iparams->restraint.kA, + iparams->restraint.lowB, iparams->restraint.up1B, + iparams->restraint.up2B, iparams->restraint.kB); + break; + case F_TABBONDS: + case F_TABBONDSNC: + case F_TABANGLES: + case F_TABDIHS: + fprintf(fp, "tab=%d, kA=%15.8e, kB=%15.8e\n", + iparams->tab.table, iparams->tab.kA, iparams->tab.kB); + break; + case F_POLARIZATION: + fprintf(fp, "alpha=%15.8e\n", iparams->polarize.alpha); + break; + case F_ANHARM_POL: + fprintf(fp, "alpha=%15.8e drcut=%15.8e khyp=%15.8e\n", + iparams->anharm_polarize.alpha, + iparams->anharm_polarize.drcut, + iparams->anharm_polarize.khyp); + break; + case F_THOLE_POL: + fprintf(fp, "a=%15.8e, alpha1=%15.8e, alpha2=%15.8e, rfac=%15.8e\n", + iparams->thole.a, iparams->thole.alpha1, iparams->thole.alpha2, + iparams->thole.rfac); + break; + case F_WATER_POL: + fprintf(fp, "al_x=%15.8e, al_y=%15.8e, al_z=%15.8e, rOH=%9.6f, rHH=%9.6f, rOD=%9.6f\n", + iparams->wpol.al_x, iparams->wpol.al_y, iparams->wpol.al_z, + iparams->wpol.rOH, iparams->wpol.rHH, iparams->wpol.rOD); + break; + case F_LJ: + fprintf(fp, "c6=%15.8e, c12=%15.8e\n", iparams->lj.c6, iparams->lj.c12); + break; + case F_LJ14: + fprintf(fp, "c6A=%15.8e, c12A=%15.8e, c6B=%15.8e, c12B=%15.8e\n", + iparams->lj14.c6A, iparams->lj14.c12A, + iparams->lj14.c6B, iparams->lj14.c12B); + break; + case F_LJC14_Q: + fprintf(fp, "fqq=%15.8e, qi=%15.8e, qj=%15.8e, c6=%15.8e, c12=%15.8e\n", + iparams->ljc14.fqq, + iparams->ljc14.qi, iparams->ljc14.qj, + iparams->ljc14.c6, iparams->ljc14.c12); + break; + case F_LJC_PAIRS_NB: + fprintf(fp, "qi=%15.8e, qj=%15.8e, c6=%15.8e, c12=%15.8e\n", + iparams->ljcnb.qi, iparams->ljcnb.qj, + iparams->ljcnb.c6, iparams->ljcnb.c12); + break; + case F_PDIHS: + case F_PIDIHS: + case F_ANGRES: + case F_ANGRESZ: + fprintf(fp, "phiA=%15.8e, cpA=%15.8e, phiB=%15.8e, cpB=%15.8e, mult=%d\n", + iparams->pdihs.phiA, iparams->pdihs.cpA, + iparams->pdihs.phiB, iparams->pdihs.cpB, + iparams->pdihs.mult); + break; + case F_DISRES: + fprintf(fp, "label=%4d, type=%1d, low=%15.8e, up1=%15.8e, up2=%15.8e, fac=%15.8e)\n", + iparams->disres.label, iparams->disres.type, + iparams->disres.low, iparams->disres.up1, + iparams->disres.up2, iparams->disres.kfac); + break; + case F_ORIRES: + fprintf(fp, "ex=%4d, label=%d, power=%4d, c=%15.8e, obs=%15.8e, kfac=%15.8e)\n", + iparams->orires.ex, iparams->orires.label, iparams->orires.power, + iparams->orires.c, iparams->orires.obs, iparams->orires.kfac); + break; + case F_DIHRES: + fprintf(fp, "phiA=%15.8e, dphiA=%15.8e, kfacA=%15.8e, phiB=%15.8e, dphiB=%15.8e, kfacB=%15.8e\n", + iparams->dihres.phiA, iparams->dihres.dphiA, iparams->dihres.kfacA, + iparams->dihres.phiB, iparams->dihres.dphiB, iparams->dihres.kfacB); + break; + case F_POSRES: + fprintf(fp, "pos0A=(%15.8e,%15.8e,%15.8e), fcA=(%15.8e,%15.8e,%15.8e), pos0B=(%15.8e,%15.8e,%15.8e), fcB=(%15.8e,%15.8e,%15.8e)\n", + iparams->posres.pos0A[XX], iparams->posres.pos0A[YY], + iparams->posres.pos0A[ZZ], iparams->posres.fcA[XX], + iparams->posres.fcA[YY], iparams->posres.fcA[ZZ], + iparams->posres.pos0B[XX], iparams->posres.pos0B[YY], + iparams->posres.pos0B[ZZ], iparams->posres.fcB[XX], + iparams->posres.fcB[YY], iparams->posres.fcB[ZZ]); + break; + case F_FBPOSRES: + fprintf(fp, "pos0=(%15.8e,%15.8e,%15.8e), geometry=%d, r=%15.8e, k=%15.8e\n", + iparams->fbposres.pos0[XX], iparams->fbposres.pos0[YY], + iparams->fbposres.pos0[ZZ], iparams->fbposres.geom, + iparams->fbposres.r, iparams->fbposres.k); + break; + case F_RBDIHS: + for (i = 0; i < NR_RBDIHS; i++) + { + fprintf(fp, "%srbcA[%d]=%15.8e", i == 0 ? "" : ", ", i, iparams->rbdihs.rbcA[i]); + } + fprintf(fp, "\n"); + for (i = 0; i < NR_RBDIHS; i++) + { + fprintf(fp, "%srbcB[%d]=%15.8e", i == 0 ? "" : ", ", i, iparams->rbdihs.rbcB[i]); + } + fprintf(fp, "\n"); + break; + case F_FOURDIHS: + /* Use the OPLS -> Ryckaert-Bellemans formula backwards to get the + * OPLS potential constants back. + */ + rbcA = iparams->rbdihs.rbcA; + rbcB = iparams->rbdihs.rbcB; + + VA[3] = -0.25*rbcA[4]; + VA[2] = -0.5*rbcA[3]; + VA[1] = 4.0*VA[3]-rbcA[2]; + VA[0] = 3.0*VA[2]-2.0*rbcA[1]; + + VB[3] = -0.25*rbcB[4]; + VB[2] = -0.5*rbcB[3]; + VB[1] = 4.0*VB[3]-rbcB[2]; + VB[0] = 3.0*VB[2]-2.0*rbcB[1]; + + for (i = 0; i < NR_FOURDIHS; i++) + { + fprintf(fp, "%sFourA[%d]=%15.8e", i == 0 ? "" : ", ", i, VA[i]); + } + fprintf(fp, "\n"); + for (i = 0; i < NR_FOURDIHS; i++) + { + fprintf(fp, "%sFourB[%d]=%15.8e", i == 0 ? "" : ", ", i, VB[i]); + } + fprintf(fp, "\n"); + break; + + case F_CONSTR: + case F_CONSTRNC: + fprintf(fp, "dA=%15.8e, dB=%15.8e\n", iparams->constr.dA, iparams->constr.dB); + break; + case F_SETTLE: + fprintf(fp, "doh=%15.8e, dhh=%15.8e\n", iparams->settle.doh, + iparams->settle.dhh); + break; + case F_VSITE2: + fprintf(fp, "a=%15.8e\n", iparams->vsite.a); + break; + case F_VSITE3: + case F_VSITE3FD: + case F_VSITE3FAD: + fprintf(fp, "a=%15.8e, b=%15.8e\n", iparams->vsite.a, iparams->vsite.b); + break; + case F_VSITE3OUT: + case F_VSITE4FD: + case F_VSITE4FDN: + fprintf(fp, "a=%15.8e, b=%15.8e, c=%15.8e\n", + iparams->vsite.a, iparams->vsite.b, iparams->vsite.c); + break; + case F_VSITEN: + fprintf(fp, "n=%2d, a=%15.8e\n", iparams->vsiten.n, iparams->vsiten.a); + break; + case F_GB12: + case F_GB13: + case F_GB14: + fprintf(fp, "sar=%15.8e, st=%15.8e, pi=%15.8e, gbr=%15.8e, bmlt=%15.8e\n", iparams->gb.sar, iparams->gb.st, iparams->gb.pi, iparams->gb.gbr, iparams->gb.bmlt); + break; + case F_CMAP: + fprintf(fp, "cmapA=%1d, cmapB=%1d\n", iparams->cmap.cmapA, iparams->cmap.cmapB); + break; + default: + gmx_fatal(FARGS, "unknown function type %d (%s) in %s line %d", + ftype, interaction_function[ftype].name, __FILE__, __LINE__); + } } -void pr_ilist(FILE *fp,int indent,const char *title, - t_functype *functype,t_ilist *ilist, gmx_bool bShowNumbers) +void pr_ilist(FILE *fp, int indent, const char *title, + t_functype *functype, t_ilist *ilist, gmx_bool bShowNumbers) { - int i,j,k,type,ftype; + int i, j, k, type, ftype; t_iatom *iatoms; - - if (available(fp,ilist,indent,title) && ilist->nr > 0) - { - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - fprintf(fp,"nr: %d\n",ilist->nr); - if (ilist->nr > 0) { - (void) pr_indent(fp,indent); - fprintf(fp,"iatoms:\n"); - iatoms=ilist->iatoms; - for (i=j=0; inr;) { + + if (available(fp, ilist, indent, title) && ilist->nr > 0) + { + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + fprintf(fp, "nr: %d\n", ilist->nr); + if (ilist->nr > 0) + { + (void) pr_indent(fp, indent); + fprintf(fp, "iatoms:\n"); + iatoms = ilist->iatoms; + for (i = j = 0; i < ilist->nr; ) + { #ifndef DEBUG - (void) pr_indent(fp,indent+INDENT); - type=*(iatoms++); - ftype=functype[type]; - (void) fprintf(fp,"%d type=%d (%s)", - bShowNumbers?j:-1,bShowNumbers?type:-1, + (void) pr_indent(fp, indent+INDENT); + type = *(iatoms++); + ftype = functype[type]; + (void) fprintf(fp, "%d type=%d (%s)", + bShowNumbers ? j : -1, bShowNumbers ? type : -1, interaction_function[ftype].name); j++; - for (k=0; kgrid_spacing; nelem = cmap_grid->grid_spacing*cmap_grid->grid_spacing; - - if(available(fp,cmap_grid,indent,title)) + + if (available(fp, cmap_grid, indent, title)) { - fprintf(fp,"%s\n",title); - - for(i=0;ingrid;i++) + fprintf(fp, "%s\n", title); + + for (i = 0; i < cmap_grid->ngrid; i++) { idx = -180.0; - fprintf(fp,"%8s %8s %8s %8s\n","V","dVdx","dVdy","d2dV"); - - fprintf(fp,"grid[%3d]={\n",bShowNumbers?i:-1); - - for(j=0;jgrid_spacing)==0) + if ( (j%cmap_grid->grid_spacing) == 0) { - fprintf(fp,"%8.1f\n",idx); - idx+=dx; + fprintf(fp, "%8.1f\n", idx); + idx += dx; } - - fprintf(fp,"%8.3f ",cmap_grid->cmapdata[i].cmap[j*4]); - fprintf(fp,"%8.3f ",cmap_grid->cmapdata[i].cmap[j*4+1]); - fprintf(fp,"%8.3f ",cmap_grid->cmapdata[i].cmap[j*4+2]); - fprintf(fp,"%8.3f\n",cmap_grid->cmapdata[i].cmap[j*4+3]); + + fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4]); + fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4+1]); + fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4+2]); + fprintf(fp, "%8.3f\n", cmap_grid->cmapdata[i].cmap[j*4+3]); } - fprintf(fp,"\n"); + fprintf(fp, "\n"); } } - + } -void pr_ffparams(FILE *fp,int indent,const char *title, +void pr_ffparams(FILE *fp, int indent, const char *title, gmx_ffparams_t *ffparams, gmx_bool bShowNumbers) { - int i,j; - - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"atnr=%d\n",ffparams->atnr); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"ntypes=%d\n",ffparams->ntypes); - for (i=0; intypes; i++) { - (void) pr_indent(fp,indent+INDENT); - (void) fprintf(fp,"functype[%d]=%s, ", - bShowNumbers?i:-1, - interaction_function[ffparams->functype[i]].name); - pr_iparams(fp,ffparams->functype[i],&ffparams->iparams[i]); - } - (void) pr_double(fp,indent,"reppow",ffparams->reppow); - (void) pr_real(fp,indent,"fudgeQQ",ffparams->fudgeQQ); - pr_cmap(fp,indent,"cmap",&ffparams->cmap_grid,bShowNumbers); + int i, j; + + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "atnr=%d\n", ffparams->atnr); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "ntypes=%d\n", ffparams->ntypes); + for (i = 0; i < ffparams->ntypes; i++) + { + (void) pr_indent(fp, indent+INDENT); + (void) fprintf(fp, "functype[%d]=%s, ", + bShowNumbers ? i : -1, + interaction_function[ffparams->functype[i]].name); + pr_iparams(fp, ffparams->functype[i], &ffparams->iparams[i]); + } + (void) pr_double(fp, indent, "reppow", ffparams->reppow); + (void) pr_real(fp, indent, "fudgeQQ", ffparams->fudgeQQ); + pr_cmap(fp, indent, "cmap", &ffparams->cmap_grid, bShowNumbers); } -void pr_idef(FILE *fp,int indent,const char *title,t_idef *idef, gmx_bool bShowNumbers) +void pr_idef(FILE *fp, int indent, const char *title, t_idef *idef, gmx_bool bShowNumbers) { - int i,j; - - if (available(fp,idef,indent,title)) { - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"atnr=%d\n",idef->atnr); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"ntypes=%d\n",idef->ntypes); - for (i=0; intypes; i++) { - (void) pr_indent(fp,indent+INDENT); - (void) fprintf(fp,"functype[%d]=%s, ", - bShowNumbers?i:-1, - interaction_function[idef->functype[i]].name); - pr_iparams(fp,idef->functype[i],&idef->iparams[i]); - } - (void) pr_real(fp,indent,"fudgeQQ",idef->fudgeQQ); - - for(j=0; (jfunctype,&idef->il[j],bShowNumbers); - } + int i, j; + + if (available(fp, idef, indent, title)) + { + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "atnr=%d\n", idef->atnr); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "ntypes=%d\n", idef->ntypes); + for (i = 0; i < idef->ntypes; i++) + { + (void) pr_indent(fp, indent+INDENT); + (void) fprintf(fp, "functype[%d]=%s, ", + bShowNumbers ? i : -1, + interaction_function[idef->functype[i]].name); + pr_iparams(fp, idef->functype[i], &idef->iparams[i]); + } + (void) pr_real(fp, indent, "fudgeQQ", idef->fudgeQQ); + + for (j = 0; (j < F_NRE); j++) + { + pr_ilist(fp, indent, interaction_function[j].longname, + idef->functype, &idef->il[j], bShowNumbers); + } + } } -static int pr_block_title(FILE *fp,int indent,const char *title,t_block *block) +static int pr_block_title(FILE *fp, int indent, const char *title, t_block *block) { - int i; + int i; - if (available(fp,block,indent,title)) + if (available(fp, block, indent, title)) { - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"nr=%d\n",block->nr); + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "nr=%d\n", block->nr); } - return indent; + return indent; } -static int pr_blocka_title(FILE *fp,int indent,const char *title,t_blocka *block) +static int pr_blocka_title(FILE *fp, int indent, const char *title, t_blocka *block) { - int i; + int i; - if (available(fp,block,indent,title)) + if (available(fp, block, indent, title)) { - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"nr=%d\n",block->nr); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"nra=%d\n",block->nra); + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "nr=%d\n", block->nr); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "nra=%d\n", block->nra); } - return indent; + return indent; } -static void low_pr_blocka(FILE *fp,int indent,const char *title,t_blocka *block, gmx_bool bShowNumbers) +static void low_pr_blocka(FILE *fp, int indent, const char *title, t_blocka *block, gmx_bool bShowNumbers) { - int i; - - if (available(fp,block,indent,title)) + int i; + + if (available(fp, block, indent, title)) { - indent=pr_blocka_title(fp,indent,title,block); - for (i=0; i<=block->nr; i++) + indent = pr_blocka_title(fp, indent, title, block); + for (i = 0; i <= block->nr; i++) { - (void) pr_indent(fp,indent+INDENT); - (void) fprintf(fp,"%s->index[%d]=%u\n", - title,bShowNumbers?i:-1,block->index[i]); + (void) pr_indent(fp, indent+INDENT); + (void) fprintf(fp, "%s->index[%d]=%u\n", + title, bShowNumbers ? i : -1, block->index[i]); } - for (i=0; inra; i++) + for (i = 0; i < block->nra; i++) { - (void) pr_indent(fp,indent+INDENT); - (void) fprintf(fp,"%s->a[%d]=%u\n", - title,bShowNumbers?i:-1,block->a[i]); + (void) pr_indent(fp, indent+INDENT); + (void) fprintf(fp, "%s->a[%d]=%u\n", + title, bShowNumbers ? i : -1, block->a[i]); } } } -void pr_block(FILE *fp,int indent,const char *title,t_block *block,gmx_bool bShowNumbers) +void pr_block(FILE *fp, int indent, const char *title, t_block *block, gmx_bool bShowNumbers) { - int i,j,ok,size,start,end; - - if (available(fp,block,indent,title)) - { - indent=pr_block_title(fp,indent,title,block); - start=0; - end=start; - if ((ok=(block->index[start]==0))==0) - (void) fprintf(fp,"block->index[%d] should be 0\n",start); - else - for (i=0; inr; i++) - { - end=block->index[i+1]; - size=pr_indent(fp,indent); - if (end<=start) - size+=fprintf(fp,"%s[%d]={}\n",title,i); - else - size+=fprintf(fp,"%s[%d]={%d..%d}\n", - title,bShowNumbers?i:-1, - bShowNumbers?start:-1,bShowNumbers?end-1:-1); - start=end; - } + int i, j, ok, size, start, end; + + if (available(fp, block, indent, title)) + { + indent = pr_block_title(fp, indent, title, block); + start = 0; + end = start; + if ((ok = (block->index[start] == 0)) == 0) + { + (void) fprintf(fp, "block->index[%d] should be 0\n", start); + } + else + { + for (i = 0; i < block->nr; i++) + { + end = block->index[i+1]; + size = pr_indent(fp, indent); + if (end <= start) + { + size += fprintf(fp, "%s[%d]={}\n", title, i); + } + else + { + size += fprintf(fp, "%s[%d]={%d..%d}\n", + title, bShowNumbers ? i : -1, + bShowNumbers ? start : -1, bShowNumbers ? end-1 : -1); + } + start = end; + } + } } } -void pr_blocka(FILE *fp,int indent,const char *title,t_blocka *block,gmx_bool bShowNumbers) +void pr_blocka(FILE *fp, int indent, const char *title, t_blocka *block, gmx_bool bShowNumbers) { - int i,j,ok,size,start,end; - - if (available(fp,block,indent,title)) - { - indent=pr_blocka_title(fp,indent,title,block); - start=0; - end=start; - if ((ok=(block->index[start]==0))==0) - (void) fprintf(fp,"block->index[%d] should be 0\n",start); - else - for (i=0; inr; i++) - { - end=block->index[i+1]; - size=pr_indent(fp,indent); - if (end<=start) - size+=fprintf(fp,"%s[%d]={",title,i); - else - size+=fprintf(fp,"%s[%d][%d..%d]={", - title,bShowNumbers?i:-1, - bShowNumbers?start:-1,bShowNumbers?end-1:-1); - for (j=start; jstart) size+=fprintf(fp,", "); - if ((size)>(USE_WIDTH)) - { - (void) fprintf(fp,"\n"); - size=pr_indent(fp,indent+INDENT); - } - size+=fprintf(fp,"%u",block->a[j]); - } - (void) fprintf(fp,"}\n"); - start=end; - } - if ((end!=block->nra)||(!ok)) + int i, j, ok, size, start, end; + + if (available(fp, block, indent, title)) + { + indent = pr_blocka_title(fp, indent, title, block); + start = 0; + end = start; + if ((ok = (block->index[start] == 0)) == 0) + { + (void) fprintf(fp, "block->index[%d] should be 0\n", start); + } + else + { + for (i = 0; i < block->nr; i++) + { + end = block->index[i+1]; + size = pr_indent(fp, indent); + if (end <= start) + { + size += fprintf(fp, "%s[%d]={", title, i); + } + else + { + size += fprintf(fp, "%s[%d][%d..%d]={", + title, bShowNumbers ? i : -1, + bShowNumbers ? start : -1, bShowNumbers ? end-1 : -1); + } + for (j = start; j < end; j++) + { + if (j > start) + { + size += fprintf(fp, ", "); + } + if ((size) > (USE_WIDTH)) + { + (void) fprintf(fp, "\n"); + size = pr_indent(fp, indent+INDENT); + } + size += fprintf(fp, "%u", block->a[j]); + } + (void) fprintf(fp, "}\n"); + start = end; + } + } + if ((end != block->nra) || (!ok)) { - (void) pr_indent(fp,indent); - (void) fprintf(fp,"tables inconsistent, dumping complete tables:\n"); - low_pr_blocka(fp,indent,title,block,bShowNumbers); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "tables inconsistent, dumping complete tables:\n"); + low_pr_blocka(fp, indent, title, block, bShowNumbers); } } } -static void pr_strings(FILE *fp,int indent,const char *title,char ***nm,int n, gmx_bool bShowNumbers) +static void pr_strings(FILE *fp, int indent, const char *title, char ***nm, int n, gmx_bool bShowNumbers) { - int i; + int i; - if (available(fp,nm,indent,title)) - { - indent=pr_title_n(fp,indent,title,n); - for (i=0; igrps,groups->grpname,bShowNumbers); - pr_strings(fp,indent,"grpname",groups->grpname,groups->ngrpname,bShowNumbers); + pr_grps(fp, indent, "grp", groups->grps, groups->grpname, bShowNumbers); + pr_strings(fp, indent, "grpname", groups->grpname, groups->ngrpname, bShowNumbers); - (void) pr_indent(fp,indent); - fprintf(fp,"groups "); - for(g=0; gngrpnr[g]); - nat_max = max(nat_max,groups->ngrpnr[g]); + printf(" %5d", groups->ngrpnr[g]); + nat_max = max(nat_max, groups->ngrpnr[g]); } printf("\n"); if (nat_max == 0) { - (void) pr_indent(fp,indent); - fprintf(fp,"groupnr[%5s] =","*"); - for(g=0; ggrpnr[g] ? groups->grpnr[g][i] : 0); } - fprintf(fp,"\n"); + fprintf(fp, "\n"); } } } -void pr_atoms(FILE *fp,int indent,const char *title,t_atoms *atoms, - gmx_bool bShownumbers) +void pr_atoms(FILE *fp, int indent, const char *title, t_atoms *atoms, + gmx_bool bShownumbers) { - if (available(fp,atoms,indent,title)) + if (available(fp, atoms, indent, title)) { - indent=pr_title(fp,indent,title); - pr_atom(fp,indent,"atom",atoms->atom,atoms->nr); - pr_strings(fp,indent,"atom",atoms->atomname,atoms->nr,bShownumbers); - pr_strings2(fp,indent,"type",atoms->atomtype,atoms->atomtypeB,atoms->nr,bShownumbers); - pr_resinfo(fp,indent,"residue",atoms->resinfo,atoms->nres,bShownumbers); + indent = pr_title(fp, indent, title); + pr_atom(fp, indent, "atom", atoms->atom, atoms->nr); + pr_strings(fp, indent, "atom", atoms->atomname, atoms->nr, bShownumbers); + pr_strings2(fp, indent, "type", atoms->atomtype, atoms->atomtypeB, atoms->nr, bShownumbers); + pr_resinfo(fp, indent, "residue", atoms->resinfo, atoms->nres, bShownumbers); } } -void pr_atomtypes(FILE *fp,int indent,const char *title,t_atomtypes *atomtypes, - gmx_bool bShowNumbers) +void pr_atomtypes(FILE *fp, int indent, const char *title, t_atomtypes *atomtypes, + gmx_bool bShowNumbers) { - int i; - if (available(fp,atomtypes,indent,title)) - { - indent=pr_title(fp,indent,title); - for(i=0;inr;i++) { - pr_indent(fp,indent); - fprintf(fp, - "atomtype[%3d]={radius=%12.5e, volume=%12.5e, gb_radius=%12.5e, surftens=%12.5e, atomnumber=%4d, S_hct=%12.5e)}\n", - bShowNumbers?i:-1,atomtypes->radius[i],atomtypes->vol[i], - atomtypes->gb_radius[i], - atomtypes->surftens[i],atomtypes->atomnumber[i],atomtypes->S_hct[i]); + int i; + if (available(fp, atomtypes, indent, title)) + { + indent = pr_title(fp, indent, title); + for (i = 0; i < atomtypes->nr; i++) + { + pr_indent(fp, indent); + fprintf(fp, + "atomtype[%3d]={radius=%12.5e, volume=%12.5e, gb_radius=%12.5e, surftens=%12.5e, atomnumber=%4d, S_hct=%12.5e)}\n", + bShowNumbers ? i : -1, atomtypes->radius[i], atomtypes->vol[i], + atomtypes->gb_radius[i], + atomtypes->surftens[i], atomtypes->atomnumber[i], atomtypes->S_hct[i]); + } } - } } -static void pr_moltype(FILE *fp,int indent,const char *title, - gmx_moltype_t *molt,int n, +static void pr_moltype(FILE *fp, int indent, const char *title, + gmx_moltype_t *molt, int n, gmx_ffparams_t *ffparams, gmx_bool bShowNumbers) { int j; - indent = pr_title_n(fp,indent,title,n); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"name=\"%s\"\n",*(molt->name)); - pr_atoms(fp,indent,"atoms",&(molt->atoms),bShowNumbers); - pr_block(fp,indent,"cgs",&molt->cgs, bShowNumbers); - pr_blocka(fp,indent,"excls",&molt->excls, bShowNumbers); - for(j=0; (jfunctype,&molt->ilist[j],bShowNumbers); + indent = pr_title_n(fp, indent, title, n); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "name=\"%s\"\n", *(molt->name)); + pr_atoms(fp, indent, "atoms", &(molt->atoms), bShowNumbers); + pr_block(fp, indent, "cgs", &molt->cgs, bShowNumbers); + pr_blocka(fp, indent, "excls", &molt->excls, bShowNumbers); + for (j = 0; (j < F_NRE); j++) + { + pr_ilist(fp, indent, interaction_function[j].longname, + ffparams->functype, &molt->ilist[j], bShowNumbers); } } -static void pr_molblock(FILE *fp,int indent,const char *title, - gmx_molblock_t *molb,int n, +static void pr_molblock(FILE *fp, int indent, const char *title, + gmx_molblock_t *molb, int n, gmx_moltype_t *molt, gmx_bool bShowNumbers) { - indent = pr_title_n(fp,indent,title,n); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"%-20s = %d \"%s\"\n", - "moltype",molb->type,*(molt[molb->type].name)); - pr_int(fp,indent,"#molecules",molb->nmol); - pr_int(fp,indent,"#atoms_mol",molb->natoms_mol); - pr_int(fp,indent,"#posres_xA",molb->nposres_xA); - if (molb->nposres_xA > 0) { - pr_rvecs(fp,indent,"posres_xA",molb->posres_xA,molb->nposres_xA); - } - pr_int(fp,indent,"#posres_xB",molb->nposres_xB); - if (molb->nposres_xB > 0) { - pr_rvecs(fp,indent,"posres_xB",molb->posres_xB,molb->nposres_xB); + indent = pr_title_n(fp, indent, title, n); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "%-20s = %d \"%s\"\n", + "moltype", molb->type, *(molt[molb->type].name)); + pr_int(fp, indent, "#molecules", molb->nmol); + pr_int(fp, indent, "#atoms_mol", molb->natoms_mol); + pr_int(fp, indent, "#posres_xA", molb->nposres_xA); + if (molb->nposres_xA > 0) + { + pr_rvecs(fp, indent, "posres_xA", molb->posres_xA, molb->nposres_xA); + } + pr_int(fp, indent, "#posres_xB", molb->nposres_xB); + if (molb->nposres_xB > 0) + { + pr_rvecs(fp, indent, "posres_xB", molb->posres_xB, molb->nposres_xB); } } -void pr_mtop(FILE *fp,int indent,const char *title,gmx_mtop_t *mtop, +void pr_mtop(FILE *fp, int indent, const char *title, gmx_mtop_t *mtop, gmx_bool bShowNumbers) { - int mt,mb; - - if (available(fp,mtop,indent,title)) { - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"name=\"%s\"\n",*(mtop->name)); - pr_int(fp,indent,"#atoms",mtop->natoms); - pr_int(fp,indent,"#molblock",mtop->nmolblock); - for(mb=0; mbnmolblock; mb++) { - pr_molblock(fp,indent,"molblock",&mtop->molblock[mb],mb, - mtop->moltype,bShowNumbers); + int mt, mb; + + if (available(fp, mtop, indent, title)) + { + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "name=\"%s\"\n", *(mtop->name)); + pr_int(fp, indent, "#atoms", mtop->natoms); + pr_int(fp, indent, "#molblock", mtop->nmolblock); + for (mb = 0; mb < mtop->nmolblock; mb++) + { + pr_molblock(fp, indent, "molblock", &mtop->molblock[mb], mb, + mtop->moltype, bShowNumbers); } - pr_ffparams(fp,indent,"ffparams",&(mtop->ffparams),bShowNumbers); - pr_atomtypes(fp,indent,"atomtypes",&(mtop->atomtypes),bShowNumbers); - for(mt=0; mtnmoltype; mt++) { - pr_moltype(fp,indent,"moltype",&mtop->moltype[mt],mt, - &mtop->ffparams,bShowNumbers); + pr_ffparams(fp, indent, "ffparams", &(mtop->ffparams), bShowNumbers); + pr_atomtypes(fp, indent, "atomtypes", &(mtop->atomtypes), bShowNumbers); + for (mt = 0; mt < mtop->nmoltype; mt++) + { + pr_moltype(fp, indent, "moltype", &mtop->moltype[mt], mt, + &mtop->ffparams, bShowNumbers); } - pr_groups(fp,indent,"groups",&mtop->groups,bShowNumbers); + pr_groups(fp, indent, "groups", &mtop->groups, bShowNumbers); } } -void pr_top(FILE *fp,int indent,const char *title,t_topology *top, gmx_bool bShowNumbers) +void pr_top(FILE *fp, int indent, const char *title, t_topology *top, gmx_bool bShowNumbers) { - if (available(fp,top,indent,title)) { - indent=pr_title(fp,indent,title); - (void) pr_indent(fp,indent); - (void) fprintf(fp,"name=\"%s\"\n",*(top->name)); - pr_atoms(fp,indent,"atoms",&(top->atoms),bShowNumbers); - pr_atomtypes(fp,indent,"atomtypes",&(top->atomtypes),bShowNumbers); - pr_block(fp,indent,"cgs",&top->cgs, bShowNumbers); - pr_block(fp,indent,"mols",&top->mols, bShowNumbers); - pr_blocka(fp,indent,"excls",&top->excls, bShowNumbers); - pr_idef(fp,indent,"idef",&top->idef,bShowNumbers); - } + if (available(fp, top, indent, title)) + { + indent = pr_title(fp, indent, title); + (void) pr_indent(fp, indent); + (void) fprintf(fp, "name=\"%s\"\n", *(top->name)); + pr_atoms(fp, indent, "atoms", &(top->atoms), bShowNumbers); + pr_atomtypes(fp, indent, "atomtypes", &(top->atomtypes), bShowNumbers); + pr_block(fp, indent, "cgs", &top->cgs, bShowNumbers); + pr_block(fp, indent, "mols", &top->mols, bShowNumbers); + pr_blocka(fp, indent, "excls", &top->excls, bShowNumbers); + pr_idef(fp, indent, "idef", &top->idef, bShowNumbers); + } } -void pr_header(FILE *fp,int indent,const char *title,t_tpxheader *sh) +void pr_header(FILE *fp, int indent, const char *title, t_tpxheader *sh) { - char buf[22]; - - if (available(fp,sh,indent,title)) + char buf[22]; + + if (available(fp, sh, indent, title)) { - indent=pr_title(fp,indent,title); - pr_indent(fp,indent); - fprintf(fp,"bIr = %spresent\n",sh->bIr?"":"not "); - pr_indent(fp,indent); - fprintf(fp,"bBox = %spresent\n",sh->bBox?"":"not "); - pr_indent(fp,indent); - fprintf(fp,"bTop = %spresent\n",sh->bTop?"":"not "); - pr_indent(fp,indent); - fprintf(fp,"bX = %spresent\n",sh->bX?"":"not "); - pr_indent(fp,indent); - fprintf(fp,"bV = %spresent\n",sh->bV?"":"not "); - pr_indent(fp,indent); - fprintf(fp,"bF = %spresent\n",sh->bF?"":"not "); - - pr_indent(fp,indent); - fprintf(fp,"natoms = %d\n",sh->natoms); - pr_indent(fp,indent); - fprintf(fp,"lambda = %e\n",sh->lambda); + indent = pr_title(fp, indent, title); + pr_indent(fp, indent); + fprintf(fp, "bIr = %spresent\n", sh->bIr ? "" : "not "); + pr_indent(fp, indent); + fprintf(fp, "bBox = %spresent\n", sh->bBox ? "" : "not "); + pr_indent(fp, indent); + fprintf(fp, "bTop = %spresent\n", sh->bTop ? "" : "not "); + pr_indent(fp, indent); + fprintf(fp, "bX = %spresent\n", sh->bX ? "" : "not "); + pr_indent(fp, indent); + fprintf(fp, "bV = %spresent\n", sh->bV ? "" : "not "); + pr_indent(fp, indent); + fprintf(fp, "bF = %spresent\n", sh->bF ? "" : "not "); + + pr_indent(fp, indent); + fprintf(fp, "natoms = %d\n", sh->natoms); + pr_indent(fp, indent); + fprintf(fp, "lambda = %e\n", sh->lambda); } } -void pr_commrec(FILE *fp,int indent,t_commrec *cr) +void pr_commrec(FILE *fp, int indent, t_commrec *cr) { - pr_indent(fp,indent); - fprintf(fp,"commrec:\n"); - indent+=2; - pr_indent(fp,indent); - fprintf(fp,"nodeid = %d\n",cr->nodeid); - pr_indent(fp,indent); - fprintf(fp,"nnodes = %d\n",cr->nnodes); - pr_indent(fp,indent); - fprintf(fp,"npmenodes = %d\n",cr->npmenodes); - /* - pr_indent(fp,indent); - fprintf(fp,"threadid = %d\n",cr->threadid); - pr_indent(fp,indent); - fprintf(fp,"nthreads = %d\n",cr->nthreads); - */ + pr_indent(fp, indent); + fprintf(fp, "commrec:\n"); + indent += 2; + pr_indent(fp, indent); + fprintf(fp, "nodeid = %d\n", cr->nodeid); + pr_indent(fp, indent); + fprintf(fp, "nnodes = %d\n", cr->nnodes); + pr_indent(fp, indent); + fprintf(fp, "npmenodes = %d\n", cr->npmenodes); + /* + pr_indent(fp,indent); + fprintf(fp,"threadid = %d\n",cr->threadid); + pr_indent(fp,indent); + fprintf(fp,"nthreads = %d\n",cr->nthreads); + */ } diff --git a/src/gromacs/gmxlib/typedefs.c b/src/gromacs/gmxlib/typedefs.c index 6d818ebc09..cc90ecb549 100644 --- a/src/gromacs/gmxlib/typedefs.c +++ b/src/gromacs/gmxlib/typedefs.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -49,14 +49,14 @@ #include "thread_mpi.h" #endif -/* The source code in this file should be thread-safe. +/* The source code in this file should be thread-safe. Please keep it that way. */ -static gmx_bool bOverAllocDD=FALSE; +static gmx_bool bOverAllocDD = FALSE; #ifdef GMX_THREAD_MPI -static tMPI_Thread_mutex_t over_alloc_mutex=TMPI_THREAD_MUTEX_INITIALIZER; +static tMPI_Thread_mutex_t over_alloc_mutex = TMPI_THREAD_MUTEX_INITIALIZER; #endif @@ -64,380 +64,421 @@ void set_over_alloc_dd(gmx_bool set) { #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_lock(&over_alloc_mutex); - /* we just make sure that we don't set this at the same time. + /* we just make sure that we don't set this at the same time. We don't worry too much about reading this rarely-set variable */ -#endif +#endif bOverAllocDD = set; #ifdef GMX_THREAD_MPI tMPI_Thread_mutex_unlock(&over_alloc_mutex); -#endif +#endif } int over_alloc_dd(int n) { - if (bOverAllocDD) - return OVER_ALLOC_FAC*n + 100; - else - return n; + if (bOverAllocDD) + { + return OVER_ALLOC_FAC*n + 100; + } + else + { + return n; + } } -int gmx_large_int_to_int(gmx_large_int_t step,const char *warn) +int gmx_large_int_to_int(gmx_large_int_t step, const char *warn) { - int i; + int i; - i = (int)step; + i = (int)step; - if (warn != NULL && (step < INT_MIN || step > INT_MAX)) { - fprintf(stderr,"\nWARNING during %s:\n",warn); - fprintf(stderr,"step value "); - fprintf(stderr,gmx_large_int_pfmt,step); - fprintf(stderr," does not fit in int, converted to %d\n\n",i); - } + if (warn != NULL && (step < INT_MIN || step > INT_MAX)) + { + fprintf(stderr, "\nWARNING during %s:\n", warn); + fprintf(stderr, "step value "); + fprintf(stderr, gmx_large_int_pfmt, step); + fprintf(stderr, " does not fit in int, converted to %d\n\n", i); + } - return i; + return i; } -char *gmx_step_str(gmx_large_int_t i,char *buf) +char *gmx_step_str(gmx_large_int_t i, char *buf) { - sprintf(buf,gmx_large_int_pfmt,i); + sprintf(buf, gmx_large_int_pfmt, i); - return buf; + return buf; } void init_block(t_block *block) { - int i; + int i; - block->nr = 0; - block->nalloc_index = 1; - snew(block->index,block->nalloc_index); - block->index[0] = 0; + block->nr = 0; + block->nalloc_index = 1; + snew(block->index, block->nalloc_index); + block->index[0] = 0; } void init_blocka(t_blocka *block) { - int i; + int i; - block->nr = 0; - block->nra = 0; - block->nalloc_index = 1; - snew(block->index,block->nalloc_index); - block->index[0] = 0; - block->nalloc_a = 0; - block->a = NULL; + block->nr = 0; + block->nra = 0; + block->nalloc_index = 1; + snew(block->index, block->nalloc_index); + block->index[0] = 0; + block->nalloc_a = 0; + block->a = NULL; } void init_atom(t_atoms *at) { - int i; + int i; - at->nr = 0; - at->nres = 0; - at->atom = NULL; - at->resinfo = NULL; - at->atomname = NULL; - at->atomtype = NULL; - at->atomtypeB= NULL; - at->pdbinfo = NULL; + at->nr = 0; + at->nres = 0; + at->atom = NULL; + at->resinfo = NULL; + at->atomname = NULL; + at->atomtype = NULL; + at->atomtypeB = NULL; + at->pdbinfo = NULL; } void init_atomtypes(t_atomtypes *at) { - at->nr = 0; - at->radius = NULL; - at->vol = NULL; - at->atomnumber = NULL; - at->gb_radius = NULL; - at->S_hct = NULL; + at->nr = 0; + at->radius = NULL; + at->vol = NULL; + at->atomnumber = NULL; + at->gb_radius = NULL; + at->S_hct = NULL; } void init_groups(gmx_groups_t *groups) { - int g; + int g; - groups->ngrpname = 0; - groups->grpname = NULL; - for(g=0; (ggrps[g].nm_ind = NULL; - groups->ngrpnr[g] = 0; - groups->grpnr[g] = NULL; - } + groups->ngrpname = 0; + groups->grpname = NULL; + for (g = 0; (g < egcNR); g++) + { + groups->grps[g].nm_ind = NULL; + groups->ngrpnr[g] = 0; + groups->grpnr[g] = NULL; + } } void init_mtop(gmx_mtop_t *mtop) { - mtop->name = NULL; - mtop->nmoltype = 0; - mtop->moltype = NULL; - mtop->nmolblock = 0; - mtop->molblock = NULL; - mtop->maxres_renum = 0; - mtop->maxresnr = -1; - init_groups(&mtop->groups); - init_block(&mtop->mols); - open_symtab(&mtop->symtab); + mtop->name = NULL; + mtop->nmoltype = 0; + mtop->moltype = NULL; + mtop->nmolblock = 0; + mtop->molblock = NULL; + mtop->maxres_renum = 0; + mtop->maxresnr = -1; + init_groups(&mtop->groups); + init_block(&mtop->mols); + open_symtab(&mtop->symtab); } void init_top (t_topology *top) { - int i; - - top->name = NULL; - init_atom (&(top->atoms)); - init_atomtypes(&(top->atomtypes)); - init_block(&top->cgs); - init_block(&top->mols); - init_blocka(&top->excls); - open_symtab(&top->symtab); + int i; + + top->name = NULL; + init_atom (&(top->atoms)); + init_atomtypes(&(top->atomtypes)); + init_block(&top->cgs); + init_block(&top->mols); + init_blocka(&top->excls); + open_symtab(&top->symtab); } void init_inputrec(t_inputrec *ir) { - memset(ir,0,(size_t)sizeof(*ir)); - snew(ir->fepvals,1); - snew(ir->expandedvals,1); - snew(ir->simtempvals,1); + memset(ir, 0, (size_t)sizeof(*ir)); + snew(ir->fepvals, 1); + snew(ir->expandedvals, 1); + snew(ir->simtempvals, 1); } -void stupid_fill_block(t_block *grp,int natom,gmx_bool bOneIndexGroup) +void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup) { - int i; + int i; - if (bOneIndexGroup) { - grp->nalloc_index = 2; - snew(grp->index,grp->nalloc_index); - grp->index[0]=0; - grp->index[1]=natom; - grp->nr=1; - } - else { - grp->nalloc_index = natom+1; - snew(grp->index,grp->nalloc_index); - snew(grp->index,natom+1); - for(i=0; (i<=natom); i++) - grp->index[i]=i; - grp->nr=natom; - } + if (bOneIndexGroup) + { + grp->nalloc_index = 2; + snew(grp->index, grp->nalloc_index); + grp->index[0] = 0; + grp->index[1] = natom; + grp->nr = 1; + } + else + { + grp->nalloc_index = natom+1; + snew(grp->index, grp->nalloc_index); + snew(grp->index, natom+1); + for (i = 0; (i <= natom); i++) + { + grp->index[i] = i; + } + grp->nr = natom; + } } -void stupid_fill_blocka(t_blocka *grp,int natom) +void stupid_fill_blocka(t_blocka *grp, int natom) { - int i; + int i; + + grp->nalloc_a = natom; + snew(grp->a, grp->nalloc_a); + for (i = 0; (i < natom); i++) + { + grp->a[i] = i; + } + grp->nra = natom; - grp->nalloc_a = natom; - snew(grp->a,grp->nalloc_a); - for(i=0; (ia[i]=i; - grp->nra=natom; - - grp->nalloc_index = natom + 1; - snew(grp->index,grp->nalloc_index); - for(i=0; (i<=natom); i++) - grp->index[i]=i; - grp->nr=natom; + grp->nalloc_index = natom + 1; + snew(grp->index, grp->nalloc_index); + for (i = 0; (i <= natom); i++) + { + grp->index[i] = i; + } + grp->nr = natom; } -void copy_blocka(const t_blocka *src,t_blocka *dest) +void copy_blocka(const t_blocka *src, t_blocka *dest) { - int i; + int i; - dest->nr = src->nr; - dest->nalloc_index = dest->nr + 1; - snew(dest->index,dest->nalloc_index); - for(i=0; inr+1; i++) { - dest->index[i] = src->index[i]; - } - dest->nra = src->nra; - dest->nalloc_a = dest->nra + 1; - snew(dest->a,dest->nalloc_a); - for(i=0; inra+1; i++) { - dest->a[i] = src->a[i]; - } + dest->nr = src->nr; + dest->nalloc_index = dest->nr + 1; + snew(dest->index, dest->nalloc_index); + for (i = 0; i < dest->nr+1; i++) + { + dest->index[i] = src->index[i]; + } + dest->nra = src->nra; + dest->nalloc_a = dest->nra + 1; + snew(dest->a, dest->nalloc_a); + for (i = 0; i < dest->nra+1; i++) + { + dest->a[i] = src->a[i]; + } } void done_block(t_block *block) { - block->nr = 0; - sfree(block->index); - block->nalloc_index = 0; + block->nr = 0; + sfree(block->index); + block->nalloc_index = 0; } void done_blocka(t_blocka *block) { - block->nr = 0; - block->nra = 0; - sfree(block->index); - if (block->a) - sfree(block->a); - block->nalloc_index = 0; - block->nalloc_a = 0; + block->nr = 0; + block->nra = 0; + sfree(block->index); + if (block->a) + { + sfree(block->a); + } + block->nalloc_index = 0; + block->nalloc_a = 0; } void done_atom (t_atoms *at) { - at->nr = 0; - at->nres = 0; - sfree(at->atom); - sfree(at->resinfo); - sfree(at->atomname); - sfree(at->atomtype); - sfree(at->atomtypeB); - if (at->pdbinfo) - sfree(at->pdbinfo); + at->nr = 0; + at->nres = 0; + sfree(at->atom); + sfree(at->resinfo); + sfree(at->atomname); + sfree(at->atomtype); + sfree(at->atomtypeB); + if (at->pdbinfo) + { + sfree(at->pdbinfo); + } } void done_atomtypes(t_atomtypes *atype) { - atype->nr = 0; - sfree(atype->radius); - sfree(atype->vol); - sfree(atype->surftens); - sfree(atype->atomnumber); - sfree(atype->gb_radius); - sfree(atype->S_hct); + atype->nr = 0; + sfree(atype->radius); + sfree(atype->vol); + sfree(atype->surftens); + sfree(atype->atomnumber); + sfree(atype->gb_radius); + sfree(atype->S_hct); } void done_moltype(gmx_moltype_t *molt) { - int f; - - done_atom(&molt->atoms); - done_block(&molt->cgs); - done_blocka(&molt->excls); + int f; - for(f=0; filist[f].iatoms); - molt->ilist[f].nalloc = 0; - } + done_atom(&molt->atoms); + done_block(&molt->cgs); + done_blocka(&molt->excls); + + for (f = 0; f < F_NRE; f++) + { + sfree(molt->ilist[f].iatoms); + molt->ilist[f].nalloc = 0; + } } void done_molblock(gmx_molblock_t *molb) { - if (molb->nposres_xA > 0) { - molb->nposres_xA = 0; - free(molb->posres_xA); - } - if (molb->nposres_xB > 0) { - molb->nposres_xB = 0; - free(molb->posres_xB); - } + if (molb->nposres_xA > 0) + { + molb->nposres_xA = 0; + free(molb->posres_xA); + } + if (molb->nposres_xB > 0) + { + molb->nposres_xB = 0; + free(molb->posres_xB); + } } -void done_mtop(gmx_mtop_t *mtop,gmx_bool bDoneSymtab) +void done_mtop(gmx_mtop_t *mtop, gmx_bool bDoneSymtab) { - int i; + int i; - if (bDoneSymtab) { - done_symtab(&mtop->symtab); - } + if (bDoneSymtab) + { + done_symtab(&mtop->symtab); + } - sfree(mtop->ffparams.functype); - sfree(mtop->ffparams.iparams); + sfree(mtop->ffparams.functype); + sfree(mtop->ffparams.iparams); - for(i=0; inmoltype; i++) { - done_moltype(&mtop->moltype[i]); - } - sfree(mtop->moltype); - for(i=0; inmolblock; i++) { - done_molblock(&mtop->molblock[i]); - } - sfree(mtop->molblock); - done_block(&mtop->mols); + for (i = 0; i < mtop->nmoltype; i++) + { + done_moltype(&mtop->moltype[i]); + } + sfree(mtop->moltype); + for (i = 0; i < mtop->nmolblock; i++) + { + done_molblock(&mtop->molblock[i]); + } + sfree(mtop->molblock); + done_block(&mtop->mols); } void done_top(t_topology *top) { - int f; - - sfree(top->idef.functype); - sfree(top->idef.iparams); - for (f = 0; f < F_NRE; ++f) - { - sfree(top->idef.il[f].iatoms); - top->idef.il[f].iatoms = NULL; - top->idef.il[f].nalloc = 0; - } + int f; - done_atom (&(top->atoms)); + sfree(top->idef.functype); + sfree(top->idef.iparams); + for (f = 0; f < F_NRE; ++f) + { + sfree(top->idef.il[f].iatoms); + top->idef.il[f].iatoms = NULL; + top->idef.il[f].nalloc = 0; + } + + done_atom (&(top->atoms)); - /* For GB */ - done_atomtypes(&(top->atomtypes)); + /* For GB */ + done_atomtypes(&(top->atomtypes)); - done_symtab(&(top->symtab)); - done_block(&(top->cgs)); - done_block(&(top->mols)); - done_blocka(&(top->excls)); + done_symtab(&(top->symtab)); + done_block(&(top->cgs)); + done_block(&(top->mols)); + done_blocka(&(top->excls)); } static void done_pullgrp(t_pullgrp *pgrp) { - sfree(pgrp->ind); - sfree(pgrp->ind_loc); - sfree(pgrp->weight); - sfree(pgrp->weight_loc); + sfree(pgrp->ind); + sfree(pgrp->ind_loc); + sfree(pgrp->weight); + sfree(pgrp->weight_loc); } static void done_pull(t_pull *pull) { - int i; + int i; - for(i=0; ingrp+1; i++) { - done_pullgrp(pull->grp); - done_pullgrp(pull->dyna); - } + for (i = 0; i < pull->ngrp+1; i++) + { + done_pullgrp(pull->grp); + done_pullgrp(pull->dyna); + } } void done_inputrec(t_inputrec *ir) { - int m; - - for(m=0; (mex[m].a) sfree(ir->ex[m].a); - if (ir->ex[m].phi) sfree(ir->ex[m].phi); - if (ir->et[m].a) sfree(ir->et[m].a); - if (ir->et[m].phi) sfree(ir->et[m].phi); - } - - sfree(ir->opts.nrdf); - sfree(ir->opts.ref_t); - sfree(ir->opts.annealing); - sfree(ir->opts.anneal_npoints); - sfree(ir->opts.anneal_time); - sfree(ir->opts.anneal_temp); - sfree(ir->opts.tau_t); - sfree(ir->opts.acc); - sfree(ir->opts.nFreeze); - sfree(ir->opts.QMmethod); - sfree(ir->opts.QMbasis); - sfree(ir->opts.QMcharge); - sfree(ir->opts.QMmult); - sfree(ir->opts.bSH); - sfree(ir->opts.CASorbitals); - sfree(ir->opts.CASelectrons); - sfree(ir->opts.SAon); - sfree(ir->opts.SAoff); - sfree(ir->opts.SAsteps); - sfree(ir->opts.bOPT); - sfree(ir->opts.bTS); - - if (ir->pull) { - done_pull(ir->pull); - sfree(ir->pull); - } + int m; + + for (m = 0; (m < DIM); m++) + { + if (ir->ex[m].a) + { + sfree(ir->ex[m].a); + } + if (ir->ex[m].phi) + { + sfree(ir->ex[m].phi); + } + if (ir->et[m].a) + { + sfree(ir->et[m].a); + } + if (ir->et[m].phi) + { + sfree(ir->et[m].phi); + } + } + + sfree(ir->opts.nrdf); + sfree(ir->opts.ref_t); + sfree(ir->opts.annealing); + sfree(ir->opts.anneal_npoints); + sfree(ir->opts.anneal_time); + sfree(ir->opts.anneal_temp); + sfree(ir->opts.tau_t); + sfree(ir->opts.acc); + sfree(ir->opts.nFreeze); + sfree(ir->opts.QMmethod); + sfree(ir->opts.QMbasis); + sfree(ir->opts.QMcharge); + sfree(ir->opts.QMmult); + sfree(ir->opts.bSH); + sfree(ir->opts.CASorbitals); + sfree(ir->opts.CASelectrons); + sfree(ir->opts.SAon); + sfree(ir->opts.SAoff); + sfree(ir->opts.SAsteps); + sfree(ir->opts.bOPT); + sfree(ir->opts.bTS); + + if (ir->pull) + { + done_pull(ir->pull); + sfree(ir->pull); + } } static void zero_ekinstate(ekinstate_t *eks) { - eks->ekin_n = 0; - eks->ekinh = NULL; - eks->ekinf = NULL; - eks->ekinh_old = NULL; - eks->ekinscalef_nhc = NULL; - eks->ekinscaleh_nhc = NULL; - eks->vscale_nhc = NULL; - eks->dekindl = 0; - eks->mvcos = 0; + eks->ekin_n = 0; + eks->ekinh = NULL; + eks->ekinf = NULL; + eks->ekinh_old = NULL; + eks->ekinscalef_nhc = NULL; + eks->ekinscaleh_nhc = NULL; + eks->vscale_nhc = NULL; + eks->dekindl = 0; + eks->mvcos = 0; } void init_energyhistory(energyhistory_t * enerhist) @@ -461,7 +502,7 @@ static void done_delta_h_history(delta_h_history_t *dht) { int i; - for(i=0; inndh; i++) + for (i = 0; i < dht->nndh; i++) { sfree(dht->dh[i]); } @@ -484,25 +525,26 @@ void done_energyhistory(energyhistory_t * enerhist) void init_gtc_state(t_state *state, int ngtc, int nnhpres, int nhchainlength) { - int i,j; + int i, j; - state->ngtc = ngtc; - state->nnhpres = nnhpres; + state->ngtc = ngtc; + state->nnhpres = nnhpres; state->nhchainlength = nhchainlength; if (state->ngtc > 0) { - snew(state->nosehoover_xi,state->nhchainlength*state->ngtc); - snew(state->nosehoover_vxi,state->nhchainlength*state->ngtc); - snew(state->therm_integral,state->ngtc); - for(i=0; ingtc; i++) + snew(state->nosehoover_xi, state->nhchainlength*state->ngtc); + snew(state->nosehoover_vxi, state->nhchainlength*state->ngtc); + snew(state->therm_integral, state->ngtc); + for (i = 0; i < state->ngtc; i++) { - for (j=0;jnhchainlength;j++) + for (j = 0; j < state->nhchainlength; j++) { - state->nosehoover_xi[i*state->nhchainlength + j] = 0.0; + state->nosehoover_xi[i*state->nhchainlength + j] = 0.0; state->nosehoover_vxi[i*state->nhchainlength + j] = 0.0; } } - for(i=0; ingtc; i++) { + for (i = 0; i < state->ngtc; i++) + { state->therm_integral[i] = 0.0; } } @@ -515,13 +557,13 @@ void init_gtc_state(t_state *state, int ngtc, int nnhpres, int nhchainlength) if (state->nnhpres > 0) { - snew(state->nhpres_xi,state->nhchainlength*nnhpres); - snew(state->nhpres_vxi,state->nhchainlength*nnhpres); - for(i=0; inhpres_xi, state->nhchainlength*nnhpres); + snew(state->nhpres_vxi, state->nhchainlength*nnhpres); + for (i = 0; i < nnhpres; i++) { - for (j=0;jnhchainlength;j++) + for (j = 0; j < state->nhchainlength; j++) { - state->nhpres_xi[i*nhchainlength + j] = 0.0; + state->nhpres_xi[i*nhchainlength + j] = 0.0; state->nhpres_vxi[i*nhchainlength + j] = 0.0; } } @@ -536,131 +578,176 @@ void init_gtc_state(t_state *state, int ngtc, int nnhpres, int nhchainlength) void init_state(t_state *state, int natoms, int ngtc, int nnhpres, int nhchainlength, int nlambda) { - int i; - - state->natoms = natoms; - state->nrng = 0; - state->flags = 0; - state->lambda = 0; - snew(state->lambda,efptNR); - for (i=0;ilambda[i] = 0; - } - state->veta = 0; - clear_mat(state->box); - clear_mat(state->box_rel); - clear_mat(state->boxv); - clear_mat(state->pres_prev); - clear_mat(state->svir_prev); - clear_mat(state->fvir_prev); - init_gtc_state(state,ngtc,nnhpres,nhchainlength); - state->nalloc = state->natoms; - if (state->nalloc > 0) { - snew(state->x,state->nalloc); - snew(state->v,state->nalloc); - } else { - state->x = NULL; - state->v = NULL; - } - state->sd_X = NULL; - state->cg_p = NULL; - - zero_ekinstate(&state->ekinstate); - - init_energyhistory(&state->enerhist); - - init_df_history(&state->dfhist,nlambda,0); - - state->ddp_count = 0; - state->ddp_count_cg_gl = 0; - state->cg_gl = NULL; - state->cg_gl_nalloc = 0; + int i; + + state->natoms = natoms; + state->nrng = 0; + state->flags = 0; + state->lambda = 0; + snew(state->lambda, efptNR); + for (i = 0; i < efptNR; i++) + { + state->lambda[i] = 0; + } + state->veta = 0; + clear_mat(state->box); + clear_mat(state->box_rel); + clear_mat(state->boxv); + clear_mat(state->pres_prev); + clear_mat(state->svir_prev); + clear_mat(state->fvir_prev); + init_gtc_state(state, ngtc, nnhpres, nhchainlength); + state->nalloc = state->natoms; + if (state->nalloc > 0) + { + snew(state->x, state->nalloc); + snew(state->v, state->nalloc); + } + else + { + state->x = NULL; + state->v = NULL; + } + state->sd_X = NULL; + state->cg_p = NULL; + + zero_ekinstate(&state->ekinstate); + + init_energyhistory(&state->enerhist); + + init_df_history(&state->dfhist, nlambda, 0); + + state->ddp_count = 0; + state->ddp_count_cg_gl = 0; + state->cg_gl = NULL; + state->cg_gl_nalloc = 0; } void done_state(t_state *state) { - if (state->nosehoover_xi) sfree(state->nosehoover_xi); - if (state->x) sfree(state->x); - if (state->v) sfree(state->v); - if (state->sd_X) sfree(state->sd_X); - if (state->cg_p) sfree(state->cg_p); - state->nalloc = 0; - if (state->cg_gl) sfree(state->cg_gl); - state->cg_gl_nalloc = 0; + if (state->nosehoover_xi) + { + sfree(state->nosehoover_xi); + } + if (state->x) + { + sfree(state->x); + } + if (state->v) + { + sfree(state->v); + } + if (state->sd_X) + { + sfree(state->sd_X); + } + if (state->cg_p) + { + sfree(state->cg_p); + } + state->nalloc = 0; + if (state->cg_gl) + { + sfree(state->cg_gl); + } + state->cg_gl_nalloc = 0; } -static void do_box_rel(t_inputrec *ir,matrix box_rel,matrix b,gmx_bool bInit) +static void do_box_rel(t_inputrec *ir, matrix box_rel, matrix b, gmx_bool bInit) { - int d,d2; + int d, d2; - for(d=YY; d<=ZZ; d++) { - for(d2=XX; d2<=(ir->epct==epctSEMIISOTROPIC ? YY : ZZ); d2++) { - /* We need to check if this box component is deformed - * or if deformation of another component might cause - * changes in this component due to box corrections. - */ - if (ir->deform[d][d2] == 0 && - !(d == ZZ && d2 == XX && ir->deform[d][YY] != 0 && - (b[YY][d2] != 0 || ir->deform[YY][d2] != 0))) { - if (bInit) { - box_rel[d][d2] = b[d][d2]/b[XX][XX]; - } else { - b[d][d2] = b[XX][XX]*box_rel[d][d2]; - } - } + for (d = YY; d <= ZZ; d++) + { + for (d2 = XX; d2 <= (ir->epct == epctSEMIISOTROPIC ? YY : ZZ); d2++) + { + /* We need to check if this box component is deformed + * or if deformation of another component might cause + * changes in this component due to box corrections. + */ + if (ir->deform[d][d2] == 0 && + !(d == ZZ && d2 == XX && ir->deform[d][YY] != 0 && + (b[YY][d2] != 0 || ir->deform[YY][d2] != 0))) + { + if (bInit) + { + box_rel[d][d2] = b[d][d2]/b[XX][XX]; + } + else + { + b[d][d2] = b[XX][XX]*box_rel[d][d2]; + } + } + } } - } } -void set_box_rel(t_inputrec *ir,t_state *state) +void set_box_rel(t_inputrec *ir, t_state *state) { - /* Make sure the box obeys the restrictions before we fix the ratios */ - correct_box(NULL,0,state->box,NULL); + /* Make sure the box obeys the restrictions before we fix the ratios */ + correct_box(NULL, 0, state->box, NULL); - clear_mat(state->box_rel); + clear_mat(state->box_rel); - if (PRESERVE_SHAPE(*ir)) - do_box_rel(ir,state->box_rel,state->box,TRUE); + if (PRESERVE_SHAPE(*ir)) + { + do_box_rel(ir, state->box_rel, state->box, TRUE); + } } -void preserve_box_shape(t_inputrec *ir,matrix box_rel,matrix b) +void preserve_box_shape(t_inputrec *ir, matrix box_rel, matrix b) { - if (PRESERVE_SHAPE(*ir)) - do_box_rel(ir,box_rel,b,FALSE); + if (PRESERVE_SHAPE(*ir)) + { + do_box_rel(ir, box_rel, b, FALSE); + } } -void add_t_atoms(t_atoms *atoms,int natom_extra,int nres_extra) +void add_t_atoms(t_atoms *atoms, int natom_extra, int nres_extra) { int i; - - if (natom_extra > 0) + + if (natom_extra > 0) { - srenew(atoms->atomname,atoms->nr+natom_extra); - srenew(atoms->atom,atoms->nr+natom_extra); + srenew(atoms->atomname, atoms->nr+natom_extra); + srenew(atoms->atom, atoms->nr+natom_extra); if (NULL != atoms->pdbinfo) - srenew(atoms->pdbinfo,atoms->nr+natom_extra); + { + srenew(atoms->pdbinfo, atoms->nr+natom_extra); + } if (NULL != atoms->atomtype) - srenew(atoms->atomtype,atoms->nr+natom_extra); + { + srenew(atoms->atomtype, atoms->nr+natom_extra); + } if (NULL != atoms->atomtypeB) - srenew(atoms->atomtypeB,atoms->nr+natom_extra); - for(i=atoms->nr; (inr+natom_extra); i++) { + { + srenew(atoms->atomtypeB, atoms->nr+natom_extra); + } + for (i = atoms->nr; (i < atoms->nr+natom_extra); i++) + { atoms->atomname[i] = NULL; - memset(&atoms->atom[i],0,sizeof(atoms->atom[i])); + memset(&atoms->atom[i], 0, sizeof(atoms->atom[i])); if (NULL != atoms->pdbinfo) - memset(&atoms->pdbinfo[i],0,sizeof(atoms->pdbinfo[i])); + { + memset(&atoms->pdbinfo[i], 0, sizeof(atoms->pdbinfo[i])); + } if (NULL != atoms->atomtype) + { atoms->atomtype[i] = NULL; + } if (NULL != atoms->atomtypeB) + { atoms->atomtypeB[i] = NULL; + } } atoms->nr += natom_extra; } if (nres_extra > 0) { - srenew(atoms->resinfo,atoms->nres+nres_extra); - for(i=atoms->nres; (inres+nres_extra); i++) { - memset(&atoms->resinfo[i],0,sizeof(atoms->resinfo[i])); + srenew(atoms->resinfo, atoms->nres+nres_extra); + for (i = atoms->nres; (i < atoms->nres+nres_extra); i++) + { + memset(&atoms->resinfo[i], 0, sizeof(atoms->resinfo[i])); } atoms->nres += nres_extra; } @@ -668,95 +755,120 @@ void add_t_atoms(t_atoms *atoms,int natom_extra,int nres_extra) void init_t_atoms(t_atoms *atoms, int natoms, gmx_bool bPdbinfo) { - atoms->nr=natoms; - atoms->nres=0; - snew(atoms->atomname,natoms); - atoms->atomtype=NULL; - atoms->atomtypeB=NULL; - snew(atoms->resinfo,natoms); - snew(atoms->atom,natoms); - if (bPdbinfo) - snew(atoms->pdbinfo,natoms); - else - atoms->pdbinfo=NULL; + atoms->nr = natoms; + atoms->nres = 0; + snew(atoms->atomname, natoms); + atoms->atomtype = NULL; + atoms->atomtypeB = NULL; + snew(atoms->resinfo, natoms); + snew(atoms->atom, natoms); + if (bPdbinfo) + { + snew(atoms->pdbinfo, natoms); + } + else + { + atoms->pdbinfo = NULL; + } } t_atoms *copy_t_atoms(t_atoms *src) { - t_atoms *dst; - int i; - - snew(dst,1); - init_t_atoms(dst,src->nr,(NULL != src->pdbinfo)); - dst->nr = src->nr; - if (NULL != src->atomname) - snew(dst->atomname,src->nr); - if (NULL != src->atomtype) - snew(dst->atomtype,src->nr); - if (NULL != src->atomtypeB) - snew(dst->atomtypeB,src->nr); - for(i=0; (inr); i++) { - dst->atom[i] = src->atom[i]; - if (NULL != src->pdbinfo) - dst->pdbinfo[i] = src->pdbinfo[i]; + t_atoms *dst; + int i; + + snew(dst, 1); + init_t_atoms(dst, src->nr, (NULL != src->pdbinfo)); + dst->nr = src->nr; if (NULL != src->atomname) - dst->atomname[i] = src->atomname[i]; + { + snew(dst->atomname, src->nr); + } if (NULL != src->atomtype) - dst->atomtype[i] = src->atomtype[i]; + { + snew(dst->atomtype, src->nr); + } if (NULL != src->atomtypeB) - dst->atomtypeB[i] = src->atomtypeB[i]; - } - dst->nres = src->nres; - for(i=0; (inres); i++) { - dst->resinfo[i] = src->resinfo[i]; - } - return dst; + { + snew(dst->atomtypeB, src->nr); + } + for (i = 0; (i < src->nr); i++) + { + dst->atom[i] = src->atom[i]; + if (NULL != src->pdbinfo) + { + dst->pdbinfo[i] = src->pdbinfo[i]; + } + if (NULL != src->atomname) + { + dst->atomname[i] = src->atomname[i]; + } + if (NULL != src->atomtype) + { + dst->atomtype[i] = src->atomtype[i]; + } + if (NULL != src->atomtypeB) + { + dst->atomtypeB[i] = src->atomtypeB[i]; + } + } + dst->nres = src->nres; + for (i = 0; (i < src->nres); i++) + { + dst->resinfo[i] = src->resinfo[i]; + } + return dst; } -void t_atoms_set_resinfo(t_atoms *atoms,int atom_ind,t_symtab *symtab, - const char *resname,int resnr,unsigned char ic, +void t_atoms_set_resinfo(t_atoms *atoms, int atom_ind, t_symtab *symtab, + const char *resname, int resnr, unsigned char ic, int chainnum, char chainid) { - t_resinfo *ri; + t_resinfo *ri; - ri = &atoms->resinfo[atoms->atom[atom_ind].resind]; - ri->name = put_symtab(symtab,resname); - ri->rtp = NULL; - ri->nr = resnr; - ri->ic = ic; - ri->chainnum = chainnum; - ri->chainid = chainid; + ri = &atoms->resinfo[atoms->atom[atom_ind].resind]; + ri->name = put_symtab(symtab, resname); + ri->rtp = NULL; + ri->nr = resnr; + ri->ic = ic; + ri->chainnum = chainnum; + ri->chainid = chainid; } -void free_t_atoms(t_atoms *atoms,gmx_bool bFreeNames) +void free_t_atoms(t_atoms *atoms, gmx_bool bFreeNames) { - int i; + int i; - if (bFreeNames) { - for(i=0; inr; i++) { - sfree(*atoms->atomname[i]); - *atoms->atomname[i]=NULL; + if (bFreeNames) + { + for (i = 0; i < atoms->nr; i++) + { + sfree(*atoms->atomname[i]); + *atoms->atomname[i] = NULL; + } + for (i = 0; i < atoms->nres; i++) + { + sfree(*atoms->resinfo[i].name); + *atoms->resinfo[i].name = NULL; + } } - for(i=0; inres; i++) { - sfree(*atoms->resinfo[i].name); - *atoms->resinfo[i].name=NULL; + sfree(atoms->atomname); + /* Do we need to free atomtype and atomtypeB as well ? */ + sfree(atoms->resinfo); + sfree(atoms->atom); + if (atoms->pdbinfo) + { + sfree(atoms->pdbinfo); } - } - sfree(atoms->atomname); - /* Do we need to free atomtype and atomtypeB as well ? */ - sfree(atoms->resinfo); - sfree(atoms->atom); - if (atoms->pdbinfo) - sfree(atoms->pdbinfo); - atoms->nr=0; - atoms->nres=0; - atoms->atomname = NULL; - atoms->resinfo = NULL; - atoms->atom = NULL; - atoms->pdbinfo = NULL; + atoms->nr = 0; + atoms->nres = 0; + atoms->atomname = NULL; + atoms->resinfo = NULL; + atoms->atom = NULL; + atoms->pdbinfo = NULL; } -real max_cutoff(real cutoff1,real cutoff2) +real max_cutoff(real cutoff1, real cutoff2) { if (cutoff1 == 0 || cutoff2 == 0) { @@ -764,7 +876,7 @@ real max_cutoff(real cutoff1,real cutoff2) } else { - return max(cutoff1,cutoff2); + return max(cutoff1, cutoff2); } } @@ -772,46 +884,48 @@ extern void init_df_history(df_history_t *dfhist, int nlambda, real wl_delta) { int i; - dfhist->bEquil = 0; - dfhist->nlambda = nlambda; + dfhist->bEquil = 0; + dfhist->nlambda = nlambda; dfhist->wl_delta = wl_delta; - snew(dfhist->sum_weights,dfhist->nlambda); - snew(dfhist->sum_dg,dfhist->nlambda); - snew(dfhist->sum_minvar,dfhist->nlambda); - snew(dfhist->sum_variance,dfhist->nlambda); - snew(dfhist->n_at_lam,dfhist->nlambda); - snew(dfhist->wl_histo,dfhist->nlambda); + snew(dfhist->sum_weights, dfhist->nlambda); + snew(dfhist->sum_dg, dfhist->nlambda); + snew(dfhist->sum_minvar, dfhist->nlambda); + snew(dfhist->sum_variance, dfhist->nlambda); + snew(dfhist->n_at_lam, dfhist->nlambda); + snew(dfhist->wl_histo, dfhist->nlambda); /* allocate transition matrices here */ - snew(dfhist->Tij,dfhist->nlambda); - snew(dfhist->Tij_empirical,dfhist->nlambda); + snew(dfhist->Tij, dfhist->nlambda); + snew(dfhist->Tij_empirical, dfhist->nlambda); - for (i=0;inlambda;i++) { - snew(dfhist->Tij[i],dfhist->nlambda); - snew(dfhist->Tij_empirical[i],dfhist->nlambda); + for (i = 0; i < dfhist->nlambda; i++) + { + snew(dfhist->Tij[i], dfhist->nlambda); + snew(dfhist->Tij_empirical[i], dfhist->nlambda); } - snew(dfhist->accum_p,dfhist->nlambda); - snew(dfhist->accum_m,dfhist->nlambda); - snew(dfhist->accum_p2,dfhist->nlambda); - snew(dfhist->accum_m2,dfhist->nlambda); + snew(dfhist->accum_p, dfhist->nlambda); + snew(dfhist->accum_m, dfhist->nlambda); + snew(dfhist->accum_p2, dfhist->nlambda); + snew(dfhist->accum_m2, dfhist->nlambda); - for (i=0;inlambda;i++) { - snew((dfhist->accum_p)[i],dfhist->nlambda); - snew((dfhist->accum_m)[i],dfhist->nlambda); - snew((dfhist->accum_p2)[i],dfhist->nlambda); - snew((dfhist->accum_m2)[i],dfhist->nlambda); + for (i = 0; i < dfhist->nlambda; i++) + { + snew((dfhist->accum_p)[i], dfhist->nlambda); + snew((dfhist->accum_m)[i], dfhist->nlambda); + snew((dfhist->accum_p2)[i], dfhist->nlambda); + snew((dfhist->accum_m2)[i], dfhist->nlambda); } } extern void copy_df_history(df_history_t *df_dest, df_history_t *df_source) { - int i,j; + int i, j; - init_df_history(df_dest,df_source->nlambda,df_source->wl_delta); + init_df_history(df_dest, df_source->nlambda, df_source->wl_delta); df_dest->nlambda = df_source->nlambda; - df_dest->bEquil = df_source->bEquil; - for (i=0;inlambda;i++) + df_dest->bEquil = df_source->bEquil; + for (i = 0; i < df_dest->nlambda; i++) { df_dest->sum_weights[i] = df_source->sum_weights[i]; df_dest->sum_dg[i] = df_source->sum_dg[i]; @@ -825,11 +939,11 @@ extern void copy_df_history(df_history_t *df_dest, df_history_t *df_source) df_dest->accum_m2[i] = df_source->accum_m2[i]; } - for (i=0;inlambda;i++) + for (i = 0; i < df_dest->nlambda; i++) { - for (j=0;jnlambda;j++) + for (j = 0; j < df_dest->nlambda; j++) { - df_dest->Tij[i][j] = df_source->Tij[i][j]; + df_dest->Tij[i][j] = df_source->Tij[i][j]; df_dest->Tij_empirical[i][j] = df_source->Tij_empirical[i][j]; } } diff --git a/src/gromacs/gmxlib/viewit.c b/src/gromacs/gmxlib/viewit.c index 7f9350e10a..c2244de20e 100644 --- a/src/gromacs/gmxlib/viewit.c +++ b/src/gromacs/gmxlib/viewit.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -45,77 +45,105 @@ #include "macros.h" #include "gmx_fatal.h" -static const int can_view_ftp[] = { 0, - efEPS, efXPM, efXVG, efPDB }; +static const int can_view_ftp[] = { + 0, + efEPS, efXPM, efXVG, efPDB +}; #define NVIEW asize(can_view_ftp) -static const char* view_program[] = { NULL, - "ghostview", "display", NULL, "xterm -e rasmol" }; +static const char* view_program[] = { + NULL, + "ghostview", "display", NULL, "xterm -e rasmol" +}; int can_view(int ftp) { - int i; - - for(i=1; i #include -/* +/* * Plugin header files; get plugin source from www.ks.uiuc.edu/Research/vmd" */ #include "external/vmd_molfile/molfile_plugin.h" @@ -99,43 +99,53 @@ typedef int (*finifunc)(void); -static int register_cb(void *v, vmdplugin_t *p) { - const char *key = p->name; +static int register_cb(void *v, vmdplugin_t *p) +{ + const char *key = p->name; t_gmxvmdplugin *vmdplugin = (t_gmxvmdplugin*)v; - if (strcmp(key,vmdplugin->filetype)==0) + if (strcmp(key, vmdplugin->filetype) == 0) { vmdplugin->api = (molfile_plugin_t *)p; } return VMDPLUGIN_SUCCESS; } -static int load_sharedlibrary_plugins(const char *fullpath,t_gmxvmdplugin* vmdplugin) { +static int load_sharedlibrary_plugins(const char *fullpath, t_gmxvmdplugin* vmdplugin) +{ /* Open the dll; try to execute the init function. */ - void *handle, *ifunc, *registerfunc; + void *handle, *ifunc, *registerfunc; handle = vmddlopen(fullpath); - if (!handle) { - if (debug) fprintf(debug, "\nUnable to open dynamic library %s.\n%s\n", fullpath, vmddlerror()); /*only to debug because of stdc++ erros */ + if (!handle) + { + if (debug) + { + fprintf(debug, "\nUnable to open dynamic library %s.\n%s\n", fullpath, vmddlerror()); /*only to debug because of stdc++ erros */ + } return 0; } ifunc = vmddlsym(handle, "vmdplugin_init"); - if (!ifunc || ((initfunc)(ifunc))()) { + if (!ifunc || ((initfunc)(ifunc))()) + { printf("\nvmdplugin_init() for %s returned an error; plugin(s) not loaded.\n", fullpath); vmddlclose(handle); return 0; } registerfunc = vmddlsym(handle, "vmdplugin_register"); - if (!registerfunc) { + if (!registerfunc) + { printf("\nDidn't find the register function in %s; plugin(s) not loaded.\n", fullpath); vmddlclose(handle); return 0; - } else { + } + else + { /* Load plugins from the library.*/ ((regfunc)registerfunc)(vmdplugin, register_cb); - } - + } + /* in case this library does not support the filetype, close it */ if (vmdplugin->api == NULL) { @@ -146,15 +156,15 @@ static int load_sharedlibrary_plugins(const char *fullpath,t_gmxvmdplugin* vmdpl } /*return: 1: success, 0: last frame, -1: error*/ -gmx_bool read_next_vmd_frame(int status,t_trxframe *fr) +gmx_bool read_next_vmd_frame(int status, t_trxframe *fr) { - int rc,i; - rvec vec, angle; + int rc, i; + rvec vec, angle; molfile_timestep_t ts; fr->bV = fr->vmdplugin->bV; - + #ifdef GMX_DOUBLE snew(ts.coords, fr->natoms*3); if (fr->bV) @@ -171,7 +181,8 @@ gmx_bool read_next_vmd_frame(int status,t_trxframe *fr) rc = fr->vmdplugin->api->read_next_timestep(fr->vmdplugin->handle, fr->natoms, &ts); - if (rc < -1) { + if (rc < -1) + { fprintf(stderr, "\nError reading input file (error code %d)\n", rc); } if (rc < 0) @@ -181,7 +192,7 @@ gmx_bool read_next_vmd_frame(int status,t_trxframe *fr) } #ifdef GMX_DOUBLE - for (i=0;inatoms;i++) + for (i = 0; i < fr->natoms; i++) { fr->x[i][0] = .1*ts.coords[i*3]; fr->x[i][1] = .1*ts.coords[i*3+1]; @@ -199,25 +210,25 @@ gmx_bool read_next_vmd_frame(int status,t_trxframe *fr) sfree(ts.velocities); } #else - for (i=0;inatoms;i++) + for (i = 0; i < fr->natoms; i++) { - svmul(.1,fr->x[i],fr->x[i]); + svmul(.1, fr->x[i], fr->x[i]); if (fr->bV) { - svmul(.1,fr->v[i],fr->v[i]); + svmul(.1, fr->v[i], fr->v[i]); } } #endif - fr->bX = 1; + fr->bX = 1; 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); - if (fr->vmdplugin->api->abiversion>10) + 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); + if (fr->vmdplugin->api->abiversion > 10) { fr->bTime = TRUE; - fr->time = ts.physical_time; + fr->time = ts.physical_time; } else { @@ -230,28 +241,28 @@ gmx_bool read_next_vmd_frame(int status,t_trxframe *fr) static int load_vmd_library(const char *fn, t_gmxvmdplugin *vmdplugin) { - char pathname[GMX_PATH_MAX],filename[GMX_PATH_MAX]; - const char *pathenv; - const char *err; - int i; - int ret=0; - char pathenv_buffer[GMX_PATH_MAX]; + char pathname[GMX_PATH_MAX], filename[GMX_PATH_MAX]; + const char *pathenv; + const char *err; + int i; + int ret = 0; + char pathenv_buffer[GMX_PATH_MAX]; #ifndef GMX_NATIVE_WINDOWS - glob_t globbuf; - const char *defpath_suffix = "/plugins/*/molfile"; - const char *defpathenv = GMX_VMD_PLUGIN_PATH; + glob_t globbuf; + const char *defpath_suffix = "/plugins/*/molfile"; + const char *defpathenv = GMX_VMD_PLUGIN_PATH; #else WIN32_FIND_DATA ffd; - HANDLE hFind = INVALID_HANDLE_VALUE; - char progfolder[GMX_PATH_MAX]; - char defpathenv[GMX_PATH_MAX]; - const char *defpath_suffix = "\\plugins\\WIN32\\molfile"; - SHGetFolderPath(NULL,CSIDL_PROGRAM_FILES,NULL,SHGFP_TYPE_CURRENT,progfolder); - sprintf(defpathenv,"%s\\University of Illinois\\VMD\\plugins\\WIN32\\molfile",progfolder); + HANDLE hFind = INVALID_HANDLE_VALUE; + char progfolder[GMX_PATH_MAX]; + char defpathenv[GMX_PATH_MAX]; + const char *defpath_suffix = "\\plugins\\WIN32\\molfile"; + SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, progfolder); + sprintf(defpathenv, "%s\\University of Illinois\\VMD\\plugins\\WIN32\\molfile", progfolder); #endif - vmdplugin->api = NULL; - vmdplugin->filetype = strrchr(fn,'.'); + vmdplugin->api = NULL; + vmdplugin->filetype = strrchr(fn, '.'); if (!vmdplugin->filetype) { return 0; @@ -263,14 +274,14 @@ static int load_vmd_library(const char *fn, t_gmxvmdplugin *vmdplugin) * given at configure time. This last might be hard-coded to the * default for VMD installs. */ pathenv = getenv("VMD_PLUGIN_PATH"); - if (pathenv==NULL) + if (pathenv == NULL) { pathenv = getenv("VMDDIR"); if (NULL == pathenv) { printf("\nNeither VMD_PLUGIN_PATH or VMDDIR set. "); - printf("Using default location:\n%s\n",defpathenv); - pathenv=defpathenv; + printf("Using default location:\n%s\n", defpathenv); + pathenv = defpathenv; } else { @@ -280,46 +291,46 @@ static int load_vmd_library(const char *fn, t_gmxvmdplugin *vmdplugin) #else snprintf(pathenv_buffer, sizeof(pathenv_buffer), "%s%s", pathenv, defpath_suffix); #endif - printf("Using semi-default location:\n%s\n",pathenv_buffer); + printf("Using semi-default location:\n%s\n", pathenv_buffer); pathenv = pathenv_buffer; } } - strncpy(pathname,pathenv,sizeof(pathname)); + strncpy(pathname, pathenv, sizeof(pathname)); #ifndef GMX_NATIVE_WINDOWS - strcat(pathname,"/*.so"); + strcat(pathname, "/*.so"); glob(pathname, 0, NULL, &globbuf); if (globbuf.gl_pathc == 0) { printf("\nNo VMD Plugins found\n" - "Set the environment variable VMD_PLUGIN_PATH to the molfile folder within the\n" - "VMD installation.\n" - "The architecture (e.g. 32bit versus 64bit) of Gromacs and VMD has to match.\n"); + "Set the environment variable VMD_PLUGIN_PATH to the molfile folder within the\n" + "VMD installation.\n" + "The architecture (e.g. 32bit versus 64bit) of Gromacs and VMD has to match.\n"); return 0; } - for (i=0; iapi == NULL; i++) + for (i = 0; i < globbuf.gl_pathc && vmdplugin->api == NULL; i++) { /* FIXME: Undefined which plugin is chosen if more than one plugin can read a certain file ending. Requires some additional command line option or enviroment variable to specify which plugin should be picked. - */ - ret|=load_sharedlibrary_plugins(globbuf.gl_pathv[i],vmdplugin); + */ + ret |= load_sharedlibrary_plugins(globbuf.gl_pathv[i], vmdplugin); } globfree(&globbuf); #else - strcat(pathname,"\\*.so"); + strcat(pathname, "\\*.so"); hFind = FindFirstFile(pathname, &ffd); - if (INVALID_HANDLE_VALUE == hFind) + if (INVALID_HANDLE_VALUE == hFind) { printf("\nNo VMD Plugins found\n"); return 0; - } + } do { - sprintf(filename,"%s\\%s",pathenv,ffd.cFileName); - ret|=load_sharedlibrary_plugins(filename,vmdplugin); + sprintf(filename, "%s\\%s", pathenv, ffd.cFileName); + ret |= load_sharedlibrary_plugins(filename, vmdplugin); } - while (FindNextFile(hFind, &ffd ) != 0 && vmdplugin->api == NULL ); + while (FindNextFile(hFind, &ffd ) != 0 && vmdplugin->api == NULL); FindClose(hFind); #endif @@ -327,20 +338,20 @@ static int load_vmd_library(const char *fn, t_gmxvmdplugin *vmdplugin) { printf("\nCould not open any VMD library.\n"); err = vmddlerror(); - if (!err) + if (!err) { printf("Compiled with dlopen?\n"); } else { - printf("Last error:\n%s\n",err); + printf("Last error:\n%s\n", err); } return 0; } if (vmdplugin->api == NULL) { - printf("\nNo plugin for %s found\n",vmdplugin->filetype); + printf("\nNo plugin for %s found\n", vmdplugin->filetype); return 0; } @@ -350,43 +361,49 @@ static int load_vmd_library(const char *fn, t_gmxvmdplugin *vmdplugin) return 0; } - printf("\nUsing VMD plugin: %s (%s)\n",vmdplugin->api->name,vmdplugin->api->prettyname); + printf("\nUsing VMD plugin: %s (%s)\n", vmdplugin->api->name, vmdplugin->api->prettyname); return 1; } -int read_first_vmd_frame(int *status,const char *fn,t_trxframe *fr,int flags) +int read_first_vmd_frame(int *status, const char *fn, t_trxframe *fr, int flags) { - molfile_timestep_metadata_t *metadata=NULL; - - snew(fr->vmdplugin,1); - if (!load_vmd_library(fn,fr->vmdplugin)) + molfile_timestep_metadata_t *metadata = NULL; + + snew(fr->vmdplugin, 1); + if (!load_vmd_library(fn, fr->vmdplugin)) { return 0; } fr->vmdplugin->handle = fr->vmdplugin->api->open_file_read(fn, fr->vmdplugin->filetype, &fr->natoms); - if (!fr->vmdplugin->handle) { + if (!fr->vmdplugin->handle) + { fprintf(stderr, "\nError: could not open file '%s' for reading.\n", fn); return 0; } - if (fr->natoms == MOLFILE_NUMATOMS_UNKNOWN) { + 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) { + } + 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*/ + } + 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); + + snew(fr->x, fr->natoms); fr->vmdplugin->bV = 0; if (fr->vmdplugin->api->abiversion > 10 && fr->vmdplugin->api->read_timestep_metadata) @@ -396,7 +413,7 @@ int read_first_vmd_frame(int *status,const char *fn,t_trxframe *fr,int flags) fr->vmdplugin->bV = metadata->has_velocities; if (fr->vmdplugin->bV) { - snew(fr->v,fr->natoms); + snew(fr->v, fr->natoms); } } else diff --git a/src/gromacs/gmxlib/vmdio.h b/src/gromacs/gmxlib/vmdio.h index f4150b847f..ca270f9a83 100644 --- a/src/gromacs/gmxlib/vmdio.h +++ b/src/gromacs/gmxlib/vmdio.h @@ -1,6 +1,6 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This file is part of Gromacs Copyright (c) 1991-2008 * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen. * @@ -11,7 +11,7 @@ * * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org - * + * * And Hey: * Gnomes, ROck Monsters And Chili Sauce */ @@ -29,13 +29,13 @@ extern "C" { struct gmxvmdplugin { molfile_plugin_t *api; - const char* filetype; - void* handle; - gmx_bool bV; + const char * filetype; + void * handle; + gmx_bool bV; }; - -int read_first_vmd_frame(int *status,const char *fn, struct trxframe *fr,int flags); -gmx_bool read_next_vmd_frame(int status,struct trxframe *fr); + +int read_first_vmd_frame(int *status, const char *fn, struct trxframe *fr, int flags); +gmx_bool read_next_vmd_frame(int status, struct trxframe *fr); #ifdef __cplusplus } diff --git a/src/gromacs/gmxlib/warninp.c b/src/gromacs/gmxlib/warninp.c index 86bf5cb818..3c0750a449 100644 --- a/src/gromacs/gmxlib/warninp.c +++ b/src/gromacs/gmxlib/warninp.c @@ -1,12 +1,12 @@ /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*- * - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -17,19 +17,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -47,39 +47,39 @@ typedef struct warninp { gmx_bool bAllowWarnings; - int nwarn_note; - int nwarn_warn; - int nwarn_error; - int maxwarn; - int lineno; - char filenm[256]; + int nwarn_note; + int nwarn_warn; + int nwarn_error; + int maxwarn; + int lineno; + char filenm[256]; } t_warninp; -warninp_t init_warning(gmx_bool bAllowWarnings,int maxwarning) +warninp_t init_warning(gmx_bool bAllowWarnings, int maxwarning) { warninp_t wi; - snew(wi,1); + snew(wi, 1); wi->bAllowWarnings = bAllowWarnings; wi->maxwarn = maxwarning; wi->nwarn_note = 0; wi->nwarn_warn = 0; wi->nwarn_error = 0; - strcpy(wi->filenm,"unknown"); + strcpy(wi->filenm, "unknown"); wi->lineno = 0; return wi; } -void set_warning_line(warninp_t wi,const char *s,int line) +void set_warning_line(warninp_t wi, const char *s, int line) { if (s == NULL) { gmx_incons("Calling set_warning_line with NULL pointer"); } - strcpy(wi->filenm,s); + strcpy(wi->filenm, s); wi->lineno = line; } @@ -93,126 +93,126 @@ const char *get_warning_file(warninp_t wi) return wi->filenm; } -static void low_warning(warninp_t wi,const char *wtype,int n,const char *s) +static void low_warning(warninp_t wi, const char *wtype, int n, const char *s) { -#define indent 2 +#define indent 2 char *temp, *temp2; - int i; - + int i; + if (s == NULL) { s = "Empty error message."; } - snew(temp,strlen(s)+indent+1); - for(i=0; ifilenm) > 0) { if (wi->lineno != -1) { - fprintf(stderr,"\n%s %d [file %s, line %d]:\n%s\n\n", - wtype,n,wi->filenm,wi->lineno,temp2); + fprintf(stderr, "\n%s %d [file %s, line %d]:\n%s\n\n", + wtype, n, wi->filenm, wi->lineno, temp2); } else { - fprintf(stderr,"\n%s %d [file %s]:\n%s\n\n", - wtype,n,wi->filenm,temp2); - } + fprintf(stderr, "\n%s %d [file %s]:\n%s\n\n", + wtype, n, wi->filenm, temp2); + } } else { - fprintf(stderr,"\n%s %d:\n%s\n\n",wtype,n,temp2); + fprintf(stderr, "\n%s %d:\n%s\n\n", wtype, n, temp2); } sfree(temp); sfree(temp2); } -void warning(warninp_t wi,const char *s) +void warning(warninp_t wi, const char *s) { if (wi->bAllowWarnings) { wi->nwarn_warn++; - low_warning(wi,"WARNING",wi->nwarn_warn,s); + low_warning(wi, "WARNING", wi->nwarn_warn, s); } else { - warning_error(wi,s); + warning_error(wi, s); } } -void warning_note(warninp_t wi,const char *s) +void warning_note(warninp_t wi, const char *s) { wi->nwarn_note++; - low_warning(wi,"NOTE",wi->nwarn_note,s); + low_warning(wi, "NOTE", wi->nwarn_note, s); } -void warning_error(warninp_t wi,const char *s) +void warning_error(warninp_t wi, const char *s) { wi->nwarn_error++; - low_warning(wi,"ERROR",wi->nwarn_error,s); + low_warning(wi, "ERROR", wi->nwarn_error, s); } -static void print_warn_count(const char *type,int n) +static void print_warn_count(const char *type, int n) { if (n > 0) { - fprintf(stderr,"\nThere %s %d %s%s\n", - (n==1) ? "was" : "were", n, type, (n==1) ? "" : "s"); + fprintf(stderr, "\nThere %s %d %s%s\n", + (n == 1) ? "was" : "were", n, type, (n == 1) ? "" : "s"); } } -void check_warning_error(warninp_t wi,int f_errno,const char *file,int line) +void check_warning_error(warninp_t wi, int f_errno, const char *file, int line) { if (wi->nwarn_error > 0) { - print_warn_count("note",wi->nwarn_note); - print_warn_count("warning",wi->nwarn_warn); + print_warn_count("note", wi->nwarn_note); + print_warn_count("warning", wi->nwarn_warn); - gmx_fatal(f_errno,file,line,"There %s %d error%s in input file(s)", - (wi->nwarn_error==1) ? "was" : "were",wi->nwarn_error, - (wi->nwarn_error==1) ? "" : "s"); + gmx_fatal(f_errno, file, line, "There %s %d error%s in input file(s)", + (wi->nwarn_error == 1) ? "was" : "were", wi->nwarn_error, + (wi->nwarn_error == 1) ? "" : "s"); } } -void done_warning(warninp_t wi,int f_errno,const char *file,int line) +void done_warning(warninp_t wi, int f_errno, const char *file, int line) { - print_warn_count("note",wi->nwarn_note); - print_warn_count("warning",wi->nwarn_warn); + print_warn_count("note", wi->nwarn_note); + print_warn_count("warning", wi->nwarn_warn); - check_warning_error(wi,f_errno,file,line); + check_warning_error(wi, f_errno, file, line); if (wi->maxwarn >= 0 && wi->nwarn_warn > wi->maxwarn) { - gmx_fatal(f_errno,file,line, + gmx_fatal(f_errno, file, line, "Too many warnings (%d), %s terminated.\n" "If you are sure all warnings are harmless, use the -maxwarn option.", - wi->nwarn_warn,Program()); + wi->nwarn_warn, Program()); } sfree(wi); } -void _too_few(warninp_t wi,const char *fn,int line) +void _too_few(warninp_t wi, const char *fn, int line) { char buf[STRLEN]; - + sprintf(buf, "Too few parameters on line (source file %s, line %d)", - fn,line); - warning(wi,buf); + fn, line); + warning(wi, buf); } -void _incorrect_n_param(warninp_t wi,const char *fn,int line) +void _incorrect_n_param(warninp_t wi, const char *fn, int line) { char buf[STRLEN]; sprintf(buf, "Incorrect number of parameters on line (source file %s, line %d)", - fn,line); - warning(wi,buf); + fn, line); + warning(wi, buf); } diff --git a/src/gromacs/gmxlib/wgms.c b/src/gromacs/gmxlib/wgms.c index f7eee35e91..1ae4d20c41 100644 --- a/src/gromacs/gmxlib/wgms.c +++ b/src/gromacs/gmxlib/wgms.c @@ -1,11 +1,11 @@ /* - * + * * This source code is part of - * + * * G R O M A C S - * + * * GROningen MAchine for Chemical Simulations - * + * * VERSION 3.2.0 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others. * Copyright (c) 1991-2000, University of Groningen, The Netherlands. @@ -16,19 +16,19 @@ * 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 - * + * * And Hey: * GROningen Mixture of Alchemy and Childrens' Stories */ @@ -43,43 +43,58 @@ /*static int n=0;*/ #define FPL 10 -void write_gms(FILE *fp,int natoms,rvec x[],matrix box) +void write_gms(FILE *fp, int natoms, rvec x[], matrix box) { - int i,j,n; + int i, j, n; - n=0; - for(i=0;(i=", "\\ensuremath{\\geq{}}"}, - { "<", "\\textless{}" }, - { ">", "\\textgreater{}" }, - { "^", "\\^{}" }, - { "\\^{}t", "\\ensuremath{^t}" }, - { "\\^{}a", "\\ensuremath{^a}" }, - { "\\^{}b", "\\ensuremath{^b}" }, - { "\\^{}2", "\\ensuremath{^2}" }, - { "\\^{}3", "\\ensuremath{^3}" }, - { "\\^{}6", "\\ensuremath{^6}" }, - { "#", "\\#" }, - { "[BR]", "\\\\" }, - { "%", "\\%" }, - { "&", "\\&" }, - /* The next couple of lines allow true Greek symbols to be written to the - manual, which makes it look pretty */ - { "[GRK]", "\\ensuremath{\\" }, - { "[grk]", "}" }, - { "[MATH]","\\ensuremath{" }, - { "[math]","}" }, - { "[CHEVRON]", "\\ensuremath{<}" }, - { "[chevron]", "\\ensuremath{>}" }, - { "[MAG]", "\\ensuremath{|}" }, - { "[mag]", "\\ensuremath{|}" }, - { "[INT]","\\ensuremath{\\int" }, - { "[FROM]","_" }, - { "[from]","" }, - { "[TO]", "^" }, - { "[to]", "" }, - { "[int]","}" }, - { "[SUM]","\\ensuremath{\\sum" }, - { "[sum]","}" }, - { "[SUB]","\\ensuremath{_{" }, - { "[sub]","}}" }, - { "[SQRT]","\\ensuremath{\\sqrt{" }, - { "[sqrt]","}}" }, - { "[EXP]","\\ensuremath{\\exp{(" }, - { "[exp]",")}}" }, - { "[LN]","\\ensuremath{\\ln{(" }, - { "[ln]",")}}" }, - { "[LOG]","\\ensuremath{\\log{(" }, - { "[log]",")}}" }, - { "[COS]","\\ensuremath{\\cos{(" }, - { "[cos]",")}}" }, - { "[SIN]","\\ensuremath{\\sin{(" }, - { "[sin]",")}}" }, - { "[TAN]","\\ensuremath{\\tan{(" }, - { "[tan]",")}}" }, - { "[COSH]","\\ensuremath{\\cosh{(" }, - { "[cosh]",")}}" }, - { "[SINH]","\\ensuremath{\\sinh{(" }, - { "[sinh]",")}}" }, - { "[TANH]","\\ensuremath{\\tanh{(" }, - { "[tanh]",")}}" } + { "[TT]", "{\\tt " }, + { "[tt]", "}" }, + { "[BB]", "{\\bf " }, + { "[bb]", "}" }, + { "[IT]", "{\\em " }, + { "[it]", "}" }, + { "[PAR]", "\n\n" }, + /* Escaping underscore for LaTeX is no longer necessary, and it breaks + * text searching and the index if you do. */ + /* + { "_", "\\_" }, + */ + { "$", "\\$" }, + { "<=", "\\ensuremath{\\leq{}}"}, + { ">=", "\\ensuremath{\\geq{}}"}, + { "<", "\\textless{}" }, + { ">", "\\textgreater{}" }, + { "^", "\\^{}" }, + { "\\^{}t", "\\ensuremath{^t}" }, + { "\\^{}a", "\\ensuremath{^a}" }, + { "\\^{}b", "\\ensuremath{^b}" }, + { "\\^{}2", "\\ensuremath{^2}" }, + { "\\^{}3", "\\ensuremath{^3}" }, + { "\\^{}6", "\\ensuremath{^6}" }, + { "#", "\\#" }, + { "[BR]", "\\\\" }, + { "%", "\\%" }, + { "&", "\\&" }, + /* The next couple of lines allow true Greek symbols to be written to the + manual, which makes it look pretty */ + { "[GRK]", "\\ensuremath{\\" }, + { "[grk]", "}" }, + { "[MATH]", "\\ensuremath{" }, + { "[math]", "}" }, + { "[CHEVRON]", "\\ensuremath{<}" }, + { "[chevron]", "\\ensuremath{>}" }, + { "[MAG]", "\\ensuremath{|}" }, + { "[mag]", "\\ensuremath{|}" }, + { "[INT]", "\\ensuremath{\\int" }, + { "[FROM]", "_" }, + { "[from]", "" }, + { "[TO]", "^" }, + { "[to]", "" }, + { "[int]", "}" }, + { "[SUM]", "\\ensuremath{\\sum" }, + { "[sum]", "}" }, + { "[SUB]", "\\ensuremath{_{" }, + { "[sub]", "}}" }, + { "[SQRT]", "\\ensuremath{\\sqrt{" }, + { "[sqrt]", "}}" }, + { "[EXP]", "\\ensuremath{\\exp{(" }, + { "[exp]", ")}}" }, + { "[LN]", "\\ensuremath{\\ln{(" }, + { "[ln]", ")}}" }, + { "[LOG]", "\\ensuremath{\\log{(" }, + { "[log]", ")}}" }, + { "[COS]", "\\ensuremath{\\cos{(" }, + { "[cos]", ")}}" }, + { "[SIN]", "\\ensuremath{\\sin{(" }, + { "[sin]", ")}}" }, + { "[TAN]", "\\ensuremath{\\tan{(" }, + { "[tan]", ")}}" }, + { "[COSH]", "\\ensuremath{\\cosh{(" }, + { "[cosh]", ")}}" }, + { "[SINH]", "\\ensuremath{\\sinh{(" }, + { "[sinh]", ")}}" }, + { "[TANH]", "\\ensuremath{\\tanh{(" }, + { "[tanh]", ")}}" } }; #define NSRTEX asize(sandrTeX) const t_sandr_const sandrTty[] = { - { "[TT]", "" }, - { "[tt]", "" }, - { "[BB]", "" }, - { "[bb]", "" }, - { "[IT]", "" }, - { "[it]", "" }, - { "[MATH]","" }, - { "[math]","" }, - { "[CHEVRON]","<" }, - { "[chevron]",">" }, - { "[MAG]", "|" }, - { "[mag]", "|" }, - { "[INT]","integral" }, - { "[FROM]"," from " }, - { "[from]","" }, - { "[TO]", " to " }, - { "[to]", " of" }, - { "[int]","" }, - { "[SUM]","sum" }, - { "[sum]","" }, - { "[SUB]","_" }, - { "[sub]","" }, - { "[SQRT]","sqrt(" }, - { "[sqrt]",")" }, - { "[EXP]","exp(" }, - { "[exp]",")" }, - { "[LN]","ln(" }, - { "[ln]",")" }, - { "[LOG]","log(" }, - { "[log]",")" }, - { "[COS]","cos(" }, - { "[cos]",")" }, - { "[SIN]","sin(" }, - { "[sin]",")" }, - { "[TAN]","tan(" }, - { "[tan]",")" }, - { "[COSH]","cosh(" }, - { "[cosh]",")" }, - { "[SINH]","sinh(" }, - { "[sinh]",")" }, - { "[TANH]","tanh(" }, - { "[tanh]",")" }, - { "[PAR]","\n\n" }, - { "[BR]", "\n"}, - { "[GRK]", "" }, - { "[grk]", "" } + { "[TT]", "" }, + { "[tt]", "" }, + { "[BB]", "" }, + { "[bb]", "" }, + { "[IT]", "" }, + { "[it]", "" }, + { "[MATH]", "" }, + { "[math]", "" }, + { "[CHEVRON]", "<" }, + { "[chevron]", ">" }, + { "[MAG]", "|" }, + { "[mag]", "|" }, + { "[INT]", "integral" }, + { "[FROM]", " from " }, + { "[from]", "" }, + { "[TO]", " to " }, + { "[to]", " of" }, + { "[int]", "" }, + { "[SUM]", "sum" }, + { "[sum]", "" }, + { "[SUB]", "_" }, + { "[sub]", "" }, + { "[SQRT]", "sqrt(" }, + { "[sqrt]", ")" }, + { "[EXP]", "exp(" }, + { "[exp]", ")" }, + { "[LN]", "ln(" }, + { "[ln]", ")" }, + { "[LOG]", "log(" }, + { "[log]", ")" }, + { "[COS]", "cos(" }, + { "[cos]", ")" }, + { "[SIN]", "sin(" }, + { "[sin]", ")" }, + { "[TAN]", "tan(" }, + { "[tan]", ")" }, + { "[COSH]", "cosh(" }, + { "[cosh]", ")" }, + { "[SINH]", "sinh(" }, + { "[sinh]", ")" }, + { "[TANH]", "tanh(" }, + { "[tanh]", ")" }, + { "[PAR]", "\n\n" }, + { "[BR]", "\n"}, + { "[GRK]", "" }, + { "[grk]", "" } }; #define NSRTTY asize(sandrTty) const t_sandr_const sandrWiki[] = { - { "&", "&" }, - { "<", "<" }, - { ">", ">" }, - { "[TT]", "<code>" }, - { "[tt]", "</code>" }, - { "[BB]", "'''" }, - { "[bb]", "'''" }, - { "[IT]", "''" }, - { "[it]", "''" }, - { "[MATH]","" }, - { "[math]","" }, - { "[CHEVRON]","<" }, - { "[chevron]",">" }, - { "[MAG]", "|" }, - { "[mag]", "|" }, - { "[INT]","integral" }, - { "[FROM]"," from " }, - { "[from]","" }, - { "[TO]", " to " }, - { "[to]", " of" }, - { "[int]","" }, - { "[SUM]","sum" }, - { "[sum]","" }, - { "[SUB]","_" }, - { "[sub]","" }, - { "[SQRT]","sqrt(" }, - { "[sqrt]",")", }, - { "[EXP]","exp(" }, - { "[exp]",")" }, - { "[LN]","ln(" }, - { "[ln]",")" }, - { "[LOG]","log(" }, - { "[log]",")" }, - { "[COS]","cos(" }, - { "[cos]",")" }, - { "[SIN]","sin(" }, - { "[sin]",")" }, - { "[TAN]","tan(" }, - { "[tan]",")" }, - { "[COSH]","cosh(" }, - { "[cosh]",")" }, - { "[SINH]","sinh(" }, - { "[sinh]",")" }, - { "[TANH]","tanh(" }, - { "[tanh]",")" }, - { "[PAR]","\n\n" }, - { "[BR]", "\n" }, - { "[GRK]", "&" }, - { "[grk]", ";" } + { "&", "&" }, + { "<", "<" }, + { ">", ">" }, + { "[TT]", "<code>" }, + { "[tt]", "</code>" }, + { "[BB]", "'''" }, + { "[bb]", "'''" }, + { "[IT]", "''" }, + { "[it]", "''" }, + { "[MATH]", "" }, + { "[math]", "" }, + { "[CHEVRON]", "<" }, + { "[chevron]", ">" }, + { "[MAG]", "|" }, + { "[mag]", "|" }, + { "[INT]", "integral" }, + { "[FROM]", " from " }, + { "[from]", "" }, + { "[TO]", " to " }, + { "[to]", " of" }, + { "[int]", "" }, + { "[SUM]", "sum" }, + { "[sum]", "" }, + { "[SUB]", "_" }, + { "[sub]", "" }, + { "[SQRT]", "sqrt(" }, + { "[sqrt]", ")", }, + { "[EXP]", "exp(" }, + { "[exp]", ")" }, + { "[LN]", "ln(" }, + { "[ln]", ")" }, + { "[LOG]", "log(" }, + { "[log]", ")" }, + { "[COS]", "cos(" }, + { "[cos]", ")" }, + { "[SIN]", "sin(" }, + { "[sin]", ")" }, + { "[TAN]", "tan(" }, + { "[tan]", ")" }, + { "[COSH]", "cosh(" }, + { "[cosh]", ")" }, + { "[SINH]", "sinh(" }, + { "[sinh]", ")" }, + { "[TANH]", "tanh(" }, + { "[tanh]", ")" }, + { "[PAR]", "\n\n" }, + { "[BR]", "\n" }, + { "[GRK]", "&" }, + { "[grk]", ";" } }; #define NSRWIKI asize(sandrWiki) const t_sandr_const sandrNROFF[] = { - { "[TT]", "\\fB " }, - { "[tt]", "\\fR" }, - { "[BB]", "\\fB " }, - { "[bb]", "\\fR" }, - { "[IT]", "\\fI " }, - { "[it]", "\\fR" }, - { "[MATH]","" }, - { "[math]","" }, - { "[CHEVRON]","<" }, - { "[chevron]",">" }, - { "[MAG]", "|" }, - { "[mag]", "|" }, - { "[INT]","integral" }, - { "[FROM]"," from " }, - { "[from]","" }, - { "[TO]", " to " }, - { "[to]", " of" }, - { "[int]","" }, - { "[SUM]","sum" }, - { "[sum]","" }, - { "[SUB]","_" }, - { "[sub]","" }, - { "[SQRT]","sqrt(" }, - { "[sqrt]",")", }, - { "[EXP]","exp(" }, - { "[exp]",")" }, - { "[LN]","ln(" }, - { "[ln]",")" }, - { "[LOG]","log(" }, - { "[log]",")" }, - { "[COS]","cos(" }, - { "[cos]",")" }, - { "[SIN]","sin(" }, - { "[sin]",")" }, - { "[TAN]","tan(" }, - { "[tan]",")" }, - { "[COSH]","cosh(" }, - { "[cosh]",")" }, - { "[SINH]","sinh(" }, - { "[sinh]",")" }, - { "[TANH]","tanh(" }, - { "[tanh]",")" }, - { "[PAR]","\n\n" }, - { "\n ", "\n" }, - { "<", "" }, - { ">", "" }, - { "^", "" }, - { "#", "" }, - { "[BR]", "\n"}, - { "-", "\\-"}, - { "[GRK]", "" }, - { "[grk]", "" } + { "[TT]", "\\fB " }, + { "[tt]", "\\fR" }, + { "[BB]", "\\fB " }, + { "[bb]", "\\fR" }, + { "[IT]", "\\fI " }, + { "[it]", "\\fR" }, + { "[MATH]", "" }, + { "[math]", "" }, + { "[CHEVRON]", "<" }, + { "[chevron]", ">" }, + { "[MAG]", "|" }, + { "[mag]", "|" }, + { "[INT]", "integral" }, + { "[FROM]", " from " }, + { "[from]", "" }, + { "[TO]", " to " }, + { "[to]", " of" }, + { "[int]", "" }, + { "[SUM]", "sum" }, + { "[sum]", "" }, + { "[SUB]", "_" }, + { "[sub]", "" }, + { "[SQRT]", "sqrt(" }, + { "[sqrt]", ")", }, + { "[EXP]", "exp(" }, + { "[exp]", ")" }, + { "[LN]", "ln(" }, + { "[ln]", ")" }, + { "[LOG]", "log(" }, + { "[log]", ")" }, + { "[COS]", "cos(" }, + { "[cos]", ")" }, + { "[SIN]", "sin(" }, + { "[sin]", ")" }, + { "[TAN]", "tan(" }, + { "[tan]", ")" }, + { "[COSH]", "cosh(" }, + { "[cosh]", ")" }, + { "[SINH]", "sinh(" }, + { "[sinh]", ")" }, + { "[TANH]", "tanh(" }, + { "[tanh]", ")" }, + { "[PAR]", "\n\n" }, + { "\n ", "\n" }, + { "<", "" }, + { ">", "" }, + { "^", "" }, + { "#", "" }, + { "[BR]", "\n"}, + { "-", "\\-"}, + { "[GRK]", "" }, + { "[grk]", "" } }; #define NSRNROFF asize(sandrNROFF) const t_sandr_const sandrHTML[] = { - { "<", "<" }, - { ">", ">" }, - { "[TT]", "" }, - { "[tt]", "" }, - { "[BB]", "" }, - { "[bb]", "" }, - { "[IT]", "" }, - { "[it]", "" }, - { "[MATH]","" }, - { "[math]","" }, - { "[CHEVRON]","<" }, - { "[chevron]",">" }, - { "[MAG]", "|" }, - { "[mag]", "|" }, - { "[INT]","integral" }, - { "[FROM]"," from " }, - { "[from]","" }, - { "[TO]", " to " }, - { "[to]", " of" }, - { "[int]","" }, - { "[SUM]","sum" }, - { "[sum]","" }, - { "[SUB]","_" }, - { "[sub]","" }, - { "[SQRT]","sqrt(" }, - { "[sqrt]",")", }, - { "[EXP]","exp(" }, - { "[exp]",")" }, - { "[LN]","ln(" }, - { "[ln]",")" }, - { "[LOG]","log(" }, - { "[log]",")" }, - { "[COS]","cos(" }, - { "[cos]",")" }, - { "[SIN]","sin(" }, - { "[sin]",")" }, - { "[TAN]","tan(" }, - { "[tan]",")" }, - { "[COSH]","cosh(" }, - { "[cosh]",")" }, - { "[SINH]","sinh(" }, - { "[sinh]",")" }, - { "[TANH]","tanh(" }, - { "[tanh]",")" }, - { "[PAR]","

" }, - { "[BR]", "
" }, - { "[GRK]", "&" }, - { "[grk]", ";" } + { "<", "<" }, + { ">", ">" }, + { "[TT]", "" }, + { "[tt]", "" }, + { "[BB]", "" }, + { "[bb]", "" }, + { "[IT]", "" }, + { "[it]", "" }, + { "[MATH]", "" }, + { "[math]", "" }, + { "[CHEVRON]", "<" }, + { "[chevron]", ">" }, + { "[MAG]", "|" }, + { "[mag]", "|" }, + { "[INT]", "integral" }, + { "[FROM]", " from " }, + { "[from]", "" }, + { "[TO]", " to " }, + { "[to]", " of" }, + { "[int]", "" }, + { "[SUM]", "sum" }, + { "[sum]", "" }, + { "[SUB]", "_" }, + { "[sub]", "" }, + { "[SQRT]", "sqrt(" }, + { "[sqrt]", ")", }, + { "[EXP]", "exp(" }, + { "[exp]", ")" }, + { "[LN]", "ln(" }, + { "[ln]", ")" }, + { "[LOG]", "log(" }, + { "[log]", ")" }, + { "[COS]", "cos(" }, + { "[cos]", ")" }, + { "[SIN]", "sin(" }, + { "[sin]", ")" }, + { "[TAN]", "tan(" }, + { "[tan]", ")" }, + { "[COSH]", "cosh(" }, + { "[cosh]", ")" }, + { "[SINH]", "sinh(" }, + { "[sinh]", ")" }, + { "[TANH]", "tanh(" }, + { "[tanh]", ")" }, + { "[PAR]", "

" }, + { "[BR]", "
" }, + { "[GRK]", "&" }, + { "[grk]", ";" } }; #define NSRHTML asize(sandrHTML) const t_sandr_const sandrXML[] = { - { "<", "<" }, - { ">", ">" }, - { "[TT]", "" }, - { "[tt]", "" }, - { "[BB]", "" }, - { "[bb]", "" }, - { "[IT]", "" }, - { "[it]", "" }, - { "[MATH]","" }, - { "[math]","" }, - { "[CHEVRON]","<" }, - { "[chevron]",">" }, - { "[MAG]", "|" }, - { "[mag]", "|" }, - { "[INT]","integral" }, - { "[FROM]"," from " }, - { "[from]","" }, - { "[TO]", " to " }, - { "[to]", " of" }, - { "[int]","" }, - { "[SUM]","sum" }, - { "[sum]","" }, - { "[SUB]","_" }, - { "[sub]","" }, - { "[SQRT]","sqrt(" }, - { "[sqrt]",")", }, - { "[EXP]","exp(" }, - { "[exp]",")" }, - { "[LN]","ln(" }, - { "[ln]",")" }, - { "[LOG]","log(" }, - { "[log]",")" }, - { "[COS]","cos(" }, - { "[cos]",")" }, - { "[SIN]","sin(" }, - { "[sin]",")" }, - { "[TAN]","tan(" }, - { "[tan]",")" }, - { "[COSH]","cosh(" }, - { "[cosh]",")" }, - { "[SINH]","sinh(" }, - { "[sinh]",")" }, - { "[TANH]","tanh(" }, - { "[tanh]",")" }, - { "[PAR]","\n" }, - { "[BR]", "
" }, - { "[GRK]", "" }, - { "[grk]", "" } + { "<", "<" }, + { ">", ">" }, + { "[TT]", "" }, + { "[tt]", "" }, + { "[BB]", "" }, + { "[bb]", "" }, + { "[IT]", "" }, + { "[it]", "" }, + { "[MATH]", "" }, + { "[math]", "" }, + { "[CHEVRON]", "<" }, + { "[chevron]", ">" }, + { "[MAG]", "|" }, + { "[mag]", "|" }, + { "[INT]", "integral" }, + { "[FROM]", " from " }, + { "[from]", "" }, + { "[TO]", " to " }, + { "[to]", " of" }, + { "[int]", "" }, + { "[SUM]", "sum" }, + { "[sum]", "" }, + { "[SUB]", "_" }, + { "[sub]", "" }, + { "[SQRT]", "sqrt(" }, + { "[sqrt]", ")", }, + { "[EXP]", "exp(" }, + { "[exp]", ")" }, + { "[LN]", "ln(" }, + { "[ln]", ")" }, + { "[LOG]", "log(" }, + { "[log]", ")" }, + { "[COS]", "cos(" }, + { "[cos]", ")" }, + { "[SIN]", "sin(" }, + { "[sin]", ")" }, + { "[TAN]", "tan(" }, + { "[tan]", ")" }, + { "[COSH]", "cosh(" }, + { "[cosh]", ")" }, + { "[SINH]", "sinh(" }, + { "[sinh]", ")" }, + { "[TANH]", "tanh(" }, + { "[tanh]", ")" }, + { "[PAR]", "
\n" }, + { "[BR]", "
" }, + { "[GRK]", "" }, + { "[grk]", "" } }; #define NSRXML asize(sandrXML) -static void mynum(char *buf,int n) +static void mynum(char *buf, int n) { - if (n >= 10) - sprintf(buf,"%2d",n); - else - sprintf(buf,"0%1d",n); + if (n >= 10) + { + sprintf(buf, "%2d", n); + } + else + { + sprintf(buf, "0%1d", n); + } } -static char *mydate(char buf[], int maxsize,gmx_bool bWiki) +static char *mydate(char buf[], int maxsize, gmx_bool bWiki) { - const char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - const char *day[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; - time_t now; - struct tm tm; - - time(&now); + const char *mon[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + const char *day[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + time_t now; + struct tm tm; + + time(&now); #ifdef GMX_NATIVE_WINDOWS - /* Native windows */ - localtime_s(&tm,&now); + /* Native windows */ + localtime_s(&tm, &now); #else - localtime_r(&now,&tm); + localtime_r(&now, &tm); #endif - /* subtract one from maxsize, so we have room for \0. */ - if (bWiki) { - char dd[8],mm[8],ss[8],hh[8],mn[8]; - - mynum(dd,tm.tm_mday); - mynum(mm,tm.tm_mon); - mynum(ss,tm.tm_sec); - mynum(hh,tm.tm_hour); - mynum(mn,tm.tm_min); - sprintf(buf,"%4d-%2s-%2sT%2s:%2s:%2sZ", - tm.tm_year+1900,mm,dd,hh,mn,ss); - } - else - sprintf(buf,"%s %d %s %d",day[tm.tm_wday],tm.tm_mday, - mon[tm.tm_mon],tm.tm_year+1900); - - return buf; + /* subtract one from maxsize, so we have room for \0. */ + if (bWiki) + { + char dd[8], mm[8], ss[8], hh[8], mn[8]; + + mynum(dd, tm.tm_mday); + mynum(mm, tm.tm_mon); + mynum(ss, tm.tm_sec); + mynum(hh, tm.tm_hour); + mynum(mn, tm.tm_min); + sprintf(buf, "%4d-%2s-%2sT%2s:%2s:%2sZ", + tm.tm_year+1900, mm, dd, hh, mn, ss); + } + else + { + sprintf(buf, "%s %d %s %d", day[tm.tm_wday], tm.tm_mday, + mon[tm.tm_mon], tm.tm_year+1900); + } + + return buf; } /* Data structure for saved HTML links */ typedef struct t_linkdata { - int nsr; - t_sandr *sr; + int nsr; + t_sandr *sr; } t_linkdata; static t_linkdata *init_linkdata() { - t_linkdata *p; - snew(p,1); - p->sr=NULL; - p->nsr=0; + t_linkdata *p; + snew(p, 1); + p->sr = NULL; + p->nsr = 0; - return p; + return p; } static void finish_linkdata(t_linkdata *p) { - int i; - - for(i=0;insr;i++) { - sfree(p->sr[i].search); - sfree(p->sr[i].replace); - } - sfree(p->sr); - sfree(p); + int i; + + for (i = 0; i < p->nsr; i++) + { + sfree(p->sr[i].search); + sfree(p->sr[i].replace); + } + sfree(p->sr); + sfree(p); } -static char *repall(const char *s,int nsr,const t_sandr_const sa[]) +static char *repall(const char *s, int nsr, const t_sandr_const sa[]) { try { @@ -492,7 +502,7 @@ static char *repall(const char *s,int nsr,const t_sandr_const sa[]) GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR; } -static char *repallww(const char *s,int nsr,const t_sandr sa[]) +static char *repallww(const char *s, int nsr, const t_sandr sa[]) { try { @@ -506,816 +516,1012 @@ static char *repallww(const char *s,int nsr,const t_sandr sa[]) GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR; } -static char *html_xref(char *s,const char *program, t_linkdata *links,gmx_bool bWiki) +static char *html_xref(char *s, const char *program, t_linkdata *links, gmx_bool bWiki) { - char buf[256],**filestr; - int i,j,n; - - if (links->sr == NULL) { - n=get_file("links.dat",&(filestr)); - links->nsr=n; - snew(links->sr,n); - for(i=0,j=0; (isr[j].search=gmx_strdup(filestr[i]); - if (bWiki) - sprintf(buf,"[[%s]]",filestr[i]); - else - sprintf(buf,"%s",filestr[i],filestr[i]); - links->sr[j].replace=gmx_strdup(buf); - j++; - } - } - links->nsr=j; - for(i=0;insr,links->sr); + char buf[256], **filestr; + int i, j, n; + + if (links->sr == NULL) + { + n = get_file("links.dat", &(filestr)); + links->nsr = n; + snew(links->sr, n); + for (i = 0, j = 0; (i < n); i++) + { + if (!program || (gmx_strcasecmp(program, filestr[i]) != 0)) + { + links->sr[j].search = gmx_strdup(filestr[i]); + if (bWiki) + { + sprintf(buf, "[[%s]]", filestr[i]); + } + else + { + sprintf(buf, "%s", filestr[i], filestr[i]); + } + links->sr[j].replace = gmx_strdup(buf); + j++; + } + } + links->nsr = j; + for (i = 0; i < n; i++) + { + sfree(filestr[i]); + } + sfree(filestr); + } + return repallww(s, links->nsr, links->sr); } char *check_tex(const char *s) { - return repall(s,NSRTEX,sandrTeX); + return repall(s, NSRTEX, sandrTeX); } static char *check_nroff(const char *s) { - return repall(s,NSRNROFF,sandrNROFF); + return repall(s, NSRNROFF, sandrNROFF); } -static char *check_wiki(const char *s,const char *program, t_linkdata *links) +static char *check_wiki(const char *s, const char *program, t_linkdata *links) { - char *buf; - - buf = repall(s,NSRWIKI,sandrWiki); - buf = html_xref(buf,program,links,TRUE); - - return buf; + char *buf; + + buf = repall(s, NSRWIKI, sandrWiki); + buf = html_xref(buf, program, links, TRUE); + + return buf; } -static char *check_html(const char *s,const char *program, t_linkdata *links) +static char *check_html(const char *s, const char *program, t_linkdata *links) { - char *buf; - - buf = repall(s,NSRHTML,sandrHTML); - buf = html_xref(buf,program,links,FALSE); - - return buf; + char *buf; + + buf = repall(s, NSRHTML, sandrHTML); + buf = html_xref(buf, program, links, FALSE); + + return buf; } -#define NWR(s) check_wiki(s,program,links) -#define NSR(s) check_html(s,program,links) - -#define FLAG_SET(flag, mask) ((flag & mask) == mask) -char *fileopt(unsigned long flag,char buf[],int maxsize) +#define NWR(s) check_wiki(s, program, links) +#define NSR(s) check_html(s, program, links) + +#define FLAG_SET(flag, mask) ((flag &mask) == mask) +char *fileopt(unsigned long flag, char buf[], int maxsize) { - char tmp[256]; - - if (FLAG_SET(flag, ffRW)) - sprintf(tmp,"In/Out"); - else if (FLAG_SET(flag, ffREAD)) - sprintf(tmp,"Input"); - else if (FLAG_SET(flag, ffWRITE)) - sprintf(tmp,"Output"); - else - sprintf(tmp,"Dunno"); - - if (FLAG_SET(flag, ffOPT)) { - strcat(tmp,", Opt"); - if (FLAG_SET(flag, ffSET)) - strcat(tmp,"!"); + char tmp[256]; + + if (FLAG_SET(flag, ffRW)) + { + sprintf(tmp, "In/Out"); + } + else if (FLAG_SET(flag, ffREAD)) + { + sprintf(tmp, "Input"); + } + else if (FLAG_SET(flag, ffWRITE)) + { + sprintf(tmp, "Output"); + } else - strcat(tmp,"."); - } - if (FLAG_SET(flag, ffLIB)) - strcat(tmp,", Lib."); - if (FLAG_SET(flag, ffMULT)) - strcat(tmp,", Mult."); - - sprintf(buf,"%s",tmp); - - return buf; + { + sprintf(tmp, "Dunno"); + } + + if (FLAG_SET(flag, ffOPT)) + { + strcat(tmp, ", Opt"); + if (FLAG_SET(flag, ffSET)) + { + strcat(tmp, "!"); + } + else + { + strcat(tmp, "."); + } + } + if (FLAG_SET(flag, ffLIB)) + { + strcat(tmp, ", Lib."); + } + if (FLAG_SET(flag, ffMULT)) + { + strcat(tmp, ", Mult."); + } + + sprintf(buf, "%s", tmp); + + return buf; } -static void write_texman(FILE *out,const char *program, - int nldesc,const char **desc, - int nfile,t_filenm *fnm, - int npargs,t_pargs *pa, - int nbug,const char **bugs, - t_linkdata *links) +static void write_texman(FILE *out, const char *program, + int nldesc, const char **desc, + int nfile, t_filenm *fnm, + int npargs, t_pargs *pa, + int nbug, const char **bugs, + t_linkdata *links) { - int i; - char tmp[256]; - - fprintf(out,"\\section{\\normindex{%s}}\\label{%s}\n\n",check_tex(program),check_tex(program)); - - if (nldesc > 0) - for(i=0; (i 0) { - fprintf(out,"\\vspace{-2ex}\\begin{tabbing}\n"); - fprintf(out,"\n{\\normalsize \\bf Files}\\nopagebreak\\\\\n"); - fprintf(out,"{\\tt ~~~~~~~} \\= {\\tt ~~~~~~~~~~~~~~} \\= " - "~~~~~~~~~~~~~~~~~~~~~~ \\= \\nopagebreak\\kill\n"); - for(i=0; (i{\\tt %s} \\'\\> {\\tt %s} \\' %s \\> " - "\\parbox[t]{0.55\\linewidth}{%s} \\\\\n", - check_tex(fnm[i].opt),check_tex(fnm[i].fns[0]), - check_tex(fileopt(fnm[i].flag,tmp,255)), - check_tex(ftp2desc(fnm[i].ftp))); - fprintf(out,"\\end{tabbing}\\vspace{-4ex}\n"); - } - if (npargs > 0) { - fprintf(out,"\\vspace{-2ex}\\begin{tabbing}\n"); - fprintf(out,"\n{\\normalsize \\bf Other options}\\nopagebreak\\\\\n"); - fprintf(out,"{\\tt ~~~~~~~~~~} \\= vector \\= " - "{\\tt ~~~~~~~} \\= \\nopagebreak\\kill\n"); - for(i=0; (i {\\tt %s} \\'\\> %s \\'\\> {\\tt %s} \\' " - "\\parbox[t]{0.68\\linewidth}{%s}\\\\\n", - check_tex(pa[i].option),get_arg_desc(pa[i].type), - check_tex(pa_val(&(pa[i]),tmp,255)), - check_tex(pa[i].desc)); - else - fprintf(out,"\\> {\\tt %s} \\'\\> %s \\'\\>\\\\\n" - "\\> \\'\\> \\'\\> {\\tt %s} \\' " - "\\parbox[t]{0.7\\linewidth}{%s}\\\\\n", - check_tex(pa[i].option),get_arg_desc(pa[i].type), - check_tex(pa_val(&(pa[i]),tmp,255)), - check_tex(pa[i].desc)); - } - fprintf(out,"\\end{tabbing}\\vspace{-4ex}\n"); - } - if (nbug > 0) { - fprintf(out,"\n"); - fprintf(out,"\\begin{itemize}\n"); - for(i=0; (i 0) + { + for (i = 0; (i < nldesc); i++) + { + fprintf(out, "%s\n", check_tex(desc[i])); + } + } + + if (nfile > 0) + { + fprintf(out, "\\vspace{-2ex}\\begin{tabbing}\n"); + fprintf(out, "\n{\\normalsize \\bf Files}\\nopagebreak\\\\\n"); + fprintf(out, "{\\tt ~~~~~~~} \\= {\\tt ~~~~~~~~~~~~~~} \\= " + "~~~~~~~~~~~~~~~~~~~~~~ \\= \\nopagebreak\\kill\n"); + for (i = 0; (i < nfile); i++) + { + fprintf(out, "\\>{\\tt %s} \\'\\> {\\tt %s} \\' %s \\> " + "\\parbox[t]{0.55\\linewidth}{%s} \\\\\n", + check_tex(fnm[i].opt), check_tex(fnm[i].fns[0]), + check_tex(fileopt(fnm[i].flag, tmp, 255)), + check_tex(ftp2desc(fnm[i].ftp))); + } + fprintf(out, "\\end{tabbing}\\vspace{-4ex}\n"); + } + if (npargs > 0) + { + fprintf(out, "\\vspace{-2ex}\\begin{tabbing}\n"); + fprintf(out, "\n{\\normalsize \\bf Other options}\\nopagebreak\\\\\n"); + fprintf(out, "{\\tt ~~~~~~~~~~} \\= vector \\= " + "{\\tt ~~~~~~~} \\= \\nopagebreak\\kill\n"); + for (i = 0; (i < npargs); i++) + { + if (strlen(check_tex(pa_val(&(pa[i]), tmp, 255))) <= 8) + { + fprintf(out, "\\> {\\tt %s} \\'\\> %s \\'\\> {\\tt %s} \\' " + "\\parbox[t]{0.68\\linewidth}{%s}\\\\\n", + check_tex(pa[i].option), get_arg_desc(pa[i].type), + check_tex(pa_val(&(pa[i]), tmp, 255)), + check_tex(pa[i].desc)); + } + else + { + fprintf(out, "\\> {\\tt %s} \\'\\> %s \\'\\>\\\\\n" + "\\> \\'\\> \\'\\> {\\tt %s} \\' " + "\\parbox[t]{0.7\\linewidth}{%s}\\\\\n", + check_tex(pa[i].option), get_arg_desc(pa[i].type), + check_tex(pa_val(&(pa[i]), tmp, 255)), + check_tex(pa[i].desc)); + } + } + fprintf(out, "\\end{tabbing}\\vspace{-4ex}\n"); + } + if (nbug > 0) + { + fprintf(out, "\n"); + fprintf(out, "\\begin{itemize}\n"); + for (i = 0; (i < nbug); i++) + { + fprintf(out, "\\item %s\n", check_tex(bugs[i])); + } + fprintf(out, "\\end{itemize}\n"); + } /* fprintf(out,"\n\\newpage\n"); */ } static void write_nroffman(FILE *out, - const char *program, - int nldesc,const char **desc, - int nfile,t_filenm *fnm, - int npargs,t_pargs *pa, - int nbug,const char **bugs, - t_linkdata *links) + const char *program, + int nldesc, const char **desc, + int nfile, t_filenm *fnm, + int npargs, t_pargs *pa, + int nbug, const char **bugs, + t_linkdata *links) { - int i; - char tmp[256]; - - - fprintf(out,".TH %s 1 \"%s\" \"\" \"GROMACS suite, %s\"\n",program,mydate(tmp,255,FALSE),GromacsVersion()); - fprintf(out,".SH NAME\n"); - fprintf(out,"%s@DESC@\n\n",program); - fprintf(out,".B %s\n",GromacsVersion()); - - fprintf(out,".SH SYNOPSIS\n"); - fprintf(out,"\\f3%s\\fP\n",program); - - /* command line arguments */ - if (nfile > 0) { - for(i=0; (i 0) { - for(i=0; (i 0) { - fprintf(out,".SH DESCRIPTION\n"); - for(i=0; (i 0) { - fprintf(out,".SH FILES\n"); - for(i=0; (i 0 ) { - for(i=0; (i 0) { - fprintf(out,".SH KNOWN PROBLEMS\n"); - for(i=0; (i.\n"); + int i; + char tmp[256]; + + + fprintf(out, ".TH %s 1 \"%s\" \"\" \"GROMACS suite, %s\"\n", program, mydate(tmp, 255, FALSE), GromacsVersion()); + fprintf(out, ".SH NAME\n"); + fprintf(out, "%s@DESC@\n\n", program); + fprintf(out, ".B %s\n", GromacsVersion()); + + fprintf(out, ".SH SYNOPSIS\n"); + fprintf(out, "\\f3%s\\fP\n", program); + + /* command line arguments */ + if (nfile > 0) + { + for (i = 0; (i < nfile); i++) + { + fprintf(out, ".BI \"%s\" \" %s \"\n", check_nroff(fnm[i].opt), + check_nroff(fnm[i].fns[0])); + } + } + if (npargs > 0) + { + for (i = 0; (i < npargs); i++) + { + if (pa[i].type == etBOOL) + { + fprintf(out, ".BI \"\\-[no]%s\" \"\"\n", check_nroff(pa[i].option+1)); + } + else + { + fprintf(out, ".BI \"%s\" \" %s \"\n", check_nroff(pa[i].option), + check_nroff(get_arg_desc(pa[i].type))); + } + } + } + + /* description */ + if (nldesc > 0) + { + fprintf(out, ".SH DESCRIPTION\n"); + for (i = 0; (i < nldesc); i++) + { + fprintf(out, "\\&%s\n", check_nroff(desc[i])); + } + } + + /* FILES */ + if (nfile > 0) + { + fprintf(out, ".SH FILES\n"); + for (i = 0; (i < nfile); i++) + { + fprintf(out, ".BI \"%s\" \" %s\" \n.B %s\n %s \n\n", + check_nroff(fnm[i].opt), + check_nroff(fnm[i].fns[0]), + check_nroff(fileopt(fnm[i].flag, tmp, 255)), + check_nroff(ftp2desc(fnm[i].ftp))); + } + } + + /* other options */ + fprintf(out, ".SH OTHER OPTIONS\n"); + if (npargs > 0) + { + for (i = 0; (i < npargs); i++) + { + if (pa[i].type == etBOOL) + { + fprintf(out, ".BI \"\\-[no]%s\" \"%s\"\n %s\n\n", + check_nroff(pa[i].option+1), + check_nroff(pa_val(&(pa[i]), tmp, 255)), + check_nroff(pa[i].desc)); + } + else + { + fprintf(out, ".BI \"%s\" \" %s\" \" %s\" \n %s\n\n", + check_nroff(pa[i].option), + check_nroff(get_arg_desc(pa[i].type)), + check_nroff(pa_val(&(pa[i]), tmp, 255)), + check_nroff(pa[i].desc)); + } + } + } + + if (nbug > 0) + { + fprintf(out, ".SH KNOWN PROBLEMS\n"); + for (i = 0; (i < nbug); i++) + { + fprintf(out, "\\- %s\n\n", check_nroff(bugs[i])); + } + } + + fprintf(out, ".SH SEE ALSO\n.BR gromacs(7)\n\n"); + fprintf(out, "More information about \\fBGROMACS\\fR is available at <\\fIhttp://www.gromacs.org/\\fR>.\n"); } char *check_tty(const char *s) { - return repall(s,NSRTTY,sandrTty); + return repall(s, NSRTTY, sandrTty); } void -print_tty_formatted(FILE *out, int nldesc, const char **desc,int indent, - t_linkdata *links,const char *program,gmx_bool bWiki) +print_tty_formatted(FILE *out, int nldesc, const char **desc, int indent, + t_linkdata *links, const char *program, gmx_bool bWiki) { - char *buf; - char *temp; - int buflen,i; - - buflen = 80*nldesc; - snew(buf,buflen); - for(i=0; (i0) && - (buf[strlen(buf)-1] !=' ') && (buf[strlen(buf)-1] !='\n')) - strcat(buf," "); - if (bWiki) - temp=NWR(desc[i]); - else - temp=check_tty(desc[i]); - if (strlen(buf) + strlen(temp) >= (size_t)(buflen-2)) { - buflen += strlen(temp); - srenew(buf,buflen); + char *buf; + char *temp; + int buflen, i; + + buflen = 80*nldesc; + snew(buf, buflen); + for (i = 0; (i < nldesc); i++) + { + if ((strlen(buf) > 0) && + (buf[strlen(buf)-1] != ' ') && (buf[strlen(buf)-1] != '\n')) + { + strcat(buf, " "); + } + if (bWiki) + { + temp = NWR(desc[i]); + } + else + { + temp = check_tty(desc[i]); + } + if (strlen(buf) + strlen(temp) >= (size_t)(buflen-2)) + { + buflen += strlen(temp); + srenew(buf, buflen); + } + strcat(buf, temp); + sfree(temp); } - strcat(buf,temp); + /* Make lines of at most 79 characters */ + temp = wrap_lines(buf, 78, indent, FALSE); + fprintf(out, "%s\n", temp); sfree(temp); - } - /* Make lines of at most 79 characters */ - temp = wrap_lines(buf,78,indent,FALSE); - fprintf(out,"%s\n",temp); - sfree(temp); - sfree(buf); + sfree(buf); } static void write_ttyman(FILE *out, - const char *program, - int nldesc,const char **desc, - int nfile,t_filenm *fnm, - int npargs,t_pargs *pa, - int nbug,const char **bugs,gmx_bool bHeader, - t_linkdata *links) + const char *program, + int nldesc, const char **desc, + int nfile, t_filenm *fnm, + int npargs, t_pargs *pa, + int nbug, const char **bugs, gmx_bool bHeader, + t_linkdata *links) { - int i; - char buf[256]; - char *tmp; - - if (bHeader) { - fprintf(out,"%s\n\n",check_tty(program)); - fprintf(out,"%s\n%s\n",GromacsVersion(),mydate(buf,255,FALSE)); - } - if (nldesc > 0) { - fprintf(out,"DESCRIPTION\n-----------\n"); - print_tty_formatted(out,nldesc,desc,0,links,program,FALSE); - } - if (nbug > 0) { - fprintf(out,"\n"); - fprintf(out,"KNOWN PROBLEMS\n----------\n"); - for(i=0; i 0) { - fprintf(out,"\n"); - pr_fns(out,nfile,fnm); - } - if (npargs > 0) { - print_pargs(out,npargs,pa,FALSE); - } + int i; + char buf[256]; + char *tmp; + + if (bHeader) + { + fprintf(out, "%s\n\n", check_tty(program)); + fprintf(out, "%s\n%s\n", GromacsVersion(), mydate(buf, 255, FALSE)); + } + if (nldesc > 0) + { + fprintf(out, "DESCRIPTION\n-----------\n"); + print_tty_formatted(out, nldesc, desc, 0, links, program, FALSE); + } + if (nbug > 0) + { + fprintf(out, "\n"); + fprintf(out, "KNOWN PROBLEMS\n----------\n"); + for (i = 0; i < nbug; i++) + { + snew(tmp, strlen(bugs[i])+3); + strcpy(tmp, "* "); + strcpy(tmp+2, check_tty(bugs[i])); + fprintf(out, "%s\n", wrap_lines(tmp, 78, 2, FALSE)); + sfree(tmp); + } + } + if (nfile > 0) + { + fprintf(out, "\n"); + pr_fns(out, nfile, fnm); + } + if (npargs > 0) + { + print_pargs(out, npargs, pa, FALSE); + } } -static void pr_html_files(FILE *out,int nfile,t_filenm fnm[], - const char *program,t_linkdata *links,gmx_bool bWiki) -{ - int i; - char link[10],tmp[255]; - - if (bWiki) - fprintf(out," %-10s %-12s %-12s %-s\n" - " -----------------------------------------------------\n", - "Option","Filename","Type","Description"); - else - fprintf(out, - "\n" - "" - "" - "" - "" - "" - "\n"); - - for(i=0; (i" - "" - "" - "" - "" - "\n", - fnm[i].opt,link,fnm[i].fns[0],fileopt(fnm[i].flag,tmp,255), - NSR(ftp2desc(fnm[i].ftp))); - } - if (!bWiki) - fprintf(out,"
optionfilenametypedescription
%s %12s %s %s
\n"); + { + fprintf(out, + "\n" + "" + "" + "" + "" + "" + "\n"); + } + + for (i = 0; (i < nfile); i++) + { + strcpy(link, ftp2ext(fnm[i].ftp)); + if (strcmp(link, "???") == 0) + { + strcpy(link, "files"); + } + if (bWiki) + { + fprintf(out, " %-10s %-16s %-12s %-s\n", + fnm[i].opt, + NWR(fnm[i].fns[0]), + fileopt(fnm[i].flag, tmp, 255), + NWR(ftp2desc(fnm[i].ftp))); + } + else + { + fprintf(out, + "" + "" + "" + "" + "" + "\n", + fnm[i].opt, link, fnm[i].fns[0], fileopt(fnm[i].flag, tmp, 255), + NSR(ftp2desc(fnm[i].ftp))); + } + } + if (!bWiki) + { + fprintf(out, "
optionfilenametypedescription
%s %12s %s %s
\n"); + } } static void write_wikiman(FILE *out, - const char *program, - int nldesc,const char **desc, - int nfile,t_filenm *fnm, - int npargs,t_pargs *pa, - int nbug,const char **bugs,gmx_bool bHeader, - t_linkdata *links) + const char *program, + int nldesc, const char **desc, + int nfile, t_filenm *fnm, + int npargs, t_pargs *pa, + int nbug, const char **bugs, gmx_bool bHeader, + t_linkdata *links) { - int i; - char buf[256]; - char *tmp; - fprintf(out,"\nManual:%s_%s\n",program, - VERSION); - fprintf(out,"\n"); - fprintf(out,"%s\n",mydate(buf,255,TRUE)); - fprintf(out,"\n"); - if (nldesc > 0) { - fprintf(out,"== Description ==\n"); - print_tty_formatted(out,nldesc,desc,0,links,program,TRUE); - fprintf(out,"\n"); - } - if (nbug > 0) { - fprintf(out,"== Known Problems ==\n"); - for(i=0; i 0) { - fprintf(out,"\n== Files ==\n"); - pr_html_files(out,nfile,fnm,program,links,TRUE); - } - if (npargs > 0) { - fprintf(out,"\n== Options ==\n"); - fprintf(out," %-12s %-6s %-6s %-s\n", - "Option","Type","Value","Description"); - fprintf(out," ------------------------------------------------------\n"); - for(i=0; (i\n"); - fprintf(out,"\n"); - fprintf(out,"\n\n"); + int i; + char buf[256]; + char *tmp; + fprintf(out, "\nManual:%s_%s\n", program, + VERSION); + fprintf(out, "\n"); + fprintf(out, "%s\n", mydate(buf, 255, TRUE)); + fprintf(out, "\n"); + if (nldesc > 0) + { + fprintf(out, "== Description ==\n"); + print_tty_formatted(out, nldesc, desc, 0, links, program, TRUE); + fprintf(out, "\n"); + } + if (nbug > 0) + { + fprintf(out, "== Known Problems ==\n"); + for (i = 0; i < nbug; i++) + { + snew(tmp, strlen(bugs[i])+3); + strcpy(tmp, "* "); + strcpy(tmp+2, bugs[i]); + fprintf(out, "%s\n", NWR(tmp)); + sfree(tmp); + } + } + if (nfile > 0) + { + fprintf(out, "\n== Files ==\n"); + pr_html_files(out, nfile, fnm, program, links, TRUE); + } + if (npargs > 0) + { + fprintf(out, "\n== Options ==\n"); + fprintf(out, " %-12s %-6s %-6s %-s\n", + "Option", "Type", "Value", "Description"); + fprintf(out, " ------------------------------------------------------\n"); + for (i = 0; (i < npargs); i++) + { + tmp = NWR(pargs_print_line(&pa[i], TRUE)); + fprintf(out, "%s", tmp); + sfree(tmp); + } + } + fprintf(out, "[[category:Manual_Pages_%s|%s]]\n", VERSION, program); + fprintf(out, "\n"); + fprintf(out, "\n"); + fprintf(out, "\n\n"); } static void write_htmlman(FILE *out, - const char *program, - int nldesc,const char **desc, - int nfile,t_filenm *fnm, - int npargs,t_pargs *pa, - int nbug,const char **bugs, - t_linkdata *links) + const char *program, + int nldesc, const char **desc, + int nfile, t_filenm *fnm, + int npargs, t_pargs *pa, + int nbug, const char **bugs, + t_linkdata *links) { - int i; - char tmp[255]; - - fprintf(out,"\n\n%s\n",program); - fprintf(out,"\n"); - fprintf(out,"\n"); - fprintf(out,"\n
\n"); - fprintf(out,"\n\n"); - fprintf(out,"\n
\n"); - fprintf(out,"" - "" - "

%s

",program); - fprintf(out,"Main Table of Contents
"); - fprintf(out,"

%s
\n",GromacsVersion()); - fprintf(out,"%s

\n


\n",mydate(tmp,255,FALSE)); - - if (nldesc > 0) { - fprintf(out,"

Description

\n

\n"); - for(i=0; (i 0) { - fprintf(out,"

\n"); - fprintf(out,"

Files

\n"); - pr_html_files(out,nfile,fnm,program,links,FALSE); - } - if (npargs > 0) { - fprintf(out,"

\n"); - fprintf(out,"

Other options

\n"); - fprintf(out, - "\n" - "" - "" - "" - "" - "" - "\n"); - for(i=0; (i" - "" - "" - "" - "" - "\n", - (pa[i].type == etBOOL)?"-[no]":"-",pa[i].option+1, - get_arg_desc(pa[i].type),pa_val(&(pa[i]),tmp,255),NSR(pa[i].desc)); - fprintf(out,"
optiontypedefaultdescription
%s%s %s %s %s
\n"); - } - if (nbug > 0) { - fprintf(out,"

\n"); - fprintf(out,"

Known problems

\n"); - fprintf(out,"
    \n"); - for(i=0; (i%s\n",NSR(bugs[i])); - fprintf(out,"
\n"); - } - fprintf(out,"

\n"); - fprintf(out,"


\n
\n"); - fprintf(out,"" - "http://www.gromacs.org
\n"); - fprintf(out,"" - "gromacs@gromacs.org
\n"); - fprintf(out,"
\n"); - fprintf(out,"\n"); + int i; + char tmp[255]; + + fprintf(out, "\n\n%s\n", program); + fprintf(out, "\n"); + fprintf(out, "\n"); + fprintf(out, "\n
\n"); + fprintf(out, "\n\n"); + fprintf(out, "\n
\n"); + fprintf(out, "" + "" + "

%s

", program); + fprintf(out, "Main Table of Contents
"); + fprintf(out, "

%s
\n", GromacsVersion()); + fprintf(out, "%s

\n
\n", mydate(tmp, 255, FALSE)); + + if (nldesc > 0) + { + fprintf(out, "

Description

\n

\n"); + for (i = 0; (i < nldesc); i++) + { + fprintf(out, "%s\n", NSR(desc[i])); + } + } + if (nfile > 0) + { + fprintf(out, "

\n"); + fprintf(out, "

Files

\n"); + pr_html_files(out, nfile, fnm, program, links, FALSE); + } + if (npargs > 0) + { + fprintf(out, "

\n"); + fprintf(out, "

Other options

\n"); + fprintf(out, + "\n" + "" + "" + "" + "" + "" + "\n"); + for (i = 0; (i < npargs); i++) + { + fprintf(out, + "" + "" + "" + "" + "" + "\n", + (pa[i].type == etBOOL) ? "-[no]" : "-", pa[i].option+1, + get_arg_desc(pa[i].type), pa_val(&(pa[i]), tmp, 255), NSR(pa[i].desc)); + } + fprintf(out, "
optiontypedefaultdescription
%s%s %s %s %s
\n"); + } + if (nbug > 0) + { + fprintf(out, "

\n"); + fprintf(out, "

Known problems

\n"); + fprintf(out, "
    \n"); + for (i = 0; (i < nbug); i++) + { + fprintf(out, "
  • %s\n", NSR(bugs[i])); + } + fprintf(out, "
\n"); + } + fprintf(out, "

\n"); + fprintf(out, "


\n
\n"); + fprintf(out, "" + "http://www.gromacs.org
\n"); + fprintf(out, "" + "gromacs@gromacs.org
\n"); + fprintf(out, "
\n"); + fprintf(out, "\n"); } -char *check_xml(const char *s,const char *program,t_linkdata *links) +char *check_xml(const char *s, const char *program, t_linkdata *links) { - char *buf; - - buf=repall(s,NSRXML,sandrXML); - buf=html_xref(buf,program,links,FALSE); /* the same in html and xml */ - - return buf; + char *buf; + + buf = repall(s, NSRXML, sandrXML); + buf = html_xref(buf, program, links, FALSE); /* the same in html and xml */ + + return buf; } static void write_xmlman(FILE *out, - const char *program, - int nldesc,const char **desc, - int nfile,t_filenm *fnm, - int npargs,t_pargs *pa, - int nbug,const char **bugs, - t_linkdata *links) + const char *program, + int nldesc, const char **desc, + int nfile, t_filenm *fnm, + int npargs, t_pargs *pa, + int nbug, const char **bugs, + t_linkdata *links) { - int i; - char link[10],buf[256],opt[10]; - -#define NSR2(s) check_xml(s,program,links) -#define FLAG(w,f) (((w) & (f))==(f)) - - fprintf(out,"\n",GromacsVersion(),mydate(buf,255,FALSE)); - /* fprintf(out,"\n"); */ - - fprintf(out,"",program); - if (nldesc > 0) { - fprintf(out,"\n\n\n"); - for(i=0; (i\n\n"); - - if (nfile > 0) { - fprintf(out,"\n\n"); - for(i=0; (i\n" - "\t\n" - "\t\n" - "\t%s\n" - "\t%s\n" - "\n", - ftp2defnm(fnm[i].ftp), /* from gmxlib/filenm.c */ - fnm[i].ftp, - FLAG(fnm[i].flag,ffREAD), FLAG(fnm[i].flag,ffWRITE), FLAG(fnm[i].flag,ffOPT), - opt,link,fnm[i].fn,/*fileopt(fnm[i].flag),*/ - NSR(ftp2desc(fnm[i].ftp))); - } - fprintf(out,"\n"); - } - - if (npargs > 0) { - fprintf(out,"\n\n"); - for(i=0; (i\n"); - } - - if (nbug > 0) { - fprintf(out,"\n\n"); - for(i=0; (i%s\n",NSR(bugs[i])); - fprintf(out,"\n"); - } - fprintf(out,"\n\n\n"); -#undef FLAG + int i; + char link[10], buf[256], opt[10]; + +#define NSR2(s) check_xml(s, program, links) +#define FLAG(w, f) (((w) & (f)) == (f)) + + fprintf(out, "\n", GromacsVersion(), mydate(buf, 255, FALSE)); + /* fprintf(out,"\n"); */ + + fprintf(out, "", program); + if (nldesc > 0) + { + fprintf(out, "\n\n\n"); + for (i = 0; (i < nldesc); i++) + { + fprintf(out, "%s\n", NSR2(desc[i])); + } + } + fprintf(out, "\n\n"); + + if (nfile > 0) + { + fprintf(out, "\n\n"); + for (i = 0; (i < nfile); i++) + { + strcpy(link, ftp2ext(fnm[i].ftp)); + if (strcmp(link, "???") == 0) + { + strcpy(link, "files"); + } + if (fnm[i].opt[0] == '-') + { + strcpy(opt, fnm[i].opt+1); + } + else + { + strcpy(opt, fnm[i].opt); + } + fprintf(out, + "\n" + "\t\n" + "\t\n" + "\t%s\n" + "\t%s\n" + "\n", + ftp2defnm(fnm[i].ftp), /* from gmxlib/filenm.c */ + fnm[i].ftp, + FLAG(fnm[i].flag, ffREAD), FLAG(fnm[i].flag, ffWRITE), FLAG(fnm[i].flag, ffOPT), + opt, link, fnm[i].fn, /*fileopt(fnm[i].flag),*/ + NSR(ftp2desc(fnm[i].ftp))); + } + fprintf(out, "\n"); + } + + if (npargs > 0) + { + fprintf(out, "\n\n"); + for (i = 0; (i < npargs); i++) + { + fprintf(out, + "\n", + get_arg_desc(pa[i].type), is_hidden(&pa[i]), + pa[i].option+1, /* +1 - with no trailing '-' */ + pa_val(&(pa[i]), buf, 255), pa[i].desc); /*get_argtp()[pa[i].type],*/ + } + fprintf(out, "\n"); + } + + if (nbug > 0) + { + fprintf(out, "\n\n"); + for (i = 0; (i < nbug); i++) + { + fprintf(out, "\t%s\n", NSR(bugs[i])); + } + fprintf(out, "\n"); + } + fprintf(out, "\n\n\n"); +#undef FLAG } -static void pr_opts(FILE *fp, - int nfile, t_filenm *fnm, - int npargs, t_pargs pa[], int shell) +static void pr_opts(FILE *fp, + int nfile, t_filenm *fnm, + int npargs, t_pargs pa[], int shell) { - int i; - - switch (shell) { - case eshellCSH: - fprintf(fp," \"c/-/("); - for (i=0; i 0) { - fprintf(out,"\n BUGS and PROBLEMS\n"); - for(i=0; i 0) + { + fprintf(out, "\n BUGS and PROBLEMS\n"); + for (i = 0; i < nbug; i++) + { + snew(tmp, strlen(bugs[i])+3); + strcpy(tmp, "* "); + strcpy(tmp+2, check_tty(bugs[i])); + fprintf(out, "%s\n", wrap_lines(tmp, 78, 10, TRUE)); + sfree(tmp); + } + } + fprintf(out, " \"\"\"\n\n # Command line options\n"); + /* File options */ + fprintf(out, " flags = []\n"); + for (i = 0; (i < nfile); i++) + { + fprintf(out, " flags.append(pca_file('%s',\"%s\",0,%d))\n", + ftp2ext_generic(fnm[i].ftp), fnm[i].opt ? fnm[i].opt : "k", + is_optional(&(fnm[i]))); + } + + + /* Other options */ + for (i = 0; (i < npargs); i++) + { + switch (pa[i].type) + { + case etINT: + fprintf(out, " flags.append(pca_int(\"%s\",\"%s\",%d,%d))\n", + pa[i].option, pa[i].desc, *pa[i].u.i, is_hidden(&(pa[i]))); + break; + case etREAL: + case etTIME: + fprintf(out, " flags.append(pca_float(\"%s\",\"%s\",%f,%d))\n", + pa[i].option, pa[i].desc, *pa[i].u.r, is_hidden(&(pa[i]))); + break; + case etSTR: + case etBOOL: + fprintf(out, " flags.append(pca_gmx_bool(\"%s\",\"%s\",%d,%d))\n", + pa[i].option, pa[i].desc, *pa[i].u.b, is_hidden(&(pa[i]))); + break; + case etRVEC: + fprintf(stderr, "Sorry, no rvecs yet...\n"); + break; + case etENUM: + fprintf(out, " flags.append(pca_enum(\"%s\",\"%s\",\n", + pa[i].option, pa[i].desc); + fprintf(out, " ['%s'", pa[i].u.c[1]); + for (j = 2; (pa[i].u.c[j] != NULL); j++) + { + fprintf(out, ",'%s'", pa[i].u.c[j]); + } + fprintf(out, "],%d))\n", is_hidden(&(pa[i]))); + break; + default: + break; + } + } + + /* Make the dialog box */ + fprintf(out, " gmxd = gmx_dialog(tk,\"%s\",flags,%s_help)\n\n", + cls, cls); + + /* Main loop */ + fprintf(out, "#####################################################\n"); + fprintf(out, "tk = Tk()\n"); + fprintf(out, "my%s = %s(tk)\n", cls, cls); + fprintf(out, "tk.mainloop()\n"); } -void write_man(FILE *out,const char *mantp, - const char *program, - int nldesc,const char **desc, - int nfile,t_filenm *fnm, - int npargs,t_pargs *pa, - int nbug,const char **bugs, - gmx_bool bHidden) +void write_man(FILE *out, const char *mantp, + const char *program, + int nldesc, const char **desc, + int nfile, t_filenm *fnm, + int npargs, t_pargs *pa, + int nbug, const char **bugs, + gmx_bool bHidden) { - const char *pr; - int i,npar; - t_pargs *par; - - t_linkdata *links; - - links=init_linkdata(); - - /* Don't write hidden options to completions, it just - * makes the options more complicated for normal users - */ - - if (bHidden) { - npar=npargs; - par=pa; - } - else { - snew(par,npargs); - npar=0; - for(i=0;i