Newer
Older
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
## =============================================================================
## Simple script to output a unified file name based on a set of data options
## Note: this file name will not have an extension, as it is mean to be used as
## a file name root.
function print_the_help {
echo "USAGE: print_fname [arguments]"
echo "REQUIRED ARGUMENTS:"
echo " --ebeam Electron beam energy"
echo " --pbeam Ion beam energy"
echo " --config Generator configuration identifier"
echo " --type What type of output file is this? (e.g. sim, rec, ...)"
echo "OPTIONAL ARGUMENTS:"
echo " --decay Specific decay particle (if applicable)."
echo " -h,--help Print this message"
echo ""
echo " This script will generate a unique file name for the benchmark output."
exit
}
## =============================================================================
## Process the command line arguments
## Required variables
EBEAM=
PBEAM=
CONFIG=
TYPE=
## Optional variables
DECAY=
while [ $# -gt 0 ]; do
key=$1
case $key in
--ebeam)
EBEAM="$2"
shift
shift
;;
--pbeam)
PBEAM="$2"
shift
shift
;;
--config)
CONFIG="$2"
shift
shift
;;
--type)
TYPE="$2"
shift
shift
;;
--decay)
DECAY="$2"
shift
shift
;;
-h|--help)
print_the_help
exit 0
;;
*)
echo "Unknown option $key to print_fname, aborting..."
exit 1
esac
done
if [ -z $EBEAM ]; then
echo "EBEAM not defined in print_fname, aborting..."
print_the_help
exit 1
elif [ -z $PBEAM ]; then
echo "PBEAM not defined in print_fname, aborting..."
print_the_help
exit 1
elif [ -z $CONFIG ]; then
echo "CONFIG not defined in print_fname, aborting..."
print_the_help
exit 1
elif [ -z $TYPE ]; then
echo "TYPE not defined in print_fname, aborting..."
print_the_help
exit 1
fi
## =============================================================================
## Generate a unique identifier based on the configuration arguments
## Add decay info to CONFIG if requested
if [ ! -z $DECAY ]; then
CONFIG=${CONFIG}_${DECAY}
fi
echo "${TYPE}-${CONFIG}-${EBEAM}on${PBEAM}"
## all done.