mirror of
https://github.com/LCPQ/quantum_package
synced 2024-10-19 14:31:44 +02:00
Improved qp completion
This commit is contained in:
parent
cd7d0280d7
commit
1ed1733332
2
configure
vendored
2
configure
vendored
@ -70,7 +70,7 @@ while true : ; do
|
||||
exit 0;;
|
||||
--) shift ; break ;;
|
||||
*)
|
||||
error "unknown option $1, try --help"
|
||||
error $(basename $0)": unknown option $1, try --help"
|
||||
exit 2;;
|
||||
esac
|
||||
done
|
||||
|
@ -5,8 +5,8 @@ export QP_EZFIO=${QP_ROOT}/external/ezfio
|
||||
|
||||
function source_if_exists() {
|
||||
if [[ -f $1 ]]; then
|
||||
source $1
|
||||
fi
|
||||
cd $(dirname $1) ; source $(basename $1) ; cd -
|
||||
fi &> /dev/null
|
||||
}
|
||||
|
||||
source ${QP_ROOT}/etc/autocomplete.rc
|
||||
|
@ -8,10 +8,11 @@ export IRPF90=${IRPF90_PATH}/bin/irpf90
|
||||
|
||||
function source_if_exists() {
|
||||
if [[ -f $1 ]]; then
|
||||
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
|
||||
|
@ -8,6 +8,8 @@ let () =
|
||||
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";
|
||||
@ -25,8 +27,6 @@ let () =
|
||||
]
|
||||
|> set_specs ;
|
||||
|
||||
set_description_doc
|
||||
"Opens a text editor to edit the parameters of a EZFIO directory.";
|
||||
end;
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -7,6 +7,15 @@ function error() {
|
||||
|
||||
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
|
||||
@ -28,8 +37,7 @@ In your SLURM script file, use:
|
||||
exit -1
|
||||
fi
|
||||
|
||||
PROG=$1
|
||||
INPUT=$2
|
||||
|
||||
|
||||
# Check if quantum_package.rc is sourced
|
||||
|
||||
|
@ -94,8 +94,8 @@ def main(arguments):
|
||||
arguments["<name>"] = [os.path.normpath(name) for name in arguments["<name>"]]
|
||||
|
||||
if arguments["list"]:
|
||||
if arguments["-q"]:
|
||||
l_result = [f for f in os.path.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
|
||||
@ -113,20 +113,20 @@ def main(arguments):
|
||||
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 os.path.listdir(QP_SRC) \
|
||||
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"]:
|
||||
if arguments["--installed"]:
|
||||
l_result = [f for f in l_plugins if f in l_installed]
|
||||
|
||||
elif arguments["-u"]:
|
||||
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])
|
||||
@ -135,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"
|
||||
|
||||
@ -266,7 +266,7 @@ 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 + \
|
||||
|
@ -7,6 +7,15 @@ function error() {
|
||||
|
||||
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
|
||||
@ -28,8 +37,6 @@ In your SLURM script file, use:
|
||||
exit -1
|
||||
fi
|
||||
|
||||
PROG=$1
|
||||
INPUT=$2
|
||||
|
||||
# Check if quantum_package.rc is sourced
|
||||
|
||||
|
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user