From 6fe10712d0cf9e47ceea331b4488c685a982e050 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 3 Jan 2022 13:18:45 +0100 Subject: [PATCH] Working on configure --- .gitmodules | 6 + EZFIO | 1 + Makefile | 11 ++ Makefile.am | 76 +++++++++++++ configure.ac | 36 +++++- f77_zmq | 1 + m4/ax_blas.m4 | 241 ++++++++++++++++++++++++++++++++++++++++ m4/ax_irpf90.m4 | 4 + m4/ax_lapack.m4 | 135 ++++++++++++++++++++++ m4/ax_zmq.m4 | 9 +- scripts/compile_src.sh | 6 - src/MAIN/admc.org | 229 ++++++++++++++++++++++++++++++++++++++ src/MAIN/vmc_test.irp.f | 2 +- src/Makefile | 1 + 14 files changed, 746 insertions(+), 12 deletions(-) create mode 100644 .gitmodules create mode 160000 EZFIO create mode 100644 Makefile.am create mode 160000 f77_zmq create mode 100644 m4/ax_blas.m4 create mode 100644 m4/ax_lapack.m4 create mode 100644 src/MAIN/admc.org diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ec36f9f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "EZFIO"] + path = EZFIO + url = https://gitlab.com/scemama/EZFIO.git +[submodule "f77_zmq"] + path = f77_zmq + url = https://github.com/zeromq/f77_zmq.git diff --git a/EZFIO b/EZFIO new file mode 160000 index 0000000..ed1df9f --- /dev/null +++ b/EZFIO @@ -0,0 +1 @@ +Subproject commit ed1df9f3c1f51752656ca98da5693a4119add05c diff --git a/Makefile b/Makefile index f988cee..aad6084 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,14 @@ +# QMC=Chem + +FC = gfortran +LIBS = +CPPFLAGS = +LDFLAGS= + +ZMQ_LIBS = -lzmq +ZMQ_LDFLAGS = +ZMQ_CPPFLAGS = + include make.config diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..6a452da --- /dev/null +++ b/Makefile.am @@ -0,0 +1,76 @@ +# QMC=Chem + +FC = @FC@ +LIBS = @LIBS@ +CPPFLAGS = @CPPFLAGS@ +LDFLAGS= @LDFLAGS@ + +ZMQ_LIBS = @ZMQ_LIBS@ +ZMQ_LDFLAGS = @ZMQ_LDFLAGS@ +ZMQ_CPPFLAGS = @ZMQ_CPPFLAGS@ + + + +default_target: all + +.phony: clean always + +clean: + ./scripts/clean.sh + +# put all files of PROPERTIES here +# -------------------------------- + +ezfio_config/properties.config ocaml/Property.ml: scripts/create_properties_python.py src/PROPERTIES/properties.irp.f src/PROPERTIES/properties_energy.irp.f src/PROPERTIES/properties_general.irp.f src/irpf90.make + bash -c "source qmcchemrc ; exec python2 ./scripts/create_properties_ezfio.py" + +# EZFIO +# ----- + +build lib/libezfio.a lib/libezfio_irp.a EZFIO/lib/libezfio.a EZFIO/lib/libezfio_irp.a EZFIO/Ocaml/ezfio.ml EZFIO/Python/ezfio.py: ezfio_config/qmc.config ezfio_config/properties.config make.config scripts/create_properties_ezfio.py src/tags src/irpf90_entities src/irpf90.make src/irpf90.make + ./scripts/compile_ezfio.sh + + +# Fortran executables +# ------------------- + + +always: /dev/null + +src/tags src/irpf90_entities src/irpf90.make: make.config always + ./scripts/compile_irpf90.sh + +src/MAIN/qmc src/MAIN/vmc_test src/MAIN/qmc_create_walkers src/MAIN/qmcchem_info: lib/libezfio.a lib/libezfio_irp.a src/tags src/irpf90_entities src/irpf90.make src/irpf90.make + ./scripts/compile_src.sh + +# OCaml +# ----- + +ocaml/qmcchem: EZFIO/Ocaml/ezfio.ml $(wildcard ocaml/*.ml) + ./scripts/compile_ocaml.sh + +# Archive +# ------- + +qmcchem.tar.gz: all + git archive --format tar.gz HEAD --prefix "QmcChem/" -7 -o qmcchem.tar.gz + + +# Binaries +# -------- + +bin/qmc: src/MAIN/qmc + cp src/MAIN/qmc bin/ + +bin/qmcchem_info: src/MAIN/qmcchem_info + cp src/MAIN/qmcchem_info bin/ + +bin/qmc_create_walkers: src/MAIN/qmc_create_walkers + cp src/MAIN/qmc_create_walkers bin/ + +bin/qmcchem: ocaml/qmcchem + cp ocaml/qmcchem bin/ + +all: bin/qmc bin/qmcchem_info bin/qmc_create_walkers bin/qmcchem + + diff --git a/configure.ac b/configure.ac index c905233..7f42e88 100644 --- a/configure.ac +++ b/configure.ac @@ -4,22 +4,52 @@ AC_PREREQ([2.69]) AC_INIT([QMC=Chem], [2.0.0], [https://gitlab.com/scemama/qmcchem/-/issues/new]) +AM_INIT_AUTOMAKE([foreign subdir-objects silent-rules]) + AC_CONFIG_SRCDIR([README.md]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([include/config.h]) # Checks for programs. - AC_PROG_AWK -AC_PROG_FC -#AC_PROG_INSTALL +AC_PROG_CC +AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AX_PROG_IRPF90 +# Fortran compiler checks +AC_PROG_FC([ifort gfortran]) +AC_FC_LINE_LENGTH([512]) + # Checks for libraries. AX_ZMQ([4.0], [], [ AC_MSG_ERROR([Please install ZeroMQ >= 4.0]) ]) +AX_BLAS() +AX_LAPACK() + +# Required by EZFIO +AC_CHECK_FUNCS([mkdir strerror]) +AC_TYPE_SIZE_T + +# Required by OCaml C bindings +AC_CHECK_FUNCS([inet_ntoa]) +AC_CHECK_FUNCS([memset]) +AC_CHECK_FUNCS([socket]) +AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/ioctl.h sys/socket.h]) + +# Required by ZeroMQ +AC_CHECK_HEADERS([stddef.h]) +AC_TYPE_INT32_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT8_T + +# Required by QMCkl +#AC_CHECK_HEADER_STDBOOL +#AC_TYPE_INT64_T +#AC_TYPE_UINT64_T + AC_LANG([Fortran]) diff --git a/f77_zmq b/f77_zmq new file mode 160000 index 0000000..934e063 --- /dev/null +++ b/f77_zmq @@ -0,0 +1 @@ +Subproject commit 934e063881553e42d81c5d1aaed35822988529f0 diff --git a/m4/ax_blas.m4 b/m4/ax_blas.m4 new file mode 100644 index 0000000..9571905 --- /dev/null +++ b/m4/ax_blas.m4 @@ -0,0 +1,241 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_blas.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro looks for a library that implements the BLAS linear-algebra +# interface (see http://www.netlib.org/blas/). On success, it sets the +# BLAS_LIBS output variable to hold the requisite library linkages. +# +# To link with BLAS, you should link with: +# +# $BLAS_LIBS $LIBS $FLIBS +# +# in that order. FLIBS is the output variable of the +# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is +# sometimes necessary in order to link with F77 libraries. Users will also +# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same +# reason. +# +# Many libraries are searched for, from ATLAS to CXML to ESSL. The user +# may also use --with-blas= in order to use some specific BLAS +# library . In order to link successfully, however, be aware that you +# will probably need to use the same Fortran compiler (which can be set +# via the F77 env. var.) as was used to compile the BLAS library. +# +# ACTION-IF-FOUND is a list of shell commands to run if a BLAS library is +# found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is +# not found. If ACTION-IF-FOUND is not specified, the default action will +# define HAVE_BLAS. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2019 Geoffrey M. Oxberry +# +# 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 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 17 + +AU_ALIAS([ACX_BLAS], [AX_BLAS]) +AC_DEFUN([AX_BLAS], [ +AC_PREREQ([2.55]) +AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS]) +AC_REQUIRE([AC_CANONICAL_HOST]) +ax_blas_ok=no + +AC_ARG_WITH(blas, + [AS_HELP_STRING([--with-blas=], [use BLAS library ])]) +case $with_blas in + yes | "") ;; + no) ax_blas_ok=disable ;; + -* | */* | *.a | *.so | *.so.* | *.dylib | *.dylib.* | *.o) + BLAS_LIBS="$with_blas" + ;; + *) BLAS_LIBS="-l$with_blas" ;; +esac + +# Get fortran linker names of BLAS functions to check for. +AC_F77_FUNC(sgemm) +AC_F77_FUNC(dgemm) + +ax_blas_save_LIBS="$LIBS" +LIBS="$LIBS $FLIBS" + +# First, check BLAS_LIBS environment variable +if test $ax_blas_ok = no; then +if test "x$BLAS_LIBS" != x; then + save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS" + AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes], [BLAS_LIBS=""]) + AC_MSG_RESULT($ax_blas_ok) + LIBS="$save_LIBS" +fi +fi + +# BLAS linked to by default? (happens on some supercomputers) +if test $ax_blas_ok = no; then + save_LIBS="$LIBS"; LIBS="$LIBS" + AC_MSG_CHECKING([if $sgemm is being linked in already]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes]) + AC_MSG_RESULT($ax_blas_ok) + LIBS="$save_LIBS" +fi + +# BLAS in OpenBLAS library? (http://xianyi.github.com/OpenBLAS/) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(openblas, $sgemm, [ax_blas_ok=yes + BLAS_LIBS="-lopenblas"]) +fi + +# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(atlas, ATL_xerbla, + [AC_CHECK_LIB(f77blas, $sgemm, + [AC_CHECK_LIB(cblas, cblas_dgemm, + [ax_blas_ok=yes + BLAS_LIBS="-lcblas -lf77blas -latlas"], + [], [-lf77blas -latlas])], + [], [-latlas])]) +fi + +# BLAS in PhiPACK libraries? (requires generic BLAS lib, too) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(blas, $sgemm, + [AC_CHECK_LIB(dgemm, $dgemm, + [AC_CHECK_LIB(sgemm, $sgemm, + [ax_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"], + [], [-lblas])], + [], [-lblas])]) +fi + +# BLAS in Intel MKL library? +if test $ax_blas_ok = no; then + # MKL for gfortran + if test x"$ac_cv_fc_compiler_gnu" = xyes; then + # 64 bit + if test $host_cpu = x86_64; then + AC_CHECK_LIB(mkl_gf_lp64, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread]) + # 32 bit + elif test $host_cpu = i686; then + AC_CHECK_LIB(mkl_gf, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_gf -lmkl_sequential -lmkl_core -lpthread]) + fi + # MKL for other compilers (Intel, PGI, ...?) + else + # 64-bit + if test $host_cpu = x86_64; then + AC_CHECK_LIB(mkl_intel_lp64, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread]) + # 32-bit + elif test $host_cpu = i686; then + AC_CHECK_LIB(mkl_intel, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_intel -lmkl_sequential -lmkl_core -lpthread]) + fi + fi +fi +# Old versions of MKL +if test $ax_blas_ok = no; then + AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread"],,[-lguide -lpthread]) +fi + +# BLAS in Apple vecLib library? +if test $ax_blas_ok = no; then + save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS" + AC_MSG_CHECKING([for $sgemm in -framework vecLib]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$sgemm])], [ax_blas_ok=yes;BLAS_LIBS="-framework vecLib"]) + AC_MSG_RESULT($ax_blas_ok) + LIBS="$save_LIBS" +fi + +# BLAS in Alpha CXML library? +if test $ax_blas_ok = no; then + AC_CHECK_LIB(cxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"]) +fi + +# BLAS in Alpha DXML library? (now called CXML, see above) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(dxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"]) +fi + +# BLAS in Sun Performance library? +if test $ax_blas_ok = no; then + if test "x$GCC" != xyes; then # only works with Sun CC + AC_CHECK_LIB(sunmath, acosp, + [AC_CHECK_LIB(sunperf, $sgemm, + [BLAS_LIBS="-xlic_lib=sunperf -lsunmath" + ax_blas_ok=yes],[],[-lsunmath])]) + fi +fi + +# BLAS in SCSL library? (SGI/Cray Scientific Library) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(scs, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lscs"]) +fi + +# BLAS in SGIMATH library? +if test $ax_blas_ok = no; then + AC_CHECK_LIB(complib.sgimath, $sgemm, + [ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"]) +fi + +# BLAS in IBM ESSL library? (requires generic BLAS lib, too) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(blas, $sgemm, + [AC_CHECK_LIB(essl, $sgemm, + [ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"], + [], [-lblas $FLIBS])]) +fi + +# Generic BLAS library? +if test $ax_blas_ok = no; then + AC_CHECK_LIB(blas, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lblas"]) +fi + +AC_SUBST(BLAS_LIBS) + +LIBS="$ax_blas_save_LIBS" + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_blas_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1]) + : +else + ax_blas_ok=no + $2 +fi +])dnl AX_BLAS diff --git a/m4/ax_irpf90.m4 b/m4/ax_irpf90.m4 index 49f5401..50942a2 100644 --- a/m4/ax_irpf90.m4 +++ b/m4/ax_irpf90.m4 @@ -65,5 +65,9 @@ AC_PATH_PROG([IRPF90], [irpf90], [nocommand]) AS_IF([test "x$IRPF90" = xnocommand], [ AC_MSG_ERROR([irpf90 not found in $PATH]) ]) +AC_FC_FREEFORM +AC_FC_LINE_LENGTH +AC_FC_MODULE_EXTENSION + ]) diff --git a/m4/ax_lapack.m4 b/m4/ax_lapack.m4 new file mode 100644 index 0000000..86265ff --- /dev/null +++ b/m4/ax_lapack.m4 @@ -0,0 +1,135 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_lapack.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_LAPACK([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro looks for a library that implements the LAPACK linear-algebra +# interface (see http://www.netlib.org/lapack/). On success, it sets the +# LAPACK_LIBS output variable to hold the requisite library linkages. +# +# To link with LAPACK, you should link with: +# +# $LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS +# +# in that order. BLAS_LIBS is the output variable of the AX_BLAS macro, +# called automatically. FLIBS is the output variable of the +# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is +# sometimes necessary in order to link with F77 libraries. Users will also +# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same +# reason. +# +# The user may also use --with-lapack= in order to use some specific +# LAPACK library . In order to link successfully, however, be aware +# that you will probably need to use the same Fortran compiler (which can +# be set via the F77 env. var.) as was used to compile the LAPACK and BLAS +# libraries. +# +# ACTION-IF-FOUND is a list of shell commands to run if a LAPACK library +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +# is not found. If ACTION-IF-FOUND is not specified, the default action +# will define HAVE_LAPACK. +# +# LICENSE +# +# Copyright (c) 2009 Steven G. Johnson +# Copyright (c) 2019 Geoffrey M. Oxberry +# +# 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 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 10 + +AU_ALIAS([ACX_LAPACK], [AX_LAPACK]) +AC_DEFUN([AX_LAPACK], [ +AC_REQUIRE([AX_BLAS]) +ax_lapack_ok=no + +AC_ARG_WITH(lapack, + [AS_HELP_STRING([--with-lapack=], [use LAPACK library ])]) +case $with_lapack in + yes | "") ;; + no) ax_lapack_ok=disable ;; + -* | */* | *.a | *.so | *.so.* | *.dylib | *.dylib.* | *.o) + LAPACK_LIBS="$with_lapack" + ;; + *) LAPACK_LIBS="-l$with_lapack" ;; +esac + +# Get fortran linker name of LAPACK function to check for. +AC_F77_FUNC(cheev) + +# We cannot use LAPACK if BLAS is not found +if test "x$ax_blas_ok" != xyes; then + ax_lapack_ok=noblas + LAPACK_LIBS="" +fi + +# First, check LAPACK_LIBS environment variable +if test "x$LAPACK_LIBS" != x; then + save_LIBS="$LIBS"; LIBS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS" + AC_MSG_CHECKING([for $cheev in $LAPACK_LIBS]) + AC_LINK_IFELSE([AC_LANG_CALL([], [$cheev])], [ax_lapack_ok=yes], [LAPACK_LIBS=""]) + AC_MSG_RESULT($ax_lapack_ok) + LIBS="$save_LIBS" + if test $ax_lapack_ok = no; then + LAPACK_LIBS="" + fi +fi + +# LAPACK linked to by default? (is sometimes included in BLAS lib) +if test $ax_lapack_ok = no; then + save_LIBS="$LIBS"; LIBS="$LIBS $BLAS_LIBS $FLIBS" + AC_CHECK_FUNC($cheev, [ax_lapack_ok=yes]) + LIBS="$save_LIBS" +fi + +# Generic LAPACK library? +for lapack in lapack lapack_rs6k; do + if test $ax_lapack_ok = no; then + save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS" + AC_CHECK_LIB($lapack, $cheev, + [ax_lapack_ok=yes; LAPACK_LIBS="-l$lapack"], [], [$FLIBS]) + LIBS="$save_LIBS" + fi +done + +AC_SUBST(LAPACK_LIBS) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_lapack_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_LAPACK,1,[Define if you have LAPACK library.]),[$1]) + : +else + ax_lapack_ok=no + $2 +fi +])dnl AX_LAPACK + diff --git a/m4/ax_zmq.m4 b/m4/ax_zmq.m4 index 43f6cd4..83e7b78 100644 --- a/m4/ax_zmq.m4 +++ b/m4/ax_zmq.m4 @@ -60,8 +60,13 @@ AC_DEFUN([AX_ZMQ], [ #endif ],[ AC_MSG_RESULT(yes) - HAVE_ZMQ=1 - ZMQ_LIBS="-lzmq" + AC_CHECK_LIB([zmq],[zmq_send],[ + HAVE_ZMQ=1 + ZMQ_LIBS="-lzmq" + ],[ + AC_MSG_ERROR([libzmq.so not in LIBRARY_PATH]) + ]) + AC_SUBST(ZMQ_LDFLAGS) AC_SUBST(ZMQ_CPPFLAGS) AC_SUBST(ZMQ_LIBS) diff --git a/scripts/compile_src.sh b/scripts/compile_src.sh index f9f9cab..e195426 100755 --- a/scripts/compile_src.sh +++ b/scripts/compile_src.sh @@ -18,12 +18,6 @@ OBJ="${OBJ} IRPF90_temp/ZMQ/f77_zmq_module.o" INCLUDES="${INCLUDES} -I AO -I SAMPLING -I TOOLS -I JASTROW -I MAIN -I PROPERTIES -I ZMQ" IRPF90_FLAGS="${IRPF90_FLAGS} ${INCLUDES}" -# Check IRPF90 version -if [[ $( ${IRPF90} -v | python2 -c "import sys ; print float(sys.stdin.read().rsplit('.',1)[0]) >= 1.6") == False ]] -then - echo "IRPF90 version >= 1.6 required" - exit -1 -fi export IRPF90 IRPF90_FLAGS INCLUDES LIB SRC OBJ diff --git a/src/MAIN/admc.org b/src/MAIN/admc.org new file mode 100644 index 0000000..b4b1912 --- /dev/null +++ b/src/MAIN/admc.org @@ -0,0 +1,229 @@ +#+TITLE: Asynchronous DMC +#+AUTHOR: Anthony Scemama +#+EMAIL: scemama@irsamc.ups-tlse.fr + + +#+PROPERTY: header-args :tangle no :noweb yes + + +* Main program + +** Declarations + + #+NAME: declarations + #+begin_src f90 + include '../types.F' + + integer :: iter + integer :: k_full ! Index of walkers in elec_coord_full + integer :: k_new ! Index of walkers in elec_coord_new + integer :: iw ! Number of copies in branching + integer :: l + + double precision :: w, E_out, w_sum + + double precision, allocatable :: elec_coord_new(:,:,:) + + double precision, external :: qmc_ranf + + allocate(elec_coord_new(elec_num+1,3,walk_num)) + #+end_src + +** Main flow + + - Fetch ~walk_num~ electron coordinates in ~elec_coord_full~ + - For each set of coordinates, + - Make a PDMC trajectory, and output the weight ~w~ + - Perform branching depending on the value of the weight + - Store the new sets of coordinates in ~elec_coord_new~ + - When ~elec_coord_new~ is full, send it to the server + + #+begin_src f90 :tangle "admc.irp.f" +program admc + call run + call ezfio_finish +end program admc + +subroutine run + implicit none + + <> + + ! Initialization + if (vmc_algo /= t_Brownian) then + call abrt(irp_here,'DMC should run with Brownian algorithm') + endif + + do iter=1,2 + call read_coords() + + k_new = 1 + do while (k_new < walk_num) + call pdmc_trajectory(k_full, w, E_out, w_sum) + write(*,*) 'E', E_out, w_sum + k_full = k_full+1 + if (k_full > walk_num) k_full = 1 + + <> + + end do + + elec_coord_full(1:elec_num+1,1:3,1:walk_num) = & + elec_coord_new(1:elec_num+1,1:3,1:walk_num) + + call write_coords() + end do + +end subroutine run + +<> +<> +<> + #+end_src + +** Branching + + #+NAME: branching + #+begin_src f90 + ! Find number of copies + iw = int(w) + w = w - int(w) + if (qmc_ranf() < w) then + iw = iw+1 + end if + + ! Duplicate walker + do l=1,iw + elec_coord_new(1:elec_num+1,1:3,k_new) = & + elec_coord_full(1:elec_num+1,1:3,k_full) + k_new = k_new+1 + if (k_new > walk_num) exit + end do + + #+end_src + +* Read/write coordinates + +** Read + + Fetch a new set of coordinates for ~walk_num~ walkers from the pool of coordinates. + + #+NAME: read_coords + #+begin_src f90 +subroutine read_coords() + implicit none + + integer :: i, k + + do k=1,walk_num + do i=1,elec_num + read(*,*) elec_coord_full(i,1:3,k) + end do + end do + + SOFT_TOUCH elec_coord_full + +end subroutine read_coords + #+end_src + +** Write + + Send the current set of coordinates for ~walk_num~ walkers to the pool of coordinates. + + #+NAME: write_coords + #+begin_src f90 +subroutine write_coords() + implicit none + + integer :: i, k + + do k=1,walk_num + do i=1,elec_num + write(*,*) 'C', elec_coord_full(i,1:3,k) + end do + end do + +end subroutine write_coords + #+end_src + +* PDMC trajectory + + Computes a PDMC trajectory until the weight ~w~ is $1/2 < w < 3/2$. + The energy of the trajectory is computed as + \[ + E = \frac{\sum_i w_i E(R_i)}{\sum_i w_i} + \] + + The function returns: + - ~pdmc_weight~: the last of all $w_i$ + - ~E_out~: The average energy $E$ of the trajectory + - ~w_sum~: The sum of the weights + + #+NAME: declarations_pdmc + #+begin_src f90 + integer :: i,j,l + double precision :: delta + + ! If true, continue to make more steps + logical :: loop + + ! Brownian step variables + double precision :: p,q + real :: delta_x + logical :: accepted + + ! Local energies from the past + double precision :: E_loc_save(4) + + #+end_src + + #+NAME: pdmc_trajectory + #+begin_src f90 +subroutine pdmc_trajectory(k_full, pdmc_weight, E_out, w_sum) + implicit none + + integer, intent(in) :: k_full + double precision, intent(out) :: pdmc_weight, E_out, w_sum + + <> + + elec_coord(1:elec_num+1,1:3) = elec_coord_full(1:elec_num+1,1:3,k_full) + TOUCH elec_coord + + E_out = 0.d0 + w_sum = 0.d0 + + E_loc_save(1:4) = E_loc + + pdmc_weight = 1.d0 + loop = .True. + + do while (loop) + + call brownian_step(p,q,accepted,delta_x) + + delta = (9.d0*E_loc+19.d0*E_loc_save(1)-5.d0*E_loc_save(2)+E_loc_save(3))/24.d0 + delta = (delta - E_ref)*p + + if (delta >= 0.d0) then + pdmc_weight = dexp(-dtime_step*delta) + else + pdmc_weight = 2.d0-dexp(dtime_step*delta) + endif + elec_coord(elec_num+1,1) += p*time_step + elec_coord(elec_num+1,2) = E_loc + elec_coord(elec_num+1,3) = pdmc_weight + + w_sum = w_sum + pdmc_weight + E_out = E_out + pdmc_weight * E_loc + + loop = pdmc_weight > 0.5d0 .or. pdmc_weight < 1.5d0 + + end do + + elec_coord_full(1:elec_num+1,1:3,k_full) = elec_coord(1:elec_num+1,1:3) + SOFT_TOUCH elec_coord_full + +end subroutine pdmc_trajectory + #+end_src + diff --git a/src/MAIN/vmc_test.irp.f b/src/MAIN/vmc_test.irp.f index 4876f6d..fb54a9b 100644 --- a/src/MAIN/vmc_test.irp.f +++ b/src/MAIN/vmc_test.irp.f @@ -1,4 +1,4 @@ -program vmc_test +program vmc_test real :: t1,t2 print *, 'Ndet=',det_num print *, 'Ndet alpha beta =',det_alpha_num, det_beta_num diff --git a/src/Makefile b/src/Makefile index 5964b67..68e3a23 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,3 +1,4 @@ +IRPF90=irpf90 IRPF90+= $(IRPF90_FLAGS) include irpf90.make export