Skip to content

Commit 0f8bc74

Browse files
authored
Merge pull request #22 from polyluxus/devel_0.3.0
Upgrade to 0.3.0
2 parents 41f960d + 7523cbd commit 0f8bc74

5 files changed

Lines changed: 360 additions & 88 deletions

File tree

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ The following script options are available:
9191
This also requires setting a queueing system with `-Q` (see below).
9292
(configuration option `run_interactive=sub`).
9393
* `-Q <ARG>` Set a queueing system for which the submitscript should be prepared.
94-
Currently supported are `pbs-gen`, `bsub-gen`, and `bsub-rwth`
94+
Currently supported are `pbs-gen`, `slurm-gen`, `slurm-rwth`, `bsub-gen`, and `bsub-rwth`
9595
(configuration option `request_qsys=<ARG>`).
96+
The `*rwth` suffix will test a few more options and will set some constraints according to
97+
the recommendations of the RWTH IT centre.
9698
* `-P <ARG>` Account to project `<ARG>`, which will also (currently) trigger
9799
`-Q bsub-rwth` to be set. It will not trigger `-s`/`-S`.
98100
* `-M` Use preinstalled modules instead of paths.
@@ -118,7 +120,8 @@ The following script options are available:
118120
If specified twice, it will also suppress warnings,
119121
if specified more than twice, it will suppress also errors.
120122
* `-h` Prints a small help text and current configuration.
121-
* `-H` Opens the `HOWTO` (manual) of the original distribution.
123+
* `-H` Retrieve the man page of xtb of the original distribution.
124+
* `-X` Retrieve the man page of xcontrol of the original distribution.
122125

123126
## Included files
124127

@@ -128,16 +131,21 @@ The following files come with this script:
128131
* `runxtb.rc` An example set-up file.
129132
* `xtb.dummy` A tiny bash script only for testing.
130133
This will only echo `<coord_file> [options]` verbatim.
134+
* `crest.prepare.sh` A small script that creates a new directory
135+
with a suitable `coord` file to start a `crest` run.
131136
* `README.md` This file.
132137
* `configure` A directury containing a script to configure the wrapper.
133138

134139
## Exit status
135140

136-
The script carries over the exit statusses of its dependencies.
141+
The script `runxtb` carries over the exit statusses of its dependencies.
137142
In interactive mode that is the exit status of `xtb`.
138-
In submission mode it is the exit status of `qsub` or `bsub`.
143+
In submission mode it is the exit status of `qsub`, `bsub`, or `sbatch`.
139144
In all other cases it will be `0` if everything went according to plan,
140145
or `1` if there was a problem.
146+
The script `crest.prepare.sh` will exit with `0` if nothing went wrong
147+
and a crest run can be started. If files are not present, or I/O operations
148+
fail it will exit with `1`.
141149
The dummy script `xtb.dummy` always exits with `2`.
142150

143151
## Debug
@@ -154,4 +162,4 @@ please include the debug output when submitting a bug report to the
154162
[GitHub issue tracker](https://github.com/polyluxus/runxtb.bash/issues).
155163

156164

157-
(Martin; 2019-02-14; wrapper version 0.2.1)
165+
(Martin; 2019-03-18; wrapper version 0.3.0)

configure/configure.sh

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ warning ()
1717
return 1
1818
}
1919

