source: branches/DEV_r1879_FCM/NEMOGCM/CONFIG/makenemo @ 2136

Last change on this file since 2136 was 2136, checked in by rblod, 11 years ago

add compilation of tools like rebuild or nesting tools

  • Property svn:executable set to *
File size: 5.6 KB
Line 
1#!/bin/bash
2#set -x
3set -o posix
4#set -u
5#set -e
6#+
7#
8# ===============
9# makenemo
10# ===============
11#
12# --------------------------
13# Compile NEMO
14# --------------------------
15#
16# SYNOPSIS
17# ========
18#
19# ::
20#
21#  $ makenemo
22#
23#
24# DESCRIPTION
25# ===========
26#
27#
28# This script aims :
29#
30# - to choose MYCONFIG
31# - to choose compiler options 
32# - to create the CONFIG/MYCONFIG/WORK directory
33# - to compile this configuration
34#
35#  Variables used :
36#
37#  From user input
38#
39# - NEW_CONF    : configuration to be created
40# - REF_CONF    : reference configuration to build the new one
41# - CMP_NAM     : compiler name
42# - NBR_PRC     : number of processes used to compile 
43# - NEM_SUBDIR  : NEMO subdirectory used (specified)
44#
45#  Locally defined :
46#
47# - TAB         : NEMO subdirectory used (read) 
48# - MAIN_DIR : self explaining
49# - CONFIG_DIR  :   "    "    "   
50# - MODELES_DIR :   "    "    "
51# - TOOLS_DIR   :   "    "    "
52# - NEMO_DIR    :   "    "    "
53#
54# EXAMPLES
55# ========
56#
57# ::
58#
59#  $ ./makenemo -t ifort_osx - j3 -n ORCA2_LIM
60#
61#
62# TODO
63# ====
64#
65# option debug
66#
67#
68# EVOLUTIONS
69# ==========
70#
71# $Id$
72#
73#
74# - rblod 2010-06-20T16:11:47Z
75#
76#   * creation
77#
78#-
79
80#- Local variables ---
81b_n=$(basename ${0})
82export MAIN_DIR=${PWD%/NEMOGCM*}/NEMOGCM
83export CONFIG_DIR=${MAIN_DIR}/CONFIG
84export TOOLS_DIR=${MAIN_DIR}/TOOLS
85export COMPIL_DIR=${MAIN_DIR}/TOOLS/COMPILE
86export NEMO_DIR=${MAIN_DIR}/NEMO
87export AGRIFUSE=10
88declare -a TAB
89#-
90#- FCM and functions location ---
91export PATH=${MAIN_DIR}/EXTERNAL/fcm/bin:$PATH
92
93#-
94#- Choice of the options ---
95x_d="";
96x_n="";
97x_r="";
98x_m="";
99x_t="";
100x_j=1;
101while getopts :hld:n:r:m:j:t: V
102  do
103    case $V in
104      (h)  echo "Usage   : "${b_n} \
105                " [-h] [-l] [-n name] [-m arch] [-d "dir1 dir2"] [-r conf] [-j No]";
106           echo " -h  : help";
107           echo " -l  : list existing configurations";
108           echo " -n name : config name";
109           echo " -m arch : choose machine";
110           echo " -d dir  : choose NEMO sub-directories";
111           echo " -r conf : choose reference configuration";
112           echo " -j No  : number of processes used to compile (0=nocompilation)";
113           echo " -t dir  : remporary directory for compilation"
114           echo "";
115           echo "Example to install a new configuration MY_CONFIG";
116           echo "with OPA_SRC and LIM_SRC_2 ";
117           echo "makenemo -n MY_CONFIG -d \"OPA_SRC LIM_SRC_2\"";
118           echo "";
119           echo "Defaults    : ";
120           echo "";
121           exit 0;;
122      (d)  x_d=${OPTARG};;
123      (n)  x_n=${OPTARG};;
124      (r)  x_r=${OPTARG};;
125      (m)  x_m=${OPTARG};;
126      (j)  x_j=${OPTARG};;
127      (t)  x_t=${OPTARG};;
128      (l)  echo "Available configurations :"; cat ${COMPIL_DIR}/cfg.txt; exit;;
129      (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
130           exit 2;;
131      (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
132           exit 2;;
133    esac
134  done
135shift $(($OPTIND-1));
136
137#-
138#- Go to NEMOGCM/config directory ---
139cd ${CONFIG_DIR}
140
141#-
142#- Initialisation from input ---
143export NEW_CONF=${x_n}
144NBR_PRC=${x_j}
145CMP_NAM=${x_m}
146NEM_SUBDIR=${x_d}
147REF_CONF=${x_r}
148NEMO_TDIR=${x_t:-$NEMO_TDIR}
149export NEMO_TDIR=${NEMO_TDIR:-$CONFIG_DIR}
150
151#- When used for the first time, choose a compiler ---
152. ${COMPIL_DIR}/Fcheck_archfile.sh arch_nemo.fcm ${CMP_NAM} || exit
153
154#-
155#- Choose a default configuration if needed ---
156#- ORCA2_LIM or last one used ---
157. ${COMPIL_DIR}/Fcheck_config.sh ${NEW_CONF} || exit
158
159if [ ${#NEW_CONF} -eq 0 ] ; then
160   if [ ${#NEM_SUBDIR} -eq 0 -a ${#REF_CONF} -eq 0 ]; then
161      echo "You are  installing a new configuration"
162      ind=0
163      . ${COMPIL_DIR}/Fread_dir.sh OPA_SRC   YES
164      . ${COMPIL_DIR}/Fread_dir.sh LIM_SRC_2   YES
165      . ${COMPIL_DIR}/Fread_dir.sh LIM_SRC_3    NO 
166      . ${COMPIL_DIR}/Fread_dir.sh TOP_SRC    NO 
167      . ${COMPIL_DIR}/Fread_dir.sh C1D_SRC   YES
168      . ${COMPIL_DIR}/Fread_dir.sh NST_SRC   YES
169      . ${COMPIL_DIR}/Fread_dir.sh OFF_SRC    NO 
170      REF_CONF=ORCA2_LIM
171   elif [ ${#NEM_SUBDIR} -gt 0 ] && [ ${#REF_CONF} -eq 0 ]; then
172      echo "You are  installing a new configuration"
173      TAB=( ${NEM_SUBDIR} )
174      REF_CONF=ORCA2_LIM
175   elif [ ${#NEM_SUBDIR} -eq 0 ] && [ ${#REF_CONF} -gt 0 ]; then
176      echo "You are  installing a new configuration based on ${REF_CONF}"
177      . ${COMPIL_DIR}/Fcopy_dir.sh ${REF_CONF} 
178   fi
179   NEW_CONF=${x_n}
180    . ${COMPIL_DIR}/Fmake_config.sh ${NEW_CONF} ${REF_CONF}
181else
182   sed -e "/${NEW_CONF} /d"  ${COMPIL_DIR}/cfg.txt >  ${COMPIL_DIR}/cfg.tmp
183   \m${COMPIL_DIR}/cfg.tmp  ${COMPIL_DIR}/cfg.txt
184fi
185
186#-
187#- Save new configuration and directories names ---
188echo ${NEW_CONF} ${TAB[*]} >> ${COMPIL_DIR}/cfg.txt
189
190#-
191#- Create the WORK ---
192#- Clean links and librairies ---
193#- Creating the good links, at first on OPA_SRC ---
194. ${COMPIL_DIR}/Fmake_WORK.sh ${NEW_CONF} ${TAB[*]} || exit
195
196. ${COMPIL_DIR}/Fmake_bld.sh ${CONFIG_DIR} ${NEW_CONF}  ${NEMO_TDIR} || exit
197
198#- At this stage the configuration has beeen chosen
199#- We look after agrif
200grep key_agrif ${COMPIL_DIR}/cpp.fcm && export AGRIFUSE=1
201. ${COMPIL_DIR}/Fprep_agrif.sh ${NEW_CONF} ${NEMO_TDIR} || exit
202
203#-
204#_ END OF CONFIGURATION PHASE
205#_
206
207#-
208#- Compile ---
209
210if [ "${NBR_PRC}" -gt 0 ]; then
211cd ${NEMO_TDIR}/${NEW_CONF} || cd -
212
213#if AGRIF we do a first preprocessing
214[ "$AGRIFUSE" == 1 ] && fcm build --ignore-lock -s 2 ${COMPIL_DIR}/bld.cfg
215[ "$AGRIFUSE" == 1 ] && rm -rf  ${NEMO_TDIR}/${NEW_CONF}/BLD/*
216fcm build --ignore-lock -v 1 -j ${NBR_PRC} ${COMPIL_DIR}/bld.cfg || cd -
217[ -f ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/nemo.exe ] && ln -sf ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/nemo.exe  ${CONFIG_DIR}/${NEW_CONF}/EXP00/opa
218[ -f ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/server.exe ] && ln -sf ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/server.exe  ${CONFIG_DIR}/${NEW_CONF}/EXP00/server.exe
219fi
220
221#-
222#- Come back to original directory ---
223cd -
224
225#-
226#- Unset variables
227${COMPIL_DIR}/Fclean_var.sh
228
229
230exit 0;
Note: See TracBrowser for help on using the repository browser.