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.
makenemo in branches/DEV_r1879_FCM/NEMOGCM/CONFIG – NEMO

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

Last change on this file since 2292 was 2292, checked in by smasson, 13 years ago

update DEV_r1879_FCM for additional tests...

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 6.2 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 -m 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#
75#   * creation
76#
77#-
78
79#- Local variables ---
80b_n=$(basename ${0})
81export MAIN_DIR=${PWD%/CONFIG*}
82export CONFIG_DIR=${MAIN_DIR}/CONFIG
83export TOOLS_DIR=${MAIN_DIR}/TOOLS
84export COMPIL_DIR=${MAIN_DIR}/TOOLS/COMPILE
85export NEMO_DIR=${MAIN_DIR}/NEMO
86export AGRIFUSE=10
87
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_c="";
101x_j=1;
102while getopts :hd:n:r:m:j:t: V
103  do
104    case $V in
105      (h)  echo "Usage   : "${b_n} \
106                " [-h] [-n name] [-m arch] [-d "dir1 dir2"] [-r conf] [-j No]";
107           echo " -h  : help";
108           echo " -n name : config name, [-n help] to list existing configurations";
109           echo " -m arch : choose compiler, [-m help] to list exiting compilers";
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 "Available configurations :"; cat ${COMPIL_DIR}/cfg.txt;
120           echo "";
121                          . ${COMPIL_DIR}/Flist_archfile.sh  ;
122                          echo "";
123                          echo "Default : previous configuration and compiler";
124           exit 0;;
125      (d)  x_d=${OPTARG};;
126      (n)  x_n=${OPTARG};;
127      (r)  x_r=${OPTARG};;
128      (m)  x_m=${OPTARG};;
129      (j)  x_j=${OPTARG};;
130      (t)  x_t=${OPTARG};;
131      (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
132           exit 2;;
133      (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
134           exit 2;;
135    esac
136  done
137shift $(($OPTIND-1));
138
139#-
140#- Get the clean option
141[[ "${#@}" -ne 0 && "${@}" != clean ]] && echo "Invalid option "$@" " && exit
142[ "${#@}" -ne 0 ] && x_c="--$@"
143
144#-
145#- Go to NEMOGCM/config directory ---
146cd ${CONFIG_DIR}
147
148#-
149#- Initialisation from input ---
150export NEW_CONF=${x_n}
151NBR_PRC=${x_j}
152CMP_NAM=${x_m}
153NEM_SUBDIR=${x_d}
154REF_CONF=${x_r}
155NEMO_TDIR=${x_t:-$NEMO_TDIR}
156export NEMO_TDIR=${NEMO_TDIR:-$CONFIG_DIR}
157
158#- Check if the tool or the compiler exist or list it
159if [ "${NEW_CONF}" == help ] ; then
160 echo "Available configurations :" 
161 cat ${COMPIL_DIR}/cfg.txt
162exit
163fi
164[ "${CMP_NAM}" ==  help ] && . ${COMPIL_DIR}/Flist_archfile.sh && exit
165
166#- When used for the first time, choose a compiler ---
167. ${COMPIL_DIR}/Fcheck_archfile.sh arch_nemo.fcm ${CMP_NAM} || exit
168
169#-
170#- Choose a default configuration if needed ---
171#- ORCA2_LIM or last one used ---
172. ${COMPIL_DIR}/Fcheck_config.sh cfg.txt ${NEW_CONF} || exit
173
174if [ ${#NEW_CONF} -eq 0 ] ; then
175   if [ ${#NEM_SUBDIR} -eq 0 -a ${#REF_CONF} -eq 0 ]; then
176      echo "You are  installing a new configuration"
177      ind=0
178      . ${COMPIL_DIR}/Fread_dir.sh OPA_SRC   YES
179      . ${COMPIL_DIR}/Fread_dir.sh LIM_SRC_2   YES
180      . ${COMPIL_DIR}/Fread_dir.sh LIM_SRC_3    NO 
181      . ${COMPIL_DIR}/Fread_dir.sh TOP_SRC    NO 
182      . ${COMPIL_DIR}/Fread_dir.sh C1D_SRC   YES
183      . ${COMPIL_DIR}/Fread_dir.sh NST_SRC   YES
184      . ${COMPIL_DIR}/Fread_dir.sh OFF_SRC    NO 
185      REF_CONF=ORCA2_LIM
186   elif [ ${#NEM_SUBDIR} -gt 0 ] && [ ${#REF_CONF} -eq 0 ]; then
187      echo "You are  installing a new configuration"
188      TAB=( ${NEM_SUBDIR} )
189      REF_CONF=ORCA2_LIM
190   elif [ ${#NEM_SUBDIR} -eq 0 ] && [ ${#REF_CONF} -gt 0 ]; then
191      echo "You are  installing a new configuration based on ${REF_CONF}"
192      . ${COMPIL_DIR}/Fcopy_dir.sh ${REF_CONF} 
193   fi
194   NEW_CONF=${x_n}
195    . ${COMPIL_DIR}/Fmake_config.sh ${NEW_CONF} ${REF_CONF}
196else
197   sed -e "/${NEW_CONF} /d"  ${COMPIL_DIR}/cfg.txt >  ${COMPIL_DIR}/cfg.tmp
198   \m${COMPIL_DIR}/cfg.tmp  ${COMPIL_DIR}/cfg.txt
199fi
200
201#-
202#- Save new configuration and directories names ---
203echo ${NEW_CONF} ${TAB[*]} >> ${COMPIL_DIR}/cfg.txt
204
205#-
206#- Create the WORK ---
207#- Clean links and librairies ---
208#- Creating the good links, at first on OPA_SRC ---
209. ${COMPIL_DIR}/Fmake_WORK.sh ${NEW_CONF} ${TAB[*]} || exit
210
211. ${COMPIL_DIR}/Fmake_bld.sh ${CONFIG_DIR} ${NEW_CONF}  ${NEMO_TDIR} || exit
212
213#- At this stage the configuration has beeen chosen
214#- We look after agrif
215grep key_agrif ${COMPIL_DIR}/cpp.fcm && export AGRIFUSE=1
216. ${COMPIL_DIR}/Fprep_agrif.sh ${NEW_CONF} ${NEMO_TDIR} || exit
217
218#-
219#_ END OF CONFIGURATION PHASE
220#_
221
222#-
223#- Compile ---
224
225if [ "${NBR_PRC}" -gt 0 ]; then
226   cd ${NEMO_TDIR}/${NEW_CONF} || cd -
227
228   #if AGRIF we do a first preprocessing
229   if [ ${#x_c} -eq 0 ]; then
230      [ "$AGRIFUSE" == 1 ] && fcm build --ignore-lock -s 2 ${COMPIL_DIR}/bld.cfg
231      [ "$AGRIFUSE" == 1 ] && rm -rf  ${NEMO_TDIR}/${NEW_CONF}/BLD/*
232   fi
233   fcm build ${x_c} --ignore-lock -v 1 -j ${NBR_PRC} ${COMPIL_DIR}/bld.cfg || cd -
234   [ -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
235   [ -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
236fi
237
238#-
239#- Come back to original directory ---
240cd -
241
242#-
243#- Unset variables
244${COMPIL_DIR}/Fclean_var.sh
245
246
247exit 0;
Note: See TracBrowser for help on using the repository browser.