New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
use_cfg in trunk/VALID – NEMO

source: trunk/VALID/use_cfg @ 890

Last change on this file since 890 was 890, checked in by ctlod, 16 years ago

Update NVTK scripts to take into account LIM 3.0, see ticket: #114

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