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 branches/dev_001_GM/VALID – NEMO

source: branches/dev_001_GM/VALID/use_cfg @ 4153

Last change on this file since 4153 was 697, checked in by ctlod, 17 years ago

NVTK installation

  • Property svn:executable set to *
File size: 7.8 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 [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   
83echo " LIM_SRC selected "
84echo "  "
85    else
86echo " LIM_SRC Not selected "
87echo "  "
88    fi
89unset answer
90echo -n " TOP_SRC [Y/n] "
91    read answer
92    answer=`echo $answer | sed 's/^[yY].*$/y/'`
93    if [  -z "$answer" -o "x$answer" = "xy" ]; then
94    TAB[3]=TOP_SRC   
95echo " TOP_SRC selected "
96echo "  "
97    else
98echo " TOP_SRC Not selected "
99echo "  "
100    fi
101unset answer   
102echo -n " C1D_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[4]=C1D_SRC   
107echo " C1D_SRC selected "
108echo "  "
109    else
110echo " C1D_SRC Not selected "
111echo "  "
112    fi
113unset answer
114echo -n " NST_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[5]=NST_SRC   
119echo " NST_SRC selected "
120echo "  "
121    else
122echo " NST_SRC Not selected "
123echo "  "
124    fi
125unset answer
126
127else
128set -A TAB ${x_d} 
129fi
130print ${m_n} ${TAB[*]} >> ${d_n}/cfg.txt
131fi
132
133
134#- Create the config  --
135r_cfg='ORCA2_LIM'
136if [ ${#x_r} -ne 0 ]; then
137r_cfg=${x_r}
138fi
139
140if  [ ! -d ${d_n}/../../config/${m_n} ]; then
141echo " The new configuration ${x_n} will be based on ${r_cfg} following files:"
142echo "`ls ../${r_cfg}/AA_make*` "
143echo "`ls ../${r_cfg}/scripts/BB_make*` "
144echo "`ls ../${r_cfg}/EXP00/*` "
145echo "`ls ../${r_cfg}/MY_SRC/*` "
146echo "  "
147\mkdir  ${d_n}/../../config/${m_n} 
148\mkdir  ${d_n}/../../config/${m_n}/scripts
149\mkdir  ${d_n}/../../config/${m_n}/EXP00
150\mkdir  ${d_n}/../../config/${m_n}/MY_SRC
151\cp -R ${d_n}/../../config/${r_cfg}/AA_make ${d_n}/../../config/${m_n}/.
152\cp -R ${d_n}/../../config/${r_cfg}/AA_make.ldef ${d_n}/../../config/${m_n}/.
153\cp -R ${d_n}/../../config/${r_cfg}/scripts/BB_make ${d_n}/../../config/${m_n}/scripts/.
154\cp -R ${d_n}/../../config/${r_cfg}/scripts/BB_make.ldef ${d_n}/../../config/${m_n}/scripts/.
155\cp -R ${d_n}/../../config/${r_cfg}/EXP00/* ${d_n}/../../config/${m_n}/EXP00/.
156\cp -R ${d_n}/../../config/${r_cfg}/MY_SRC/* ${d_n}/../../config/${m_n}/MY_SRC/.
157fi
158#- Create the WORK --
159d_m=`find ${d_n}/../.. -name ${m_n}`  ;
160[ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK;
161cd ${d_m}/WORK
162
163#- Clean links and librairies
164[ -n "`\ls`" ] && \rm *
165
166#- Find the number of directories ---
167NDIR=${#TAB[*]}
168
169#- Creating the good links, at first on OPA_SRC ---
170    echo " Creating ${m_n}/WORK = ${TAB[*]} for ${m_n}"
171
172    i=0
173    while [ i -lt $NDIR ]
174    do
175   [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../../../modeles/NEMO/OPA_SRC/*.[Ffh]90 .
176   [ ${#TAB[i]} -ne 0 ] && [ "${TAB[i]}" = "OPA_SRC" ] && ln -sf ../../../modeles/NEMO/OPA_SRC/*/*.[Ffh]90 . && break
177   let i=$i+1
178    done
179
180    i=0
181    while [ i -lt $NDIR ]
182    do
183      if [ "${TAB[i]}" = "LIM_SRC" ]; then
184     ln -sf ../../../modeles/NEMO/LIM_SRC/*.[Ffh]90 . 
185     
186      elif [ "${TAB[i]}" = "TOP_SRC" ]; then
187     \rm trcstp.F90                   
188     \rm sms.F90                   
189     ln -sf ../../../modeles/NEMO/TOP_SRC/*.[Ffh] .           
190     ln -sf ../../../modeles/NEMO/TOP_SRC/*.[Ffh]90 .       
191     ln -sf ../../../modeles/NEMO/TOP_SRC/SMS/*.[Ffh] .       
192     ln -sf ../../../modeles/NEMO/TOP_SRC/SMS/*.[Ffh]90 . 
193     ln -sf ../../../modeles/NEMO/TOP_SRC/TRP/*.[Ffh]90 .
194     
195      elif [ "${TAB[i]}" = "SRC_OFFLINE_TOP" ]; then 
196     ln -sf ../../../modeles/NEMO/TOP_SRC/*.[Ffh] .
197     ln -sf ../../../modeles/NEMO/TOP_SRC/SMS/*.[Ffh] .
198     ln -sf ../../../modeles/NEMO/SRC_OFFLINE_TOP/*.[Ffh] .
199
200      elif [ "${TAB[i]}" = "C1D_SRC" ]; then 
201     ln -sf ../../../modeles/NEMO/C1D_SRC/*.[Ffh]90 .
202
203      elif [ "${TAB[i]}" = "NST_SRC" ]; then 
204     ln -sf ../../../modeles/NEMO/NST_SRC/*.[Ffh]90 .
205      fi
206      let i=$i+1
207    done
208
209    ln -sf ../../../*/${m_n}/scripts/BB_make AA_make ;
210    ln -sf ../../../*/${m_n}/scripts/BB_make.ldef AA_make.ldef ;
211
212
213    if [ -d ../../../config/${m_n}/MY_SRC ]; then
214        f_list=`\ls ../../../config/${m_n}/MY_SRC/*.[Ffh]90`  ;
215        if [ ${#f_list} -ne 0 ] ; then
216            echo " "
217            echo " Files in the ../config/${m_n}/MY_SRC directory will be taken into account"
218            echo " "
219       for i in `ls ../../../config/${m_n}/MY_SRC/*.[Ffh]90`
220          do
221          [ -f $i ] && \rm $i 
222          [ -f ../../../config/${m_n}/MY_SRC/$i ] &&  ln -sf ../../../config/${m_n}/MY_SRC/${i} .
223        done
224        fi
225    fi
226
227#- Building the standard list of source files ---
228cat >.patron <<"EOF" 
229CVS
230SRC_PARAM
231SRC_FILE_LIST
232tmplist
233AA_make
234KEY_CPP
235Makefile
236*?.o
237 i.?*
238*?.L
239.patron
240bloc.com
241para.com
242defcst.f
243fontbc.f
244icdyna.f
245thersf.f
246OPAFILES
247EOF
248
249[ ! -d ../../../config/${m_n}/scripts/Attic ] && \mkdir ../../../config/${m_n}/scripts/Attic
250
251#- Writing KEY_CPP file ---
252sed -e "s/#-Q- sxnec *//" -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > ../../../config/${m_n}/scripts/Attic/KEY_CPP 
253ln -sf ../../../config/${m_n}/scripts/Attic/KEY_CPP . 
254
255#- Creating SRC list ---
256ls -1 | fgrep -v -f .patron  > ../../../config/${m_n}/scripts/Attic/SRC_FILE_LIST
257ln -sf ../../../config/${m_n}/scripts/Attic/SRC_FILE_LIST .
258cp SRC_FILE_LIST SRC_FILE_LIST.temp   
259
260#- Save new configuration and directories names ---
261print ${m_n} ${TAB[*]} >.config
262
263#- Create repository to store modified files
264[ ! -d ../../../config/${m_n}/MY_SRC ] && \mkdir ../../../config/${m_n}/MY_SRC
265cp ../../../modeles/NEMO/OPA_SRC/par_oce.F90 ../../../config/${m_n}/MY_SRC/par_oce.F90_keep
266if [ -d ../../../config/HEAD/2TEST ]; then
267    f_2test=`\ls ../../../config/HEAD/2TEST/*.[Ffh]90`  ;
268    if [ ${#f_2test} -ne 0 ] ; then
269        echo " "
270        echo " Files in the ../config/HEAD/2TEST directory will be taken into account"
271        echo " "
272        for i in `ls ../../../config/HEAD/2TEST/*.[Ffh]90`
273          do
274             ln -sf ../../../config/HEAD/2TEST/${i} ../../../config/${m_n}/MY_SRC/.
275          done
276    fi
277fi
278
279unset m_n
280unset TAB
281unset CONFIG
282exit 0;
Note: See TracBrowser for help on using the repository browser.