-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlink.Cheyenne_Intel
executable file
·197 lines (172 loc) · 6.4 KB
/
link.Cheyenne_Intel
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
#!/bin/sh
# --------------------------------------------------------------------------- #
# link : Linker script for use in make (customized for hardware and #
# optimization. Note that this script will not be replaced if part #
# of WAVEWATCH III is re-installed. #
# #
# use : link name [name ... ] #
# name: name of source code file without the extension. #
# the first name will become the program name. #
# #
# error codes : all error output directly to screen. #
# #
# remarks : #
# #
# - Upon (first) installation of WAVEWATCH III the user needs to check the #
# following parts of this scripts : #
# sec. 3 : Provide correct link command #
# #
# - This version is made for the Intel ifort version 12 on nehalem. #
# processor. #
# #
# Hendrik L. Tolman #
# February 2012 #
# --------------------------------------------------------------------------- #
# 1. Preparations #
# --------------------------------------------------------------------------- #
# 1.a Check and process input
if [ "$#" -lt '1' ]
then
echo "usage: link name [name]" ; exit 1
fi
prog=$1
echo " Linking $prog"
input="$*"
# 1.b Internal variables - - - - - - - - - - - - - - - - - - - - - - - - - - -
# The following line must not be removed: it is a switch for local install
# so that all bin scripts point to the local wwatch3.env
export ww3_env=/glade/u/home/qingli/wwatch3_v5.16_cheyenne/wwatch3.env
# For manual install (without install_ww3_tar or install_ww3_svn) make sure to
# either use the generic ww3_env or to add your own ww3_env="${my_directory}"
if [ ${WWATCH3_ENV} ]; then ww3_env="${WWATCH3_ENV}"; fi # alternate setup file
# 1.c Read data from the environment file - - - - - - - - - - - - - - - - - -
if [ -f $ww3_env ]
then
set `grep WWATCH3_DIR $ww3_env` ; shift
main_dir="$*"
else
echo "*** Set-up file $ww3_env not found ***"
exit 2
fi
# 1.d Initial clean-up - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rm -f $main_dir/exe/$prog
# --------------------------------------------------------------------------- #
# 2. Check objects #
# --------------------------------------------------------------------------- #
cd $main_dir/obj
objects=$NULL
error='n'
set $input
while [ "$#" -gt '0' ]
do
file=$1.o
if [ -f "$file" ]
then
objects="$objects $file"
else
echo " *** file $file not found ***"
error='y'
fi
shift
done
if [ "$error" = 'y' ]
then
echo "*** Missing object files ***"
exit 3
fi
# --------------------------------------------------------------------------- #
# 3. Link all things #
# --------------------------------------------------------------------------- #
# Add here the correct linker call including switches
# Intel compiler ------------------------------------------------------------
# 3.a Build options and determine compiler name
# No GRIB libraries for this one
# linking options
libs=""
opt="-O3 -march=corei7 -axAVX -ip -o $prog"
# opt="-O3 -xSSE4.2 -ip -o $prog"
# opt="-O3 -prec-div -prec-sqrt -xHost -align array128byte -ip -o $prog"
# opt="-O0 -g -traceback -check all -fpe0 -ftrapuv -o $prog"
# mpi implementation
if [ "$mpi_mod" = 'yes' ]
then
comp=mpif90
which mpif90 1> /dev/null 2> /dev/null
OK=$?
if [ $OK != 0 ]
then
comp='ifort -lmpi'
fi
# opt="-O3 -o $prog"
else
comp=ifort
fi
# open mpi implementation
if [ "$omp_mod" = 'yes' ]
then
opt="$opt -qopenmp"
fi
# palm coupler archive
if [ "$prog" = 'ww3_shel' ] || [ "$prog" = 'ww3_multi' ] || [ "$prog" = 'ww3_sbs1' ]
then
if [ "$palm_mod" = 'yes' ]
then
comp=ar
opt="-rv $prog.a"
prog="$prog.a"
fi
fi
# oasis coupler archive
if [ "$prog" = 'ww3_shel' ] || [ "$prog" = 'ww3_multi' ] || [ "$prog" = 'ww3_sbs1' ] || \
[ "$prog" = 'ww3_prnc' ] || [ "$prog" = 'ww3_prep' ] || [ "$prog" = 'ww3_prtide' ] || \
[ "$prog" = 'ww3_gspl' ]
then
if [ "$oasis_mod" = 'yes' ]
then
echo "link with oasis"
libs="$libs $OASISDIR/lib/libpsmile.MPI1.a $OASISDIR/lib/libmct.a $OASISDIR/lib/libmpeu.a $OASISDIR/lib/libscrip.a" ;
fi
fi
# netcdf library dir
if [ "$netcdf_compile" = 'yes' ]
then
case $WWATCH3_NETCDF in
NC3) libs="$libs -L$NETCDF_LIBDIR -lnetcdf" ;;
NC4) if [ "$mpi_mod" = 'no' ]; then comp="`$NETCDF_CONFIG --fc`"; fi
libs="$libs `$NETCDF_CONFIG --flibs`" ;;
esac
fi
# 3.b Link
$comp $opt $objects $libs > link.out 2> link.err
OK="$?"
# --------------------------------------------------------------------------- #
# 4. Postprocessing #
# --------------------------------------------------------------------------- #
if [ "$OK" != '0' ]
then
echo " *** error in linking ***"
echo ' '
cat link.out
echo ' '
cat link.err
echo ' '
rm -f link.???
rm -f $prog
exit $OK
else
if [ ! -f $prog ]
then
echo " *** program $prog not found ***"
echo ' '
cat link.out
echo ' '
cat link.err
echo ' '
rm -f link.???
exit 1
else
mv $prog $main_dir/exe/.
rm -f link.???
fi
fi
# end of link --------------------------------------------------------------- #