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
#!/bin/bash
#set -x
set -o posix
#set -u
#set -e
#+
#
# ==================
# Fcheck_archfile.sh
# ==================
#
# --------------------------
# Check the compilation file
# --------------------------
#
# SYNOPSIS
# ========
#
# ::
#
# $ Fcheck_archfile.sh
#
#
# DESCRIPTION
# ===========
#
#
# Check the choice of the compiler.
# Three cases :
#
# - There was a previous choice
# - A new one has be specified, we use this one
# - No information, exit
#
# We use TOOLS/COMPILE/arch.fcm to see if something was chosen.
#
# EXAMPLES
# ========
#
# ::
#
# $ ./Fcheck_archfile.sh ARCHFILE CPPFILE COMPILER
#
#
# TODO
# ====
#
# option debug
#
#
# EVOLUTIONS
# ==========
#
# $Id: Fcheck_archfile.sh 14945 2021-06-04 07:38:41Z gsamson $
#
#
#
# * creation
#
#-
cpeval ()
{
cat > $2 << EOF
#==========================================================
# Automatically generated by Fcheck_archfile.sh from
# $1
#==========================================================
EOF
while read line
do
eval "echo \"$line\" >> $2"
done < $1
}
# cleaning related to the old version

Guillaume Samson
committed
rm -f $( find ${COMPIL_DIR} -type f -name $1 -print )
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
208
209
210
211
212
213
214
215
216
#
if [ ${#3} -eq 0 ]; then # arch not specified
if [ ! -f ${COMPIL_DIR}/arch.history ]; then
echo "Warning !!!"
echo "NO compiler chosen"
echo "Try makenemo -h for help"
echo "EXITING..."
exit 1
else # use the arch file defined in arch.history
myarch=$( cat ${COMPIL_DIR}/arch.history )
if [ ! -f $myarch ]; then
echo "Warning !!!"
echo "previously used arch file no more found:"
echo $myarch
echo "EXITING..."
exit 1
else
if [ -f ${COMPIL_DIR}/$1 ]; then
if [ "$2" != "nocpp" ]
then
# has the cpp keys file been changed since we copied the arch file in ${COMPIL_DIR}?
mycpp=$( ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" )
if [ "$mycpp" != "$( cat ${COMPIL_DIR}/cpp.history )" ]; then
echo $mycpp > ${COMPIL_DIR}/cpp.history
cpeval ${myarch} ${COMPIL_DIR}/$1
fi
# has the cpp keys file been updated since we copied the arch file in ${COMPIL_DIR}?
mycpp=$( find -L ${COMPIL_DIR} -cnewer ${COMPIL_DIR}/$1 -name $2 -print )
[ ${#mycpp} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
fi
# has myarch file been updated since we copied it in ${COMPIL_DIR}?
myarchdir=$( dirname ${myarch} )
myarchname=$( basename ${myarch} )
myarch=$( find -L $myarchdir -cnewer ${COMPIL_DIR}/$1 -name $myarchname -print )
[ ${#myarch} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
else
cpeval ${myarch} ${COMPIL_DIR}/$1
fi
fi
fi
else
nb=$( find ${MAIN_DIR}/arch -name arch-${3}.fcm -print | wc -l )
if [ $nb -eq 0 ]; then # no arch file found
echo "Warning !!!"
echo "Compiler not existing"
echo "Try makenemo -h for help"
echo "EXITING..."
exit 1
fi
if [ $nb -gt 1 ]; then # more than 1 arch file found
echo "Warning !!!"
echo "more than 1 arch file for the same compiler have been found"
find ${MAIN_DIR}/arch -name arch-${3}.fcm -print
echo "keep only 1"
echo "EXITING..."
exit 1
fi
myarch=$( find ${MAIN_DIR}/arch -name arch-${3}.fcm -print )
# we were already using this arch file ?
if [ "$myarch" == "$( cat ${COMPIL_DIR}/arch.history )" ]; then
if [ -f ${COMPIL_DIR}/$1 ]; then
if [ "$2" != "nocpp" ]
then
# has the cpp keys file been changed since we copied the arch file in ${COMPIL_DIR}?
mycpp=$( ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" )
if [ "$mycpp" != "$( cat ${COMPIL_DIR}/cpp.history )" ]; then
echo $mycpp > ${COMPIL_DIR}/cpp.history
cpeval ${myarch} ${COMPIL_DIR}/$1
fi
# has the cpp keys file been updated since we copied the arch file in ${COMPIL_DIR}?
mycpp=$( find -L ${COMPIL_DIR} -cnewer ${COMPIL_DIR}/$1 -name $2 -print )
[ ${#mycpp} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
fi
# has myarch file been updated since we copied it in ${COMPIL_DIR}?
myarch=$( find -L ${MAIN_DIR}/arch -cnewer ${COMPIL_DIR}/$1 -name arch-${3}.fcm -print )
[ ${#myarch} -ne 0 ] && cpeval ${myarch} ${COMPIL_DIR}/$1
else
cpeval ${myarch} ${COMPIL_DIR}/$1
fi
else
if [ "$2" != "nocpp" ]
then
ls -l ${COMPIL_DIR}/$2 | sed -e "s/.* -> //" > ${COMPIL_DIR}/cpp.history
fi
echo ${myarch} > ${COMPIL_DIR}/arch.history
cpeval ${myarch} ${COMPIL_DIR}/$1
fi
fi
#- do we need xios library?
#- 2 cases:
#- in CONFIG directory looking for key_xios or key_iomput
if [ "$1" == "arch_nemo.fcm" ]
then
if [ "$2" != "nocpp" ]
then
use_iom=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$2 | grep -c "key_xios\|key_iomput" )
else
use_iom=0
fi
have_lxios=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$1 | grep -c "\-lxios" )
if [[ ( $use_iom -eq 0 ) && ( $have_lxios -ge 1 ) ]]
then
sed -e "s/-lxios//g" ${COMPIL_DIR}/$1 > ${COMPIL_DIR}/tmp$$
mv -f ${COMPIL_DIR}/tmp$$ ${COMPIL_DIR}/$1
fi
#- in TOOLS directory looking for USE xios
else
use_iom=$( egrep --exclude-dir=.svn -r USE ${NEW_CONF}/src/* | grep -c xios )
have_lxios=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$1 | grep -c "\-lxios" )
if [[ ( $use_iom -eq 0 ) || ( $have_lxios != 1 ) ]]
then
sed -e "s/-lxios//g" ${COMPIL_DIR}/$1 > ${COMPIL_DIR}/tmp$$
mv -f ${COMPIL_DIR}/tmp$$ ${COMPIL_DIR}/$1
fi
fi
#- do we need oasis libraries?
if [ "$2" != "nocpp" ]
then
use_oasis=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$2 | grep -c key_oasis3 )
else
use_oasis=0
fi
#ignore use_oasis if XIOS_OASIS is set (doesn't matter to what value)
if [[ ! -z "$XIOS_OASIS" ]]; then
use_oasis=1
fi
for liboa in psmile.MPI1 mct mpeu scrip mpp_io
do
have_liboa=$( sed -e "s/#.*$//" ${COMPIL_DIR}/$1 | grep -c "\-l${liboa}" )
if [[ ( $use_oasis -eq 0 ) && ( $have_liboa -ge 1 ) ]]
then
sed -e "s/-l${liboa}//g" ${COMPIL_DIR}/$1 > ${COMPIL_DIR}/tmp$$
mv -f ${COMPIL_DIR}/tmp$$ ${COMPIL_DIR}/$1
fi
done

Guillaume Samson
committed
# Nemo debug ?
if [ -n "${NEMO_DBG}" ]; then
if (! grep -q "^%DEBUG_FCFLAGS" ${COMPIL_DIR}/$1 ); then

Guillaume Samson
committed
echo "ERROR: You must defined '%DEBUG_FCFLAGS' in your arch file if you want to compile Nemo in debug mode using '-d' option"
exit 1
fi
# duplicate the lines starting with %DEBUG_XXX and replace, in the duplicated line, %DEBUG_XXX by %XXX
sed -i "/^%DEBUG_/{p;s/^%DEBUG_\([^ ]*\)/%\1/;}" ${COMPIL_DIR}/$1
else
if (! grep -q "^%PROD_FCFLAGS" ${COMPIL_DIR}/$1 ); then

Guillaume Samson
committed
echo "WARNING: '%PROD_FCFLAGS' not defined in your arch file, makenemo will use '%FCFLAGS' instead"
fi
# duplicate the lines starting with %PROD_XXX and replace, in the duplicated line, %PROD_XXX by %XXX
sed -i "/^%PROD_/{p;s/^%PROD_\([^ ]*\)/%\1/;}" ${COMPIL_DIR}/$1
fi