forked from ComputationalRadiationPhysics/picongpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createParameterSet
executable file
·152 lines (134 loc) · 3.95 KB
/
createParameterSet
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
#!/bin/bash
#
# Copyright 2013 Axel Huebl, Rene Widera
#
# This file is part of PIConGPU.
#
# PIConGPU is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PIConGPU is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PIConGPU.
# If not, see <http://www.gnu.org/licenses/>.
#
this_dir=`dirname $0`
#only copy submit and params if we clone from default pic folder
default_folder_to_copy="submit include/simulation_defines/param include/simulation_defines/unitless"
#if we clone a project we copy full include
folder_to_clone="submit include"
files_to_copy="cmakeFlags executeOnClone"
help()
{
echo "createParameterSet create a new parameter set"
echo "merge default picongpu paramter and given src"
echo ""
echo "usage: createParameterSet [OPTION] [src_dir] dest_dir"
echo "If no src_dir is set picongpu a default case is cloned"
echo ""
echo "-f | --force - merge data if destination already exists"
echo "-h | --help - show this help message"
echo ""
echo "Dependencies: rsync"
}
force_param=0
# options may be followed by one colon to indicate they have a required argument
OPTS=`getopt -o fh -l force,help -- "$@"`
if [ $? != 0 ] ; then
# something went wrong, getopt will put out an error message for us
exit 1
fi
eval set -- "$OPTS"
while true ; do
case "$1" in
-f|--force)
force_param=1
;;
-h|--help)
echo -e "$(help)"
exit 1
;;
--) shift; break;;
esac
shift
done
cmake_path="$*"
default_param_dir="$this_dir/src/picongpu"
if [ $# -eq 0 ] || [ $# -gt 2 ] ; then
echo "Missing destination directory or to many directories were given." >&2
exit
fi
if [ $# -eq 2 ] ; then
src_path=$1
dst_path=$2
selected_default_folder_to_copy=$folder_to_clone
else
src_path=$this_dir
dst_path=$1
selected_default_folder_to_copy=$default_folder_to_copy
fi
if [ ! -d "$src_path" ] ; then
echo "$src_path not exists" >&2
fi
if [ -d "$src_path/src/picongpu" ] ; then
src_path="$src_path/src/picongpu"
fi
if [ -d "$dst_path" ] && [ "$force_param" -eq 0 ] ; then
echo "$dst_path already exists!" >&2
read -e -p "Merge data into $dst_path [yes|NO]? : " input
if [ -z "$input" ] ; then
input="NO"
fi
input=`echo "$input" | tr '[:upper:]' '[:lower:]'`
if [ $input != "yes" ] ; then
echo "Abortion!" >&2
exit
fi
else
if [ ! -d "$dst_path" ] ; then
mkdir -p "$dst_path"
fi
fi
#first copy default parameter
for d in $default_folder_to_copy
do
dir_dst="$dst_path/$d"
dir_src="$default_param_dir/$d"
if [ ! -d "$dir_dst" ] ; then
mkdir -p "$dir_dst"
fi
rsync --inplace -q -avc --exclude=".*" $dir_src/* $dir_dst
done
#copy all data from src_path if path is not picongpu default param path
if [ "$src_path" != "$this_dir/src/picongpu" ] ; then
for d in $selected_default_folder_to_copy
do
dir_dst="$dst_path/$d"
dir_src="$src_path/$d"
if [ ! -d "$dir_dst" ] ; then
mkdir -p "$dir_dst"
fi
rsync --inplace -q -avc --exclude=".*" $dir_src/* $dir_dst
done
fi
#copy files
for d in $files_to_copy
do
file_dst="$dst_path/$d"
file_src="$src_path/$d"
if [ ! -d "$dir_dst" ] ; then
mkdir -p "$dir_dst"
fi
if [ -f "$src_path/$d" ] ; then
rsync --inplace -q -avc --exclude=".*" $file_src $file_dst
fi
done
if [ -f "$src_path/executeOnClone" ] ; then
`sh $src_path/executeOnClone $dst_path`
fi