20+
fatal ()
21+
{
22+
echo "ERROR : $*" >&2
23+
exit 1
24+
}
25+
2026
debug ()
2127
{
2228
echo "DEBUG : $*" >&4
@@ -224,6 +230,13 @@ recover_rc ()
224230
if read_boolean ; then ask_installation_path ; fi
225231
fi
226232
debug "use_xtbhome=$use_xtbhome; use_xtbname=$use_xtbname"
233+
if [[ -z $use_xtbname ]] ; then
234+
ask_callname
235+
else
236+
message "recovered setting 'xtb_callname=$use_xtbname'."
237+
ask "Would you like to change these settings?"
238+
if read_boolean ; then ask_callname ; fi
239+
fi
227240

228241
use_chatty="$stay_quiet"
229242
if [[ -z $use_chatty ]] ; then
@@ -256,20 +269,21 @@ recover_rc ()
256269
debug "use_interactivity=$use_interactivity"
257270

258271
use_queue="$request_qsys"
259-
use_bsub_project="$bsub_project"
272+
# Try to recover old vrsion where it was bsub_project
273+
use_qsys_project="${qsys_project:-$bsub_project}"
260274
if [[ -z $use_queue ]] ; then
261275
ask_qsys_details
262276
else
263277
message "Recovered queueing system setting 'request_qsys=$use_queue'."
264-
if [[ ! -z $use_bsub_project ]] ; then
265-
message "Recovered project setting 'bsub_project=$bsub_project'."
278+
if [[ -n $use_qsys_project ]] ; then
279+
message "Recovered project setting 'qsys_project=$use_qsys_project'."
266280
ask "Would you like to change these settings?"
267281
else
268282
ask "Would you like to change this setting?"
269283
fi
270284
if read_boolean ; then ask_qsys_details ; fi
271285
fi
272-
debug "use_queue=$use_queue; use_bsub_project=$use_bsub_project"
286+
debug "use_queue=$use_queue; use_qsys_project=$use_qsys_project"
273287

274288
use_module_system="$use_modules"
275289
use_module_items=( "${load_modules[@]}" )
@@ -329,7 +343,7 @@ read_boolean ()
329343
pattern_true_false="[Tt]([Rr]([Uu][Ee]?)?)?|[Ff]([Aa]([Ll]([Ss][Ee]?)?)?)?"
330344
pattern_yes_no="[Yy]([Ee][Ss]?)?|[Nn][Oo]?"
331345
pattern="($pattern_true_false|$pattern_yes_no|0|1)"
332-
until [[ $readvar =~ ^[[:space:]]*$pattern[[:space:]]*$ ]] ; do
346+
until [[ $readvar =~ ^[[:space:]]*${pattern}[[:space:]]*$ ]] ; do
333347
message "Please enter t(rue)/y(es)/1 or f(alse)/n(o)/0."
334348
echo -n "Answer : " >&3
335349
read -r readvar
@@ -397,6 +411,13 @@ ask_installation_path ()
397411
debug "use_xtbname=$use_xtbname"
398412
}
399413

414+
ask_callname ()
415+
{
416+
ask "What is the name of the xtb binary?"
417+
use_xtbname="$(read_human_input)"
418+
debug "use_xtbname=$use_xtbname"
419+
}
420+
400421
ask_modules ()
401422
{
402423
ask "If a modular cluster management is available, do you want to use it?"
@@ -453,7 +474,7 @@ ask_interactivity ()
453474

454475
ask_qsys_details ()
455476
{
456-
message "Currently supported: pbs-gen, bsub-gen, bsub-rwth"
477+
message "Currently supported: pbs-gen, bsub-gen, slurm-gen, bsub-rwth, slurm-rwth"
457478
local test_queue
458479
test_queue=$(read_human_input)
459480
debug "test_queue=$test_queue"
@@ -464,11 +485,17 @@ ask_qsys_details ()
464485
[Bb][Ss][Uu][Bb]* )
465486
use_queue="bsub-gen"
466487
ask "What project would you like to specify?"
467-
use_bsub_project=$(read_human_input)
468-
debug "use_bsub_project=$use_bsub_project"
488+
use_qsys_project=$(read_human_input)
489+
debug "use_qsys_project=$use_qsys_project"
490+
;;&
491+
[Ss][Ll][Uu][Rr][Mm]* )
492+
use_queue="slurm-gen"
493+
ask "What project would you like to specify?"
494+
use_qsys_project=$(read_human_input)
495+
debug "use_qsys_project=$use_qsys_project"
469496
;;&
470497
*[Rr][Ww][Tt][Hh] )
471-
use_queue="bsub-rwth"
498+
use_queue="${use_queue%-*}-rwth"
472499
;;
473500
'' )
474501
: ;;
@@ -635,7 +662,7 @@ print_settings ()
635662
echo "###"
636663

637664
echo "## Set default queueing system for which the script should be written"
638-
echo "## (pbs-gen, bsub-gen, or bsub-rwth [special case, see source])"
665+
echo "## (pbs-gen, bsub-gen, slurm-gen, or *-rwth [special cases, see source])"
639666
echo "# "
640667
if [[ -z $use_queue ]] ; then
641668
echo "# request_qsys=\"bsub-rwth\""
@@ -645,14 +672,14 @@ print_settings ()
645672
echo "# "
646673
echo "###"
647674

