1 |
#!/bin/bash |
2 |
# |
3 |
# $Header: /u/gcmpack/MITgcm/tools/build_options/linux_amd64_ifort,v 1.8 2011/09/12 16:58:50 jmc Exp $ |
4 |
# $Name: $ |
5 |
# |
6 |
# Composed and tested by ce107 on ross/weddell (Opteron system) |
7 |
# Should work fine on EM64T and other AMD64 compatible Intel systems |
8 |
# a) Processor specific flags: |
9 |
# 1) for more speed on Core2 processors replace -xW with -xT |
10 |
# 2) for more speed on Pentium4 based EM64T processors replaces -xW with -xP |
11 |
# b) For more speed, provided your data size doesn't exceed 2GB you can |
12 |
# remove -fPIC which carries a performance penalty of 2-6%. |
13 |
# c) Provided that the libraries you link to are compiled with -fPIC this |
14 |
# optfile should work. |
15 |
# d) You can replace -fPIC with -mcmodel=medium which may perform faster |
16 |
# than -fPIC and still support data sizes over 2GB per process but all |
17 |
# the libraries you link to must be compiled with -fPIC or -mcmodel=medium |
18 |
# e) Changed from -O3 to -O2 to avoid buggy Intel v.10 compilers. Speed |
19 |
# impact appears to be minimal. |
20 |
# |
21 |
# MPI : DON'T FORGET to set environment variable MPI_INC_DIR to the include |
22 |
# directory of your MPI implementation |
23 |
|
24 |
#------- |
25 |
# run with OpenMP: needs to set environment var. OMP_NUM_THREADS |
26 |
# and generally, needs to increase the stack-size: |
27 |
# - sh,bash: |
28 |
# > export OMP_NUM_THREADS=2 |
29 |
# > export KMP_STACKSIZE=400m |
30 |
# - csh,tcsh: |
31 |
# > setenv OMP_NUM_THREADS 2 |
32 |
# > setenv KMP_STACKSIZE 400m |
33 |
# NOTE: with MPI+OpenMP, need to set KMP_STACKSIZE in ~/.tcshrc (but curiously, |
34 |
# works without OMP_NUM_THREADS in ~/.tcshrc). |
35 |
#------- |
36 |
|
37 |
if test "x$MPI" = xtrue ; then |
38 |
CC=mpicc |
39 |
FC=mpif77 |
40 |
F90C=mpif90 |
41 |
LINK="$F90C -i-dynamic -no-ipo" |
42 |
else |
43 |
CC=icc |
44 |
FC=ifort |
45 |
F90C=ifort |
46 |
LINK="$F90C -i-dynamic -no-ipo" |
47 |
fi |
48 |
|
49 |
DEFINES='-DWORDLENGTH=4' |
50 |
CPP='cpp -traditional -P' |
51 |
F90FIXEDFORMAT='-fixed -Tf' |
52 |
EXTENDED_SRC_FLAG='-132' |
53 |
GET_FC_VERSION="--version" |
54 |
OMPFLAG='-openmp' |
55 |
|
56 |
NOOPTFLAGS='-O0 -g' |
57 |
NOOPTFILES='' |
58 |
|
59 |
FFLAGS="$FFLAGS -w95 -W0 -WB -convert big_endian -assume byterecl" |
60 |
FFLAGS="$FFLAGS -fPIC" |
61 |
#- might want to use '-r8' for fizhi pkg: |
62 |
#FFLAGS="$FFLAGS -r8" |
63 |
|
64 |
if test "x$IEEE" = x ; then #- with optimisation: |
65 |
FOPTIM='-O2 -align -xW -ip' |
66 |
else |
67 |
if test "x$DEVEL" = x ; then #- no optimisation + IEEE : |
68 |
# "-mp" is for ieee "maintain precision" |
69 |
FOPTIM='-O0 -noalign -xW -ip -mp' |
70 |
else #- development/check options: |
71 |
FFLAGS="$FFLAGS -warn all -warn nounused" |
72 |
FOPTIM="-fpe0 -fpstkchk -fpmodel except -check all -ftrapuv" |
73 |
FOPTIM="$FOPTIM -O0 -noalign -g -traceback" |
74 |
fi |
75 |
fi |
76 |
|
77 |
F90FLAGS=$FFLAGS |
78 |
F90OPTIM=$FOPTIM |
79 |
CFLAGS='-O0 -ip -fPIC' |
80 |
|
81 |
INCLUDEDIRS='' |
82 |
INCLUDES='' |
83 |
LIBS='' |
84 |
|
85 |
if [ "x$NETCDF_ROOT" != x ] ; then |
86 |
INCLUDEDIRS="${NETCDF_ROOT}/include" |
87 |
INCLUDES="-I${NETCDF_ROOT}/include" |
88 |
LIBS="-L${NETCDF_ROOT}/lib" |
89 |
elif [ "x$NETCDF_HOME" != x ]; then |
90 |
INCLUDEDIRS="${NETCDF_HOME}/include" |
91 |
INCLUDES="-I${NETCDF_HOME}/include" |
92 |
LIBS="-L${NETCDF_HOME}/lib" |
93 |
elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then |
94 |
NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'` |
95 |
NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'` |
96 |
INCLUDEDIRS="${NETCDF_INC}" |
97 |
INCLUDES="-I${NETCDF_INC}" |
98 |
LIBS="-L${NETCDF_LIB}" |
99 |
elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then |
100 |
INCLUDEDIRS="${NETCDF_INCDIR}" |
101 |
INCLUDES="-I${NETCDF_INCDIR}" |
102 |
LIBS="-L${NETCDF_LIBDIR}" |
103 |
elif test -d /usr/include/netcdf-3 ; then |
104 |
INCLUDEDIRS='/usr/include/netcdf-3' |
105 |
INCLUDES='-I/usr/include/netcdf-3' |
106 |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
107 |
elif test -d /usr/include/netcdf ; then |
108 |
INCLUDEDIRS='/usr/include/netcdf' |
109 |
INCLUDES='-I/usr/include/netcdf' |
110 |
elif test -d /usr/local/netcdf ; then |
111 |
INCLUDEDIRS='/usr/include/netcdf/include' |
112 |
INCLUDES='-I/usr/local/netcdf/include' |
113 |
LIBS='-L/usr/local/netcdf/lib' |
114 |
elif test -d /usr/local/include/netcdf.inc ; then |
115 |
INCLUDEDIRS='/usr/local/include' |
116 |
INCLUDES='-I/usr/local/include' |
117 |
LIBS='-L/usr/local/lib64' |
118 |
fi |
119 |
|
120 |
if [ -n "$MPI_INC_DIR" -a "x$MPI" = xtrue ] ; then |
121 |
INCLUDES="$INCLUDES -I$MPI_INC_DIR" |
122 |
INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR" |
123 |
MPIINCLUDEDIR="$MPI_INC_DIR" |
124 |
MPI_HEADER_FILES='mpif.h mpiof.h' |
125 |
MPI_HEADER_FILES_INC='./mpi_headers/mpif.h ./mpi_headers/mpiof.h' |
126 |
fi |