From d31cca38df6f9b78ec1b5e1444e2cb32f6fd45a6 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 12 Jan 2018 21:42:37 +0100 Subject: [PATCH 1/5] Fixes #223 --- plugins/GPI2/NEEDED_CHILDREN_MODULES | 1 - plugins/GPI2/README.rst | 14 ---- plugins/GPI2/gpi_test.irp.f | 13 ---- plugins/GPI2/utils.irp.f | 76 ------------------- .../read_integral/print_integrals_mo.irp.f | 6 +- plugins/read_integral/read_integrals_mo.irp.f | 3 +- 6 files changed, 5 insertions(+), 108 deletions(-) delete mode 100644 plugins/GPI2/NEEDED_CHILDREN_MODULES delete mode 100644 plugins/GPI2/README.rst delete mode 100644 plugins/GPI2/gpi_test.irp.f delete mode 100644 plugins/GPI2/utils.irp.f diff --git a/plugins/GPI2/NEEDED_CHILDREN_MODULES b/plugins/GPI2/NEEDED_CHILDREN_MODULES deleted file mode 100644 index aae89501..00000000 --- a/plugins/GPI2/NEEDED_CHILDREN_MODULES +++ /dev/null @@ -1 +0,0 @@ -Determinants diff --git a/plugins/GPI2/README.rst b/plugins/GPI2/README.rst deleted file mode 100644 index d6be4958..00000000 --- a/plugins/GPI2/README.rst +++ /dev/null @@ -1,14 +0,0 @@ -===== -GASPI -===== - -Providers for GASPI programs (with the GPI2 library). - -Needed Modules -============== -.. Do not edit this section It was auto-generated -.. by the `update_README.py` script. -Documentation -============= -.. Do not edit this section It was auto-generated -.. by the `update_README.py` script. diff --git a/plugins/GPI2/gpi_test.irp.f b/plugins/GPI2/gpi_test.irp.f deleted file mode 100644 index 1fc109e6..00000000 --- a/plugins/GPI2/gpi_test.irp.f +++ /dev/null @@ -1,13 +0,0 @@ -program test - double precision :: energy(N_states) - if (is_gaspi_master) then - energy = 1.d0 - else - energy = 0.d0 - endif - call broadcast_wf(energy) - print *, 'energy (1.d0) :', GASPI_rank, energy(1) - print *, 'coef :', GASPI_rank, psi_coef(1,1) - print *, 'det :', GASPI_rank, psi_det (1,1,1) - call gaspi_finalize -end diff --git a/plugins/GPI2/utils.irp.f b/plugins/GPI2/utils.irp.f deleted file mode 100644 index cfb17b75..00000000 --- a/plugins/GPI2/utils.irp.f +++ /dev/null @@ -1,76 +0,0 @@ - BEGIN_PROVIDER [ logical, GASPI_is_initialized ] -&BEGIN_PROVIDER [ logical, has_gaspi ] - implicit none - BEGIN_DOC -! This is true when GASPI_Init has been called - END_DOC - - has_gaspi = .False. - IRP_IF GASPI - use GASPI - integer(gaspi_return_t) :: res - res = gaspi_proc_init(GASPI_BLOCK) - if (res /= GASPI_SUCCESS) then - print *, res - print *, 'GASPI failed to initialize' - stop -1 - endif - has_gaspi = .True. - IRP_ENDIF - GASPI_is_initialized = .True. -END_PROVIDER - - - BEGIN_PROVIDER [ integer, GASPI_rank ] -&BEGIN_PROVIDER [ integer, GASPI_size ] -&BEGIN_PROVIDER [ logical, is_GASPI_master ] - implicit none - BEGIN_DOC -! Usual GASPI variables - END_DOC - - PROVIDE GASPI_is_initialized - - IRP_IF GASPI - use GASPI - integer(gaspi_return_t) :: res - integer(gaspi_rank_t) :: n - res = gaspi_proc_num(n) - GASPI_size = n - if (res /= GASPI_SUCCESS) then - print *, res - print *, 'Unable to get GASPI_size' - stop -1 - endif - res = gaspi_proc_rank(n) - GASPI_rank = n - if (res /= GASPI_SUCCESS) then - print *, res - print *, 'Unable to get GASPI_rank' - stop -1 - endif - is_GASPI_master = (GASPI_rank == 0) - IRP_ELSE - GASPI_rank = 0 - GASPI_size = 1 - is_GASPI_master = .True. - IRP_ENDIF - - -END_PROVIDER - -subroutine gaspi_finalize() - implicit none - PROVIDE GASPI_is_initialized - IRP_IF GASPI - use GASPI - integer(gaspi_return_t) :: res - res = gaspi_proc_term(GASPI_BLOCK) - if (res /= GASPI_SUCCESS) then - print *, res - print *, 'Unable to finalize GASPI' - stop -1 - endif - IRP_ENDIF -end subroutine - diff --git a/plugins/read_integral/print_integrals_mo.irp.f b/plugins/read_integral/print_integrals_mo.irp.f index 18795249..45745c13 100644 --- a/plugins/read_integral/print_integrals_mo.irp.f +++ b/plugins/read_integral/print_integrals_mo.irp.f @@ -45,13 +45,13 @@ program print_integrals do k=1,mo_tot_num do j=l,mo_tot_num do i=k,mo_tot_num - !if (i>=j) then + if (i>=j) then double precision :: get_mo_bielec_integral integral = get_mo_bielec_integral(i,j,k,l,mo_integrals_map) if (dabs(integral) > mo_integrals_threshold) then - write (iunit,'(4(I6,X),F20.15)') i,j,k,l, integral + write (iunit,'(4(I6,X),E25.15)') i,j,k,l, integral endif - !end if + end if enddo enddo enddo diff --git a/plugins/read_integral/read_integrals_mo.irp.f b/plugins/read_integral/read_integrals_mo.irp.f index 06db0ddf..a2d1cb6b 100644 --- a/plugins/read_integral/read_integrals_mo.irp.f +++ b/plugins/read_integral/read_integrals_mo.irp.f @@ -69,9 +69,10 @@ subroutine run 13 continue close(iunit) - call insert_into_mo_integrals_map(n_integrals,buffer_i,buffer_values,0.d0) + call map_append(mo_integrals_map, buffer_i, buffer_values, n_integrals) call map_sort(mo_integrals_map) + call map_unique(mo_integrals_map) call map_save_to_disk(trim(ezfio_filename)//'/work/mo_ints',mo_integrals_map) call ezfio_set_integrals_bielec_disk_access_mo_integrals("Read") From 02161df6d0078ef3c7a40d0433e5bb10c67b0a69 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 13 Jan 2018 18:15:12 +0100 Subject: [PATCH 2/5] Fixes #223 --- plugins/read_integral/NEEDED_CHILDREN_MODULES | 2 +- .../read_integral/print_integrals_mo.irp.f | 14 ++++---- plugins/read_integral/read_integrals_mo.irp.f | 36 +++++++++++++++++++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/plugins/read_integral/NEEDED_CHILDREN_MODULES b/plugins/read_integral/NEEDED_CHILDREN_MODULES index e492a3ce..566762ba 100644 --- a/plugins/read_integral/NEEDED_CHILDREN_MODULES +++ b/plugins/read_integral/NEEDED_CHILDREN_MODULES @@ -1 +1 @@ -Integrals_Monoelec Integrals_Bielec +Integrals_Monoelec Integrals_Bielec Hartree_Fock diff --git a/plugins/read_integral/print_integrals_mo.irp.f b/plugins/read_integral/print_integrals_mo.irp.f index 45745c13..2381da52 100644 --- a/plugins/read_integral/print_integrals_mo.irp.f +++ b/plugins/read_integral/print_integrals_mo.irp.f @@ -44,14 +44,12 @@ program print_integrals do l=1,mo_tot_num do k=1,mo_tot_num do j=l,mo_tot_num - do i=k,mo_tot_num - if (i>=j) then - double precision :: get_mo_bielec_integral - integral = get_mo_bielec_integral(i,j,k,l,mo_integrals_map) - if (dabs(integral) > mo_integrals_threshold) then - write (iunit,'(4(I6,X),E25.15)') i,j,k,l, integral - endif - end if + do i=max(j,k),mo_tot_num + double precision :: get_mo_bielec_integral + integral = get_mo_bielec_integral(i,j,k,l,mo_integrals_map) + if (dabs(integral) > mo_integrals_threshold) then + write (iunit,'(4(I6,X),E25.15)') i,j,k,l, integral + endif enddo enddo enddo diff --git a/plugins/read_integral/read_integrals_mo.irp.f b/plugins/read_integral/read_integrals_mo.irp.f index a2d1cb6b..c021941c 100644 --- a/plugins/read_integral/read_integrals_mo.irp.f +++ b/plugins/read_integral/read_integrals_mo.irp.f @@ -5,8 +5,44 @@ program read_integrals ! - nuclear_mo ! - bielec_mo END_DOC + + integer :: iunit + integer :: getunitandopen + integer :: i,j,n + PROVIDE ezfio_filename call ezfio_set_integrals_monoelec_disk_access_mo_one_integrals("None") + + logical :: has + call ezfio_has_mo_basis_mo_tot_num(has) + if (.not.has) then + + iunit = getunitandopen('nuclear_mo','r') + n=0 + do + read (iunit,*,end=12) i + n = max(n,i) + enddo + 12 continue + close(iunit) + call ezfio_set_mo_basis_mo_tot_num(n) + + call ezfio_has_ao_basis_ao_num(has) + mo_label = "None" + if (has) then + call huckel_guess + else + call ezfio_set_ao_basis_ao_num(n) + double precision, allocatable :: X(:,:) + allocate (X(n,n)) + X = 0.d0 + do i=1,n + X(i,i) = 1.d0 + enddo + call ezfio_set_mo_basis_mo_coef(X) + call save_mos + endif + endif call run end From 35708de94457a19ec8111522ac91884e29c9379b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 22 Jan 2018 01:19:03 +0100 Subject: [PATCH 3/5] Upgrade to OCaml 4.06 and Core 0.10 --- README.md | 6 +++-- configure | 28 +++++++++++++--------- install/scripts/install_ocaml.sh | 5 ++-- ocaml/TaskServer.ml | 11 +++++---- ocaml/qp_create_ezfio_from_xyz.ml | 2 +- ocaml/qp_create_guess.ml | 2 +- ocaml/qp_find_pi_space.ml | 2 +- ocaml/qp_print.ml | 2 +- ocaml/qp_run.ml | 2 +- ocaml/qp_set_mo_class.ml | 2 +- scripts/ezfio_interface/upgrade_1.0_2.0.sh | 27 --------------------- scripts/qp_upgrade_ocaml.sh | 19 +++++++++++++++ 12 files changed, 55 insertions(+), 53 deletions(-) delete mode 100755 scripts/ezfio_interface/upgrade_1.0_2.0.sh create mode 100755 scripts/qp_upgrade_ocaml.sh diff --git a/README.md b/README.md index a11c5713..52f949c3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ ## IMPORTANT -If you have problems upgrading to the current version, consider re-installing everything from scratch including the OCaml compiler. -To do this, you will have to remove the `quantum_package` directory **and** the `$HOME/.opam` directory as well. +If you have problems upgrading to the current version, first try +`qp_upgrade_ocaml.sh`. If it fails, then consider re-installing everything from +scratch including the OCaml compiler. To do this, you will have to remove the +`quantum_package` directory **and** the `$HOME/.opam` directory as well. diff --git a/configure b/configure index 9b59b209..9f677e92 100755 --- a/configure +++ b/configure @@ -49,7 +49,7 @@ QP_ROOT_INSTALL = join(QP_ROOT, "install") os.environ["PATH"] = os.environ["PATH"] + ":" + QP_ROOT_BIN d_dependency = { - "ocaml": ["m4", "curl", "zlib", "patch", "gcc", "zeromq"], + "ocaml": ["m4", "curl", "zlib", "patch", "gcc", "zeromq", "gmp"], "m4": ["make"], "curl": ["make"], "zlib": ["gcc", "make"], @@ -67,7 +67,8 @@ d_dependency = { "ninja": ["g++", "python"], "make": [], "p_graphviz": ["python"], - "bats": [] + "bats": [], + "gmp" : ["make", "g++"] } from collections import namedtuple @@ -136,6 +137,11 @@ zeromq = Info( description=' ZeroMQ', default_path=join(QP_ROOT_LIB, "libzmq.a")) +gmp= Info( + url='https://gmplib.org/download/gmp/gmp-6.1.2.tar.bz2', + description=' The GNU Multiple Precision Arithmetic Library', + default_path=join(QP_ROOT_LIB, "libgmp.a")) + f77zmq = Info( url='{head}/zeromq/f77_zmq/{tail}'.format(**path_github), description=' F77-ZeroMQ', @@ -155,7 +161,7 @@ d_info = dict() for m in ["ocaml", "m4", "curl", "zlib", "patch", "irpf90", "docopt", "resultsFile", "ninja", "emsl", "ezfio", "p_graphviz", - "zeromq", "f77zmq", "bats"]: + "zeromq", "f77zmq", "bats", "gmp"]: exec ("d_info['{0}']={0}".format(m)) @@ -480,16 +486,16 @@ def create_ninja_and_rc(l_installed): 'export QP_PYTHON={0}'.format(":".join(l_python)), "", 'export IRPF90={0}'.format(path_irpf90.replace(QP_ROOT,"${QP_ROOT}")), 'export NINJA={0}'.format(path_ninja.replace(QP_ROOT,"${QP_ROOT}")), - 'function qp_append_export () {', - ' #Append path $2:${!1}. Add the semicolon only if ${!1} is defined', + 'function qp_prepend_export () {', + ' #Prepend path $2:${!1}. Add the semicolon only if ${!1} is defined', ' eval "value_1=\"\${$1}\""', - ' echo ${2}${value_1:+:${value_1}}', + ' echo ${value_1:+${value_1}:}${2}', '}', - 'export PYTHONPATH=$(qp_append_export "PYTHONPATH" "${QP_EZFIO}/Python":"${QP_PYTHON}")', - 'export PATH=$(qp_append_export "PATH" "${QP_PYTHON}":"${QP_ROOT}"/bin:"${QP_ROOT}"/ocaml)', - 'export LD_LIBRARY_PATH=$(qp_append_export "LD_LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64)', - 'export LIBRARY_PATH=$(qp_append_export "LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64)', - 'export C_INCLUDE_PATH=$(qp_append_export "C_INCLUDE_PATH" "${QP_ROOT}"/include)', + 'export PYTHONPATH=$(qp_prepend_export "PYTHONPATH" "${QP_EZFIO}/Python":"${QP_PYTHON}")', + 'export PATH=$(qp_prepend_export "PATH" "${QP_PYTHON}":"${QP_ROOT}"/bin:"${QP_ROOT}"/ocaml)', + 'export LD_LIBRARY_PATH=$(qp_prepend_export "LD_LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64)', + 'export LIBRARY_PATH=$(qp_prepend_export "LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64)', + 'export C_INCLUDE_PATH=$(qp_prepend_export "C_INCLUDE_PATH" "${QP_ROOT}"/include)', '', 'if [[ $SHELL == "bash" ]] ; then', ' source ${QP_ROOT}/install/EZFIO/Bash/ezfio.sh', diff --git a/install/scripts/install_ocaml.sh b/install/scripts/install_ocaml.sh index f322bd0b..9e8a2b25 100755 --- a/install/scripts/install_ocaml.sh +++ b/install/scripts/install_ocaml.sh @@ -5,11 +5,12 @@ QP_ROOT=$PWD cd - # Normal installation -PACKAGES="core.v0.9.1 cryptokit.1.10 ocamlfind sexplib.v0.9.1 ZMQ ppx_sexp_conv ppx_deriving" +PACKAGES="core.v0.10.0 cryptokit ocamlfind sexplib.v0.10.0 ZMQ ppx_sexp_conv ppx_deriving" # Needed for ZeroMQ export C_INCLUDE_PATH="${QP_ROOT}"/include:"${C_INCLUDE_PATH}" export LIBRARY_PATH="${QP_ROOT}"/lib:"${LIBRARY_PATH}" +export LDFLAGS="-L$QP_ROOT/lib" export LD_LIBRARY_PATH="${QP_ROOT}"/lib:"${LD_LIBRARY_PATH}" # return 0 if program version is equal or greater than check version @@ -64,7 +65,7 @@ fi cd Downloads || exit 1 chmod +x ocaml.sh || exit 1 -echo N | ./ocaml.sh ${QP_ROOT}/bin/ 4.04.2 || exit 1 +echo N | ./ocaml.sh ${QP_ROOT}/bin/ 4.06.0 || exit 1 ${QP_ROOT}/bin/opam config setup -a -q || exit 1 diff --git a/ocaml/TaskServer.ml b/ocaml/TaskServer.ml index 31d6ab3b..170e011a 100644 --- a/ocaml/TaskServer.ml +++ b/ocaml/TaskServer.ml @@ -1,6 +1,7 @@ open Core open Qptypes +module StringHashtbl = Hashtbl.Make(String) type pub_state = | Waiting @@ -28,7 +29,7 @@ type t = progress_bar : Progress_bar.t option ; running : bool; accepting_clients : bool; - data : (string, string) Hashtbl.t; + data : string StringHashtbl.t; } @@ -208,7 +209,7 @@ let end_job msg program_state rep_socket pair_socket = address_inproc = None; running = true; accepting_clients = false; - data = Hashtbl.create ~hashable:String.hashable (); + data = StringHashtbl.create (); } and wait n = @@ -592,7 +593,7 @@ let put_data msg rest_of_msg program_state rep_socket = in let success () = - Hashtbl.set program_state.data ~key ~data:value ; + StringHashtbl.set program_state.data ~key ~data:value ; Message.PutDataReply (Message.PutDataReply_msg.create ()) |> Message.to_string |> ZMQ.Socket.send rep_socket; @@ -622,7 +623,7 @@ let get_data msg program_state rep_socket = let success () = let value = - match Hashtbl.find program_state.data key with + match StringHashtbl.find program_state.data key with | Some value -> value | None -> "" in @@ -776,7 +777,7 @@ let run ~port = address_inproc = None; progress_bar = None ; accepting_clients = false; - data = Hashtbl.create ~hashable:String.hashable (); + data = StringHashtbl.create (); } in diff --git a/ocaml/qp_create_ezfio_from_xyz.ml b/ocaml/qp_create_ezfio_from_xyz.ml index 93c8c8ff..737052ee 100644 --- a/ocaml/qp_create_ezfio_from_xyz.ml +++ b/ocaml/qp_create_ezfio_from_xyz.ml @@ -665,7 +665,7 @@ let run ?o b au c d m p cart xyz_file = let command = - Command.basic + Command.basic_spec ~summary: "Quantum Package command" ~readme:(fun () -> " diff --git a/ocaml/qp_create_guess.ml b/ocaml/qp_create_guess.ml index b841c350..71a5b296 100644 --- a/ocaml/qp_create_guess.ml +++ b/ocaml/qp_create_guess.ml @@ -128,7 +128,7 @@ let spec = +> anon ("ezfio_file" %: string) let () = - Command.basic + Command.basic_spec ~summary: "Quantum Package command" ~readme:( fun () -> " Creates an open-shell multiplet initial guess\n\n" ) diff --git a/ocaml/qp_find_pi_space.ml b/ocaml/qp_find_pi_space.ml index 0f5f7365..dcd671ce 100644 --- a/ocaml/qp_find_pi_space.ml +++ b/ocaml/qp_find_pi_space.ml @@ -95,7 +95,7 @@ let spec = let command = - Command.basic + Command.basic_spec ~summary: "Quantum Package command" ~readme:(fun () -> "Find all the pi molecular orbitals to create a pi space. diff --git a/ocaml/qp_print.ml b/ocaml/qp_print.ml index ea52bd7f..efbdc01e 100644 --- a/ocaml/qp_print.ml +++ b/ocaml/qp_print.ml @@ -141,7 +141,7 @@ let run_o ~action ezfio_filename = ;; let command = - Command.basic + Command.basic_spec ~summary: "Quantum Package command" ~readme:(fun () -> " diff --git a/ocaml/qp_run.ml b/ocaml/qp_run.ml index f426932b..f3f0b14e 100644 --- a/ocaml/qp_run.ml +++ b/ocaml/qp_run.ml @@ -150,7 +150,7 @@ let spec = let () = - Command.basic + Command.basic_spec ~summary: "Quantum Package command" ~readme:( fun () -> " Executes a Quantum Package binary file among these:\n\n" diff --git a/ocaml/qp_set_mo_class.ml b/ocaml/qp_set_mo_class.ml index ef2cc977..e12a2d75 100644 --- a/ocaml/qp_set_mo_class.ml +++ b/ocaml/qp_set_mo_class.ml @@ -323,7 +323,7 @@ let spec = let command = - Command.basic + Command.basic_spec ~summary: "Quantum Package command" ~readme:(fun () -> "Set the orbital classes in an EZFIO directory diff --git a/scripts/ezfio_interface/upgrade_1.0_2.0.sh b/scripts/ezfio_interface/upgrade_1.0_2.0.sh deleted file mode 100755 index ec0ab770..00000000 --- a/scripts/ezfio_interface/upgrade_1.0_2.0.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# Convert a old ezfio file (with option.irp.f ezfio_default) -# into a new EZFIO.cfg type - -# Hartree Fock -# Changin the case, don't know if is needed or not -mv $1/Hartree_Fock $1/hartree_fock 2> /dev/null - -mv $1/hartree_Fock/thresh_SCF $1/hartree_fock/thresh_scf 2> /dev/null - -# BiInts -mv $1/bi_integrals $1/bielect_integrals 2> /dev/null - -if [ -f $1/bielect_integrals/read_ao_integrals ]; then - if [ `cat $1/bielect_integrals/read_ao_integrals` -eq "True" ] - then - echo "Read" > $1/bielect_integrals/disk_access_ao_integrals - - elif [ `cat bielect_integrals/write_ao_integrals` -eq "True" ] - then - echo "Write" > $1/bielect_integrals/disk_access_ao_integrals - - else - echo "None" > $1/bielect_integrals/disk_access_ao_integrals - - fi -fi \ No newline at end of file diff --git a/scripts/qp_upgrade_ocaml.sh b/scripts/qp_upgrade_ocaml.sh new file mode 100755 index 00000000..ad2156e9 --- /dev/null +++ b/scripts/qp_upgrade_ocaml.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +OCAML_VERSION="4.06.0" +PACKAGES="core.v0.10.0 cryptokit ocamlfind sexplib.v0.10.0 ZMQ ppx_sexp_conv ppx_deriving" + +if [[ -z ${QP_ROOT} ]] +then + print "The QP_ROOT environment variable is not set." + print "Please reload the quantum_package.rc file." + exit -1 +fi + +cd $QP_ROOT/ocaml +opam update +opam switch ${OCAML_VERSION} +eval `opam config env` +opam install -y ${PACKAGES} || echo "Upgrade failed. You can try running +configure ; $0" + From cee0b40463849c06aec515014407d3155ced6c9b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 22 Jan 2018 01:46:46 +0100 Subject: [PATCH 5/5] Fixed qp_edit --- scripts/ezfio_interface/qp_edit_template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ezfio_interface/qp_edit_template b/scripts/ezfio_interface/qp_edit_template index 55a35f83..2e2c26c6 100644 --- a/scripts/ezfio_interface/qp_edit_template +++ b/scripts/ezfio_interface/qp_edit_template @@ -256,7 +256,7 @@ let spec = let command = - Command.basic + Command.basic_spec ~summary: "Quantum Package command" ~readme:(fun () -> "