forked from Expander/FlexibleSUSY
/
createmodel
executable file
·196 lines (163 loc) · 6.44 KB
/
createmodel
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/sh
# configure script for FlexibleSUSY
# Author: Alexander Voigt
# directory of this script
BASEDIR=$(dirname $0)
overwrite="no"
model_file=""
name=""
sarah_model=""
# exit codes
exit_ok="0"
exit_syntax_error="1"
exit_model_dir_exists="2"
exit_no_default_model="3"
#_____________________________________________________________________
find_default_model_files() {
# searches for FlexibleSUSY.m.in files within the model_files/
# directory. If a FlexibleSUSY.m.in was found, the corresponding
# model name will be stored in the variable $default_models .
default_models="`find ${BASEDIR}/model_files/ -mindepth 2 -type f -name FlexibleSUSY.m.in -printf '%h\n' | awk -F / '{ print $NF }' | tr '\n' ' ' | sort -u`"
}
#_____________________________________________________________________
help() {
find_default_model_files
local available_default_model_files="${default_models}"
cat <<EOF
Usage: ./`basename $0` [options] --name=<model-name>
Options:
--name= Name of the FlexibleSUSY model.
Example: --name=MyMSSM
--model-file= Name of the model whose FlexibleSUSY model file
should be used. If empty, it will be searched for
model_files/<model-name>/FlexibleSUSY.m.in , where
<model-name> is the name of the FlexibleSUSY model
given by --name= . If no such model file can be found,
the MSSM model file is used. All FlexibleSUSY
model files are stored in model_files/ .
Available models are: ${available_default_model_files}
--sarah-model= Name of the SARAH model, used in SARAH\`Start[].
If empty, the value given by --name= is used.
A sub-model can be specified after a /
Syntax: <sarah-model>[/<sub-model>]
Example: --sarah-model=MSSM/CKM
--force,-f Overwrite existing model files.
--help,-h Print this help message.
Examples:
Create a FlexibleSUSY model for the E6SSM:
./createmodel --name=E6SSM
Create a new FlexibleSUSY model named MyMSSM, using the FlexibleSUSY
model file model_files/NUHMSSM/FlexibleSUSY.m.in and using the MSSM
as underlying SARAH model (SARAH\`Start["MSSM"]).
./createmodel --name=MyMSSM --model-file=NUHMSSM --sarah-model=MSSM
EOF
}
if test $# -lt 1 ; then
echo "Error: Too few arguments"
help
exit ${exit_syntax_error}
fi
if test $# -gt 0 ; then
while test ! "x$1" = "x" ; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--force|-f) overwrite="yes" ;;
--help|-h) help; exit ${exit_ok} ;;
--model-file=*) model_file="$optarg" ;;
--name=*) name="$optarg" ;;
--sarah-model=*) sarah_model="$optarg" ;;
*) echo "Invalid option '$1'. Try $0 --help" ; exit ${exit_syntax_error} ;;
esac
shift
done
fi
if [ -z "$name" ] ; then
echo "Error: no model specified!"
help
exit ${exit_syntax_error}
fi
sub_model=$(echo $sarah_model | awk -F / '{ if (NF > 1) print $NF }')
sarah_model=$(echo $sarah_model | awk -F / '{ print $1 }')
if [ -z "$sarah_model" ]; then
sarah_model="$name"
fi
# create target directory name
targetdir="models/${name}"
if test -d "$targetdir" -a "x$overwrite" = "xno" ; then
echo "Error: directory $targetdir already exists!"
echo "Please chose another model name or use the --force option."
echo "See ./`basename $0` --help for more information."
exit ${exit_model_dir_exists}
fi
if [ -n "$sub_model" ]; then
echo "creating model $name (SARAH model: $sarah_model, sub-model: $sub_model)"
else
echo "creating model $name (SARAH model: $sarah_model)"
fi
# check if we provide a FlexibleSUSY model file for the given model
# name
model_file_dir="model_files"
if [ -n "$model_file" ]; then
printf " searching for ${model_file} model file ... "
if test -d "$model_file_dir/$model_file"; then
model_file_dir="$model_file_dir/$model_file"
printf "found in ${model_file_dir}/\n"
else
printf "not found in ${model_file_dir}/${model_file}\n"
echo "Error: There is no default model file for the ${model_file}!"
echo " You can create one via"
echo ""
echo " \$ mkdir ${model_file_dir}/${model_file}"
echo " \$ cp ${model_file_dir}/FlexibleSUSY.m.in ${model_file_dir}/${model_file}/"
exit ${exit_no_default_model}
fi
else
# if the user has no default model file specified, we check if one
# exists in model_files/$name/
if test -r "$model_file_dir/$name/FlexibleSUSY.m.in"; then
model_file_dir="$model_file_dir/$name"
fi
printf " using default model file ${model_file_dir}/FlexibleSUSY.m.in\n"
fi
if test ! -d "$targetdir" ; then
printf " creating model directory %s ... " "$targetdir"
mkdir $targetdir
echo "done"
fi
set -- $(find $model_file_dir -maxdepth 0 -type f -iname LesHouches.in\* -printf " %f")
SLHA_input_files="$*"
SLHA_input_files_in_mk=$(echo "$SLHA_input_files" |
sed 's/ / \\\\\\n/g;
s,\(^\|\\n\)\(.\),\1 $(DIR)/\2,g')
printf " creating Makefile module %s/module.mk ... " "$targetdir"
sed -e "s|@DIR@|$targetdir|g" \
-e "s|@MODEL@|$sarah_model|g" \
-e "s|@CLASSNAME@|$name|g" \
-e "s|@SLHA_INPUT@|$SLHA_input_files_in_mk|g" \
< templates/module.mk.in > $targetdir/module.mk
echo "done"
printf " creating start script %s/start.m ... " "$targetdir"
sub_model_replacement=""
if [ -n "$sub_model" ]; then
sub_model_replacement=", \"$sub_model\""
fi
sed -e "s|@DIR@|$targetdir|g" \
-e "s|@ModelName@|$sarah_model|g" \
-e "s|@SubModel@|$sub_model_replacement|g" \
-e "s|@CLASSNAME@|$name|g" \
< templates/start.m.in > $targetdir/start.m
echo "done"
printf " creating FlexibleSUSY model file %s/FlexibleSUSY.m ... " "$targetdir"
sed -e "s|@DIR@|$targetdir|g" \
-e "s|@ModelName@|$sarah_model|g" \
-e "s|@CLASSNAME@|$name|g" \
< $model_file_dir/FlexibleSUSY.m.in > $targetdir/FlexibleSUSY.m
echo "done"
for slha_in in $SLHA_input_files; do
printf " creating SLHA input file %s/%s ... " "$targetdir" "$slha_in"
cp $model_file_dir/$slha_in $targetdir
echo "done"
done