Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
#set -x
set -o posix
#set -u
#set -e
#+
#
# ===============
# maketools
# ===============
#
# --------------------------
# Compile NEMO
# --------------------------
#
# SYNOPSIS
# ========
#
# ::
#
# $ maketools
#
#
# DESCRIPTION
# ===========
#
#
# This script aims :
#
# - to choose a tool to compile
# - to choose compiler options
# - to compile this tool
#
# Variables used :
#
# From user input
#
# - NEW_CONF : configuration to be created
# - CMP_NAM : compiler name
# - NBR_PRC : number of processes used to compile
#
# Locally defined :
#
# - MAIN_DIR : self explaining
# - MODELES_DIR : " " "
# - TOOLS_DIR : " " "
# - NEMO_DIR : " " "
#
# EXAMPLES
# ========
#
# ::
#
# $ ./maketools -t ifort_osx - j3 -n NESTING
#
#
# TODO
# ====
#
# option debug
#
#
# EVOLUTIONS
# ==========
#
# $Id: maketools 12415 2020-02-19 20:29:26Z smueller $
#
#
#
# * creation
#
#-
#- Local variables ---
b_n=$(basename ${0})
export TOOLS_DIR=$(cd $(dirname "$0"); pwd)
export MAIN_DIR=${TOOLS_DIR%/tools}
export COMPIL_DIR=${MAIN_DIR}/mk
export NEMO_DIR=${MAIN_DIR}/NEMO
#-
#- FCM and functions location ---
export PATH=${MAIN_DIR}/ext/FCM/bin:$PATH
#-
#- Choice of the options ---
x_h="";
x_n="";
x_m="";
x_t="";
x_c="";
x_j=1;
while getopts :hm:n:r:j:t: V
do
case $V in
(h) x_h=${OPTARG};
echo "Usage : "${b_n} \
" [-h] [-n name] [-m arch] [-j No] [-t tmpdir]";
echo " -h : help";
echo " -h institute : specific help for consortium members";
echo " -n name : tool name, [-n help] to list existing tools";
echo " -m arch : choose compiler, [-m help] to list exiting compilers";
echo " -j No : number of processes used to compile (0=nocompilation)";
echo " -t dir : remporary directory for compilation"
echo "";
echo "Example to compile Agrif Nesting tools";
echo "maketools -n NESTING" ;
echo "";
printf "%s\n" "Available tools :" `ls ${TOOLS_DIR}|grep -v COMPILE | grep -v maketools`;
echo "";
. ${COMPIL_DIR}/Flist_archfile.sh ${x_h};
echo "";
echo "Default : previous tool and compiler";
exit 0;;
(n) x_n=${OPTARG};;
(m) x_m=${OPTARG};;
(j) x_j=${OPTARG};;
(t) x_t=${OPTARG};;
(:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
exit 2;;
(\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
exit 2;;
esac
done
shift $(($OPTIND-1));
#-
#- Get the clean option
[[ "${#@}" -ne 0 && "${@}" != clean ]] && echo "Invalid option "$@" " && exit
[ "${#@}" -ne 0 ] && x_c="--$@"
#-
#- Go to NEMOGCM/tools directory ---
cd ${TOOLS_DIR}
#-
#- Initialisation from input ---
export NEW_CONF=${x_n}
NBR_PRC=${x_j}
CMP_NAM=${x_m}
NEMO_TDIR=${x_t:-$NEMO_TDIR}
export NEMO_TDIR=${NEMO_TDIR:-$TOOLS_DIR}
#- Check if the tool or the compiler exist or list it
[ "${NEW_CONF}" == help ] && printf "%s\n" "Available tools :" `ls ${TOOLS_DIR}|grep -v COMPILE | grep -v maketools` && exit
[ "${CMP_NAM}" == help ] && . ${COMPIL_DIR}/Flist_archfile.sh all && exit
#- Choose a default tool if needed ---
#- REBUILD or last one used ---
. ${COMPIL_DIR}/Fcheck_config.sh tools.txt ${NEW_CONF} || exit
#- Save new configuration ---
echo "${NEW_CONF} " > ${COMPIL_DIR}/tools.txt
#- Make the building directory
. ${COMPIL_DIR}/Fmake_tools_bld.sh ${TOOLS_DIR} ${NEW_CONF} ${NEMO_TDIR} || exit
#- At this stage cpp keys have been updated. we can check the arch file
#- When used for the first time, choose a compiler ---
. ${COMPIL_DIR}/Fcheck_archfile.sh arch_tools.fcm cpp_tools.fcm ${CMP_NAM} || exit
#- At this stage the configuration has beeen chosen
#- We coose the default light file
export USEBLD=bldxag_tools.cfg
#- We look after agrif
grep key_agrif ${COMPIL_DIR}/cpp_tools.fcm && export AGRIFUSE=1 && export USEBLD=${USEBLD/xag/}
. ${COMPIL_DIR}/Fprep_agrif.sh ${NEW_CONF} ${TOOLS_DIR} arch_tools.fcm|| exit 3
#-
#_ END OF CONFIGURATION PHASE
#_
#-
#- Compile ---
if [ "${NBR_PRC}" -gt 0 ]; then
cd ${TOOLS_DIR}/${NEW_CONF} || cd -
## if AGRIF we do a first preprocessing
if [[ ${#x_c} -eq 0 && "$AGRIFUSE" -eq 1 ]]; then
fcm build --ignore-lock -j 1 ${COMPIL_DIR}/bld_preproagr_tools.cfg ||{ cd - ; exit 1 ;}
echo ''
echo "---------------------------------"
echo "CONV preprocessing successfull !!"
echo "---------------------------------"
echo ''
fi
fcm build ${x_c} --ignore-lock -v 1 -j ${NBR_PRC} ${COMPIL_DIR}/${USEBLD} || cd -
if [ -n "$(ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe)" ]; then
for i in `ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe`
do
ln -sf ${i} ${TOOLS_DIR}/${NEW_CONF}/.
done
fi
fi
#-
#- Come back to original directory ---
cd -
#-
#- Unset variables
${COMPIL_DIR}/Fclean_var.sh
exit 0;