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 tags/nemo_v3_2/nemo_v3_2/NVTK – NEMO

source: tags/nemo_v3_2/nemo_v3_2/NVTK/use_cfg @ 1878

Last change on this file since 1878 was 1878, checked in by flavoni, 14 years ago

initial test for nemogcm

File size: 8.1 KB
Line 
1#!/bin/ksh
2# $Id: use_cfg 1611 2009-08-12 11:07:20Z ctlod $
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######################################################
12d_n=$(dirname $0); b_n=$(basename $0);
13
14#set -xv
15
16#- Saisie et validation des options
17x_d="";
18x_n="";
19x_r="";
20while 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
47shift $(($OPTIND-1));
48
49#- Some tests ---
50m_n=${x_n}
51
52if [ ${#x_n} -eq 0 ]; then
53echo "Warning"
54echo "No configuration specified"
55echo "use_cfg -h for help"
56exit
57fi
58
59cat ${d_n}/cfg.txt | grep ${m_n} > ${d_n}/cfg.tmp
60read CONFIG TAB[0] TAB[1] TAB[2] TAB[3] TAB[4] TAB[5] < ${d_n}/cfg.tmp
61\rm ${d_n}/cfg.tmp
62
63if [ ${#CONFIG} -eq 0 ] ; then
64if [ ${#x_d} -eq 0 ] ; then
65
66echo "You are  installing a new configuration"
67echo -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   
72echo " OPA_SRC selected "
73echo "  "
74    else
75echo " OPA_SRC Not selected "
76echo "  "
77    fi
78unset answer
79echo -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
84echo " LIM_SRC_2 selected "
85echo "  "
86    else
87echo " LIM_SRC_2 Not selected "
88echo "  "
89    fi
90unset answer
91echo -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
96echo " LIM_SRC_3 selected "
97echo "  "
98    else
99echo " LIM_SRC_3 Not selected "
100echo "  "
101    fi
102unset answer
103echo -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   
108echo " TOP_SRC selected "
109echo "  "
110    else
111echo " TOP_SRC Not selected "
112echo "  "
113    fi
114unset answer   
115echo -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   
120echo " C1D_SRC selected "
121echo "  "
122    else
123echo " C1D_SRC Not selected "
124echo "  "
125    fi
126unset answer
127echo -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   
132echo " NST_SRC selected "
133echo "  "
134    else
135echo " NST_SRC Not selected "
136echo "  "
137    fi
138unset answer
139
140else
141set -A TAB ${x_d} 
142fi
143print ${m_n} ${TAB[*]} >> ${d_n}/cfg.txt
144fi
145
146
147#- Create the config  --
148r_cfg='ORCA2_LIM'
149if [ ${#x_r} -ne 0 ]; then
150r_cfg=${x_r}
151fi
152
153if  [ ! -d ${d_n}/../../config/${m_n} ]; then
154echo " The new configuration ${x_n} will be based on ${r_cfg} following files:"
155echo "`ls ../${r_cfg}/AA_make*` "
156echo "`ls ../${r_cfg}/scripts/BB_make*` "
157echo "`ls ../${r_cfg}/EXP00/*` "
158echo "`ls ../${r_cfg}/MY_SRC/*` "
159echo "  "
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/.
170fi
171#- Create the WORK --
172d_m=`find ${d_n}/../.. -name ${m_n}`  ;
173[ -d ${d_m}/WORK ] || mkdir ${d_m}/WORK;
174cd ${d_m}/WORK
175
176#- Clean links and librairies
177[ -n "`\ls`" ] && \rm *
178
179#- Find the number of directories ---
180NDIR=${#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 ---
244cat >.patron <<"EOF" 
245CVS
246SRC_PARAM
247SRC_FILE_LIST
248tmplist
249AA_make
250KEY_CPP
251Makefile
252*?.o
253 i.?*
254*?.L
255.patron
256bloc.com
257para.com
258defcst.f
259fontbc.f
260icdyna.f
261thersf.f
262OPAFILES
263EOF
264
265[ ! -d ../../../config/${m_n}/scripts/Attic ] && \mkdir ../../../config/${m_n}/scripts/Attic
266
267#- Writing KEY_CPP file ---
268sed -e "s/#-Q- sxnec *//" -e /^P_P/\!d -e "s/P_P = //" AA_make.ldef > ../../../config/${m_n}/scripts/Attic/KEY_CPP 
269ln -sf ../../../config/${m_n}/scripts/Attic/KEY_CPP . 
270
271#- Creating SRC list ---
272ls -1 | fgrep -v -f .patron  > ../../../config/${m_n}/scripts/Attic/SRC_FILE_LIST
273ln -sf ../../../config/${m_n}/scripts/Attic/SRC_FILE_LIST .
274cp SRC_FILE_LIST SRC_FILE_LIST.temp   
275
276#- Save new configuration and directories names ---
277print ${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
281cp ../../../modeles/NEMO/OPA_SRC/par_oce.F90 ../../../config/${m_n}/MY_SRC/par_oce.F90_keep
282if [ -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
293fi
294
295unset m_n
296unset TAB
297unset CONFIG
298exit 0;
Note: See TracBrowser for help on using the repository browser.