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_fcm.sh in branches/DEV_r1879_FCM/NEMOGCM/TOOLS – NEMO

source: branches/DEV_r1879_FCM/NEMOGCM/TOOLS/makenemo_fcm.sh @ 1972

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

Add TOOLS directory and scripts to compile with FCM, see ticket: #685

  • Property svn:executable set to *
File size: 5.2 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=0
87declare -a TAB
88#-
89#- FCM and functions location ---
90#RB Should we add fcm as a vendor ???
91#export PATH=${MAIN_DIR}/modeles/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_fcm -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 ${TOOLS_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#-
152#- Find fcm ---
153. Fcheck_script.sh fcm || exit
154
155#-
156#- When used for the first time, choose a compiler ---
157. Fcheck_archfile.sh ${CMP_NAM} || exit
158
159#-
160#- Choose a default configuration if needed ---
161#- ORCA2_LIM or last one used ---
162. Fcheck_config.sh ${NEW_CONF} || exit
163
164if [ ${#NEW_CONF} -eq 0 ] ; then
165   if [ ${#NEM_SUBDIR} -eq 0 -a ${#REF_CONF} -eq 0 ]; then
166      echo "You are  installing a new configuration"
167      ind=0
168      . Fread_dir.sh OPA_SRC  YES
169      . Fread_dir.sh LIM_SRC_2 YES
170      . Fread_dir.sh LIM_SRC_3 NO 
171      . Fread_dir.sh TOP_SRC  NO 
172      . Fread_dir.sh C1D_SRC  YES
173      . Fread_dir.sh NST_SRC  YES
174      . Fread_dir.sh OFF_SRC  NO 
175      REF_CONF=ORCA2_LIM
176   elif [ ${#NEM_SUBDIR} -gt 0 ] && [ ${#REF_CONF} -eq 0 ]; then
177      echo "You are  installing a new configuration"
178      TAB=( ${NEM_SUBDIR} )
179      REF_CONF=ORCA2_LIM
180   elif [ ${#NEM_SUBDIR} -eq 0 ] && [ ${#REF_CONF} -gt 0 ]; then
181      echo "You are  installing a new configuration based on ${REF_CONF}"
182      Fcopy_dir.sh ${REF_CONF} 
183   fi
184   NEW_CONF=${x_n}
185    . Fmake_config.sh ${NEW_CONF} ${REF_CONF}
186else
187   sed -e "/${NEW_CONF} /d"  ${TOOLS_DIR}/cfg.txt >  ${TOOLS_DIR}/cfg.tmp
188   \m${TOOLS_DIR}/cfg.tmp  ${TOOLS_DIR}/cfg.txt
189fi
190
191#-
192#- Save new configuration and directories names ---
193echo ${NEW_CONF} ${TAB[*]} >> ${TOOLS_DIR}/cfg.txt
194
195#-
196#- Create the WORK ---
197#- Clean links and librairies ---
198#- Creating the good links, at first on OPA_SRC ---
199. Fmake_WORK.sh ${NEW_CONF} ${TAB[*]} || exit
200
201##SF   exit
202
203. Fmake_bld.sh ${NEW_CONF}  ${NEMO_TDIR} || exit
204
205#- At this stage the configuration has beeen chosen
206#- We look after agrif
207grep key_agrif ${TOOLS_DIR}/cpp.fcm && export AGRIFUSE=1
208. Fprep_agrif.sh ${NEW_CONF} ${NEMO_TDIR} || exit
209
210#-
211#_ END OF CONFIGURATION PHASE
212#_
213
214#-
215#- Compile ---
216
217if [ "${NBR_PRC}" -gt 0 ]; then
218cd ${NEMO_TDIR}/${NEW_CONF} || cd -
219
220#if AGRIF we do a first preprocessing
221[ "$AGRIFUSE" == 1 ] && fcm build --ignore-lock -s 2 ${TOOLS_DIR}/bld.cfg
222[ "$AGRIFUSE" == 1 ] && rm -rf  ${NEMO_TDIR}/${NEW_CONF}/BLD/*
223fcm build --ignore-lock -v 1 -j ${NBR_PRC} ${TOOLS_DIR}/bld.cfg || cd -
224[ -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
225fi
226
227#-
228#- Come back to original directory ---
229cd -
230
231#-
232#- Unset variables
233Fclean_var.sh
234
235
236exit 0;
Note: See TracBrowser for help on using the repository browser.