-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoinorb
More file actions
executable file
·42 lines (41 loc) · 889 Bytes
/
joinorb
File metadata and controls
executable file
·42 lines (41 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# join rows to get a matrix view
# for molcas files remove rows before and after orbitals
if [[ $# -lt 2 ]]; then
echo 'Usage: joinorb <orb-file> "<list of dimensions of each symmetry>"'
echo 'e.g., joinorb h2o.overlap "11 4 7 2"'
echo ' or, joinorb h2o.overlap "11A1 + 4B1 + 7B2 + 2A2"'
exit
fi
IFS=' ,+' read -ra DIMSRAW <<< "$2"
DIMSY=
for dim in "${DIMSRAW[@]}"; do
DIMSY="$DIMSY $(echo $dim | grep -oP "^\d*")"
done
awk -F"[, ]+" -v dimstr="$DIMSY" '
BEGIN {
ndim=split(dimstr,dims," ");
cdim=1;
nl=0;
len=0;
}
#non-empty with a number
(NF>0 && ($1 ~ /^[0-9eE\-\+\.]+$/ || ($1=="" && $2 ~ /^[0-9eE\-\+\.]+$/) ) ){
for(i=1;i<=NF;i++){
if ($i!="") {
len++;
printf "%s ", $i;
}
}
}
(len>=dims[cdim]) {
printf "\n";
nl++;
if(nl>=dims[cdim]) {
cdim++;
if (cdim>ndim) exit;
nl=0;
}
len=0
}
' "$1"