648-
echo "## If project options are enabled (e.g. for bsub-rwth), "
649-
echo "## set to which it should be accounted."
675+
echo "## If project/ account options are enabled (e.g. for bsub-rwth), "
676+
echo "## set the name to which it should be accounted to."
650677
echo "## This can be overwritten with -P0 or -P default."
651678
echo "#"
652-
if [[ -z $use_bsub_project ]] ; then
653-
echo "# bsub_project=\"default\""
679+
if [[ -z $use_qsys_project ]] ; then
680+
echo "# qsys_project=\"default\""
654681
else
655-
echo " bsub_project=\"$use_bsub_project\""
682+
echo " qsys_project=\"$use_qsys_project\""
656683
fi
657684
echo "# "
658685
echo "###"
@@ -702,21 +729,25 @@ print_settings ()
702729

703730
create_bin_link ()
704731
{
705-
local link_target_path="$HOME/bin"
706-
local link_target_name="runxtb"
707-
local link_target="$link_target_path/$link_target_name"
732+
local link_target_path="$HOME/bin"
733+
local link_target_name link_target link_source
708734

735+
for link_target_name in "runxtb" "crest.prepare" ; do
736+
link_target="$link_target_path/$link_target_name"
737+
link_source="$runxtbrc_path/${link_target_name}.sh"
709738
if [[ -e "$link_target" ]] ; then
710739
debug "Link '$link_target' does already exist."
740+
continue
711741
else
712742
ask "Would you like to create a symbolic link '$link_target'?"
713743
if read_boolean ; then
714744
[[ -r "$link_target_path" ]] || fatal "Cannot read '$link_target_path'."
715745
[[ -w "$link_target_path" ]] || fatal "Cannot write to '$link_target_path'."
716-
[[ -x "$runxtbrc_path/runxtb.sh" ]] || fatal "Not executable: '$runxtbrc_path/runxtb.sh'."
717-
message "$(ln -vs "$runxtbrc_path/runxtb.sh" "$link_target")"
746+
[[ -x "$link_source" ]] || fatal "Not executable: '$link_source'."
747+
message "$( ln -vs "$link_source" "$link_target" )"
718748
fi
719749
fi
750+
done
720751
}
721752

722753
#

