mirror of
https://github.com/LCPQ/quantum_package
synced 2024-06-02 11:25:26 +02:00
commit
1e2ad83cee
125
configure
vendored
125
configure
vendored
|
@ -3,59 +3,76 @@
|
|||
# Quantum Package configuration script
|
||||
#
|
||||
|
||||
TEMP=`getopt -o c:i:h -l config:,install:,help -n $0 -- "$@"` || exit 1
|
||||
eval set -- "$TEMP"
|
||||
|
||||
export QP_ROOT="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
echo "QP_ROOT="$QP_ROOT
|
||||
|
||||
|
||||
help()
|
||||
function help()
|
||||
{
|
||||
cat <<EOF
|
||||
Quantum Package configuration script.
|
||||
|
||||
Usage:
|
||||
configure -c <file> | --config <file>
|
||||
configure -h | --help
|
||||
configure -i <package> | --install <package>
|
||||
$(basename $0) -c <file> | --config=<file>
|
||||
$(basename $0) -h | --help
|
||||
$(basename $0) -i <package> | --install=<package>
|
||||
|
||||
Options:
|
||||
-c <file>, --config <file> define a configuration file, in
|
||||
"${QP_ROOT}/config/".
|
||||
-h, --help print the help message
|
||||
-i <package>, --install <package> install <package>. Use at your own
|
||||
risk: no support will be provided
|
||||
for the installation of dependencies.
|
||||
-c, --config=<file> Define a configuration file, in "${QP_ROOT}/config/".
|
||||
-h, --help Print the help message
|
||||
-i, --install=<package> Install <package>. Use at your own risk:
|
||||
no support will be provided for the installation of dependencies.
|
||||
|
||||
Example:
|
||||
./configure -c config/gfortran.cfg
|
||||
./$(basename $0) -c config/gfortran.cfg
|
||||
|
||||
Note:
|
||||
- Users are encouraged to create their own configuration files instead of
|
||||
modifying the existing ones.
|
||||
Users are encouraged to create their own configuration files instead of
|
||||
modifying the existing ones.
|
||||
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
|
||||
function error() {
|
||||
>&2 echo "$(basename $0): $@"
|
||||
exit 2
|
||||
}
|
||||
|
||||
|
||||
PACKAGES=""
|
||||
OCAML_PACKAGES="ocamlbuild cryptokit zmq core sexplib ppx_sexp_conv ppx_deriving getopt"
|
||||
|
||||
while : ; do
|
||||
while true : ; do
|
||||
case "$1" in
|
||||
"")
|
||||
break;;
|
||||
-c|--config)
|
||||
CONFIG="$2"
|
||||
shift;;
|
||||
case "$2" in
|
||||
"") help ; break;;
|
||||
*) if [[ -f $2 ]] ; then
|
||||
CONFIG="$2"
|
||||
else
|
||||
error "error: configuration file not accessible"
|
||||
exit 1
|
||||
fi
|
||||
esac
|
||||
shift 2;;
|
||||
-i|--install)
|
||||
PACKAGES="${PACKAGE} $2"
|
||||
shift;;
|
||||
case "$2" in
|
||||
"") help ; break;;
|
||||
*) PACKAGES="${PACKAGE} $2"
|
||||
esac
|
||||
shift 2;;
|
||||
-h|-help|--help)
|
||||
help;;
|
||||
help
|
||||
exit 0;;
|
||||
--) shift ; break ;;
|
||||
*)
|
||||
echo "unknown option $1, try --help"
|
||||
error $(basename $0)": unknown option $1, try --help"
|
||||
exit 2;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Trim leading and trailing spaces
|
||||
|
@ -78,21 +95,20 @@ function success() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
function error() {
|
||||
echo "Error : $1"
|
||||
exit 2
|
||||
}
|
||||
|
||||
function download() {
|
||||
wget --no-check-certificate $1 --output-document=$2 || error "Unable to download $1"
|
||||
}
|
||||
|
||||
function not_found() {
|
||||
echo 'not_found'
|
||||
}
|
||||
|
||||
function find_exe() {
|
||||
which $1 2> /dev/null || echo 'not_found'
|
||||
which $1 2> /dev/null || not_found
|
||||
}
|
||||
|
||||
function find_python_lib() {
|
||||
python2 -c "import $1" &> /dev/null && echo "$1" || echo 'not_found'
|
||||
python2 -c "import $1" &> /dev/null && echo "$1" || not_found
|
||||
}
|
||||
|
||||
function find_lib() {
|
||||
|
@ -103,7 +119,7 @@ function find_lib() {
|
|||
echo "$lib"
|
||||
else
|
||||
rm "${QP_ROOT}"/external/tmp.c
|
||||
echo "not_found"
|
||||
not_found
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -111,7 +127,7 @@ function find_dir() {
|
|||
if [[ -d $1 ]] ; then
|
||||
echo "$1"
|
||||
else
|
||||
echo "not_found"
|
||||
not_found
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -216,7 +232,10 @@ EOF
|
|||
else
|
||||
# Conventional commands
|
||||
export OPAMROOT=${OPAMROOT:-${QP_ROOT}/external/opam}
|
||||
echo "QP>> Please install it here: " ${QP_ROOT}/bin
|
||||
echo "======================================================== "
|
||||
echo ""
|
||||
echo "|QP> Please install it here: " ${QP_ROOT}/bin
|
||||
echo ""
|
||||
sh ${QP_ROOT}/external/opam_installer.sh
|
||||
fi
|
||||
source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true
|
||||
|
@ -301,62 +320,62 @@ done
|
|||
|
||||
|
||||
NINJA=$(find_exe ninja)
|
||||
if [[ ${NINJA} = not_found ]] ; then
|
||||
echo "ninja is not installed."
|
||||
if [[ ${NINJA} = $(not_found) ]] ; then
|
||||
error "Ninja is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
IRPF90=$(find_exe irpf90)
|
||||
if [[ ${IRPF90} = not_found ]] ; then
|
||||
echo "irpf90 is not installed."
|
||||
if [[ ${IRPF90} = $(not_found) ]] ; then
|
||||
error "IRPf90 is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
ZEROMQ=$(find_lib -lzmq)
|
||||
if [[ ${ZEROMQ} = not_found ]] ; then
|
||||
echo "zeromq is not installed."
|
||||
if [[ ${ZEROMQ} = $(not_found) ]] ; then
|
||||
error "ZeroMQ is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
F77ZMQ=$(find_lib -lzmq -lf77zmq)
|
||||
if [[ ${F77ZMQ} = not_found ]] ; then
|
||||
echo "Fortran binding of ZeroMQ (f77zmq) is not installed."
|
||||
if [[ ${F77ZMQ} = $(not_found) ]] ; then
|
||||
error "Fortran binding of ZeroMQ (f77zmq) is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
OPAM=$(find_exe opam)
|
||||
if [[ ${OPAM} = not_found ]] ; then
|
||||
echo "OPAM (ocaml) package manager is not installed."
|
||||
if [[ ${OPAM} = $(not_found) ]] ; then
|
||||
error "OPAM (ocaml) package manager is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
OCAML=$(find_exe ocaml)
|
||||
if [[ ${OCAML} = not_found ]] ; then
|
||||
echo "OCaml compiler is not installed."
|
||||
if [[ ${OCAML} = $(not_found) ]] ; then
|
||||
error "OCaml compiler is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
EZFIO=$(find_dir "${QP_ROOT}"/external/ezfio)
|
||||
if [[ ${EZFIO} = not_found ]] ; then
|
||||
echo "ezfio is not installed."
|
||||
if [[ ${EZFIO} = $(not_found) ]] ; then
|
||||
error "EZFIO is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
EMSL=$(find_dir "${QP_ROOT}"/external/emsl)
|
||||
if [[ ${EMSL} = not_found ]] ; then
|
||||
echo "emsl is not installed."
|
||||
if [[ ${EMSL} = $(not_found) ]] ; then
|
||||
error "EMSL is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
DOCOPT=$(find_python_lib docopt)
|
||||
if [[ ${DOCOPT} = not_found ]] ; then
|
||||
echo "docopt is not installed."
|
||||
if [[ ${DOCOPT} = $(not_found) ]] ; then
|
||||
error "docopt is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
RESULTSFILE=$(find_python_lib resultsFile)
|
||||
if [[ ${RESULTSFILE} = not_found ]] ; then
|
||||
echo "resultsFile is not installed."
|
||||
if [[ ${RESULTSFILE} = $(not_found) ]] ; then
|
||||
error "resultsFile is not installed."
|
||||
fail
|
||||
fi
|
||||
|
||||
|
|
98
docs/source/programmers_guide/conventions.rst
Normal file
98
docs/source/programmers_guide/conventions.rst
Normal file
|
@ -0,0 +1,98 @@
|
|||
==================
|
||||
Coding conventions
|
||||
==================
|
||||
|
||||
|
||||
General conventions
|
||||
===================
|
||||
|
||||
All executable files should have a name with lowercase.
|
||||
|
||||
Tabs are forbidden everywhere.
|
||||
|
||||
Try to set the maximum line length to 80 characters. Long lines can be
|
||||
automatically reformatted in vim by pressing :kbd:`gqj`.
|
||||
|
||||
Use blank lines between blocks to improve readability.
|
||||
|
||||
For existing files, stay faithful to the existing indentation.
|
||||
|
||||
|
||||
|
||||
Shell scripts
|
||||
=============
|
||||
|
||||
Executables should have no extension. To know if the file is binary, or in
|
||||
what shell scripting language it was written, the :command:`file` command can
|
||||
be used. In addition, all the shell scripts should be under
|
||||
:file:`${QP_ROOT}/scripts/`.
|
||||
|
||||
The exit code of the script should be 0 upon success only.
|
||||
|
||||
Bash and Python2 are the only shell scripting language permitted for
|
||||
executables.
|
||||
|
||||
|
||||
Bash
|
||||
----
|
||||
|
||||
* Bash scripts should start with ``#!/bin/bash``
|
||||
|
||||
* All error messages should go to standard error, and should be prefixed with
|
||||
the name of the command. For example, in Bash use
|
||||
|
||||
.. code:: bash
|
||||
|
||||
function echo_err() {
|
||||
2>& echo $(basename $0)": error"
|
||||
}
|
||||
|
||||
* The command-line options should be handled with ``getopt``.
|
||||
|
||||
* The script should check that the command-line arguments are consistent.
|
||||
|
||||
* Long options should be preferred to short options.
|
||||
|
||||
* Always quote strings containing variables, command substitutions, spaces or
|
||||
shell meta characters, unless careful unquoted expansion is required.
|
||||
|
||||
* Use ``"$@"`` unless you have a specific reason to use ``$*``.
|
||||
|
||||
* Use ``$(command)`` instead of backticks, because they can be easily nested.
|
||||
|
||||
* ``[[ ... ]]`` is preferred over ``[``, ``test`` and ``/usr/bin/[``.
|
||||
|
||||
* Declare function-specific variables with local. Declaration and assignment
|
||||
should be on different lines.
|
||||
|
||||
* Pipelines should be split one per line if they don't all fit on one line.
|
||||
|
||||
* Put ``; do`` and ``; then`` on the same line as the ``while``, ``for`` or ``if``.
|
||||
|
||||
|
||||
Python
|
||||
------
|
||||
|
||||
Only Python2 is supported. The reason is that some dependencies use Python2,
|
||||
and we do not want yet to add an extra dependency to Python3.
|
||||
|
||||
Python scripts should start with ``#!/usr/bin/env python2`` to mention
|
||||
explicitly that Python2 has to be used.
|
||||
|
||||
:command:`pylint` should be used to increase the quality of the source code.
|
||||
|
||||
|
||||
|
||||
IRPF90
|
||||
======
|
||||
|
||||
The code can be automatically indented with :command:`irp_indent`.
|
||||
|
||||
Mathematical formulas in the `BEGIN_DOC...END_DOC` sections sould be written
|
||||
in LaTeX format, between `$` symbols.
|
||||
|
||||
Providers should never be present in the same file as a main program.
|
||||
|
||||
|
||||
|
||||
|
|
@ -6,27 +6,32 @@ qp_convert_output_to_ezfio
|
|||
.. program:: qp_convert_output_to_ezfio
|
||||
|
||||
This Python script uses the `resultsFile`_ Python library to gather the
|
||||
geometry, |AOs| and |MOs| from output files of |GAMESS| or Gaussian, and
|
||||
puts this data in an |EZFIO| database. Some constraints are necessary in the
|
||||
output file : the run needs to be a single point |HF|, |DFT| or |CAS| |SCF|.
|
||||
geometry, |AOs| and |MOs| from output files of |GAMESS| or Gaussian, and puts
|
||||
this data in an |EZFIO| database. Some constraints are necessary in the output
|
||||
file : the run needs to be a single point |HF|, |DFT| or |CAS| |SCF|.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
.. code:: bash
|
||||
|
||||
qp_convert_output_to_ezfio <FILE.out> [-o <EZFIO_DIRECTORY>]
|
||||
qp_convert_output_to_ezfio [-o EZFIO_DIR] FILE
|
||||
|
||||
.. option:: -o <EZFIO_DIRECTORY>
|
||||
.. option:: -o, --output=EZFIO_DIR
|
||||
|
||||
Renames the |EZFIO| directory. If this option is not present, the default
|
||||
name fill be :file:`<FILE.out>.ezfio`
|
||||
Renames the |EZFIO| directory. If this option is not present, the default
|
||||
name fill be :file:`FILE.ezfio`
|
||||
|
||||
.. note::
|
||||
The following keywords are necessary for Gaussian ::
|
||||
All the parameters of the wave functgion need to be presente in the output
|
||||
file : complete description of the |AO| basis set, full set of molecular
|
||||
orbitals, etc.
|
||||
|
||||
The following keywords are necessary for GAU$$IAN ::
|
||||
|
||||
GFPRINT pop=Full
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
|
|
@ -13,12 +13,16 @@ Usage
|
|||
|
||||
.. code:: bash
|
||||
|
||||
qp_create_ezfio_from_xyz [FLAGS] (<xyz_file> | <zmt_file>)
|
||||
Flags :
|
||||
-b [-au] [-c int] [-cart] [-d float]
|
||||
[-m int] [-o file] [-p string] [-help]
|
||||
qp_create_ezfio_from_xyz [-a] -b <string> [-c <int>] [-d <float>]
|
||||
[-h] [-m <int>] [-o EZFIO_DIR] [-p <string>] [-x] [--] FILE
|
||||
|
||||
.. option:: -b <basis_name>
|
||||
|
||||
.. option:: -a, --au
|
||||
|
||||
If present, input geometry is in atomic units.
|
||||
|
||||
|
||||
.. option:: -b, --basis=<string>
|
||||
|
||||
Name of basis set. The basis set is defined as a single string if all the
|
||||
atoms are taken from the same basis set, otherwise specific elements can be
|
||||
|
@ -28,39 +32,45 @@ Usage
|
|||
-b "cc-pvtz | 1,H:sto-3g | 3,H:6-31g"
|
||||
|
||||
By default, the basis set is obtained from the local database of the |qp|.
|
||||
This option is mandatory.
|
||||
|
||||
If ``<string>`` is set to ``show``, the list of all available basis sets is
|
||||
displayed.
|
||||
|
||||
|
||||
.. option:: -au
|
||||
|
||||
If present, input geometry is in atomic units.
|
||||
|
||||
.. option:: -c <float>
|
||||
.. option:: -c, --charge=<int>
|
||||
|
||||
Total charge of the molecule. Default is 0.
|
||||
|
||||
.. option:: -cart
|
||||
|
||||
Compute |AOs| in the Cartesian basis set (6d, 10f, ...)
|
||||
.. option:: -d, --dummy=<float>
|
||||
|
||||
.. option:: -d <float>
|
||||
Add dummy atoms (X) between atoms when the distance between two atoms
|
||||
is less than :math:`x \times \sum R_\mathrm{cov}`, the covalent radii
|
||||
of the atoms. The default is x=0, so no dummy atom is added.
|
||||
|
||||
Add dummy atoms. x * (covalent radii of the atoms)
|
||||
|
||||
.. option:: -m <int>
|
||||
.. option:: -h, --help
|
||||
|
||||
Spin multiplicity (2S+1) of the molecule. Default is 1.
|
||||
Print the help text and exit
|
||||
|
||||
.. option:: -o <EZFIO_DIRECTORY>
|
||||
|
||||
.. option:: -m, --multiplicity=<int>
|
||||
|
||||
Spin multiplicity :math:`2S+1` of the molecule. Default is 1.
|
||||
|
||||
|
||||
.. option:: -o, --output=EZFIO_DIR
|
||||
|
||||
Name of the created |EZFIO| directory.
|
||||
|
||||
.. option:: -p <string>
|
||||
.. option:: -p <string>, --pseudo=<string>
|
||||
|
||||
Name of the pseudo-potential
|
||||
Name of the pseudo-potential. Follows the same conventions as the basis set.
|
||||
|
||||
.. option:: -help, -?
|
||||
.. option:: -x, --cart
|
||||
|
||||
Print the help text and exit
|
||||
Compute |AOs| in the Cartesian basis set (6d, 10f, ...)
|
||||
|
||||
|
||||
Using custom atomic basis sets
|
||||
|
@ -73,8 +83,8 @@ and the *xyz* geometry is in ``molecule.xyz``, the following should be used::
|
|||
qp_create_ezfio_from_xyz -b custom.basis molecule.xyz
|
||||
|
||||
Basis set files should be given in |GAMESS| format, where the full names of the
|
||||
atoms are given, and the basis sets for each element are separated by a blank line.
|
||||
Here is an example ::
|
||||
atoms are given, and the basis sets for each element are separated by a blank
|
||||
line. Here is an example ::
|
||||
|
||||
HYDROGEN
|
||||
S 3
|
||||
|
@ -121,22 +131,21 @@ Using custom pseudo-potentials
|
|||
------------------------------
|
||||
|
||||
As for the basis set, if a file with the same name as the pseudo-potential
|
||||
exists, this file will be read.
|
||||
For example, if the file containing the custom pseudo-potential is named
|
||||
``custom.pseudo``, the basis set is named ``custom.basis``, and the *xyz*
|
||||
geometry is in ``molecule.xyz``, the following command should be used
|
||||
exists, this file will be read. For example, if the file containing the custom
|
||||
pseudo-potential is named ``custom.pseudo``, the basis set is named
|
||||
``custom.basis``, and the *xyz* geometry is in ``molecule.xyz``, the following
|
||||
command should be used
|
||||
|
||||
.. code:: bash
|
||||
|
||||
qp_create_ezfio_from_xyz -b custom.basis -p custom.pseudo molecule.xyz
|
||||
|
||||
Pseudo-potential files should be given in a format very close to |GAMESS|
|
||||
format. The first line should be formatted as ``%s GEN %d %d`` where the
|
||||
first string is the chemical symbol, the first integer is the number of
|
||||
core electrons to be removed and the second integer is LMAX+1 as in |GAMESS|
|
||||
format.
|
||||
The pseudo-potential for each element are separated by a blank line.
|
||||
Here is an example ::
|
||||
format. The first line should be formatted as ``%s GEN %d %d`` where the first
|
||||
string is the chemical symbol, the first integer is the number of core
|
||||
electrons to be removed and the second integer is LMAX+1 as in |GAMESS| format.
|
||||
The pseudo-potential for each element are separated by a blank line. Here is
|
||||
an example ::
|
||||
|
||||
Ne GEN 2 1
|
||||
3
|
||||
|
|
|
@ -8,14 +8,15 @@ qp_edit
|
|||
|
||||
|
||||
This command reads the content of the |EZFIO| directory and creates a temporary
|
||||
file containing the data. The data is presented as a *ReStructured Text* (rst)
|
||||
document, where each section corresponds to the corresponding |qp| module.
|
||||
The content of the file can be modified to change the input parameters. When
|
||||
the text editor is closed, the updated data is saved into the |EZFIO| directory.
|
||||
file containing the data. The data is presented as a *ReStructured Text* (rst)
|
||||
document, where each section corresponds to the corresponding |qp| module. The
|
||||
content of the file can be modified to change the input parameters. When the
|
||||
text editor is closed, the updated data is saved into the |EZFIO| directory.
|
||||
|
||||
.. note::
|
||||
The text editor which will be opened is defined by the :envvar:`EDITOR`
|
||||
environment variable.
|
||||
environment variable. If this variable is not set, the :command:`vi`
|
||||
text editor will be used by default.
|
||||
|
||||
.. warning::
|
||||
When the wave function is too large (more than 10 000 determinants), the
|
||||
|
@ -26,36 +27,33 @@ Usage
|
|||
|
||||
.. code:: bash
|
||||
|
||||
qp_edit [FLAGS] <EZFIO_DIRECTORY>
|
||||
Flags :
|
||||
[-c] [-ndet int]
|
||||
[-state int] [-help]
|
||||
qp_edit [-c] [-h] [-n <int>] [-s <range>] [--] EZFIO_DIR
|
||||
|
||||
|
||||
.. option:: -c
|
||||
.. option:: -c, --check
|
||||
|
||||
Checks the input data
|
||||
|
||||
.. option:: -ndet <int>
|
||||
|
||||
Truncates the wavefunction to the target number of determinants
|
||||
|
||||
.. option:: -state <int>
|
||||
|
||||
Pick the target state as a new wavefunction.
|
||||
|
||||
.. option:: -help
|
||||
.. option:: -h, --help
|
||||
|
||||
Print the help text and exits
|
||||
|
||||
.. option:: -n, --ndet=<int>
|
||||
|
||||
Here is a short list of important control parameters :
|
||||
Truncates the wavefunction to the target number of determinants
|
||||
|
||||
.. option:: read_wf
|
||||
.. option:: -s, --state=<range>
|
||||
|
||||
If ``false``, initialize the calculation with a single-determinant wave
|
||||
function. If ``true``, initialize the calculation with the wave function stored
|
||||
in the |EZFIO| directory.
|
||||
Select the states to extract from the |EZFIO| directory, using the same conventions
|
||||
as :ref:`qp_set_mo_class`. See example below.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code:: bash
|
||||
|
||||
qp_edit --state="[1,3-5]" test.ezfio
|
||||
|
||||
Removes all states except states 1,3,4 and 5 from :file:`test.ezfio`. The
|
||||
resulting |EZFIO| directory has 4 states.
|
||||
|
||||
|
|
|
@ -4,22 +4,27 @@ qp_export_as_tgz
|
|||
|
||||
.. program:: qp_export_as_tgz
|
||||
|
||||
In some HPC facilities, the access to the internet is limited for security reasons.
|
||||
In such an environment, the installation of |QP| is sometimes very painful because
|
||||
the OCaml compiler and the libraries can't be installed by a non-root user.
|
||||
In some HPC facilities, the access to the internet is limited for security
|
||||
reasons. In such an environment, the installation of |QP| is sometimes very
|
||||
painful because the OCaml compiler and the libraries can't be installed by a
|
||||
non-root user.
|
||||
|
||||
This command creates a self-contained binary distribution in the form of a `tar.gz` file
|
||||
that can be copied on another machine.
|
||||
This command creates a self-contained binary distribution in the form of a
|
||||
`tar.gz` file that can be copied on another machine.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
.. code:: bash
|
||||
|
||||
qp_export_as_tgz
|
||||
qp_export_as_tgz [-h|--help]
|
||||
|
||||
.. option:: -h, --help
|
||||
|
||||
Prints the help message
|
||||
|
||||
.. note::
|
||||
There can be conflicts due to the version of Glibc. The machine on which |QP| is
|
||||
There can be conflicts due to the version of glibc. The machine on which |QP| is
|
||||
compiled should be the oldest one.
|
||||
|
||||
|
||||
|
|
|
@ -6,34 +6,34 @@ qp_plugins
|
|||
|
||||
.. program:: qp_plugins
|
||||
|
||||
This command deals with all external plugins of |qp|. Plugin repositories can
|
||||
This command deals with all external plugins of |qp|. Plugin repositories can
|
||||
be downloaded, and the plugins in these repositories can be
|
||||
installed/uninstalled of created.
|
||||
installed/uninstalled or created.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
.. code:: bash
|
||||
|
||||
qp_plugins list [ -i | -u | -q ]
|
||||
qp_plugins list [-i] [-u] [-q]
|
||||
qp_plugins download <url>
|
||||
qp_plugins install <name>...
|
||||
qp_plugins uninstall <name>
|
||||
qp_plugins create -n <name> [-r <repository>] [<needed_modules>...]
|
||||
qp_plugins create -n <name> [-r <repo>] [<needed_modules>...]
|
||||
|
||||
.. option:: list
|
||||
|
||||
List all the available plugins.
|
||||
|
||||
.. option:: -i
|
||||
.. option:: -i, --installed
|
||||
|
||||
List all the *installed* plugins.
|
||||
|
||||
.. option:: -u
|
||||
.. option:: -u, --uninstalled
|
||||
|
||||
List all the *uninstalled* plugins.
|
||||
|
||||
.. option:: -q
|
||||
.. option:: -q, --repositories
|
||||
|
||||
List all the downloaded repositories.
|
||||
|
||||
|
@ -53,11 +53,11 @@ Usage
|
|||
|
||||
Uninstall the plugin ``plugin_name``.
|
||||
|
||||
.. option:: -n <plugin_name>
|
||||
.. option:: -n, --name=<plugin_name>
|
||||
|
||||
Create a new plugin named ``plugin_name`` (in local repository by default).
|
||||
|
||||
.. option:: -r <repository>
|
||||
.. option:: -r, --repository=<repo>
|
||||
|
||||
Specify in which repository the new plugin will be created.
|
||||
|
||||
|
@ -66,45 +66,49 @@ Usage
|
|||
Example
|
||||
-------
|
||||
|
||||
Let us download, install and compile some specific external plugins from `<https://gitlab.com/eginer/qp_plugins_eginer>`_ .
|
||||
Let us download, install and compile some specific external plugins from
|
||||
`<https://gitlab.com/eginer/qp_plugins_eginer>`_ .
|
||||
|
||||
|
||||
First, download the git repo associated to these plugins. To do so, first go to the `plugins` directory in the |QP| and execute:
|
||||
First, download the git repo associated to these plugins. To do so, first go
|
||||
to the `plugins` directory in the |QP| and execute:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
qp_plugins download https://gitlab.com/eginer/qp_plugins_eginer
|
||||
|
||||
|
||||
This will create in the directory `plugins` a local copy of the git repo located at the URL you indicated.
|
||||
Then, go in `qp_plugins_eginer/stable/`
|
||||
This will create in the directory `plugins` a local copy of the git repo
|
||||
located at the URL you indicated. Then, go in `qp_plugins_eginer/stable/`
|
||||
|
||||
.. code:: bash
|
||||
|
||||
cd qp_plugins_eginer/stable/
|
||||
|
||||
|
||||
In the directory `stable`, there are many directories which all correspond to a specific plugin that have been developed
|
||||
by the person in charge of the git repo. All these plugins might use some global variables and routines contained
|
||||
In the directory `stable`, there are many directories which all correspond to a
|
||||
specific plugin that have been developed by the person in charge of the git
|
||||
repo. All these plugins might use some global variables and routines contained
|
||||
in the core modules of the |QP|.
|
||||
|
||||
|
||||
Now let us install the plugin `rsdft_cipsi`:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
qp_plugins install rsdft_cipsi
|
||||
|
||||
This will link this directory to the |QP| which means that when the code will be compiled, this plugin will be compiled to and therefore
|
||||
all the executables/scripts/input keywords contained in this module will be available as if there were part of the core of the |QP|.
|
||||
This will link this directory to the |QP| which means that when the code will
|
||||
be compiled, this plugin will be compiled to and therefore all the
|
||||
executables/scripts/input keywords contained in this module will be available
|
||||
as if there were part of the core of the |QP|.
|
||||
|
||||
|
||||
Then, to compile the new plugin, just recompile the |QP| as usual by going at the root of the |QP| directory:
|
||||
Then, to compile the new plugin, just recompile the |QP| as usual by going at
|
||||
the root of the |QP| directory:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
cd $QP_ROOT
|
||||
ninja
|
||||
|
||||
Then, if you go back to the plugin directory you just installed, you should see all the executables/scripts which have been created and
|
||||
which are now available with the `qp_run` command.
|
||||
Finally, if you go back to the plugin directory you just installed, you should see
|
||||
all the executables/scripts which have been created and which are now available
|
||||
with the `qp_run` command.
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
.. _qp_run:
|
||||
|
||||
======
|
||||
qp_run
|
||||
======
|
||||
|
||||
|
@ -14,8 +15,7 @@ Usage
|
|||
|
||||
.. code:: bash
|
||||
|
||||
qp_run [-h|--help] [-p <string>|--prefix=<string>] [-s|--slave] [--]
|
||||
PROGRAM EZFIO_DIR
|
||||
qp_run [-h] [-p <string>] [-s] [--] PROGRAM EZFIO_DIR
|
||||
|
||||
``PROGRAM`` is the name of the |QP| program to be run, and ``EZFIO_DIR`` is
|
||||
the name of the |EZFIO| directory containing the data.
|
||||
|
|
|
@ -21,7 +21,7 @@ Usage
|
|||
|
||||
.. code:: bash
|
||||
|
||||
qp_set_frozen_core [-q] <EZFIO_DIRECTORY>
|
||||
qp_set_frozen_core [-q] EZFIO_DIR
|
||||
|
||||
|
||||
.. option:: -q
|
||||
|
|
|
@ -38,38 +38,32 @@ Usage
|
|||
|
||||
.. code:: bash
|
||||
|
||||
qp_set_mo_class [FLAGS] <EZFIO_DIRECTORY>
|
||||
Flags:
|
||||
[-act range] [-core range] [-del range]
|
||||
[-inact range] [-q] [-virt range]
|
||||
[-help]
|
||||
qp_set_mo_class [-a <range>] [-c <range>] [-d <range>] [-h] [-i <range>]
|
||||
[-q] [-v <range>] [--] EZFIO_DIR
|
||||
|
||||
|
||||
.. option:: -act <range>
|
||||
.. option:: -a, --act=<range>
|
||||
|
||||
Range of active orbitals
|
||||
|
||||
.. option:: -core <range>
|
||||
.. option:: -c, --core=<range>
|
||||
|
||||
Range of core orbitals
|
||||
|
||||
.. option:: -del <range>
|
||||
.. option:: -d, --del=<range>
|
||||
|
||||
Range of deleted orbitals
|
||||
|
||||
.. option:: -inact <range>
|
||||
.. option:: -i, --inact=<range>
|
||||
|
||||
Range of inactive orbitals
|
||||
|
||||
.. option:: -q
|
||||
.. option:: -q, --query
|
||||
|
||||
Query: print the current masks
|
||||
Print the |MO| classes
|
||||
|
||||
.. option:: -virt <range>
|
||||
.. option:: -v, --virt=<range>
|
||||
|
||||
Range of virtual orbitals
|
||||
|
||||
.. option:: -help, -?
|
||||
|
||||
|
||||
|
||||
|
|
8
etc/autocomplete.rc
Normal file
8
etc/autocomplete.rc
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Required for completion with zsh
|
||||
|
||||
if [[ "$(ps -p $$ -ocomm=)" == "zsh" ]] ; then
|
||||
autoload bashcompinit
|
||||
bashcompinit
|
||||
fi
|
||||
|
||||
|
35
etc/configure.rc
Normal file
35
etc/configure.rc
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Completion for the configrue command with possible configurations
|
||||
|
||||
source ${QP_ROOT}/etc/autocomplete.rc
|
||||
|
||||
_Complete()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
case "${prev}" in
|
||||
-h|--help)
|
||||
COMPREPLY=( $(compgen -W "" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
-i)
|
||||
COMPREPLY=( $(compgen -W "bats docopt emsl ezfio f77zmq irpf90 ninja\
|
||||
ocaml resultsFile zeromq" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
-c)
|
||||
COMPREPLY=( $(compgen -W "$(echo config/*.cfg ./*.cfg)" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "-h --help -c -i" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _Complete configure
|
||||
|
10
etc/ezfio.rc
10
etc/ezfio.rc
|
@ -2,15 +2,13 @@
|
|||
|
||||
export QP_EZFIO=${QP_ROOT}/external/ezfio
|
||||
|
||||
|
||||
function source_if_exists() {
|
||||
if [[ -f $1 ]]; then
|
||||
if [[ "$(ps -p $$ -ocomm=)" == "zsh" ]] ; then
|
||||
autoload bashcompinit
|
||||
bashcompinit
|
||||
fi
|
||||
source $1
|
||||
fi
|
||||
cd $(dirname $1) ; source $(basename $1) ; cd -
|
||||
fi &> /dev/null
|
||||
}
|
||||
|
||||
source ${QP_ROOT}/etc/autocomplete.rc
|
||||
source_if_exists "${QP_EZFIO}/Bash/ezfio.sh"
|
||||
|
||||
|
|
|
@ -8,14 +8,12 @@ export IRPF90=${IRPF90_PATH}/bin/irpf90
|
|||
|
||||
function source_if_exists() {
|
||||
if [[ -f $1 ]]; then
|
||||
if [[ "$(ps -p $$ -ocomm=)" == "zsh" ]] ; then
|
||||
autoload bashcompinit
|
||||
bashcompinit
|
||||
fi
|
||||
source $1
|
||||
fi
|
||||
cd $(dirname $1) ; source $(basename $1) ; cd -
|
||||
fi &> /dev/null
|
||||
}
|
||||
|
||||
|
||||
source ${QP_ROOT}/etc/autocomplete.rc
|
||||
source_if_exists "${IRPF90_PATH}/irpman-completions.bash"
|
||||
|
||||
|
||||
|
|
169
etc/qp.rc
169
etc/qp.rc
|
@ -20,23 +20,20 @@ Usage:
|
|||
qp set DIRECTORY ITEM : Array values read from stdin
|
||||
|
||||
qp run PROGRAM
|
||||
qp man PROGRAM
|
||||
qp srun PROGRAM
|
||||
qp mpirun PROGRAM
|
||||
|
||||
qp set_frozen_core
|
||||
qp create_ezfio_from_xyz --help
|
||||
qp convert_output_to_ezfio --help
|
||||
qp set_mo_class --help
|
||||
|
||||
qp create_ezfio_from_xyz
|
||||
qp convert_output_to_ezfio
|
||||
qp update
|
||||
qp set_mo_class
|
||||
qp plugins
|
||||
"
|
||||
}
|
||||
|
||||
#function test_ezfio()
|
||||
#{
|
||||
# if [[ ! -d ${EZFIO_FILE} ]] ; then
|
||||
# echo "qp: cannot access ${EZFIO_FILE}: No such file or directory"
|
||||
# return 1
|
||||
# fi
|
||||
#}
|
||||
|
||||
function qp()
|
||||
{
|
||||
|
@ -52,13 +49,22 @@ function qp()
|
|||
|
||||
"create_ezfio_from_xyz")
|
||||
shift
|
||||
NAME=$(qp_create_ezfio_from_xyz "$@")
|
||||
# Replace ':' by spaces
|
||||
for arg in $@ ; do
|
||||
if [[ $arg =~ -* ]] ; then
|
||||
_ARGS+=("\"${arg//:/ }\"")
|
||||
else
|
||||
_ARGS+=("${arg}")
|
||||
fi
|
||||
done
|
||||
NAME=$(eval "qp_create_ezfio_from_xyz ${_ARGS}")
|
||||
if [[ -d $NAME ]] ; then
|
||||
[[ -d $EZFIO_FILE ]] && ezfio unset_file
|
||||
ezfio set_file $NAME
|
||||
else
|
||||
echo $NAME | more
|
||||
fi
|
||||
unset _ARGS
|
||||
;;
|
||||
|
||||
"convert_output_to_ezfio")
|
||||
|
@ -105,10 +111,19 @@ function qp()
|
|||
printf "\e[0;31m|${EZFIO_FILE}>\e[m"
|
||||
fi
|
||||
}
|
||||
# PS1="${PS1%\\\$ } \$(_check_ezfio) $ "
|
||||
PS1="\$(_check_ezfio)\n$PS1"
|
||||
;;
|
||||
|
||||
"plugins")
|
||||
shift
|
||||
qp_plugins $@
|
||||
;;
|
||||
|
||||
"update")
|
||||
shift
|
||||
qp_update $@
|
||||
;;
|
||||
|
||||
*)
|
||||
_qp_usage
|
||||
;;
|
||||
|
@ -117,60 +132,144 @@ function qp()
|
|||
}
|
||||
|
||||
|
||||
function _get_basis_sets () {
|
||||
( qp_create_ezfio_from_xyz -b show \
|
||||
| tr ' ' ':' \
|
||||
| while IFS= read -r LINE ; do
|
||||
printf '%s\n' ${LINE}
|
||||
done
|
||||
(cd ~/quantum_package/data/basis/ ; \ls)
|
||||
) | sort | uniq
|
||||
}
|
||||
|
||||
|
||||
|
||||
_Complete()
|
||||
{
|
||||
local cur
|
||||
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
first="${COMP_WORDS[1]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
prev2="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
|
||||
case "${first}" in
|
||||
update)
|
||||
COMPREPLY=( $(compgen -W "-h" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
man)
|
||||
COMPREPLY=( $(compgen -W "$(cd ${QP_ROOT}/man ; \ls | sed 's/\.1//')" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
convert_output_to_ezfio)
|
||||
COMPREPLY=( $(compgen -W "-o $(\ls)" -- ${cur} ) )
|
||||
return 0
|
||||
;;
|
||||
create_ezfio_from_xyz)
|
||||
case "${prev}" in
|
||||
create_ezfio_from_xyz)
|
||||
COMPREPLY=( $(compgen -W "-b -a -c -d -h -m -o -p -x" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
-m|-d|-c)
|
||||
COMPREPLY=( $(compgen -W "" -- $cur ) )
|
||||
return 0;;
|
||||
-b)
|
||||
for iter in $(_get_basis_sets); do
|
||||
if [[ $iter =~ ^$cur ]]; then
|
||||
COMPREPLY+=( "${iter}" )
|
||||
fi
|
||||
done;
|
||||
return 0
|
||||
;;
|
||||
-p)
|
||||
COMPREPLY=( $(compgen -W "$(cd ~/quantum_package/data/pseudo ; \ls)" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "-b -a -c -d -h -m -o -p -x $(\ls)" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
esac;;
|
||||
plugins)
|
||||
case "${prev}" in
|
||||
plugins)
|
||||
COMPREPLY=( $(compgen -W "list download install uninstall create" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
list)
|
||||
COMPREPLY=( $(compgen -W "-i -u -q" -- $cur ) )
|
||||
return 0;;
|
||||
download)
|
||||
COMPREPLY=( $(compgen -W "http:// git@github.com: git@gitlab.com: " -- $cur ) )
|
||||
return 0;;
|
||||
install)
|
||||
COMPREPLY=( $(compgen -W "$(qp_plugins list -u)" -- $cur ) )
|
||||
return 0;;
|
||||
uninstall)
|
||||
COMPREPLY=( $(compgen -W "$(qp_plugins list -i)" -- $cur ) )
|
||||
return 0;;
|
||||
create)
|
||||
COMPREPLY=( $(compgen -W "-n " -- $cur ) )
|
||||
return 0;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "$( \ls ; cd ~/quantum_package/src ; \ls )" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
esac;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W 'plugins \
|
||||
man \
|
||||
create_ezfio_from_xyz \
|
||||
convert_output_to_ezfio \
|
||||
-h update' -- $cur ) )
|
||||
|
||||
esac
|
||||
|
||||
if [[ -n ${EZFIO_FILE} && -d ${EZFIO_FILE} ]]
|
||||
then
|
||||
|
||||
case "${prev2}" in
|
||||
"set"|has|get)
|
||||
if [[ ${prev} == "qp" ]] ; then
|
||||
COMPREPLY=( $(compgen -W "set set_frozen_core set_mo_class" -- $cur ) )
|
||||
COMPREPLY=( $(compgen -W "plugins set set_frozen_core set_mo_class" -- $cur ) )
|
||||
elif [[ ! -d ${EZFIO_FILE}/${prev} ]] ; then
|
||||
COMPREPLY=( $(compgen -W "" -- $cur ) )
|
||||
else
|
||||
COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE}/${prev} ; ls | sed 's/\.gz//' )" -- $cur ) )
|
||||
COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE}/${prev} ; \ls | sed 's/\.gz//' )" -- $cur ) )
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "$(\ls)" -- $cur ) )
|
||||
esac
|
||||
|
||||
case "${prev}" in
|
||||
case "${first}" in
|
||||
run|srun|mpirun)
|
||||
COMPREPLY=( $(compgen -W "$(cat ${QP_ROOT}/data/executables | cut -d ' ' -f 1)" -- $cur ) )
|
||||
COMPREPLY=( $(compgen -W "-h $(cat ${QP_ROOT}/data/executables | cut -d ' ' -f 1)" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
unset_file|edit|set_frozen_core)
|
||||
unset_file|set_frozen_core)
|
||||
COMPREPLY=()
|
||||
return 0
|
||||
;;
|
||||
set_mo_class)
|
||||
COMPREPLY=( $(compgen -W "-h -core -inact -act -virt -del" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
man)
|
||||
COMPREPLY=( $(compgen -W "$(cd ${QP_ROOT}/man ; \ls | sed '/\.[1-9] / /')" -- $cur ) )
|
||||
COMPREPLY=( $(compgen -W "-h -c -i -a -v -d -q" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
set|has|get)
|
||||
COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE} ; \ls -d */ | sed 's|/||g')" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
edit)
|
||||
COMPREPLY=( $(compgen -W "-h -c -n -s" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W 'has get set unset_file edit \
|
||||
COMPREPLY+=( $(compgen -W 'has get set unset_file edit \
|
||||
run srun mpirun set_frozen_core \
|
||||
set_mo_class create_ezfio_from_xyz \
|
||||
convert_output_to_ezfio \
|
||||
-h' -- $cur ) )
|
||||
set_mo_class ' \
|
||||
-- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
@ -178,24 +277,12 @@ _Complete()
|
|||
else
|
||||
|
||||
case "${prev}" in
|
||||
man)
|
||||
COMPREPLY=( $(compgen -W "$(cd ${QP_ROOT}/man ; echo * | sed 's|\.[1-9] | |g')" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
set_file)
|
||||
COMPREPLY=( $(compgen -W "$(\ls -d */ | sed 's|/||g')" -- ${cur} ) )
|
||||
return 0
|
||||
;;
|
||||
convert_output_to_ezfio|create_ezfio_from_xyz)
|
||||
COMPREPLY=( $(compgen -W "$(\ls)" -- ${cur} ) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W 'set_file \
|
||||
man \
|
||||
create_ezfio_from_xyz \
|
||||
convert_output_to_ezfio \
|
||||
-h' -- $cur ) )
|
||||
COMPREPLY+=( $(compgen -W "set_file" -- $cur ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,161 +1,199 @@
|
|||
type argument = With_arg | Without_arg | With_opt_arg
|
||||
type short_opt = char
|
||||
type long_opt = string
|
||||
type optional = Mandatory | Optional
|
||||
type documentation = string
|
||||
type argument = With_arg of string | Without_arg | With_opt_arg of string
|
||||
|
||||
let anon_args = ref []
|
||||
type description = {
|
||||
short: short_opt ;
|
||||
long : long_opt ;
|
||||
opt : optional ;
|
||||
doc : documentation ;
|
||||
arg : argument ;
|
||||
}
|
||||
|
||||
let anon_args = ref []
|
||||
and header_doc = ref ""
|
||||
and description_doc = ref ""
|
||||
and footer_doc = ref ""
|
||||
and specs = ref []
|
||||
and specs = ref []
|
||||
|
||||
let set_header_doc s = header_doc := s
|
||||
let set_description_doc s = description_doc := s
|
||||
let set_footer_doc s = footer_doc := s
|
||||
|
||||
let dict =
|
||||
let d = Hashtbl.create 67 in
|
||||
d
|
||||
(* Hash table containing all the options *)
|
||||
let dict = Hashtbl.create 67
|
||||
|
||||
let get_bool x = Hashtbl.mem dict x
|
||||
|
||||
let show_help () = get_bool "help"
|
||||
|
||||
let get x =
|
||||
try Some (Hashtbl.find dict x)
|
||||
with Not_found -> None
|
||||
try Some (Hashtbl.find dict x)
|
||||
with Not_found -> None
|
||||
|
||||
let get_bool x =
|
||||
Hashtbl.mem dict x
|
||||
let anonymous name opt doc =
|
||||
{ short=' ' ; long=name; opt; doc; arg=Without_arg; }
|
||||
|
||||
let show_help () =
|
||||
get_bool "help"
|
||||
let output_text t =
|
||||
Format.printf "@[<v 0>";
|
||||
begin
|
||||
match Str.split (Str.regexp "\n") t with
|
||||
| x :: [] -> Format.printf "@[<hov 0>";
|
||||
Str.split (Str.regexp " ") x
|
||||
|> List.iter (fun y -> Format.printf "@[%s@]@ " y) ;
|
||||
Format.printf "@]"
|
||||
| t -> List.iter (fun x ->
|
||||
Format.printf "@[<hov 0>";
|
||||
Str.split (Str.regexp " ") x
|
||||
|> List.iter (fun y -> Format.printf "@[%s@]@ " y) ;
|
||||
Format.printf "@]@;") t
|
||||
end;
|
||||
Format.printf "@]"
|
||||
;;
|
||||
|
||||
|
||||
let output_short x =
|
||||
match x.short, x.opt, x.arg with
|
||||
| ' ', Mandatory, _ -> Format.printf "@[%s@]" x.long
|
||||
| ' ', Optional , _ -> Format.printf "@[[%s]@]" x.long
|
||||
| _ , Mandatory, Without_arg -> Format.printf "@[-%c@]" x.short
|
||||
| _ , Optional , Without_arg -> Format.printf "@[[-%c]@]" x.short
|
||||
| _ , Mandatory, With_arg arg -> Format.printf "@[-%c %s@]" x.short arg
|
||||
| _ , Optional , With_arg arg -> Format.printf "@[[-%c %s]@]" x.short arg
|
||||
| _ , Mandatory, With_opt_arg arg -> Format.printf "@[-%c [%s]@]" x.short arg
|
||||
| _ , Optional , With_opt_arg arg -> Format.printf "@[[-%c [%s]]@]" x.short arg
|
||||
|
||||
|
||||
let output_long max_width x =
|
||||
let arg =
|
||||
match x.short, x.arg with
|
||||
| ' ' , _ -> x.long
|
||||
| _ , Without_arg -> x.long
|
||||
| _ , With_arg arg -> Printf.sprintf "%s=%s" x.long arg
|
||||
| _ , With_opt_arg arg -> Printf.sprintf "%s[=%s]" x.long arg
|
||||
in
|
||||
let long =
|
||||
let l = String.length arg in
|
||||
arg^(String.make (max_width-l) ' ')
|
||||
in
|
||||
Format.printf "@[<v 0>";
|
||||
begin
|
||||
match x.short with
|
||||
| ' ' -> Format.printf "@[%s @]" long
|
||||
| short -> Format.printf "@[-%c --%s @]" short long
|
||||
end;
|
||||
Format.printf "@]";
|
||||
output_text x.doc
|
||||
|
||||
let anonymous ?(optional=false) name doc =
|
||||
( ' ', name, doc,
|
||||
if optional then With_opt_arg else Without_arg
|
||||
)
|
||||
|
||||
let help () =
|
||||
|
||||
Format.printf "@[%s@]@.@." !header_doc;
|
||||
let get_param_from_doc doc =
|
||||
match Str.split (Str.regexp "[ \n\r\x0c\t]+") doc with
|
||||
| param :: doc -> param, (String.concat " " doc)
|
||||
| _ -> failwith "Bad format for documentation"
|
||||
in
|
||||
(* Print the header *)
|
||||
output_text !header_doc;
|
||||
Format.printf "@.@.";
|
||||
|
||||
let anon =
|
||||
List.filter (fun (x,_,_,_) -> x = ' ') !specs
|
||||
|> List.map (fun x ->
|
||||
match x with
|
||||
| (_,name,doc,Without_arg) -> (name,doc,false)
|
||||
| (_,name,doc,_) -> (name,doc,true)
|
||||
)
|
||||
in
|
||||
(* Find the anonymous arguments *)
|
||||
let anon =
|
||||
List.filter (fun x -> x.short = ' ') !specs
|
||||
in
|
||||
|
||||
let options =
|
||||
List.filter (fun (x,_,_,_) -> x <> ' ') !specs
|
||||
|> List.sort (fun (x,_,_,_) (y,_,_,_) -> Char.compare x y)
|
||||
|> List.map (fun x ->
|
||||
match x with
|
||||
| (short,long,doc,With_arg) -> (* with arg *)
|
||||
let param, doc = get_param_from_doc doc in
|
||||
(Printf.sprintf "-%c %s" short param,
|
||||
Printf.sprintf "--%s=%s" long param,
|
||||
doc)
|
||||
| (short,long,doc,Without_arg) -> (* without arg *)
|
||||
(Printf.sprintf "-%c" short,
|
||||
Printf.sprintf "--%s" long,
|
||||
doc)
|
||||
| (short,long,doc,With_opt_arg) -> (* with or without arg *)
|
||||
let param, doc = get_param_from_doc doc in
|
||||
(Printf.sprintf "-%c [%s]" short param,
|
||||
Printf.sprintf "--%s[=%s]" long param,
|
||||
doc)
|
||||
)
|
||||
in
|
||||
(* Find the options *)
|
||||
let options =
|
||||
List.filter (fun x -> x.short <> ' ') !specs
|
||||
|> List.sort (fun x y -> Char.compare x.short y.short)
|
||||
in
|
||||
|
||||
let max_short =
|
||||
List.map (fun (x,_,_) -> String.length x) options
|
||||
|> List.fold_left max 0
|
||||
in
|
||||
|
||||
let max_long =
|
||||
List.map (fun (_,x,_) -> String.length x) options
|
||||
|> List.fold_left max 0
|
||||
in
|
||||
|
||||
let fmt_opt max_w o =
|
||||
let l = String.length o in
|
||||
o^(String.make (max_w-l) ' ')
|
||||
in
|
||||
(* Find column lengths *)
|
||||
let max_width =
|
||||
List.map (fun x ->
|
||||
( match x.arg with
|
||||
| Without_arg -> String.length x.long
|
||||
| With_arg arg -> String.length x.long + String.length arg
|
||||
| With_opt_arg arg -> String.length x.long + String.length arg + 2
|
||||
)
|
||||
+ ( if x.opt = Optional then 2 else 0)
|
||||
) !specs
|
||||
|> List.fold_left max 0
|
||||
in
|
||||
|
||||
|
||||
let output_option ?(fixed_width=false) (short, long, doc) =
|
||||
if fixed_width then
|
||||
Format.printf "@[%s %s@]"
|
||||
(fmt_opt max_short short) (fmt_opt max_long long)
|
||||
else
|
||||
Format.printf "@[%s|%s@]" short long
|
||||
in
|
||||
(* Print usage *)
|
||||
Format.printf "@[<v>@[<v 2>Usage:@,@,@[<hov 4>@[%s@]" Sys.argv.(0);
|
||||
List.iter (fun x -> Format.printf "@ "; output_short x) options;
|
||||
Format.printf "@ @[[--]@]";
|
||||
List.iter (fun x -> Format.printf "@ "; output_short x;) anon;
|
||||
Format.printf "@]@,@]@,";
|
||||
|
||||
let output_anon ?(fixed_width=false) (name, doc, optional) =
|
||||
if optional then
|
||||
Format.printf "@[[%s]@]" name
|
||||
else
|
||||
Format.printf "@[%s@]" name
|
||||
in
|
||||
|
||||
Format.printf "@[<v>@[<v 2>Usage:@,@,@[<hov 4>@[%s@]" Sys.argv.(0);
|
||||
List.iter (fun x ->
|
||||
Format.printf "@ @[[";
|
||||
output_option ~fixed_width:false x;
|
||||
Format.printf "]@]"
|
||||
) options;
|
||||
Format.printf "@ @[[--]@]";
|
||||
List.iter (fun x ->
|
||||
Format.printf "@ @[";
|
||||
output_anon ~fixed_width:false x;
|
||||
Format.printf "@]"
|
||||
) anon;
|
||||
Format.printf "@]@]@,@,";
|
||||
(* Print arguments and doc *)
|
||||
Format.printf "@[<v 2>Arguments:@,";
|
||||
Format.printf "@[<v 0>" ;
|
||||
List.iter (fun x -> Format.printf "@ "; output_long max_width x) anon;
|
||||
Format.printf "@]@,@]@,";
|
||||
|
||||
Format.printf "@[<v>Arguments:@,";
|
||||
|
||||
Format.printf "@[<v 2>@," ;
|
||||
List.iter (fun (name,doc,optional) ->
|
||||
Format.printf "@[<h>";
|
||||
output_anon ~fixed_width:true (name,doc,optional);
|
||||
Format.printf "@ @[<v 0>%s@]@]@," doc
|
||||
) anon;
|
||||
Format.printf "@]@;";
|
||||
(* Print options and doc *)
|
||||
Format.printf "@[<v 2>Options:@,";
|
||||
|
||||
Format.printf "@[<v>Options:@,";
|
||||
Format.printf "@[<v 0>" ;
|
||||
List.iter (fun x -> Format.printf "@ "; output_long max_width x) options;
|
||||
Format.printf "@]@,@]@,";
|
||||
|
||||
|
||||
(* Print footer *)
|
||||
if !description_doc <> "" then
|
||||
begin
|
||||
Format.printf "@[<v 2>Description:@,@,";
|
||||
output_text !description_doc;
|
||||
Format.printf "@,"
|
||||
end;
|
||||
|
||||
(* Print footer *)
|
||||
output_text !footer_doc;
|
||||
Format.printf "@."
|
||||
|
||||
Format.printf "@[<v 2>@," ;
|
||||
List.iter (fun (short,long,doc) ->
|
||||
Format.printf "@[<h>";
|
||||
output_option ~fixed_width:true (short,long,doc);
|
||||
Format.printf "@ @[<v 0>%s@]@]@," doc
|
||||
) options;
|
||||
Format.printf "@]@;";
|
||||
|
||||
Format.printf "@[%s@]@." !footer_doc
|
||||
|
||||
let set_specs specs_in =
|
||||
specs := ( 'h', "help", "Prints the help message", Without_arg) :: specs_in;
|
||||
specs := { short='h' ;
|
||||
long ="help" ;
|
||||
doc ="Prints the help message." ;
|
||||
arg =Without_arg ;
|
||||
opt =Optional ;
|
||||
} :: specs_in;
|
||||
|
||||
let specs =
|
||||
List.filter (fun (x,_,_,_) -> x != ' ') !specs
|
||||
|> List.map (fun x ->
|
||||
match x with
|
||||
| (short, long, doc, With_arg) ->
|
||||
(short, long, None, Some (fun x -> Hashtbl.replace dict long x) )
|
||||
| (short, long, doc, Without_arg) ->
|
||||
(short, long, Some (fun () -> Hashtbl.replace dict long ""), None)
|
||||
| (short, long, doc, With_opt_arg) ->
|
||||
(short, long, Some (fun () -> Hashtbl.replace dict long ""),
|
||||
Some (fun x -> Hashtbl.replace dict long x) )
|
||||
)
|
||||
in
|
||||
let cmd_specs =
|
||||
List.filter (fun x -> x.short != ' ') !specs
|
||||
|> List.map (fun { short ; long ; opt ; doc ; arg } ->
|
||||
match arg with
|
||||
| With_arg _ ->
|
||||
(short, long, None, Some (fun x -> Hashtbl.replace dict long x) )
|
||||
| Without_arg ->
|
||||
(short, long, Some (fun () -> Hashtbl.replace dict long ""), None)
|
||||
| With_opt_arg _ ->
|
||||
(short, long, Some (fun () -> Hashtbl.replace dict long ""),
|
||||
Some (fun x -> Hashtbl.replace dict long x) )
|
||||
)
|
||||
in
|
||||
|
||||
Getopt.parse_cmdline specs (fun x -> anon_args := !anon_args @ [x]);
|
||||
Getopt.parse_cmdline cmd_specs (fun x -> anon_args := !anon_args @ [x]);
|
||||
|
||||
if show_help () then
|
||||
(help () ; exit 0);
|
||||
|
||||
(* Check that all mandatory arguments are set *)
|
||||
List.filter (fun x -> x.short <> ' ' && x.opt = Mandatory) !specs
|
||||
|> List.iter (fun x ->
|
||||
match get x.long with
|
||||
| Some _ -> ()
|
||||
| None -> failwith ("Error: --"^x.long^" option is missing.")
|
||||
)
|
||||
;;
|
||||
|
||||
if show_help () then
|
||||
(help () ; exit 0)
|
||||
|
||||
let anon_args () = !anon_args
|
||||
|
||||
|
||||
|
||||
|
|
126
ocaml/Command_line.mli
Normal file
126
ocaml/Command_line.mli
Normal file
|
@ -0,0 +1,126 @@
|
|||
(** Handles command-line arguments, using getopt.
|
||||
|
||||
Example:
|
||||
|
||||
let () =
|
||||
|
||||
(* Command-line specs *)
|
||||
let open Command_line in
|
||||
begin
|
||||
set_header_doc (Sys.argv.(0) ^ " - quantum_package command");
|
||||
set_description_doc
|
||||
"Opens a text editor to edit the parameters of an EZFIO directory.";
|
||||
|
||||
[ { short='c'; long="check"; opt=Optional;
|
||||
doc="Checks the input data";
|
||||
arg=Without_arg; };
|
||||
|
||||
{ short='n'; long="ndet"; opt=Optional;
|
||||
doc="Truncate the wavefunction to the target number of determinants";
|
||||
arg=With_arg "<int>"; };
|
||||
|
||||
{ short='s'; long="state"; opt=Optional;
|
||||
doc="Extract selected states, for example \"[1,3-5]\"";
|
||||
arg=With_arg "<range>"; };
|
||||
|
||||
anonymous "EZFIO_DIR" Mandatory "EZFIO directory";
|
||||
]
|
||||
|> set_specs ;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
(* Handle options *)
|
||||
let ndet =
|
||||
match Command_line.get "ndet" with
|
||||
| None -> None
|
||||
| Some s -> (try Some (int_of_string s)
|
||||
with _ -> failwith "[-n|--ndet] expects an integer")
|
||||
in
|
||||
let state =
|
||||
match Command_line.get "state" with
|
||||
| None -> None
|
||||
| Some s -> (try Some (Range.of_string s)
|
||||
with _ -> failwith "[-s|--state] expects a range")
|
||||
in
|
||||
|
||||
let c = Command_line.get_bool "check" in
|
||||
|
||||
let filename =
|
||||
match Command_line.anon_args () with
|
||||
| [x] -> x
|
||||
| _ -> (Command_line.help () ; failwith "EZFIO_DIR is missing")
|
||||
in
|
||||
|
||||
(* Run the program *)
|
||||
run c ?ndet ?state filename
|
||||
|
||||
|
||||
*)
|
||||
|
||||
|
||||
type short_opt = char
|
||||
|
||||
type long_opt = string
|
||||
|
||||
type optional = Mandatory
|
||||
| Optional
|
||||
|
||||
type documentation = string
|
||||
|
||||
type argument = With_arg of string
|
||||
| Without_arg
|
||||
| With_opt_arg of string
|
||||
|
||||
|
||||
type description =
|
||||
{
|
||||
short : short_opt;
|
||||
long : long_opt;
|
||||
opt : optional;
|
||||
doc : documentation;
|
||||
arg : argument;
|
||||
}
|
||||
|
||||
|
||||
(** Sets the header of the help message. *)
|
||||
val set_header_doc : string -> unit
|
||||
|
||||
|
||||
(** Sets the description of the help message. *)
|
||||
val set_description_doc : string -> unit
|
||||
|
||||
(** Sets the footer of the help message. *)
|
||||
val set_footer_doc : string -> unit
|
||||
|
||||
|
||||
(** Gets the value of an option. If the option is not set, returns [None]. If
|
||||
the option is set, returns Some <string>. *)
|
||||
val get : string -> string option
|
||||
|
||||
|
||||
(** Gets the value of an option with no argument. If the option is set, returns [true]. *)
|
||||
val get_bool : string -> bool
|
||||
|
||||
|
||||
(** True if the '-h' or "--help" option was found. *)
|
||||
val show_help : unit -> bool
|
||||
|
||||
|
||||
(** Creates a specification of an anonymous argument. *)
|
||||
val anonymous : long_opt -> optional -> documentation -> description
|
||||
|
||||
|
||||
(** Prints the help message *)
|
||||
val help : unit -> unit
|
||||
|
||||
|
||||
(** Sets the specification list as a list of tuples:
|
||||
( short option, long option, documentation, argument ) *)
|
||||
val set_specs : description list -> unit
|
||||
|
||||
|
||||
(** Returns the list of anonymous arguments *)
|
||||
val anon_args : unit -> string list
|
||||
|
||||
|
|
@ -82,6 +82,8 @@ git:
|
|||
${QP_EZFIO}/Ocaml/ezfio.ml:
|
||||
$(NINJA) -C ${QP_EZFIO}
|
||||
|
||||
qp_edit.ml: ../scripts/ezfio_interface/qp_edit_template
|
||||
|
||||
Input_auto_generated.ml qp_edit.ml: $(filter-out Input_auto_generated.ml, $(wildcard Input_*.ml))
|
||||
ei_handler.py ocaml_global
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ let list_basis () =
|
|||
)
|
||||
in
|
||||
List.sort basis_list ~compare:String.ascending
|
||||
|> String.concat ~sep:"\n"
|
||||
|
||||
|
||||
(** Run the program *)
|
||||
|
@ -122,7 +121,7 @@ let run ?o b au c d m p cart xyz_file =
|
|||
|
||||
let fetch_channel basis =
|
||||
let command =
|
||||
Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename
|
||||
Qpackage.root ^ "/scripts/get_basis \"" ^ temp_filename
|
||||
^ "." ^ basis ^ "\" \"" ^ basis ^"\""
|
||||
in
|
||||
let long_basis =
|
||||
|
@ -648,36 +647,54 @@ let run ?o b au c d m p cart xyz_file =
|
|||
|
||||
let () =
|
||||
|
||||
"=== Available basis sets ===
|
||||
|
||||
" ^ (list_basis ()) ^ "
|
||||
let open Command_line in
|
||||
begin
|
||||
"Creates an EZFIO directory from a standard xyz file or from a z-matrix file in Gaussian format. The basis set is defined as a single string if all the atoms are taken from the same basis set, otherwise specific elements can be defined as follows:
|
||||
|
||||
============================
|
||||
-b \"cc-pcvdz | H:cc-pvdz | C:6-31g\"
|
||||
-b \"cc-pvtz | 1,H:sto-3g | 3,H:6-31g\"
|
||||
|
||||
Creates an EZFIO directory from a standard xyz file or from a z-matrix file
|
||||
in Gaussian format. The basis set is defined as a single string if all the
|
||||
atoms are taken from the same basis set, otherwise specific elements can be
|
||||
defined as follows:
|
||||
If a file with the same name as the basis set exists, this file will be read. Otherwise, the basis set is obtained from the database.
|
||||
" |> set_description_doc ;
|
||||
set_header_doc (Sys.argv.(0) ^ " - Quantum Package command");
|
||||
|
||||
-b \"cc-pcvdz | H:cc-pvdz | C:6-31g\"
|
||||
-b \"cc-pvtz | 1,H:sto-3g | 3,H:6-31g\"
|
||||
[ { opt=Optional ; short='o'; long="output";
|
||||
arg=With_arg "EZFIO_DIR";
|
||||
doc="Name of the created EZFIO directory."} ;
|
||||
|
||||
If a file with the same name as the basis set exists, this file will be read.
|
||||
Otherwise, the basis set is obtained from the database.
|
||||
{ opt=Mandatory; short='b'; long="basis";
|
||||
arg=With_arg "<string>";
|
||||
doc="Name of basis set. If <string>=show, the list of all basis sets is displayed."} ;
|
||||
|
||||
" |> Command_line.set_header_doc ;
|
||||
{ opt=Optional ; short='a'; long="au";
|
||||
arg=Without_arg;
|
||||
doc="Input geometry is in atomic units."} ;
|
||||
|
||||
[ ( 'o', "output", "file Name of the created EZFIO file.", Command_line.With_arg) ;
|
||||
( 'b', "basis", "string Name of basis set.", Command_line.With_arg) ;
|
||||
( 'a', "au", "Input geometry is in atomic units.", Command_line.Without_arg) ;
|
||||
( 'c', "charge", "int Total charge of the molecule. Default is 0.", Command_line.With_arg) ;
|
||||
( 'd', "dummy", "float Add dummy atoms. x * (covalent radii of the atoms)", Command_line.With_arg);
|
||||
( 'm', "multiplicity", "int Spin multiplicity (2S+1) of the molecule. Default is 1.", Command_line.With_arg);
|
||||
( 'p', "pseudo", "string Name of the pseudopotential.", Command_line.With_arg);
|
||||
( 'x', "cartesian", "Compute AOs in the Cartesian basis set (6d, 10f, ...)", Command_line.Without_arg);
|
||||
Command_line.anonymous "(xyz_file|zmt_file)" "input file in xyz format or z-matrix."
|
||||
]
|
||||
|> Command_line.set_specs ;
|
||||
{ opt=Optional ; short='c'; long="charge";
|
||||
arg=With_arg "<int>";
|
||||
doc="Total charge of the molecule. Default is 0."} ;
|
||||
|
||||
{ opt=Optional ; short='d'; long="dummy";
|
||||
arg=With_arg "<float>";
|
||||
doc="Add dummy atoms. x * (covalent radii of the atoms)."} ;
|
||||
|
||||
{ opt=Optional ; short='m'; long="multiplicity";
|
||||
arg=With_arg "<int>";
|
||||
doc="Spin multiplicity (2S+1) of the molecule. Default is 1."} ;
|
||||
|
||||
{ opt=Optional ; short='p'; long="pseudo";
|
||||
arg=With_arg "<string>";
|
||||
doc="Name of the pseudopotential."} ;
|
||||
|
||||
{ opt=Optional ; short='x'; long="cartesian";
|
||||
arg=Without_arg;
|
||||
doc="Compute AOs in the Cartesian basis set (6d, 10f, ...)."} ;
|
||||
|
||||
anonymous "FILE" Mandatory "Input file in xyz format or z-matrix.";
|
||||
]
|
||||
|> set_specs
|
||||
end;
|
||||
|
||||
|
||||
(* Handle options *)
|
||||
|
@ -687,7 +704,7 @@ Otherwise, the basis set is obtained from the database.
|
|||
|
||||
let basis =
|
||||
match Command_line.get "basis" with
|
||||
| None -> (Command_line.help () ; failwith "Error: [-b|--basis] option is missing.")
|
||||
| None -> assert false
|
||||
| Some x -> x
|
||||
in
|
||||
|
||||
|
@ -721,6 +738,13 @@ Otherwise, the basis set is obtained from the database.
|
|||
Command_line.get_bool "cartesian"
|
||||
in
|
||||
|
||||
if basis = "show" then
|
||||
begin
|
||||
list_basis ()
|
||||
|> List.iter ~f:print_endline;
|
||||
exit 0
|
||||
end;
|
||||
|
||||
let xyz_filename =
|
||||
match Command_line.anon_args () with
|
||||
| [x] -> x
|
||||
|
|
|
@ -141,34 +141,32 @@ let run slave ?prefix exe ezfio_file =
|
|||
|
||||
let () =
|
||||
(* Command-line specs *)
|
||||
"Executes a Quantum Package binary file among these:\n\n"
|
||||
^ (Lazy.force Qpackage.executables
|
||||
|> List.map (fun (x,_) -> Printf.sprintf " * %s" x )
|
||||
|> String.concat "\n"
|
||||
) |> Command_line.set_header_doc;
|
||||
let open Command_line in
|
||||
begin
|
||||
set_header_doc (Sys.argv.(0) ^ " - Quantum Package command");
|
||||
"Executes a Quantum Package binary file among these:\n\n"
|
||||
^ (Lazy.force Qpackage.executables
|
||||
|> List.map (fun (x,_) -> Printf.sprintf " * %s" x )
|
||||
|> String.concat "\n")
|
||||
|> set_description_doc;
|
||||
|
||||
[ ( 's', "slave", "Required to run slave tasks in distributed environments",
|
||||
Command_line.Without_arg);
|
||||
( 'p', "prefix", "<string> Prefix before running the program, like gdb or valgrind",
|
||||
Command_line.With_arg );
|
||||
Command_line.anonymous "PROGRAM" "Name of the QP program to be run";
|
||||
Command_line.anonymous "EZFIO_DIR" "EZFIO directory";
|
||||
[ { short='s'; long="slave"; opt=Optional;
|
||||
doc="Required to run slave tasks in distributed environments.";
|
||||
arg=Without_arg; };
|
||||
|
||||
{ short='p'; long="prefix"; opt=Optional;
|
||||
doc="Prefix before running the program, like gdb or valgrind.";
|
||||
arg=With_arg "<string>"; };
|
||||
|
||||
anonymous "PROGRAM" Mandatory "Name of the QP program to be run";
|
||||
anonymous "EZFIO_DIR" Mandatory "EZFIO directory";
|
||||
]
|
||||
|> Command_line.set_specs ;
|
||||
|
||||
|> set_specs ;
|
||||
end;
|
||||
|
||||
(* Handle options *)
|
||||
if Command_line.show_help () then
|
||||
exit 0;
|
||||
|
||||
let slave =
|
||||
match Command_line.get "slave" with
|
||||
| None -> false
|
||||
| _ -> true
|
||||
in
|
||||
|
||||
let prefix =
|
||||
Command_line.get "prefix"
|
||||
let slave = Command_line.get_bool "slave"
|
||||
and prefix = Command_line.get "prefix"
|
||||
in
|
||||
|
||||
(* Run the program *)
|
||||
|
|
|
@ -314,30 +314,50 @@ let default range =
|
|||
|
||||
|
||||
let () =
|
||||
"Set the orbital classes in an EZFIO directory.
|
||||
The range of MOs has the form : \"[36-53,72-107,126-131]\"." |> Command_line.set_header_doc ;
|
||||
let open Command_line in
|
||||
begin
|
||||
"Set the orbital classes in an EZFIO directory. The range of MOs has the form : \"[36-53,72-107,126-131]\"."
|
||||
|> set_footer_doc ;
|
||||
|
||||
[ ( 'c', "core", "range Range of core MOs", Command_line.With_opt_arg);
|
||||
( 'i', "inact", "range Range of inactive MOs", Command_line.With_opt_arg);
|
||||
( 'a', "act", "range Range of active MOs", Command_line.With_opt_arg);
|
||||
( 'v', "virt", "range Range of virtual MOs", Command_line.With_opt_arg);
|
||||
( 'd', "del", "range Range of deleted MOs", Command_line.With_opt_arg);
|
||||
( 'q', "query", "Print the current MOs classes", Command_line.Without_arg);
|
||||
Command_line.anonymous "<EZFIO_FILE>" "EZFIO directory";
|
||||
] |> Command_line.set_specs ;
|
||||
[ { opt=Optional ; short='c'; long="core";
|
||||
arg=With_arg "<range>";
|
||||
doc="Range of core MOs." };
|
||||
|
||||
{ opt=Optional ; short='i'; long="inact";
|
||||
arg=With_arg "<range>";
|
||||
doc="Range of inactive MOs." };
|
||||
|
||||
{ opt=Optional ; short='a'; long="act";
|
||||
arg=With_arg "<range>";
|
||||
doc="Range of active MOs." };
|
||||
|
||||
{ opt=Optional ; short='v'; long="virt";
|
||||
arg=With_arg "<range>";
|
||||
doc="Range of virtual MOs." };
|
||||
|
||||
{ opt=Optional ; short='d'; long="del";
|
||||
arg=With_arg "<range>";
|
||||
doc="Range of deleted MOs." };
|
||||
|
||||
{ opt=Optional ; short='q'; long="query";
|
||||
arg=Without_arg;
|
||||
doc="Print the current MO classes." };
|
||||
|
||||
anonymous "EZFIO_DIR" Mandatory "EZFIO directory.";
|
||||
] |> set_specs
|
||||
end;
|
||||
|
||||
(* Handle options *)
|
||||
if Command_line.show_help () then
|
||||
exit 0;
|
||||
|
||||
let core = Command_line.get "core"
|
||||
and inact = Command_line.get "inact"
|
||||
and act = Command_line.get "act"
|
||||
and virt = Command_line.get "virt"
|
||||
and del = Command_line.get "del"
|
||||
and q = Command_line.get_bool "q"
|
||||
and q = Command_line.get_bool "query"
|
||||
in
|
||||
|
||||
|
||||
let ezfio_filename =
|
||||
match Command_line.anon_args () with
|
||||
| [x] -> x
|
||||
|
|
|
@ -9,7 +9,7 @@ open Core
|
|||
(** Interactive editing of the input.
|
||||
|
||||
WARNING
|
||||
This file is autogenerad by
|
||||
This file is automatically generated by
|
||||
`${{QP_ROOT}}/scripts/ezfio_interface/ei_handler.py`
|
||||
*)
|
||||
|
||||
|
@ -265,24 +265,33 @@ let restore_backup ezfio_filename =
|
|||
|
||||
|
||||
|
||||
|
||||
let () =
|
||||
(* Command-line specs *)
|
||||
Command_line.set_header_doc "Opens a text editor to edit the parameters of a EZFIO directory.";
|
||||
let open Command_line in
|
||||
begin
|
||||
set_header_doc (Sys.argv.(0) ^ " - quantum_package command");
|
||||
set_description_doc
|
||||
"Opens a text editor to edit the parameters of an EZFIO directory.";
|
||||
|
||||
[ ( 'c', "check", "Checks the input data", Command_line.Without_arg);
|
||||
( 'n', "ndet", "<int> Truncate the wavefunction to the target number of determinants",
|
||||
Command_line.With_arg);
|
||||
( 's', "state", "<range> Extract selected states, for example \"[1,3-5]\"", Command_line.With_arg);
|
||||
Command_line.anonymous "<EZFIO_FILE>" "EZFIO directory";
|
||||
]
|
||||
|> Command_line.set_specs ;
|
||||
[ {{ short='c'; long="check"; opt=Optional;
|
||||
doc="Checks the input data";
|
||||
arg=Without_arg; }};
|
||||
|
||||
{{ short='n'; long="ndet"; opt=Optional;
|
||||
doc="Truncates the wavefunction to the target number of determinants";
|
||||
arg=With_arg "<int>"; }};
|
||||
|
||||
{{
|
||||
short='s'; long="state"; opt=Optional;
|
||||
doc="Extracts selected states, for example \"[1,3-5]\"";
|
||||
arg=With_arg "<range>"; }};
|
||||
|
||||
anonymous "EZFIO_DIR" Mandatory "EZFIO directory";
|
||||
]
|
||||
|> set_specs ;
|
||||
|
||||
end;
|
||||
|
||||
(* Handle options *)
|
||||
if Command_line.show_help () then
|
||||
exit 0;
|
||||
|
||||
let ndet =
|
||||
match Command_line.get "ndet" with
|
||||
| None -> None
|
||||
|
@ -296,16 +305,12 @@ let () =
|
|||
with _ -> failwith "[-s|--state] expects a range")
|
||||
in
|
||||
|
||||
let c =
|
||||
match Command_line.get "check" with
|
||||
| None -> false
|
||||
| _ -> true
|
||||
in
|
||||
let c = Command_line.get_bool "check" in
|
||||
|
||||
let ezfio_filename =
|
||||
match Command_line.anon_args () with
|
||||
| [x] -> x
|
||||
| _ -> (Command_line.help () ; failwith "EZFIO_FILE is missing")
|
||||
| _ -> (Command_line.help () ; failwith "EZFIO_DIR is missing")
|
||||
in
|
||||
|
||||
at_exit (fun () -> remove_backup ezfio_filename);
|
||||
|
|
0
scripts/generate_h_apply.py
Executable file → Normal file
0
scripts/generate_h_apply.py
Executable file → Normal file
|
@ -11,8 +11,7 @@
|
|||
#DEBUG:
|
||||
#echo $0 $@ 1>&2
|
||||
|
||||
if [[ -z ${QP_ROOT} ]]
|
||||
then
|
||||
if [[ -z ${QP_ROOT} ]] ; then
|
||||
print "The QP_ROOT environment variable is not set."
|
||||
print "Please reload the quantum_package.rc file."
|
||||
exit -1
|
||||
|
@ -25,7 +24,9 @@ tmpfile="$1"
|
|||
shift
|
||||
|
||||
# Case insensitive basis in input
|
||||
#basis=$( python2 ${EMSL_API_ROOT}/EMSL_api.py list_basis | cut -d "'" -f 2 | grep -i "^${1}\$")
|
||||
#basis=$( python2 ${EMSL_API_ROOT}/EMSL_api.py list_basis \
|
||||
# | cut -d "'" -f 2\
|
||||
# | grep -i "^${1}\$")
|
||||
|
||||
basis="$1"
|
||||
shift
|
||||
|
@ -37,13 +38,13 @@ do
|
|||
atoms+="--atom ${atom} "
|
||||
done
|
||||
|
||||
if [[ $? -ne 0 ]]
|
||||
then
|
||||
echo "==================================================" 1>& 2
|
||||
echo "Unable to create temporary file $tmpfile" 1>& 2
|
||||
echo "==================================================" 1>& 2
|
||||
echo "ERROR"
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
>&2 echo "=================================================="
|
||||
>&2 echo "Unable to create temporary file $tmpfile"
|
||||
>&2 echo "=================================================="
|
||||
>&2 echo "ERROR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python2 ${EMSL_API_ROOT}/EMSL_api.py get_basis_data --treat_l --save --path="${tmpfile}" --basis="${basis}"
|
||||
exec python2 ${EMSL_API_ROOT}/EMSL_api.py get_basis_data \
|
||||
--treat_l --save --path="${tmpfile}" --basis="${basis}"
|
0
scripts/perturbation.py
Executable file → Normal file
0
scripts/perturbation.py
Executable file → Normal file
0
scripts/qp_bitmasks.py
Executable file → Normal file
0
scripts/qp_bitmasks.py
Executable file → Normal file
|
@ -3,40 +3,32 @@
|
|||
convert output of GAMESS/GAU$$IAN to ezfio
|
||||
|
||||
Usage:
|
||||
qp_convert_output_to_ezfio [-o EZFIO_FILE|--output=EZFIO_FILE] <file.out>
|
||||
qp_convert_output_to_ezfio [-o EZFIO_DIR] FILE
|
||||
|
||||
Options:
|
||||
-o EZFIO_FILE --output=EZFIO_FILE Produced directory
|
||||
by default is file.out.ezfio
|
||||
-o --output=EZFIO_DIR Produced directory
|
||||
by default is FILE.ezfio
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from functools import reduce
|
||||
|
||||
# ~#~#~#~#~#~#~#~ #
|
||||
# Add to the path #
|
||||
# ~#~#~#~#~#~#~#~ #
|
||||
from ezfio import ezfio
|
||||
from docopt import docopt
|
||||
|
||||
|
||||
try:
|
||||
QP_ROOT = os.environ["QP_ROOT"]
|
||||
QP_EZFIO = os.environ["QP_EZFIO"]
|
||||
except:
|
||||
except KeyError:
|
||||
print "Error: QP_ROOT environment variable not found."
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.path = [ QP_EZFIO + "/Python",
|
||||
QP_ROOT + "/install/resultsFile",
|
||||
QP_ROOT + "/install",
|
||||
QP_ROOT + "/scripts"] + sys.path
|
||||
|
||||
# ~#~#~#~#~#~ #
|
||||
# I m p o r t #
|
||||
# ~#~#~#~#~#~ #
|
||||
|
||||
from ezfio import ezfio
|
||||
sys.path = [QP_EZFIO + "/Python",
|
||||
QP_ROOT + "/install/resultsFile",
|
||||
QP_ROOT + "/install",
|
||||
QP_ROOT + "/scripts"] + sys.path
|
||||
|
||||
try:
|
||||
from resultsFile import *
|
||||
|
@ -44,12 +36,7 @@ except:
|
|||
print "Error: resultsFile Python library not installed"
|
||||
sys.exit(1)
|
||||
|
||||
from docopt import docopt
|
||||
|
||||
# _
|
||||
# |_ ._ _ _|_ o _ ._
|
||||
# | |_| | | (_ |_ | (_) | |
|
||||
#
|
||||
|
||||
|
||||
def write_ezfio(res, filename):
|
||||
|
@ -280,44 +267,44 @@ def write_ezfio(res, filename):
|
|||
kmax = 0
|
||||
nucl_num = len(res.geometry)
|
||||
for ecp in res.pseudo:
|
||||
lmax_local = ecp['lmax']
|
||||
lmax = max(lmax_local,lmax)
|
||||
nucl_charge_remove.append(ecp['zcore'])
|
||||
klocmax = max(klocmax, len(ecp[str(lmax_local)]))
|
||||
for l in range(lmax_local):
|
||||
kmax = max(kmax,len(ecp[str(l)]))
|
||||
lmax_local = ecp['lmax']
|
||||
lmax = max(lmax_local, lmax)
|
||||
nucl_charge_remove.append(ecp['zcore'])
|
||||
klocmax = max(klocmax, len(ecp[str(lmax_local)]))
|
||||
for l in range(lmax_local):
|
||||
kmax = max(kmax, len(ecp[str(l)]))
|
||||
lmax = lmax-1
|
||||
ezfio.set_pseudo_pseudo_lmax(lmax)
|
||||
ezfio.set_pseudo_nucl_charge_remove(nucl_charge_remove)
|
||||
ezfio.set_pseudo_pseudo_klocmax(klocmax)
|
||||
ezfio.set_pseudo_pseudo_kmax(kmax)
|
||||
pseudo_n_k = [ [ 0 for _ in range(nucl_num) ] for _ in range(klocmax) ]
|
||||
pseudo_v_k = [ [ 0. for _ in range(nucl_num) ] for _ in range(klocmax) ]
|
||||
pseudo_dz_k = [ [ 0. for _ in range(nucl_num) ] for _ in range(klocmax) ]
|
||||
pseudo_n_kl = [ [ [ 0 for _ in range(nucl_num) ] for _ in range(kmax) ] for _ in range(lmax+1) ]
|
||||
pseudo_v_kl = [ [ [ 0. for _ in range(nucl_num) ] for _ in range(kmax) ] for _ in range(lmax+1) ]
|
||||
pseudo_dz_kl = [ [ [ 0. for _ in range(nucl_num) ] for _ in range(kmax) ] for _ in range(lmax+1) ]
|
||||
pseudo_n_k = [[0 for _ in range(nucl_num)] for _ in range(klocmax)]
|
||||
pseudo_v_k = [[0. for _ in range(nucl_num)] for _ in range(klocmax)]
|
||||
pseudo_dz_k = [[0. for _ in range(nucl_num)] for _ in range(klocmax)]
|
||||
pseudo_n_kl = [[[0 for _ in range(nucl_num)] for _ in range(kmax)] for _ in range(lmax+1)]
|
||||
pseudo_v_kl = [[[0. for _ in range(nucl_num)] for _ in range(kmax)] for _ in range(lmax+1)]
|
||||
pseudo_dz_kl = [[[0. for _ in range(nucl_num)] for _ in range(kmax)] for _ in range(lmax+1)]
|
||||
for ecp in res.pseudo:
|
||||
lmax_local = ecp['lmax']
|
||||
klocmax = len(ecp[str(lmax_local)])
|
||||
atom = ecp['atom']-1
|
||||
for kloc in range(klocmax):
|
||||
try:
|
||||
v, n, dz = ecp[str(lmax_local)][kloc]
|
||||
pseudo_n_k[kloc][atom] = n-2
|
||||
pseudo_v_k[kloc][atom] = v
|
||||
pseudo_dz_k[kloc][atom] = dz
|
||||
except:
|
||||
pass
|
||||
for l in range(lmax_local):
|
||||
for k in range(kmax):
|
||||
try:
|
||||
v, n, dz = ecp[str(l)][k]
|
||||
pseudo_n_kl[l][k][atom] = n-2
|
||||
pseudo_v_kl[l][k][atom] = v
|
||||
pseudo_dz_kl[l][k][atom] = dz
|
||||
except:
|
||||
pass
|
||||
lmax_local = ecp['lmax']
|
||||
klocmax = len(ecp[str(lmax_local)])
|
||||
atom = ecp['atom']-1
|
||||
for kloc in range(klocmax):
|
||||
try:
|
||||
v, n, dz = ecp[str(lmax_local)][kloc]
|
||||
pseudo_n_k[kloc][atom] = n-2
|
||||
pseudo_v_k[kloc][atom] = v
|
||||
pseudo_dz_k[kloc][atom] = dz
|
||||
except:
|
||||
pass
|
||||
for l in range(lmax_local):
|
||||
for k in range(kmax):
|
||||
try:
|
||||
v, n, dz = ecp[str(l)][k]
|
||||
pseudo_n_kl[l][k][atom] = n-2
|
||||
pseudo_v_kl[l][k][atom] = v
|
||||
pseudo_dz_kl[l][k][atom] = dz
|
||||
except:
|
||||
pass
|
||||
ezfio.set_pseudo_pseudo_n_k(pseudo_n_k)
|
||||
ezfio.set_pseudo_pseudo_v_k(pseudo_v_k)
|
||||
ezfio.set_pseudo_pseudo_dz_k(pseudo_dz_k)
|
||||
|
@ -326,11 +313,11 @@ def write_ezfio(res, filename):
|
|||
ezfio.set_pseudo_pseudo_dz_kl(pseudo_dz_kl)
|
||||
|
||||
n_alpha = res.num_alpha
|
||||
n_beta = res.num_beta
|
||||
n_beta = res.num_beta
|
||||
for i in range(nucl_num):
|
||||
charge[i] -= nucl_charge_remove[i]
|
||||
n_alpha -= nucl_charge_remove[i]/2
|
||||
n_beta -= nucl_charge_remove[i]/2
|
||||
charge[i] -= nucl_charge_remove[i]
|
||||
n_alpha -= nucl_charge_remove[i]/2
|
||||
n_beta -= nucl_charge_remove[i]/2
|
||||
ezfio.set_nuclei_nucl_charge(charge)
|
||||
ezfio.set_electrons_elec_alpha_num(n_alpha)
|
||||
ezfio.set_electrons_elec_beta_num(n_beta)
|
||||
|
@ -353,33 +340,32 @@ def get_full_path(file_path):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = docopt(__doc__)
|
||||
ARGUMENTS = docopt(__doc__)
|
||||
|
||||
file_ = get_full_path(arguments['<file.out>'])
|
||||
FILE = get_full_path(ARGUMENTS['FILE'])
|
||||
|
||||
if arguments["--output"]:
|
||||
ezfio_file = get_full_path(arguments["--output"])
|
||||
elif arguments["-o"]:
|
||||
ezfio_file = get_full_path(arguments["-o"])
|
||||
if ARGUMENTS["--output"]:
|
||||
EZFIO_FILE = get_full_path(ARGUMENTS["--output"])
|
||||
elif ARGUMENTS["-o"]:
|
||||
EZFIO_FILE = get_full_path(ARGUMENTS["-o"])
|
||||
else:
|
||||
ezfio_file = "{0}.ezfio".format(file_)
|
||||
print ezfio_file
|
||||
EZFIO_FILE = "{0}.ezfio".format(FILE)
|
||||
print EZFIO_FILE
|
||||
|
||||
try:
|
||||
res_file = getFile(file_)
|
||||
RES_FILE = getFile(FILE)
|
||||
except:
|
||||
raise
|
||||
else:
|
||||
print file_, 'recognized as', str(res_file).split('.')[-1].split()[0]
|
||||
print FILE, 'recognized as', str(RES_FILE).split('.')[-1].split()[0]
|
||||
|
||||
write_ezfio(res_file, ezfio_file)
|
||||
write_ezfio(RES_FILE, EZFIO_FILE)
|
||||
sys.stdout.flush()
|
||||
if os.system("qp_run save_ortho_mos "+ezfio_file) != 0:
|
||||
print """Warning: You need to run
|
||||
if os.system("qp_run save_ortho_mos "+EZFIO_FILE) != 0:
|
||||
print """Warning: You need to run
|
||||
|
||||
qp run save_ortho_mos
|
||||
|
||||
to be sure your MOs will be orthogonal, which is not the case when
|
||||
the MOs are read from output files (not enough precision in output)."""
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
#!/bin/bash
|
||||
file=$1
|
||||
|
||||
qp=$QP_ROOT
|
||||
source ${qp}/quantum_package.rc
|
||||
if [[ -z ${QP_ROOT} ]] ; then
|
||||
>&2 echo "please source quantum_package.rc"
|
||||
exit 1
|
||||
fi
|
||||
source ${QP_ROOT}/quantum_package.rc
|
||||
|
||||
qp_run print_e_conv $1
|
||||
nstates=`cat ${1}/determinants/n_states`
|
||||
echo $nstates
|
||||
|
||||
|
||||
for i in `seq 1 $nstates`
|
||||
do
|
||||
out=${1}.${i}.conv
|
||||
for i in $(seq 1 $nstates) ; do
|
||||
out=${1}.${i}.conv
|
||||
cat << EOF > ${out}.plt
|
||||
set term pdf
|
||||
set output "$out.pdf"
|
||||
|
@ -28,9 +30,8 @@ rm ${out}.plt
|
|||
|
||||
done
|
||||
|
||||
for i in `seq 2 $nstates`
|
||||
do
|
||||
out=${1}.${i}.delta_e.conv
|
||||
for i in $(seq 2 $nstates) ; do
|
||||
out=${1}.${i}.delta_e.conv
|
||||
cat << EOF > ${out}.plt
|
||||
set term pdf
|
||||
set output "$out.pdf"
|
||||
|
@ -41,6 +42,6 @@ set ylabel "Energy difference (a.u.)"
|
|||
plot "$out" w lp title "Delta E_{var} state $i", "$out" u 1:3 w lp title "Delta E_{var} + PT2 state $i"
|
||||
|
||||
EOF
|
||||
gnuplot ${out}.plt
|
||||
rm ${out}.plt
|
||||
gnuplot ${out}.plt
|
||||
rm ${out}.plt
|
||||
done
|
||||
|
|
|
@ -1,14 +1,61 @@
|
|||
#!/bin/bash -x
|
||||
#!/bin/bash
|
||||
#
|
||||
# Creates a self-contained binary distribution in the form of a tar.gz file
|
||||
#
|
||||
# Mon Nov 26 22:57:50 CET 2018
|
||||
#
|
||||
|
||||
function help() {
|
||||
cat << EOF
|
||||
In some HPC facilities, the access to the internet is limited for security
|
||||
reasons. In such an environment, the installation of QP is sometimes very
|
||||
painful because the OCaml compiler and the libraries can't be installed by a
|
||||
non-root user.
|
||||
|
||||
This command creates a self-contained binary distribution in the form of a
|
||||
tar.gz file that can be copied on another machine.
|
||||
|
||||
|
||||
Usage:
|
||||
|
||||
$(basename $0) [-h|--help]
|
||||
|
||||
Options:
|
||||
|
||||
-h --help Prints the help message
|
||||
|
||||
Note:
|
||||
|
||||
There can be conflicts due to the version of Glibc. The machine on which |QP| is
|
||||
compiled should be the oldest one.
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
function error() {
|
||||
>&2 echo "$(basename $0): $@"
|
||||
exit 2
|
||||
}
|
||||
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
"")
|
||||
break;;
|
||||
-h|-help|--help)
|
||||
help;;
|
||||
*)
|
||||
echo $(basename $0)": unknown option $1, try --help"
|
||||
exit 2;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
set -x
|
||||
|
||||
# Check the QP_ROOT directory
|
||||
if [[ -z ${QP_ROOT} ]]
|
||||
then
|
||||
if [[ -z ${QP_ROOT} ]] ; then
|
||||
echo "The QP_ROOT environment variable is not set."
|
||||
echo "Please reload the quantum_package.rc file."
|
||||
exit 1
|
||||
|
@ -23,83 +70,76 @@ if [[ -f quantum_package.rc \
|
|||
&& -d bin \
|
||||
&& -d ocaml \
|
||||
&& -d external \
|
||||
&& -d scripts ]]
|
||||
then
|
||||
&& -d scripts ]] ; then
|
||||
: # OK, this is a quantum_package directory
|
||||
else
|
||||
echo "This doesn't look like a quantum_package directory"
|
||||
error "This doesn't look like a quantum_package directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Build all sources
|
||||
ninja
|
||||
if [[ $? -ne 0 ]]
|
||||
then
|
||||
echo "Error building ${dir}"
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
error "Error building ${dir}"
|
||||
fi
|
||||
|
||||
|
||||
# Copy the files in the static directory
|
||||
QPACKAGE_STATIC=${QP_ROOT}/quantum_package_static
|
||||
|
||||
function find_libs ()
|
||||
{
|
||||
for i in "$@"
|
||||
do
|
||||
function find_libs () {
|
||||
for i in "$@" ; do
|
||||
ldd $i
|
||||
done | sort | grep '/' | cut --delimiter=' ' --fields=3 | uniq
|
||||
done \
|
||||
| sort \
|
||||
| grep '/' \
|
||||
| cut --delimiter=' ' --fields=3 \
|
||||
| uniq
|
||||
}
|
||||
|
||||
function find_exec ()
|
||||
{
|
||||
function find_exec () {
|
||||
find ${QP_ROOT}/$1 -perm /u+x -type f
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
echo "Creating root of static directory"
|
||||
# ---------------------------------
|
||||
|
||||
rm --recursive --force -- "${QPACKAGE_STATIC}"
|
||||
mkdir --parents -- ${QPACKAGE_STATIC}/{bin,etc,man,lib,extra_lib,external}
|
||||
if [[ $? -ne 0 ]] ;
|
||||
then
|
||||
echo "Error creating ${QPACKAGE_STATIC}/{bin,lib,etc,man,extra_lib,external}"
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
error "Error creating ${QPACKAGE_STATIC}/{bin,lib,etc,man,extra_lib,external}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
|
||||
echo "Copying binary files"
|
||||
# --------------------
|
||||
|
||||
FORTRAN_EXEC=$(find_exec src)
|
||||
if [[ -z $FORTRAN_EXEC ]] ;
|
||||
then
|
||||
echo 'Error : No Fortran binaries found.'
|
||||
if [[ -z $FORTRAN_EXEC ]] ; then
|
||||
error 'No Fortran binaries found.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OCAML_EXEC=$(find_exec ocaml | grep .native )
|
||||
if [[ -z $OCAML_EXEC ]] ;
|
||||
then
|
||||
echo 'Error : No ocaml binaries found.'
|
||||
if [[ -z $OCAML_EXEC ]] ; then
|
||||
error 'No ocaml binaries found.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp -- ${FORTRAN_EXEC} ${OCAML_EXEC} ${QPACKAGE_STATIC}/bin
|
||||
if [[ $? -ne 0 ]] ;
|
||||
then
|
||||
cp -- ${FORTRAN_EXEC} ${OCAML_EXEC} ${QPACKAGE_STATIC}/bin
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
error "Error in cp -- ${FORTRAN_EXEC} ${OCAML_EXEC} ${QPACKAGE_STATIC}/bin"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(
|
||||
cd ${QPACKAGE_STATIC}/bin
|
||||
for i in *.native
|
||||
do
|
||||
for i in *.native ; do
|
||||
mv "$i" $(basename "$i" .native)
|
||||
done
|
||||
)
|
||||
|
@ -107,8 +147,7 @@ cd ${QPACKAGE_STATIC}/bin
|
|||
cp ${QP_ROOT}/bin/qpsh ${QPACKAGE_STATIC}/bin
|
||||
|
||||
cp --recursive -- ${QP_ROOT}/data ${QPACKAGE_STATIC}/data
|
||||
for i in ${FORTRAN_EXEC}
|
||||
do
|
||||
for i in ${FORTRAN_EXEC} ; do
|
||||
i=$(basename $i)
|
||||
echo $i \$QP_ROOT/bin/$i
|
||||
done > ${QPACKAGE_STATIC}/data/executables
|
||||
|
@ -116,11 +155,13 @@ done > ${QPACKAGE_STATIC}/data/executables
|
|||
mkdir --parents -- ${QPACKAGE_STATIC}/src/Bitmask
|
||||
cp ${QP_ROOT}/src/Bitmask/bitmasks_module.f90 ${QPACKAGE_STATIC}/src/Bitmask
|
||||
|
||||
#
|
||||
|
||||
echo "Copying dynamic libraries"
|
||||
# --------------------------
|
||||
|
||||
MKL_LIBS=$(find_libs ${FORTRAN_EXEC} | grep libmkl | head -1)
|
||||
MKL_LIBS=$(find_libs ${FORTRAN_EXEC} \
|
||||
| grep libmkl \
|
||||
| head -1)
|
||||
if [[ -n ${MKL_LIBS} ]]
|
||||
then
|
||||
MKL_LIBS=$(dirname ${MKL_LIBS})
|
||||
|
@ -128,18 +169,17 @@ then
|
|||
fi
|
||||
|
||||
ALL_LIBS=$(find_libs ${OCAML_EXEC} ${FORTRAN_EXEC})
|
||||
for i in ${ALL_LIBS} ${MKL_LIBS}
|
||||
do
|
||||
for i in ${ALL_LIBS} ${MKL_LIBS} ; do
|
||||
cp -- ${i} ${QPACKAGE_STATIC}/extra_lib
|
||||
done
|
||||
|
||||
if [[ $? -ne 0 ]] ;
|
||||
then
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
echo 'cp -- ${ALL_LIBS} ${MKL_LIBS} ${QPACKAGE_STATIC}/extra_lib'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp -- ${QPACKAGE_STATIC}/extra_lib/lib{[gi]omp*,mkl*,lapack*,blas*,z*} ${QPACKAGE_STATIC}/lib/
|
||||
cp -- ${QPACKAGE_STATIC}/extra_lib/lib{[gi]omp*,mkl*,lapack*,blas*,z*} \
|
||||
${QPACKAGE_STATIC}/lib/
|
||||
|
||||
#
|
||||
echo "Copying scripts directory"
|
||||
|
@ -148,7 +188,7 @@ echo "Copying scripts directory"
|
|||
cp --recursive -- ${QP_ROOT}/scripts ${QPACKAGE_STATIC}/
|
||||
if [[ $? -ne 0 ]] ;
|
||||
then
|
||||
echo 'cp --recursive -- ${QP_ROOT}/scripts ${QPACKAGE_STATIC}/'
|
||||
error 'cp --recursive -- ${QP_ROOT}/scripts ${QPACKAGE_STATIC}/'
|
||||
exit 1
|
||||
fi
|
||||
#
|
||||
|
@ -157,9 +197,8 @@ echo "Copying external libraries"
|
|||
# --------------------------
|
||||
|
||||
cp --recursive -- ${QP_ROOT}/external/emsl ${QPACKAGE_STATIC}/external
|
||||
if [[ $? -ne 0 ]] ;
|
||||
then
|
||||
echo 'cp --recursive -- ${QP_ROOT}/external/emsl ${QPACKAGE_STATIC}/'
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
error 'cp --recursive -- ${QP_ROOT}/external/emsl ${QPACKAGE_STATIC}/'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -170,7 +209,6 @@ cp --recursive -- ${QP_ROOT}/external/ezfio/Bash ${QPACKAGE_STATIC}/external/e
|
|||
cp --recursive -- ${QP_ROOT}/man ${QPACKAGE_STATIC}/man
|
||||
|
||||
|
||||
#
|
||||
echo "Creating quantum_package.rc"
|
||||
# ---------------------------
|
||||
|
||||
|
@ -181,17 +219,14 @@ export QP_ROOT="\$( cd \$(dirname \\\${BASH_SOURCE}) ; cd .. ; pwd -P )"
|
|||
EOF
|
||||
|
||||
|
||||
|
||||
|
||||
#exit 0
|
||||
#
|
||||
echo "Creating the archive"
|
||||
# --------------------
|
||||
|
||||
tar --create --gzip --file "${QPACKAGE_STATIC}".tar.gz quantum_package_static && rm --recursive --force -- "${QPACKAGE_STATIC}"
|
||||
if [[ $? -ne 0 ]] ;
|
||||
then
|
||||
echo 'tar --create --gzip --file "${QPACKAGE_STATIC}".tar.gz "${QPACKAGE_STATIC}" && rm --recursive --force -- "${QPACKAGE_STATIC}"'
|
||||
tar --create --gzip --file "${QPACKAGE_STATIC}".tar.gz quantum_package_static && \
|
||||
rm --recursive --force -- "${QPACKAGE_STATIC}"
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
error 'tar --create --gzip --file "${QPACKAGE_STATIC}".tar.gz "${QPACKAGE_STATIC}" &&
|
||||
rm --recursive --force -- "${QPACKAGE_STATIC}"'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,15 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
function error() {
|
||||
>&2 echo "$(basename $0): $@"
|
||||
exit 2
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
PROG=$1
|
||||
INPUT=$2
|
||||
|
||||
case ${PROG} in
|
||||
-h|--help)
|
||||
exec qp_run --help
|
||||
;;
|
||||
esac
|
||||
|
||||
NODES=($(mpirun hostname))
|
||||
|
||||
# Test that there is one MPI process per node
|
||||
NPROC=$(echo ${NODES[@]} | tr ' ' '\n' | sort | wc -l)
|
||||
NUNIQ=$(echo ${NODES[@]} | tr ' ' '\n' | sort | uniq | wc -l)
|
||||
if [[ $NPROC != $NUNIQ ]]
|
||||
then
|
||||
echo "
|
||||
if [[ $NPROC != $NUNIQ ]] ; then
|
||||
error "
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Error:
|
||||
|
||||
|
@ -20,17 +33,15 @@ In your SLURM script file, use:
|
|||
#SBATCH --ntasks-per-node=1
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"
|
||||
exit -1
|
||||
"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
PROG=$1
|
||||
INPUT=$2
|
||||
|
||||
|
||||
# Check if quantum_package.rc is sourced
|
||||
|
||||
if [[ -z ${QP_ROOT} ]]
|
||||
then
|
||||
if [[ -z ${QP_ROOT} ]] ; then
|
||||
echo "Error: quantum_package.rc is not sourced"
|
||||
exit -1
|
||||
fi
|
||||
|
@ -40,18 +51,15 @@ fi
|
|||
|
||||
MASTER_NODE=${NODES[0]}
|
||||
SLAVE_NODES=$(echo ${NODES[@]:1}| tr ' ' ',')
|
||||
if [[ $NPROC -gt 1 ]]
|
||||
then
|
||||
if [[ $NPROC -gt 1 ]] ; then
|
||||
echo "Master : $MASTER_NODE"
|
||||
echo "Slaves : $SLAVE_NODES"
|
||||
fi
|
||||
|
||||
# Check if the integrals can be read
|
||||
source ${QP_ROOT}/external/ezfio/Bash/ezfio.sh
|
||||
ezfio set_file $INPUT
|
||||
RW=$(ezfio set mo_two_e_ints io_mo_two_e_integrals)
|
||||
if [[ $RW != Read ]]
|
||||
then
|
||||
qp set_file $INPUT
|
||||
RW=$(qp get mo_two_e_ints io_mo_two_e_integrals)
|
||||
if [[ $RW != Read ]] ; then
|
||||
echo "
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Warning:
|
||||
|
@ -67,18 +75,17 @@ as a single-node job before re-submitting the current job.
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"
|
||||
fi
|
||||
rm --force "${INPUT}"/work/qp_run_address
|
||||
rm --force -- "${INPUT}"/work/qp_run_address
|
||||
set -x
|
||||
mpiexec.hydra -n 1 -hosts "$MASTER_NODE" qp_run $PROG $INPUT &
|
||||
|
||||
if [[ $NPROC -gt 1 ]]
|
||||
then
|
||||
while [[ ! -f $INPUT/work/qp_run_address ]]
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
echo "Starting slaves"
|
||||
mpiexec.hydra -n $((${SLURM_NTASKS}-1)) -hosts "$SLAVE_NODES" qp_run -slave $PROG $INPUT > $INPUT.slaves.out
|
||||
if [[ $NPROC -gt 1 ]] ; then
|
||||
while [[ ! -f $INPUT/work/qp_run_address ]] ; do
|
||||
sleep 1
|
||||
done
|
||||
echo "Starting slaves"
|
||||
mpiexec.hydra -n $((${SLURM_NTASKS}-1)) -hosts "$SLAVE_NODES" \
|
||||
qp_run --slave="$PROG" $INPUT > $INPUT.slaves.out
|
||||
fi
|
||||
wait
|
||||
|
||||
|
|
|
@ -28,13 +28,14 @@ import os
|
|||
|
||||
try:
|
||||
from docopt import docopt
|
||||
from qp_path import QP_SRC, QP_ROOT, QP_PLUGINS
|
||||
from qp_path import QP_SRC, QP_ROOT
|
||||
except ImportError:
|
||||
print "source .quantum_package.rc"
|
||||
raise
|
||||
|
||||
|
||||
def main(arguments):
|
||||
"""Main function"""
|
||||
|
||||
# Check that name exist in */IRPF90_man
|
||||
print "Checking that name exists..."
|
||||
|
@ -43,8 +44,8 @@ def main(arguments):
|
|||
f = arguments["<name>"]+".l"
|
||||
found = False
|
||||
for mod in all_modules:
|
||||
if os.path.isdir( os.path.join(QP_SRC,mod,"IRPF90_man") ):
|
||||
for filename in os.listdir( os.path.join(QP_SRC,mod,"IRPF90_man") ):
|
||||
if os.path.isdir(os.path.join(QP_SRC, mod, "IRPF90_man")):
|
||||
for filename in os.listdir(os.path.join(QP_SRC, mod, "IRPF90_man")):
|
||||
if filename == f:
|
||||
found = True
|
||||
break
|
||||
|
@ -56,7 +57,7 @@ def main(arguments):
|
|||
+ "\" was not found in the sources."
|
||||
print "Did you compile the code at the root?"
|
||||
print "Continue? [y/N] ",
|
||||
cont = sys.stdin.read(1).strip() in [ "y", "Y" ]
|
||||
cont = sys.stdin.read(1).strip() in ["y", "Y"]
|
||||
if not cont:
|
||||
print "Aborted"
|
||||
sys.exit(1)
|
||||
|
@ -70,14 +71,14 @@ def main(arguments):
|
|||
name = re.compile(r"\b"+arguments["<name>"]+r"\b", re.IGNORECASE)
|
||||
|
||||
for mod in all_modules:
|
||||
dirname = os.path.join(QP_SRC,mod)
|
||||
dirname = os.path.join(QP_SRC, mod)
|
||||
if not os.path.isdir(dirname):
|
||||
continue
|
||||
|
||||
for filename in os.listdir(dirname):
|
||||
if "." not in filename:
|
||||
continue
|
||||
filename = os.path.join(dirname,filename)
|
||||
filename = os.path.join(dirname, filename)
|
||||
if not os.path.isfile(filename):
|
||||
continue
|
||||
with open(filename, "r") as f:
|
||||
|
@ -90,15 +91,14 @@ def main(arguments):
|
|||
f.write(f_new)
|
||||
|
||||
print "Done"
|
||||
with open( os.path.join(QP_ROOT,"REPLACE"), 'a') as f:
|
||||
print >>f, "qp_name "+" ".join(sys.argv[1:])
|
||||
with open(os.path.join(QP_ROOT, "REPLACE"), 'a') as f:
|
||||
print >>f, "qp_name "+" ".join(sys.argv[1:])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = docopt(__doc__)
|
||||
main(arguments)
|
||||
|
||||
ARGS = docopt(__doc__)
|
||||
main(ARGS)
|
||||
|
||||
|
|
|
@ -2,44 +2,43 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Usage:
|
||||
qp_plugins list [ -i | -u | -q ]
|
||||
qp_plugins list [-iuq]
|
||||
qp_plugins download <url>
|
||||
qp_plugins install <name>...
|
||||
qp_plugins uninstall <name>
|
||||
qp_plugins create -n <name> [-r <repository>] [<needed_modules>...]
|
||||
qp_plugins create -n <name> [-r <repo>] [<needed_modules>...]
|
||||
|
||||
Options:
|
||||
list List all the plugins
|
||||
-i List only the installed plugins
|
||||
-u List only the uninstalled plugins
|
||||
-q List the external repositories
|
||||
list List
|
||||
-i --installed only the installed plugins
|
||||
-u --uninstalled only the uninstalled plugins
|
||||
-q --repositories the external repositories
|
||||
|
||||
download <url> Download an external repository.
|
||||
The URL points to a tar.gz file or a git repository:
|
||||
http://example.com/site/example.tar.gz
|
||||
git@gitlab.com:user/example_repository
|
||||
download <url> Download an external repository.
|
||||
The URL points to a tar.gz file or a git repository:
|
||||
http://example.com/site/example.tar.gz
|
||||
git@gitlab.com:user/example_repository
|
||||
|
||||
install Install a plugin
|
||||
install Install a plugin
|
||||
|
||||
uninstall Uninstall a plugin
|
||||
uninstall Uninstall a plugin
|
||||
|
||||
create -n <name> Create a new plugin named <name>
|
||||
-r <repository> Name of the repository in which to create the plugin
|
||||
create
|
||||
-n --name=<name> Create a new plugin named <name>
|
||||
-r --repository=<repo> Name of the repository in which to create the plugin
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
from os import listdir
|
||||
from os.path import isdir, join
|
||||
|
||||
|
||||
try:
|
||||
from docopt import docopt
|
||||
from module_handler import ModuleHandler, get_dict_child
|
||||
from module_handler import get_l_module_descendant
|
||||
from qp_path import QP_SRC, QP_PLUGINS, QP_ROOT, QP_DATA
|
||||
from qp_path import QP_SRC, QP_PLUGINS, QP_DATA
|
||||
except ImportError:
|
||||
print "Please check if you have sourced the ${QP_ROOT}/quantum_package.rc"
|
||||
print "(`source ${QP_ROOT}/quantum_package.rc`)"
|
||||
|
@ -47,6 +46,7 @@ except ImportError:
|
|||
|
||||
|
||||
def save_new_module(path, l_child):
|
||||
"""Creates a new module"""
|
||||
|
||||
# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ #
|
||||
# N E E D E D _ C H I L D R E N _ M O D U L E S #
|
||||
|
@ -78,8 +78,8 @@ def save_new_module(path, l_child):
|
|||
data = g.read()
|
||||
f.write(data)
|
||||
|
||||
with open(os.path.join(path, "%s.irp.f"%(module_name) ), "w") as f:
|
||||
f.write("program {0}".format(module_name) )
|
||||
with open(os.path.join(path, "%s.irp.f"%(module_name)), "w") as f:
|
||||
f.write("program {0}".format(module_name))
|
||||
f.write("""
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
|
@ -90,39 +90,43 @@ def save_new_module(path, l_child):
|
|||
""")
|
||||
|
||||
def main(arguments):
|
||||
arguments["<name>"] = [ os.path.normpath(name) for name in arguments["<name>"] ]
|
||||
"""Main function"""
|
||||
arguments["<name>"] = [os.path.normpath(name) for name in arguments["<name>"]]
|
||||
|
||||
if arguments["list"]:
|
||||
if arguments["-q"]:
|
||||
l_result = [ f for f in listdir(QP_PLUGINS) if f not in [ ".gitignore", "local" ] ]
|
||||
if arguments["--repositories"]:
|
||||
l_result = [f for f in os.listdir(QP_PLUGINS) if f not in [".gitignore", "local"]]
|
||||
|
||||
else:
|
||||
# Search in src all directories with a NEED file
|
||||
l_tmp = [ dirname for (dirname, _, filenames) in os.walk(QP_PLUGINS, followlinks=False) for f in filenames if f == 'NEED']
|
||||
l_tmp = [dirname for (dirname, _, filenames) in \
|
||||
os.walk(QP_PLUGINS, followlinks=False) \
|
||||
for f in filenames if f == 'NEED']
|
||||
|
||||
# Find directories which contain modules
|
||||
l_tmp = [ os.path.split(f) for f in l_tmp ]
|
||||
l_tmp = [os.path.split(f) for f in l_tmp]
|
||||
d_tmp = {}
|
||||
for (x,_) in l_tmp:
|
||||
for (x, _) in l_tmp:
|
||||
d_tmp[x] = 1
|
||||
l_repository = d_tmp.keys()
|
||||
m_all_instances = ModuleHandler(l_repository)
|
||||
m_instance = ModuleHandler(l_repository)
|
||||
l_plugins = [ module for module in m_instance.l_module ]
|
||||
l_plugins = [module for module in m_instance.l_module]
|
||||
l_result = l_plugins
|
||||
|
||||
if arguments["-i"] or arguments["-u"]:
|
||||
if arguments["--installed"] or arguments["--uninstalled"]:
|
||||
# Search in src all symbolic links that are modules
|
||||
l_installed = [ f for f in listdir(QP_SRC) if (os.path.islink(os.path.join(QP_SRC,f)) and f != ".gitignore") ]
|
||||
l_installed = [f for f in os.listdir(QP_SRC) \
|
||||
if (os.path.islink(os.path.join(QP_SRC, f)) \
|
||||
and f != ".gitignore")]
|
||||
|
||||
if arguments["-i"]:
|
||||
l_result = [ f for f in l_plugins if f in l_installed ]
|
||||
if arguments["--installed"]:
|
||||
l_result = [f for f in l_plugins if f in l_installed]
|
||||
|
||||
elif arguments["-u"]:
|
||||
l_result = [ f for f in l_plugins if f not in l_installed ]
|
||||
elif arguments["--uninstalled"]:
|
||||
l_result = [f for f in l_plugins if f not in l_installed]
|
||||
|
||||
for module in sorted(l_result):
|
||||
print "* {0}".format(module)
|
||||
print module
|
||||
|
||||
if arguments["create"]:
|
||||
m_instance = ModuleHandler([QP_SRC])
|
||||
|
@ -131,8 +135,8 @@ def main(arguments):
|
|||
|
||||
name = arguments["<name>"][0]
|
||||
|
||||
if arguments["-r"]:
|
||||
repository = arguments["-r"]
|
||||
if arguments["--repository"]:
|
||||
repository = arguments["--repository"]
|
||||
else:
|
||||
repository = "local"
|
||||
|
||||
|
@ -161,16 +165,15 @@ def main(arguments):
|
|||
|
||||
print " [ OK ]"
|
||||
print ""
|
||||
arguments["create"]=False
|
||||
arguments["install"]=True
|
||||
arguments["create"] = False
|
||||
arguments["install"] = True
|
||||
main(arguments)
|
||||
|
||||
elif arguments["download"]:
|
||||
url = arguments["<url>"]
|
||||
is_repo = not( url.endswith(".tar.gz") or \
|
||||
url.endswith(".tgz") or \
|
||||
url.endswith(".zip") \
|
||||
)
|
||||
is_repo = not(url.endswith(".tar.gz") or \
|
||||
url.endswith(".tgz") or \
|
||||
url.endswith(".zip"))
|
||||
os.chdir(QP_PLUGINS)
|
||||
if is_repo:
|
||||
subprocess.check_call(["git", "clone", url])
|
||||
|
@ -179,38 +182,33 @@ def main(arguments):
|
|||
|
||||
import requests, shutil
|
||||
try:
|
||||
r = requests.get(url,verify=True,stream=True)
|
||||
r = requests.get(url, verify=True, stream=True)
|
||||
except:
|
||||
r = requests.get(url,verify=False,stream=True)
|
||||
r = requests.get(url, verify=False, stream=True)
|
||||
r.raw.decode_content = True
|
||||
with open(filename, 'wb') as f:
|
||||
shutil.copyfileobj(r.raw, f)
|
||||
shutil.copyfileobj(r.raw, f)
|
||||
|
||||
if filename.endswith(".tar.gz") or \
|
||||
filename.endswith(".tgz") or \
|
||||
filename.endswith(".tar.bz2") or \
|
||||
filename.endswith(".tar"):
|
||||
subprocess.check_call(["tar", "xf", filename])
|
||||
os.remove(filename)
|
||||
filename.endswith(".tgz") or \
|
||||
filename.endswith(".tar.bz2") or \
|
||||
filename.endswith(".tar"):
|
||||
subprocess.check_call(["tar", "xf", filename])
|
||||
os.remove(filename)
|
||||
|
||||
elif arguments["install"]:
|
||||
|
||||
# Python 2.6 ...
|
||||
d_module_location= dict()
|
||||
|
||||
d_local = get_dict_child([QP_SRC])
|
||||
# d_plugin = get_dict_child([join(QP_PLUGINS, f) for f in listdir(QP_PLUGINS) if isdir(join(QP_PLUGINS, f))])
|
||||
l_tmp = [ dirname for (dirname, _, filenames) in os.walk(QP_PLUGINS, followlinks=False) for f in filenames if f == 'NEED']
|
||||
|
||||
l_tmp = [dirname for (dirname, _, filenames) in \
|
||||
os.walk(QP_PLUGINS, followlinks=False) \
|
||||
for f in filenames if f == 'NEED']
|
||||
d_repo_of_plugin = {}
|
||||
d_repo = {}
|
||||
for (x,y) in [ os.path.split(f) for f in l_tmp ]:
|
||||
for (x, y) in [os.path.split(f) for f in l_tmp]:
|
||||
d_repo_of_plugin[y] = x
|
||||
d_repo[x] = None
|
||||
l_repository = d_repo.keys()
|
||||
# m_all_instances = ModuleHandler(l_repository)
|
||||
# m_instance = ModuleHandler(l_repository)
|
||||
# l_plugins = [ module for module in m_instance.l_module ]
|
||||
# print l_plugins
|
||||
|
||||
d_plugin = get_dict_child(l_repository)
|
||||
|
||||
|
@ -219,9 +217,9 @@ def main(arguments):
|
|||
|
||||
normalize_case = {}
|
||||
for name in d_local.keys() + d_plugin.keys():
|
||||
normalize_case [ name.lower() ] = name
|
||||
normalize_case[name.lower()] = name
|
||||
|
||||
l_name = [ normalize_case[name.lower()] for name in arguments["<name>"] ]
|
||||
l_name = [normalize_case[name.lower()] for name in arguments["<name>"]]
|
||||
|
||||
for name in l_name:
|
||||
|
||||
|
@ -240,11 +238,11 @@ def main(arguments):
|
|||
print "Installation...",
|
||||
|
||||
for module_to_cp in l_module_to_cp:
|
||||
src = os.path.join( d_repo_of_plugin[module_to_cp], module_to_cp )
|
||||
src = os.path.join(d_repo_of_plugin[module_to_cp], module_to_cp)
|
||||
des = os.path.join(QP_SRC, module_to_cp)
|
||||
try:
|
||||
os.symlink(src, des)
|
||||
install = os.path.join(src,"install")
|
||||
install = os.path.join(src, "install")
|
||||
if os.path.isfile(install):
|
||||
wd = os.getcwd()
|
||||
os.chdir(src)
|
||||
|
@ -268,10 +266,12 @@ def main(arguments):
|
|||
if l_failed:
|
||||
print "Plugins not installed:"
|
||||
for name in sorted(l_failed):
|
||||
print "* %s" % name
|
||||
print "%s" % name
|
||||
sys.exit(1)
|
||||
|
||||
l_name_to_remove = l_name + [module for module in m_instance.l_module for name in l_name if name in d_descendant[module]]
|
||||
l_name_to_remove = l_name + \
|
||||
[module for module in m_instance.l_module \
|
||||
for name in l_name if name in d_descendant[module]]
|
||||
|
||||
print "Removing plugins:"
|
||||
print l_name_to_remove
|
||||
|
@ -282,7 +282,7 @@ def main(arguments):
|
|||
|
||||
for module in set(l_name_to_remove):
|
||||
|
||||
uninstall = os.path.join(QP_SRC,module,"uninstall")
|
||||
uninstall = os.path.join(QP_SRC, module, "uninstall")
|
||||
if os.path.isfile(uninstall):
|
||||
subprocess.check_call([uninstall])
|
||||
|
||||
|
@ -293,6 +293,6 @@ def main(arguments):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = docopt(__doc__)
|
||||
main(arguments)
|
||||
ARG = docopt(__doc__)
|
||||
main(ARG)
|
||||
|
||||
|
|
|
@ -13,35 +13,34 @@ zero.
|
|||
|
||||
|
||||
Usage:
|
||||
qp_set_frozen_core [-q|--query] <EZFIO_DIRECTORY>
|
||||
qp_set_frozen_core [-q|--query] EZFIO_DIR
|
||||
|
||||
Options:
|
||||
-q --query Prints in the standard output the number of core electrons
|
||||
-q --query Prints in the standard output the number of frozen MOs
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
try:
|
||||
from docopt import docopt
|
||||
from qp_path import QP_SRC, QP_ROOT, QP_PLUGINS
|
||||
import qp_path
|
||||
except ImportError:
|
||||
print "source .quantum_package.rc"
|
||||
raise
|
||||
|
||||
|
||||
from docopt import docopt
|
||||
from ezfio import ezfio
|
||||
|
||||
|
||||
def main(arguments):
|
||||
"""Main function"""
|
||||
|
||||
filename = arguments["<EZFIO_DIRECTORY>"]
|
||||
filename = arguments["EZFIO_DIR"]
|
||||
ezfio.set_filename(filename)
|
||||
|
||||
nb = 0
|
||||
n_frozen = 0
|
||||
try:
|
||||
do_pseudo = ezfio.pseudo_do_pseudo
|
||||
except:
|
||||
|
@ -52,25 +51,25 @@ def main(arguments):
|
|||
if charge < 5:
|
||||
pass
|
||||
elif charge < 13:
|
||||
nb += 1
|
||||
n_frozen += 1
|
||||
else:
|
||||
nb += 5
|
||||
n_frozen += 5
|
||||
|
||||
mo_num = ezfio.mo_basis_mo_num
|
||||
|
||||
if arguments["--query"]:
|
||||
print nb
|
||||
print n_frozen
|
||||
sys.exit(0)
|
||||
|
||||
if nb == 0:
|
||||
os.system( """qp_set_mo_class -a "[1-%d]" %s""" %
|
||||
(mo_num, sys.argv[1]) )
|
||||
if n_frozen == 0:
|
||||
os.system("""qp_set_mo_class -a "[1-%d]" %s""" %
|
||||
(mo_num, sys.argv[1]))
|
||||
else:
|
||||
os.system( """qp_set_mo_class -c "[1-%d]" -a "[%d-%d]" %s""" %
|
||||
(nb, nb+1, mo_num, sys.argv[1]) )
|
||||
os.system("""qp_set_mo_class -c "[1-%d]" -a "[%d-%d]" %s""" %
|
||||
(n_frozen, n_frozen+1, mo_num, sys.argv[1]))
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = docopt(__doc__)
|
||||
main(arguments)
|
||||
ARGUMENTS = docopt(__doc__)
|
||||
main(ARGUMENTS)
|
||||
|
|
|
@ -1,15 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
function error() {
|
||||
>&2 echo "$(basename $0): $@"
|
||||
exit 2
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
PROG=$1
|
||||
INPUT=$2
|
||||
|
||||
case ${PROG} in
|
||||
-h|--help)
|
||||
exec qp_run --help
|
||||
;;
|
||||
esac
|
||||
|
||||
NODES=($(srun hostname))
|
||||
|
||||
# Test that there is one MPI process per node
|
||||
NPROC=$(echo ${NODES[@]} | tr ' ' '\n' | sort | wc -l)
|
||||
NUNIQ=$(echo ${NODES[@]} | tr ' ' '\n' | sort | uniq | wc -l)
|
||||
if [[ $NPROC != $NUNIQ ]]
|
||||
then
|
||||
echo "
|
||||
if [[ $NPROC != $NUNIQ ]] ; then
|
||||
error "
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Error:
|
||||
|
||||
|
@ -20,17 +33,14 @@ In your SLURM script file, use:
|
|||
#SBATCH --ntasks-per-node=1
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"
|
||||
exit -1
|
||||
"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
PROG=$1
|
||||
INPUT=$2
|
||||
|
||||
# Check if quantum_package.rc is sourced
|
||||
|
||||
if [[ -z ${QP_ROOT} ]]
|
||||
then
|
||||
if [[ -z ${QP_ROOT} ]] ; then
|
||||
echo "Error: quantum_package.rc is not sourced"
|
||||
exit -1
|
||||
fi
|
||||
|
@ -40,18 +50,15 @@ fi
|
|||
|
||||
MASTER_NODE=${NODES[0]}
|
||||
SLAVE_NODES=$(echo ${NODES[@]:1}| tr ' ' ',')
|
||||
if [[ $NPROC -gt 1 ]]
|
||||
then
|
||||
if [[ $NPROC -gt 1 ]] ; then
|
||||
echo "Master : $MASTER_NODE"
|
||||
echo "Slaves : $SLAVE_NODES"
|
||||
fi
|
||||
|
||||
# Check if the integrals can be read
|
||||
source ${QP_ROOT}/external/ezfio/Bash/ezfio.sh
|
||||
ezfio set_file $INPUT
|
||||
RW=$(ezfio get mo_two_e_ints io_mo_two_e_integrals)
|
||||
if [[ $RW != Read ]]
|
||||
then
|
||||
qp set_file $INPUT
|
||||
RW=$(qp get mo_two_e_ints io_mo_two_e_integrals)
|
||||
if [[ $RW != Read ]] ; then
|
||||
echo "
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Warning:
|
||||
|
@ -71,14 +78,13 @@ rm --force -- "${INPUT}"/work/qp_run_address
|
|||
set -x
|
||||
srun -N 1 -n 1 qp_run $PROG $INPUT &
|
||||
|
||||
if [[ $NPROC -gt 1 ]]
|
||||
then
|
||||
while [[ ! -f $INPUT/work/qp_run_address ]]
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
echo "Starting slaves"
|
||||
srun -n $((${SLURM_NTASKS}-1)) qp_run -slave $PROG $INPUT > $INPUT.slaves.out
|
||||
if [[ $NPROC -gt 1 ]] ; then
|
||||
while [[ ! -f $INPUT/work/qp_run_address ]] ; do
|
||||
sleep 1
|
||||
done
|
||||
echo "Starting slaves"
|
||||
srun -n $((${SLURM_NTASKS}-1)) \
|
||||
qp_run -slave $PROG $INPUT > $INPUT.slaves.out
|
||||
fi
|
||||
wait
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import subprocess
|
|||
|
||||
try:
|
||||
from docopt import docopt
|
||||
from qp_path import QP_SRC, QP_PLUGINS, QP_ROOT, QP_TESTS
|
||||
from qp_path import QP_SRC, QP_TESTS
|
||||
except ImportError:
|
||||
print "Please check if you have sourced the ${QP_ROOT}/quantum_package.rc"
|
||||
print "(`source ${QP_ROOT}/quantum_package.rc`)"
|
||||
|
@ -27,26 +27,28 @@ except ImportError:
|
|||
|
||||
|
||||
def main(arguments):
|
||||
"""Main function"""
|
||||
|
||||
# Fetch all *.bats files
|
||||
l_bats = []
|
||||
def append_bats(dirname, filenames):
|
||||
for f in filenames:
|
||||
if f.endswith(".bats"):
|
||||
number, _ = f.split('.',1)
|
||||
l_bats.append( (int(number), os.path.join(dirname,f)) )
|
||||
number, _ = f.split('.', 1)
|
||||
l_bats.append((int(number), os.path.join(dirname, f)))
|
||||
|
||||
if arguments["TEST"]:
|
||||
os.environ["TEST"] = arguments["TEST"]
|
||||
os.environ["TEST"] = arguments["TEST"]
|
||||
|
||||
if arguments["-a"]:
|
||||
for (dirname, _, filenames) in os.walk(QP_SRC, followlinks=False) :
|
||||
for (dirname, _, filenames) in os.walk(QP_SRC, followlinks=False):
|
||||
if "IRPF90_temp" not in dirname:
|
||||
append_bats(dirname, filenames)
|
||||
else:
|
||||
for (dirname, _, filenames) in os.walk(os.getcwd(), followlinks=False) :
|
||||
for (dirname, _, filenames) in os.walk(os.getcwd(), followlinks=False):
|
||||
if "IRPF90_temp" not in dirname:
|
||||
append_bats(dirname, filenames)
|
||||
l_bats = [ y for x,y in sorted(l_bats) ]
|
||||
l_bats = [y for _, y in sorted(l_bats)]
|
||||
|
||||
# Execute tests
|
||||
os.chdir(QP_TESTS)
|
||||
|
@ -60,21 +62,23 @@ def main(arguments):
|
|||
if arguments["-v"]:
|
||||
p = None
|
||||
if arguments["TEST"]:
|
||||
TEST="export TEST=%s\n"%arguments["TEST"]
|
||||
test = "export TEST=%s\n"%arguments["TEST"]
|
||||
else:
|
||||
TEST=""
|
||||
script = TEST+(subprocess.check_output(["python2", "bats_to_sh.py", bats_file]) )
|
||||
test = ""
|
||||
script = test+(subprocess.check_output(["python2", \
|
||||
"bats_to_sh.py", bats_file]))
|
||||
try:
|
||||
p = subprocess.check_call(script, shell=True, env=os.environ)
|
||||
except:
|
||||
if p: p.terminate()
|
||||
if p:
|
||||
p.terminate()
|
||||
else:
|
||||
subprocess.check_call(["bats", bats_file], env=os.environ)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
arguments = docopt(__doc__)
|
||||
main(arguments)
|
||||
ARGS = docopt(__doc__)
|
||||
main(ARGS)
|
||||
|
||||
|
||||
|
|
67
scripts/qp_update
Executable file
67
scripts/qp_update
Executable file
|
@ -0,0 +1,67 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Updates the current version of QP
|
||||
#
|
||||
# Mon Jan 14 21:51:08 CET 2019
|
||||
#
|
||||
|
||||
function help() {
|
||||
cat << EOF
|
||||
Updates the current version of QP.
|
||||
|
||||
Usage:
|
||||
|
||||
$(basename $0) [-h|--help]
|
||||
|
||||
Options:
|
||||
|
||||
-h --help Prints the help message
|
||||
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
function error() {
|
||||
>&2 echo "$(basename $0): $@"
|
||||
exit 2
|
||||
}
|
||||
|
||||
|
||||
TEMP=`getopt -o h -l help -n $0 -- "$@"` || exit 1
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
""|--) shift ; break ;;
|
||||
-h|-help|--help)
|
||||
help
|
||||
shift
|
||||
exit 0;;
|
||||
*)
|
||||
echo $(basename $0)": unknown option $1, try --help"
|
||||
exit 2;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check the QP_ROOT directory
|
||||
if [[ -z ${QP_ROOT} ]] ; then
|
||||
echo "The QP_ROOT environment variable is not set."
|
||||
echo "Please reload the quantum_package.rc file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -r -p "Are you sure you want to update QP? [y/N] " response
|
||||
case "$response" in
|
||||
[yY][eE][sS]|[yY])
|
||||
:
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
cd ${QP_ROOT}
|
||||
ninja clean
|
||||
git pull origin master
|
||||
ninja
|
||||
|
||||
|
16
scripts/remove_trailing_spaces
Executable file
16
scripts/remove_trailing_spaces
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Removes white spaces at the end of lines.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# remove_trailing_spaces FILE
|
||||
#
|
||||
|
||||
if [[ -n $1 ]] ; then
|
||||
exec sed --in-place 's| *$||' $1
|
||||
else
|
||||
>&2 echo "Usage: $0 FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -5,8 +5,7 @@
|
|||
# Wed Apr 2 14:35:15 CEST 2014
|
||||
|
||||
|
||||
if [[ -z ${QP_ROOT} ]]
|
||||
then
|
||||
if [[ -z ${QP_ROOT} ]] ; then
|
||||
print "The QP_ROOT environment variable is not set."
|
||||
print "Please reload the quantum_package.rc file."
|
||||
exit -1
|
||||
|
@ -14,14 +13,12 @@ fi
|
|||
|
||||
EZFIO="$1"
|
||||
|
||||
if [[ -z "${EZFIO}" ]]
|
||||
then
|
||||
if [[ -z "${EZFIO}" ]] ; then
|
||||
echo "Error in $0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "${EZFIO}/mo_basis/mo_label" ]]
|
||||
then
|
||||
if [[ ! -f "${EZFIO}/mo_basis/mo_label" ]] ; then
|
||||
LABEL='no_label'
|
||||
else
|
||||
LABEL=$(head -1 "${EZFIO}/mo_basis/mo_label" | xargs) #xargs trims the result
|
||||
|
@ -31,19 +28,16 @@ DESTINATION="save/mo_basis/${LABEL}"
|
|||
|
||||
cd "${EZFIO}"
|
||||
|
||||
if [[ ! -d save/mo_basis ]]
|
||||
then
|
||||
if [[ ! -d save/mo_basis ]] ; then
|
||||
mkdir -p save/mo_basis
|
||||
fi
|
||||
|
||||
BACKUP="${DESTINATION}.old"
|
||||
if [[ -d "${BACKUP}" ]]
|
||||
then
|
||||
if [[ -d "${BACKUP}" ]] ; then
|
||||
rm -rf "${BACKUP}"
|
||||
fi
|
||||
|
||||
if [[ -d "${DESTINATION}" ]]
|
||||
then
|
||||
if [[ -d "${DESTINATION}" ]] ; then
|
||||
mv "${DESTINATION}" "${BACKUP}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -226,3 +226,4 @@ BEGIN_PROVIDER [double precision, final_weight_at_r, (n_points_integration_angul
|
|||
enddo
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user