-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcomp.Cheyenne_Intel
212 lines (179 loc) · 7.76 KB
/
comp.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/sh
# --------------------------------------------------------------------------- #
# comp : Compiler script for use in ad3 (customized for hardware and #
# optimization). Note that this script will not be replaced if part #
# of WAVEWATCH III is re-installed. Used by ad3. #
# #
# use : comp name #
# name: name of source code file without the extension. #
# #
# error codes : 1 : input error #
# 2 : no environment file $ww3_env found. #
# 3 : error in creating scratch directory. #
# 4 : w3adc error. #
# 5 : compiler error. #
# #
# remarks : #
# #
# - This script runs from the scratch directory, where it should remain. #
# #
# - For this script to interact with ad3, it needs to generate / leave #
# following files : #
# $name.f90 : Source code (generated by ad3). #
# $name.o : Object module. #
# $name.l : Listing file. #
# comp.stat : status file of compiler, containing number of errors #
# and number of warnings (generated by comp). #
# #
# - Upon (first) installation of WAVEWATCH III the user needs to check the #
# following parts of this script : #
# sec. 2.b : Provide correct compiler/options. #
# sec. 3.a : Provide correct error capturing. #
# sec. 3.d : Remove unnecessary files. #
# #
# - This version is made for the Intel ifort version 12 on Xeon Westmere #
# - On zeus the -list option slows down the compilation time by an order #
# of magnitude. For this section 1.c is added. #
# #
# Hendrik L. Tolman #
# June 2012 #
# --------------------------------------------------------------------------- #
# 1. Preparations #
# --------------------------------------------------------------------------- #
# 1.a Check and process input
if [ "$#" != '1' ]
then
echo "usage: comp name" ; exit 1
fi
name="$1"
# 1.b Initial clean-up - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rm -f $name.l
rm -f $name.o
rm -f comp.stat
# 1.c Set listing option - - - - - - - - - - - - - - - - - - - - - - - - - - -
list=' -list'
list=
# --------------------------------------------------------------------------- #
# 2. Compile #
# --------------------------------------------------------------------------- #
# Add here the correct compiler call including command line options
# Note: - do not invoke a link step
# - if possible, generate a listing $name.l
# - make sure the compiler point to the proper directory where the
# modules are stored ($m_path), see examples below.
# 2.a Determine file extension - - - - - - - - - - - - - - - - - - - - - - - -
# .f90 assumes free format, .f assumes fixed format, change if necessary
# *** file extension (fext) is set and exported by calling program (ad3) ***
# 2.b Perform compilation - - - - - - - - - - - - - - - - - - - - - - - - - -
# Save compiler exit code in $OK
#
# Intel compiler on Linux ----------------------------------------------------
# 2.b.1 Build options and determine compiler name
opt="-c $list -O3 -assume byterecl -march=corei7 -axAVX -ip -module $path_m"
if [ "$name" != 'ww3_gspl' ]
then
opt="$opt -convert big_endian"
fi
# mpi implementation
if [ "$mpi_mod" = 'yes' ]
then
comp=mpif90
which mpif90 1> /dev/null 2> /dev/null
OK=$?
if [ $OK != 0 ]
then
comp=ifort
fi
else
comp=ifort
fi
# open mpi implementation
if [ "$omp_mod" = 'yes' ]
then
opt="$opt -qopenmp"
fi
# oasis coupler include dir
if [ "$oasis_mod" = 'yes' ]
then
opt="$opt -I$OASISDIR/build/lib/psmile.MPI1"
fi
# palm coupler include dir
if [ "$palm_mod" = 'yes' ]
then
opt="$opt -I$PALM_LIBDIR -I$PALM_DIR"
fi
# netcdf include dir
if [ "$netcdf_compile" = 'yes' ]
then
case $WWATCH3_NETCDF in
NC3) opt="$opt -I$NETCDF_INCDIR" ;;
NC4) if [ "$mpi_mod" = 'no' ]; then comp="`$NETCDF_CONFIG --fc`"; fi
opt="$opt -I`$NETCDF_CONFIG --includedir`" ;;
esac
fi
# ftn include dir
opt="$opt -I$path_i"
# 2.b.2 Compile
$comp $opt $name.$fext > $name.out 2> $name.err
OK="$?"
# 2.b.2 Process listing
if [ -s $name.lst ]
then
mv $name.lst $name.l
fi
# 2.b.3 Add test output to listing for later viewing
if [ -s $name.l ]
then
echo '------------' >> $name.l
echo "$comp $opt" >> $name.l
echo '------------' >> $name.l
cat $name.out >> $name.l 2> /dev/null
echo '------------' >> $name.l
cat $name.err >> $name.l 2> /dev/null
echo '------------' >> $name.l
fi
# --------------------------------------------------------------------------- #
# 3. Postprocessing #
# --------------------------------------------------------------------------- #
# 3.a Capture errors
# nr_err : number of errors.
# nr_war : number of errors.
nr_err='0'
nr_war='0'
if [ -s $name.err ]
then
nr_err=`grep 'error' $name.err | wc -l | awk '{ print $1 }'`
nr_war=`grep 'warning' $name.err | wc -l | awk '{ print $1 }'`
else
if [ "$OK" != '0' ]
then
nr_err='1'
fi
fi
# 3.b Make file comp.stat - - - - - - - - - - - - - - - - - - - - - - - - - -
echo "ERROR $nr_err" > comp.stat
echo "WARNING $nr_war" >> comp.stat
# 3.c Prepare listing - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# if compiler does not provide listing, make listing from source code
# and compiler messages. Second input line for w3list identifies if
# comment lines are to be numbered.
if [ ! -f $name.l ]
then
echo "$name.$fext" > w3list.inp
echo "T" >> w3list.inp
w3list < w3list.inp 2> /dev/null
rm -f w3list.inp
mv w3list.out $name.l
echo '------------' >> $name.l
echo "$comp $opt" >> $name.l
echo '------------' >> $name.l
cat $name.out >> $name.l #2> /dev/null
echo '------------' >> $name.l
cat $name.err >> $name.l #2> /dev/null
echo '------------' >> $name.l
fi
# 3.d Remove unwanted files - - - - - - - - - - - - - - - - - - - - - - - - -
# include here unwanted files generated by the compiler
rm -f $name.out
rm -f $name.err
# end of comp --------------------------------------------------------------- #