10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-02 11:25:26 +02:00

Cleaning in scripts

This commit is contained in:
Anthony Scemama 2019-01-14 15:20:51 +01:00
parent 218ccae739
commit 316fb508d5
284 changed files with 5397 additions and 5289 deletions

125
configure vendored
View File

@ -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 "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

View File

@ -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 <file.out> [-o EZFIO_DIR]
.. option:: -o <EZFIO_DIRECTORY>
.. option:: -o, --output=EZFIO_DIR
Renames the |EZFIO| directory. If this option is not present, the default
Renames the |EZFIO| directory. If this option is not present, the default
name fill be :file:`<FILE.out>.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
-------

View File

@ -14,11 +14,20 @@ 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]
.. option:: -b <basis_name>
Flags :
[-a|--au] [-b string|--basis=string]
[-c int|--charge=int] [-d float|--dummy=float] [-h|--help]
[-m int|--multiplicity=int] [-o file|--output=file]
[-p string|--pseudo=string] [-x|--cartesian]
.. 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
@ -30,37 +39,39 @@ Usage
By default, the basis set is obtained from the local database of the |qp|.
.. 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 +84,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 +132,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

View File

@ -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,34 @@ Usage
.. code:: bash
qp_edit [FLAGS] <EZFIO_DIRECTORY>
Flags :
[-c] [-ndet int]
[-state int] [-help]
qp_edit [-c|--check] [-h|--help] [-n <int>|--ndet=<int>]
[-s <range>|--state=<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.

View File

@ -4,19 +4,24 @@ 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

View File

@ -6,38 +6,38 @@ 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, --installed | -u, --uninstalled | -q, --repositories ]
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, --repository=<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.
.. option:: download <url>
.. option:: download URL
Download an external repository. The URL points to a tar.gz file or a
git repository, for example:
@ -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.

View File

@ -1,5 +1,6 @@
.. _qp_run:
======
qp_run
======

35
etc/configure.rc Normal file
View 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

View File

@ -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
}
source ${QP_ROOT}/etc/autocomplete.rc
source_if_exists "${QP_EZFIO}/Bash/ezfio.sh"

View File

@ -8,14 +8,11 @@ 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
source $1
fi
}
source ${QP_ROOT}/etc/autocomplete.rc
source_if_exists "${IRPF90_PATH}/irpman-completions.bash"

View File

@ -122,7 +122,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 =
@ -667,13 +667,13 @@ Otherwise, the basis set is obtained from the database.
" |> Command_line.set_header_doc ;
[ ( 'o', "output", "file Name of the created EZFIO file.", Command_line.With_arg) ;
( 'b', "basis", "string Name of basis set.", Command_line.With_arg) ;
[ ( '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);
( '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."
]

0
scripts/generate_h_apply.py Executable file → Normal file
View File

View 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,8 +38,7 @@ do
atoms+="--atom ${atom} "
done
if [[ $? -ne 0 ]]
then
if [[ $? -ne 0 ]] ; then
echo "==================================================" 1>& 2
echo "Unable to create temporary file $tmpfile" 1>& 2
echo "==================================================" 1>& 2
@ -46,4 +46,5 @@ then
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
View File

0
scripts/qp_bitmasks.py Executable file → Normal file
View File

View 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|--output=EZFIO_DIR] <file.out>
Options:
-o EZFIO_FILE --output=EZFIO_FILE Produced directory
by default is file.out.ezfio
-o EZFIO_DIR --output=EZFIO_DIR Produced directory
by default is file.out.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.out>'])
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)."""

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,10 @@
#!/bin/bash
function error() {
>&2 echo "$(basename $0): $@"
exit 2
}
set -e
NODES=($(mpirun hostname))
@ -7,9 +12,8 @@ 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,8 +24,8 @@ In your SLURM script file, use:
#SBATCH --ntasks-per-node=1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
exit -1
"
exit -1
fi
PROG=$1
@ -29,8 +33,7 @@ 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 +43,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 +67,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

View File

@ -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)

View File

@ -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,36 +90,40 @@ 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" ] ]
l_result = [f for f in os.path.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"]:
# 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.path.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 ]
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 ]
l_result = [f for f in l_plugins if f not in l_installed]
for module in sorted(l_result):
print "* {0}".format(module)
@ -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)
@ -271,7 +269,9 @@ def main(arguments):
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)

View File

@ -16,32 +16,31 @@ Usage:
qp_set_frozen_core [-q|--query] <EZFIO_DIRECTORY>
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>"]
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)

View File

@ -1,5 +1,10 @@
#!/bin/bash
function error() {
>&2 echo "$(basename $0): $@"
exit 2
}
set -e
NODES=($(srun hostname))
@ -7,9 +12,8 @@ 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,8 +24,8 @@ In your SLURM script file, use:
#SBATCH --ntasks-per-node=1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
exit -1
"
exit -1
fi
PROG=$1
@ -29,8 +33,7 @@ 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 +43,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 +71,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

View File

@ -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)

16
scripts/remove_trailing_spaces Executable file
View 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

View File

@ -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

View File

@ -226,3 +226,4 @@ BEGIN_PROVIDER [double precision, final_weight_at_r, (n_points_integration_angul
enddo
END_PROVIDER