1 | #!/bin/ksh |
---|
2 | # $Id$ |
---|
3 | ###################################################### |
---|
4 | # Author : Rachid benshila for NEMO team |
---|
5 | # Contact : nemo_st@lodyc.jussieu.fr |
---|
6 | # |
---|
7 | # This script aims to create the OPA/WORK directory |
---|
8 | # and to link in the WORK the BB_make and BB_make.ldef |
---|
9 | # associated to a chosen configuration |
---|
10 | # |
---|
11 | ###################################################### |
---|
12 | d_n=$(dirname $0); b_n=$(basename $0); |
---|
13 | |
---|
14 | #set -xv |
---|
15 | |
---|
16 | #- Saisie et validation des options |
---|
17 | x_d=""; |
---|
18 | x_n=""; |
---|
19 | x_r=""; |
---|
20 | while getopts :hld:n:r: V |
---|
21 | do |
---|
22 | case $V in |
---|
23 | (h) echo "Usage : "${b_n} \ |
---|
24 | " [-h] [-l] [-d] [-p r] [-t h] "; |
---|
25 | echo " -h : help"; |
---|
26 | echo " -l : list existing configurations"; |
---|
27 | echo " -n name : config name"; |
---|
28 | echo " -d dir : choose directories"; |
---|
29 | echo ""; |
---|
30 | echo "Example to install a new configuration MY_CONFIG"; |
---|
31 | echo "with OPA_SRC and ICE_SRC "; |
---|
32 | echo "use_cfg -n MY_CONFIG -d \"OPA_SRC ICE_SRC\""; |
---|
33 | echo ""; |
---|
34 | # echo "Defaults : "; |
---|
35 | echo ""; |
---|
36 | exit 0;; |
---|
37 | (d) x_d=${OPTARG};; |
---|
38 | (n) x_n=${OPTARG};; |
---|
39 | (r) x_r=${OPTARG};; |
---|
40 | (l) cat ${d_n}/cfg.txt; exit;; |
---|
41 | (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; |
---|
42 | exit 2;; |
---|
43 | (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; |
---|
44 | exit 2;; |
---|
45 | esac |
---|
46 | done |
---|
47 | shift $(($OPTIND-1)); |
---|
48 | |
---|
49 | #- Some tests --- |
---|
50 | m_n=${x_n} |
---|
51 | |
---|
52 | if [ ${#x_n} -eq 0 ]; then |
---|
53 | echo "Warning" |
---|
54 | echo "No configuration specified" |
---|
55 | echo "use_cfg -h for help" |
---|
56 | exit |
---|
57 | fi |
---|
58 | |
---|
59 | cat ${d_n}/cfg.txt | grep ${m_n} > ${d_n}/cfg.tmp |
---|
60 | read CONFIG TAB[0] TAB[1] TAB[2] TAB[3] TAB[4] TAB[5] < ${d_n}/cfg.tmp |
---|
61 | \rm ${d_n}/cfg.tmp |
---|
62 | |
---|
63 | if [ ${#CONFIG} -eq 0 ] ; then |
---|
64 | if [ ${#x_d} -eq 0 ] ; then |
---|
65 | |
---|
66 | echo "You are installing a new configuration" |
---|
67 | echo -n " OPA_SRC [Y/n] " |
---|
68 | read answer |
---|
69 | answer=`echo $answer | sed 's/^[yY].*$/y/'` |
---|
70 | if [ -z "$answer" -o "x$answer" = "xy" ]; then |
---|
71 | TAB[1]=OPA_SRC |
---|
72 | echo " OPA_SRC selected " |
---|
73 | echo " " |
---|
74 | else |
---|
75 | echo " OPA_SRC Not selected " |
---|
76 | echo " " |
---|
77 | fi |
---|
78 | unset answer |
---|
79 | echo -n " LIM_SRC_2 [Y/n] " |
---|
80 | read answer |
---|
81 | answer=`echo $answer | sed 's/^[yY].*$/y/'` |
---|
82 | if [ -z "$answer" -o "x$answer" = "xy" ]; then |
---|
83 | TAB[2]=LIM_SRC_2 |
---|
84 | echo " LIM_SRC_2 selected " |
---|
85 | echo " " |
---|
86 | else |
---|
87 | echo " LIM_SRC_2 Not selected " |
---|
88 | echo " " |
---|
89 | fi |
---|
90 | unset answer |
---|
91 | echo -n " LIM_SRC_3 [Y/n] " |
---|
92 | read answer |
---|
93 | answer=`echo $answer | sed 's/^[yY].*$/y/'` |
---|
94 | if [ -z "$answer" -o "x$answer" = "xy" ]; then |
---|
95 | TAB[2]=LIM_SRC_3 |
---|
96 | echo " LIM_SRC_3 selected " |
---|
97 | echo " " |
---|
98 | else |
---|
99 | echo " LIM_SRC_3 Not selected " |
---|
100 | echo " " |
---|
101 | fi |
---|
102 | unset answer |
---|
103 | echo -n " TOP_SRC [Y/n] " |
---|
104 | read answer |
---|
105 | answer=`echo $answer | sed 's/^[yY].*$/y/'` |
---|
106 | if [ -z "$answer" -o "x$answer" = "xy" ]; then |
---|
107 | TAB[3]=TOP_SRC |
---|
108 | echo " TOP_SRC selected " |
---|
109 | echo " " |
---|
110 | else |
---|
111 | echo " TOP_SRC Not selected " |
---|
112 | echo " " |
---|
113 | fi |
---|
114 | unset answer |
---|
115 | echo -n " C1D_SRC [Y/n] " |
---|
116 | read answer |
---|
117 | answer=`echo $answer | sed 's/^[yY].*$/y/'` |
---|
118 | if [ -z "$answer" -o "x$answer" = "xy" ]; then |
---|
119 | TAB[4]=C1D_SRC |
---|
120 | echo " C1D_SRC selected " |
---|
121 | echo " " |
---|
122 | else |
---|
123 | echo " C1D_SRC Not selected " |
---|
124 | echo " " |
---|
125 | fi |
---|
126 | unset answer |
---|
127 | echo -n " NST_SRC [Y/n] " |
---|
128 | read answer |
---|
129 | answer=`echo $answer | sed 's/^[yY].*$/y/'` |
---|
130 | if [ -z "$answer" -o "x$answer" = "xy" ]; then |
---|
131 | TAB[5]=NST_SRC |
---|
132 | echo " NST_SRC selected " |
---|
133 | echo " " |
---|
134 | else |
---|
135 | echo " NST_SRC Not selected " |
---|
136 | echo " " |
---|
137 | fi |
---|
138 | unset answer |
---|
139 | |
---|
140 | else |
---|
141 | set -A TAB ${x_d} |
---|
142 | fi |
---|
143 | print ${m_n} ${TAB[*]} >> ${d_n}/cfg.txt |
---|
144 | fi |
---|
145 | |
---|
146 | |
---|
147 | #- Create the config -- |
---|
148 | r_cfg='ORCA2_LIM' |
---|
149 | if [ ${#x_r} -ne 0 ]; then |
---|
150 | r_cfg=${x_r} |
---|
151 | fi |
---|
152 | |
---|
153 | if [ ! -d ${d_n}/../../config/${m_n} ]; then |
---|
154 | echo " The new configuration ${x_n} will be based on ${r_cfg} following files:" |
---|
155 | echo "`ls ../${r_cfg}/AA_make*` " |
---|
156 | echo "`ls ../${r_cfg}/scripts/BB_make*` " |
---|
157 | echo "`ls ../${r_cfg}/EXP00/*` " |
---|
158 | echo "`ls ../${r_cfg}/MY_SRC/*` " |
---|
159 | echo " " |
---|
160 | \mkdir ${d_n}/../../config/${m_n} |
---|
161 | \mkdir ${d_n}/../../config/${m_n}/scripts |
---|
162 | \mkdir ${d_n}/../../config/${m_n}/EXP00 |
---|
163 | \mkdir ${d_n}/../../config/${m_n}/MY_SRC |
---|
164 | \cp -R ${d_n}/../../config/${r_cfg}/AA_make ${d_n}/../../config/${m_n}/. |
---|
165 | \cp -R ${d_n}/../../config/${r_cfg}/AA_make.ldef ${d_n}/../../config/${m_n}/. |
---|
166 | \cp -R ${d_n}/../../config/${r_cfg}/scripts/BB_make ${d_n}/../../config/${m_n}/scripts/. |
---|
167 | \cp -R ${d_n}/../../config/${r_cfg}/scripts/BB_make.ldef ${d_n}/../../config/${m_n}/scripts/. |
---|
168 | \cp -R ${d_n}/../../config/${r_cfg}/EXP00/* ${d_n}/../../config/${m_n}/EXP00/. |
---|
169 | \cp -R ${d_n}/../../config/${r_cfg}/MY_SRC/* ${d_n}/../../config/${m_n}/MY_SRC/. |
---|
170 | fi |
---|
171 | #- Create the WORK -- |
---|
172 | d_m=`find ${d_n}/../.. -name ${m_n}` ; |
---|
173 | [ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK; |
---|
174 | cd ${d_m}/WORK |
---|
175 | |
---|
176 | #- Clean links and librairies |
---|
177 | [ -n "`\ls`" ] && \rm * |
---|
178 | |
---|
179 | #- Find the number of directories --- |
---|
180 | NDIR=${#TAB[*]} |
---|
181 | |
---|
182 | #- Creating the good links, at first on OPA_SRC --- |
---|
183 | echo " Creating ${m_n}/WORK = ${TAB[*]} for ${m_n}" |
---|
184 | |
---|
185 | i=0 |
---|
186 | while [ i -lt $NDIR ] |
---|
187 | do |
---|
188 | [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../../../modeles/NEMO/OPA_SRC/*.[Ffh]90 . |
---|
189 | [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../../../modeles/NEMO/OPA_SRC/*/*.[Ffh]90 . && break |
---|
190 | let i=$i+1 |
---|
191 | done |
---|
192 | |
---|
193 | i=0 |
---|
194 | while [ i -lt $NDIR ] |
---|
195 | do |
---|
196 | if [ "${TAB[i]}" = "LIM_SRC_2" ]; then |
---|
197 | ln -sf ../../../modeles/NEMO/LIM_SRC_2/*.[Ffh]90 . |
---|
198 | |
---|
199 | elif [ "${TAB[i]}" = "LIM_SRC_3" ]; then |
---|
200 | ln -sf ../../../modeles/NEMO/LIM_SRC_3/*.[Ffh]90 . |
---|
201 | |
---|
202 | elif [ "${TAB[i]}" = "TOP_SRC" ]; then |
---|
203 | ln -sf ../../../modeles/NEMO/TOP_SRC/*.[Ffh]90 . |
---|
204 | ln -sf ../../../modeles/NEMO/TOP_SRC/*/*.[Ffh]90 . |
---|
205 | |
---|
206 | elif [ "${TAB[i]}" = "OFF_SRC" ]; then |
---|
207 | ln -sf ../../../modeles/NEMO/OFF_SRC/*.[Ffh]90 . |
---|
208 | ln -sf ../../../modeles/NEMO/OFF_SRC/*/*.[Ffh]90 . |
---|
209 | |
---|
210 | elif [ "${TAB[i]}" = "C1D_SRC" ]; then |
---|
211 | ln -sf ../../../modeles/NEMO/C1D_SRC/*.[Ffh]90 . |
---|
212 | |
---|
213 | elif [ "${TAB[i]}" = "NST_SRC" ]; then |
---|
214 | \rm agrif_opa_interp.F90 |
---|
215 | \rm agrif_opa_sponge.F90 |
---|
216 | \rm agrif_opa_update.F90 |
---|
217 | \rm agrif_top_interp.F90 |
---|
218 | \rm agrif_top_sponge.F90 |
---|
219 | \rm agrif_top_update.F90 |
---|
220 | ln -sf ../../../modeles/NEMO/NST_SRC/*.[Ffh]90 . |
---|
221 | fi |
---|
222 | let i=$i+1 |
---|
223 | done |
---|
224 | |
---|
225 | ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ; |
---|
226 | ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ; |
---|
227 | |
---|
228 | |
---|
229 | if [ -d ../../../config/${m_n}/MY_SRC ]; then |
---|
230 | f_list=`\ls ../../../config/${m_n}/MY_SRC/*.[Ffh]90` ; |
---|
231 | if [ ${#f_list} -ne 0 ] ; then |
---|
232 | echo " " |
---|
233 | echo " Files in the ../config/${m_n}/MY_SRC directory will be taken into account" |
---|
234 | echo " " |
---|
235 | for i in `ls ../../../config/${m_n}/MY_SRC/*.[Ffh]90` |
---|
236 | do |
---|
237 | [ -f $i ] && \rm $i |
---|
238 | [ -f ../../../config/${m_n}/MY_SRC/$i ] && ln -sf ../../../config/${m_n}/MY_SRC/${i} . |
---|
239 | done |
---|
240 | fi |
---|
241 | fi |
---|
242 | |
---|
243 | #- Building the standard list of source files --- |
---|
244 | cat >.patron <<"EOF" |
---|
245 | CVS |
---|
246 | SRC_PARAM |
---|
247 | SRC_FILE_LIST |
---|
248 | tmplist |
---|
249 | AA_make |
---|
250 | KEY_CPP |
---|
251 | Makefile |
---|
252 | *?.o |
---|
253 | i.?* |
---|
254 | *?.L |
---|
255 | .patron |
---|
256 | bloc.com |
---|
257 | para.com |
---|
258 | defcst.f |
---|
259 | fontbc.f |
---|
260 | icdyna.f |
---|
261 | thersf.f |
---|
262 | OPAFILES |
---|
263 | EOF |
---|
264 | |
---|
265 | [ ! -d ../../../config/${m_n}/scripts/Attic ] && \mkdir ../../../config/${m_n}/scripts/Attic |
---|
266 | |
---|
267 | #- Writing KEY_CPP file --- |
---|
268 | sed -e "s/#-Q- sxnec *//" -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > ../../../config/${m_n}/scripts/Attic/KEY_CPP |
---|
269 | ln -sf ../../../config/${m_n}/scripts/Attic/KEY_CPP . |
---|
270 | |
---|
271 | #- Creating SRC list --- |
---|
272 | ls -1 | fgrep -v -f .patron > ../../../config/${m_n}/scripts/Attic/SRC_FILE_LIST |
---|
273 | ln -sf ../../../config/${m_n}/scripts/Attic/SRC_FILE_LIST . |
---|
274 | cp SRC_FILE_LIST SRC_FILE_LIST.temp |
---|
275 | |
---|
276 | #- Save new configuration and directories names --- |
---|
277 | print ${m_n} ${TAB[*]} >.config |
---|
278 | |
---|
279 | #- Create repository to store modified files |
---|
280 | [ ! -d ../../../config/${m_n}/MY_SRC ] && \mkdir ../../../config/${m_n}/MY_SRC |
---|
281 | cp ../../../modeles/NEMO/OPA_SRC/par_oce.F90 ../../../config/${m_n}/MY_SRC/par_oce.F90_keep |
---|
282 | if [ -d ../../../config/NVTK/2TEST ]; then |
---|
283 | f_2test=`\ls ../../../config/NVTK/2TEST/*.[Ffh]90` ; |
---|
284 | if [ ${#f_2test} -ne 0 ] ; then |
---|
285 | echo " " |
---|
286 | echo " Files in the ../config/NVTK/2TEST directory will be taken into account" |
---|
287 | echo " " |
---|
288 | for i in `ls ../../../config/NVTK/2TEST/*.[Ffh]90` |
---|
289 | do |
---|
290 | ln -sf ../../../config/NVTK/2TEST/${i} ../../../config/${m_n}/MY_SRC/. |
---|
291 | done |
---|
292 | fi |
---|
293 | fi |
---|
294 | |
---|
295 | unset m_n |
---|
296 | unset TAB |
---|
297 | unset CONFIG |
---|
298 | exit 0; |
---|