crest.prepare.sh

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
#!/bin/bash
2+
#hlp ===== Not Part of xTB =====
3+
#hlp DESCRIPTION:
4+
#hlp This is a little helper script to set up a crest (via xTB) calculation.
5+
#hlp
6+
#hlp It basically creates a directory (optional) with a molecular
7+
#hlp structure in turbomole format called 'coord'.
8+
#hlp Script requires Open Babel.
9+
#hlp
10+
#hlp USAGE:
11+
#hlp ${0##*} [script options]
12+
#hlp
13+
14+
#
15+
# Print logging information and warnings nicely.
16+
# If there is an unrecoverable error: display a message and exit.
17+
#
18+
19+
message ()
20+
{
21+
if (( stay_quiet <= 0 )) ; then
22+
echo "INFO : " "$*" >&3
23+
else
24+
debug "(info ) " "$*"
25+
fi
26+
}
27+
28+
warning ()
29+
{
30+
if (( stay_quiet <= 1 )) ; then
31+
echo "WARNING: " "$*" >&2
32+
else
33+
debug "(warning) " "$*"
34+
fi
35+
return 1
36+
}
37+
38+
fatal ()
39+
{
40+
exit_status=1
41+
if (( stay_quiet <= 2 )) ; then
42+
echo "ERROR : " "$*" >&2
43+
else
44+
debug "(error ) " "$*"
45+
fi
46+
exit "$exit_status"
47+
}
48+
49+
debug ()
50+
{
51+
echo "DEBUG : (${FUNCNAME[1]})" "$*" >&4
52+
}
53+
54+
#
55+
# Print some helping commands
56+
# The lines are distributed throughout the script and grepped for
57+
#
58+
59+
helpme ()
60+
{
61+
local line
62+
local pattern="^[[:space:]]*#hlp[[:space:]]?(.*)?$"
63+
while read -r line; do
64+
[[ "$line" =~ $pattern ]] && eval "echo \"${BASH_REMATCH[1]}\""
65+
done < <(grep "#hlp" "$0")
66+
exit 0
67+
}
68+
69+
backup_if_exists ()
70+
{
71+
local move_source="$1"
72+
# File does not exist, then everithing is fine, return with status 0
73+
[[ -f "$move_source" ]] || return 0
74+
# File exists, print a warning
75+
warning "File '$move_source' already exists."
76+
# make a backup
77+
# (test default name first, if that exists, relegate to tool)
78+
local move_target="${move_source}.bak"
79+
[[ -f "$move_target" ]] && move_target=$( mktemp "${move_target}.XXXX" )
80+
# if moving failed for whatever reason, return with status 1
81+
message "Create backup: $( mv -v -- "$move_source" "$move_target" 2>&1 )" || return 1
82+
}
83+
84+
###
85+
#
86+
# MAIN
87+
#
88+
###
89+
90+
exec 3>&1
91+
92+
if [[ "$1" == "debug" ]] ; then
93+
# Secret debugging switch
94+
exec 4>&1
95+
shift
96+
else
97+
exec 4> /dev/null
98+
fi
99+
100+
101+
# Initialise Variables
102+
stay_quiet="0"
103+
OPTIND=1
104+
105+
while getopts :d:qh options ; do
106+
case $options in
107+
#hlp OPTIONS:
108+
#hlp
109+
#hlp -d <ARG> Use <ARG> as directory name to set up. [Default: crest]
110+
#hlp If <ARG> is '.', then skip creating a directory,
111+
#hlp instead convert a found '*.xyz' to 'coord', or
112+
#hlp rename existing 'xtbopt.coord' to 'coord'.
113+
d)
114+
crest_dir="$OPTARG"
115+
;;
116+
#hlp -q Stay quiet! (Only this startup script)
117+
#hlp May be specified multiple times to be more forceful.
118+
q)
119+
(( stay_quiet++ ))
120+
;;
121+
#hlp -h Prints this help text
122+
h)
123+
helpme
124+
;;
125+
\?)
126+
fatal "Invalid option: -$OPTARG."
127+
;;
128+
:)
129+
fatal "Option -$OPTARG requires an argument."
130+
;;
131+
132+
esac
133+
done
134+
135+
crest_dir="${crest_dir:-crest}"
136+
if [[ "$crest_dir" != '.' ]] ; then
137+
[[ -d "$crest_dir" ]] && fatal "Directory exists: $crest_dir"
138+
message "$( mkdir -v -- "$crest_dir" )" || fatal "Failed to create '$crest_dir'."
139+
else
140+
debug "Target directory is '$crest_dir'."
141+
fi
142+
143+
if [[ -r "xtbopt.xyz" ]] ; then
144+
obabel_cmd="$( command -v obabel )" || fatal "Command not found: obabel"
145+
backup_if_exists "$crest_dir/coord"
146+
message "$( "$obabel_cmd" -ixyz "xtbopt.xyz" -oTmol -O"$crest_dir/coord" 2>&1 )" || fatal "Failure in Open Babel."
147+
elif [[ -r "xtbopt.coord" ]] ; then
148+
message "Found optimised molecular structure in turbomole format."
149+
backup_if_exists "$crest_dir/coord"
150+
message "$( cp -v -- "xtbopt.coord" "$crest_dir/coord" )"
151+
else
152+
warning "No optimised molecular structure found in current directory."
153+
for structure_file in "coord" *.xyz ; do
154+
if [[ -r "$structure_file" ]] ; then
155+
message "Will use molecular structure in '$structure_file' instead."
156+
if [[ "$structure_file" == "coord" ]] ; then
157+
[[ "$crest_dir" == '.' ]] && fatal "'$structure_file' and '$crest_dir/coord' are the same file."
158+
message "$( cp -v -- "$structure_file" "$crest_dir/coord" )"
159+
break
160+
else
161+
obabel_cmd="$( command -v obabel )" || fatal "Command not found: obabel"
162+
backup_if_exists "$crest_dir/coord"
163+
message "$( "$obabel_cmd" -ixyz "$structure_file" -oTmol -O"$crest_dir/coord" 2>&1 )" || fatal "Failure in Open Babel."
164+
break
165+
fi
166+
fi
167+
done
168+
fi
169+
170+
if [[ -r ".UHF" ]] ; then
171+
message "$( cp -v -- ".UHF" "$crest_dir/.UHF" )"
172+
fi
173+
174+
if [[ -r ".CHRG" ]] ; then
175+
message "$( cp -v -- ".CHRG" "$crest_dir/.CHRG" )"
176+
fi
177+
178+
debug "Content of created directory: $( ls -lah "$crest_dir" )"
179+
message "All Done: ${0##*/}."
180+

0 commit comments

Comments
 (0)