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

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

Correct makenemo on FCM branch

  • Property svn:executable set to *
File size: 5.5 KB
Line 
1#!/bin/bash
2#set -x
3set -o posix
4#set -u
5#set -e
6#+
7#
8# ===============
9# makenemo_fcm.sh
10# ===============
11#
12# --------------------------
13# Compile NEMO
14# --------------------------
15#
16# SYNOPSIS
17# ========
18#
19# ::
20#
21#  $ makenemo_fcm.sh
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_fcm -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 NEMO_DIR=${MAIN_DIR}/NEMO
86export AGRIFUSE=10
87declare -a TAB
88#-
89#- FCM and functions location ---
90export PATH=${MAIN_DIR}/EXTERNAL/fcm/bin:$PATH
91
92#-
93#- Choice of the options ---
94x_d="";
95x_n="";
96x_r="";
97x_m="";
98x_t="";
99x_j=1;
100while getopts :hld:n:r:m:j:t: V
101  do
102    case $V in
103      (h)  echo "Usage   : "${b_n} \
104                " [-h] [-l] [-n name] [-m arch] [-d "dir1 dir2"] [-r conf] [-j No]";
105           echo " -h    : help";
106           echo " -l    : list existing configurations";
107           echo " -n name : config name";
108           echo " -m arch : choose machine";
109           echo " -d dir  : choose NEMO sub-directories";
110           echo " -r conf : choose reference configuration";
111           echo " -j No  : number of processes used to compile (0=nocompilation)";
112           echo " -t dir  : remporary directory for compilation"
113           echo "";
114           echo "Example to install a new configuration MY_CONFIG";
115           echo "with OPA_SRC and LIM_SRC_2 ";
116           echo "makenemo_fcm -n MY_CONFIG -d \"OPA_SRC LIM_SRC_2\"";
117           echo "";
118           echo "Defaults    : ";
119           echo "";
120           exit 0;;
121      (d)  x_d=${OPTARG};;
122      (n)  x_n=${OPTARG};;
123      (r)  x_r=${OPTARG};;
124      (m)  x_m=${OPTARG};;
125      (j)  x_j=${OPTARG};;
126      (t)  x_t=${OPTARG};;
127      (l)  echo "Available configurations :"; cat ${TOOLS_DIR}/cfg.txt; exit;;
128      (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
129           exit 2;;
130      (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
131           exit 2;;
132    esac
133  done
134shift $(($OPTIND-1));
135
136#-
137#- Go to NEMOGCM/config directory ---
138cd ${CONFIG_DIR}
139
140#-
141#- Initialisation from input ---
142export NEW_CONF=${x_n}
143NBR_PRC=${x_j}
144CMP_NAM=${x_m}
145NEM_SUBDIR=${x_d}
146REF_CONF=${x_r}
147NEMO_TDIR=${x_t:-$NEMO_TDIR}
148export NEMO_TDIR=${NEMO_TDIR:-$CONFIG_DIR}
149
150#- When used for the first time, choose a compiler ---
151. ${TOOLS_DIR}/Fcheck_archfile.sh ${CMP_NAM} || exit
152
153#-
154#- Choose a default configuration if needed ---
155#- ORCA2_LIM or last one used ---
156. ${TOOLS_DIR}/Fcheck_config.sh ${NEW_CONF} || exit
157
158if [ ${#NEW_CONF} -eq 0 ] ; then
159   if [ ${#NEM_SUBDIR} -eq 0 -a ${#REF_CONF} -eq 0 ]; then
160      echo "You are  installing a new configuration"
161      ind=0
162      . ${TOOLS_DIR}/Fread_dir.sh OPA_SRC YES
163      . ${TOOLS_DIR}/Fread_dir.sh LIM_SRC_2   YES
164      . ${TOOLS_DIR}/Fread_dir.sh LIM_SRC_3    NO 
165      . ${TOOLS_DIR}/Fread_dir.sh TOP_SRC  NO 
166      . ${TOOLS_DIR}/Fread_dir.sh C1D_SRC YES
167      . ${TOOLS_DIR}/Fread_dir.sh NST_SRC YES
168      . ${TOOLS_DIR}/Fread_dir.sh OFF_SRC  NO 
169      REF_CONF=ORCA2_LIM
170   elif [ ${#NEM_SUBDIR} -gt 0 ] && [ ${#REF_CONF} -eq 0 ]; then
171      echo "You are  installing a new configuration"
172      TAB=( ${NEM_SUBDIR} )
173      REF_CONF=ORCA2_LIM
174   elif [ ${#NEM_SUBDIR} -eq 0 ] && [ ${#REF_CONF} -gt 0 ]; then
175      echo "You are  installing a new configuration based on ${REF_CONF}"
176      . ${TOOLS_DIR}/Fcopy_dir.sh ${REF_CONF} 
177   fi
178   NEW_CONF=${x_n}
179    . ${TOOLS_DIR}/Fmake_config.sh ${NEW_CONF} ${REF_CONF}
180else
181   sed -e "/${NEW_CONF} /d"  ${TOOLS_DIR}/cfg.txt >  ${TOOLS_DIR}/cfg.tmp
182   \m${TOOLS_DIR}/cfg.tmp  ${TOOLS_DIR}/cfg.txt
183fi
184
185#-
186#- Save new configuration and directories names ---
187echo ${NEW_CONF} ${TAB[*]} >> ${TOOLS_DIR}/cfg.txt
188
189#-
190#- Create the WORK ---
191#- Clean links and librairies ---
192#- Creating the good links, at first on OPA_SRC ---
193. ${TOOLS_DIR}/Fmake_WORK.sh ${NEW_CONF} ${TAB[*]} || exit
194
195. ${TOOLS_DIR}/Fmake_bld.sh ${NEW_CONF}  ${NEMO_TDIR} || exit
196
197#- At this stage the configuration has beeen chosen
198#- We look after agrif
199grep key_agrif ${TOOLS_DIR}/cpp.fcm && export AGRIFUSE=1
200. ${TOOLS_DIR}/Fprep_agrif.sh ${NEW_CONF} ${NEMO_TDIR} || exit
201
202#-
203#_ END OF CONFIGURATION PHASE
204#_
205
206#-
207#- Compile ---
208
209if [ "${NBR_PRC}" -gt 0 ]; then
210cd ${NEMO_TDIR}/${NEW_CONF} || cd -
211
212#if AGRIF we do a first preprocessing
213[ "$AGRIFUSE" == 1 ] && fcm build --ignore-lock -s 2 ${TOOLS_DIR}/bld.cfg
214[ "$AGRIFUSE" == 1 ] && rm -rf  ${NEMO_TDIR}/${NEW_CONF}/BLD/*
215fcm build --ignore-lock -v 1 -j ${NBR_PRC} ${TOOLS_DIR}/bld.cfg || cd -
216[ -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
217[ -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
218fi
219
220#-
221#- Come back to original directory ---
222cd -
223
224#-
225#- Unset variables
226${TOOLS_DIR}/Fclean_var.sh
227
228
229exit 0;
Note: See TracBrowser for help on using the repository browser.