-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun_fde.sh
60 lines (47 loc) · 1.55 KB
/
run_fde.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Michael Nickerson 2022-07-27
# Run small Lumerical FDE job on a Linux machine, to be used with remote dispatch
# Input: lms file with FDE simulation
# Set REFRESH=1 to refresh/regenerate lms file before execution; useful when working with disparate versions
## Variable definitions
export EXECDIR=~/lumerical/tmp/
# Performance and path definitions
THREADS=16 # Default
CAD="/opt/lumerical/v222/bin/mode-solutions-app"
ENG="/opt/lumerical/v222/bin/fd-engine"
LSFREFRESH="~/lumerical/refresh.lsf"
NICE="nice -n 15"
XVNC="~/lumerical/xvnc-run -a"
## Process input
# Get full path of input and verify existence
INPUT="$( readlink -f "$1" )"
BASENAME="$( basename "$INPUT" )"
cd $EXECDIR || exit 1
[[ -f "$INPUT" ]] || {
echo "'$1' not found, skipping"
exit 1
}
[[ "${INPUT##*.}" == "lms" ]] || {
echo "'$INPUT' not a .lms file, aborting"
exit 1
}
# Possibly refresh/regenerate the lms file
[[ "$REFRESH" -eq 1 ]] && {
# Make temporary refresh script
TMPSCRIPT="${INPUT/.lms/_refresh_$RANDOM.lsf}"
sed "s#<infile>#${INPUT}#" "$LSFREFRESH" > "$TMPSCRIPT"
# Load and refresh file with CAD to avoid cross-version bugs
printf "Refreshing %s to avoid cross-version bugs..." $BASENAME
$NICE $XVNC $CAD -nw -run "$TMPSCRIPT" -exit
rm "$TMPSCRIPT"
printf " done\n"
}
## Run job
echo "Running $(basename $ENG) on $BASENAME..."
$NICE $ENG -t $THREADS \"$INPUT\" || {
echo "Error processing $BASENAME, aborting"
exit 1
}
echo "Processed $BASENAME"
rm "${INPUT/.lms/_p0.log}" # Remove engine log file
echo "Work on $BASENAME complete!"