1 |
#!/bin/bash |
2 |
# |
3 |
# $Header: /u/gcmpack/MITgcm/tools/build_options/linux_ia32_gfortran,v 1.11 2011/09/08 23:10:15 jmc Exp $ |
4 |
# $Name: $ |
5 |
# |
6 |
|
7 |
# Tested with gcc-gfortran v4.1.1 on FC5, FC6, FC8, using flags |
8 |
# formally for gcc-gfortran 4.3* |
9 |
# + with gcc-gfortran v4.3.0 on FC9 |
10 |
|
11 |
#------- |
12 |
# run with OpenMP: needs to set environment var. OMP_NUM_THREADS |
13 |
# and generally, needs to increase the thread stack-size: |
14 |
# - sh,bash: |
15 |
# > export OMP_NUM_THREADS=2 |
16 |
# > export GOMP_STACKSIZE=400m |
17 |
# - csh,tcsh: |
18 |
# > setenv OMP_NUM_THREADS 2 |
19 |
# > setenv GOMP_STACKSIZE 400m |
20 |
#------- |
21 |
|
22 |
if test "x$MPI" = xtrue ; then |
23 |
CC=${CC:=mpicc -m32} |
24 |
FC=${FC:=mpif77 -m32} |
25 |
F90C=${F90C:=mpif90 -m32} |
26 |
else |
27 |
CC=gcc |
28 |
FC=gfortran |
29 |
F90C=gfortran |
30 |
fi |
31 |
|
32 |
DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR' |
33 |
CPP='cpp -traditional -P' |
34 |
EXTENDED_SRC_FLAG='-ffixed-line-length-132' |
35 |
GET_FC_VERSION="--version" |
36 |
OMPFLAG='-fopenmp' |
37 |
|
38 |
NOOPTFLAGS='-O0' |
39 |
NOOPTFILES='' |
40 |
|
41 |
has_sse2=f |
42 |
grep flags /proc/cpuinfo | grep sse2 > /dev/null 2>&1 && has_sse2=t |
43 |
|
44 |
# Requires gfortran from 2006 onwards for -fconvert=big-endian |
45 |
FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none" |
46 |
#- otherwise, switch to the home-made byte-swap: |
47 |
#DEFINES="-D_BYTESWAPIO $DEFINES" |
48 |
|
49 |
if test "x$IEEE" = x ; then #- with optimisation: |
50 |
FOPTIM='-O3 -funroll-loops' |
51 |
#if test "x$has_sse2" = xt ; then |
52 |
# FOPTIM="$FOPTIM -ftree-vectorize -msse -msse2" # <-- from optfile gfortran4.4 |
53 |
#fi |
54 |
else |
55 |
if test "x$DEVEL" = x ; then #- no optimisation + IEEE : |
56 |
if test "x$has_sse2" = xt ; then |
57 |
FOPTIM='-O0 -mfpmath=sse -msse -msse2' |
58 |
else |
59 |
FOPTIM='-O0 -ffloat-store' |
60 |
fi |
61 |
else #- development/check options: |
62 |
FOPTIM='-O0 -ffloat-store' |
63 |
FOPTIM="$FOPTIM -g -ffpe-trap=invalid,zero,overflow -fbounds-check" |
64 |
fi |
65 |
fi |
66 |
# version 4.3.0 has problems with option "-malign-double" ; |
67 |
# may want to put it back with older/newer version (when it works) |
68 |
#FOPTIM="$FOPTIM -malign-double" |
69 |
F90FLAGS=$FFLAGS |
70 |
F90OPTIM=$FOPTIM |
71 |
CFLAGS='-O0' |
72 |
|
73 |
INCLUDEDIRS='' |
74 |
INCLUDES='' |
75 |
LIBS='' |
76 |
|
77 |
if [ "x$NETCDF_ROOT" != x ] ; then |
78 |
INCLUDEDIR="${NETCDF_ROOT}/include" |
79 |
INCLUDES="-I${NETCDF_ROOT}/include" |
80 |
LIBDIR="${NETCDF_ROOT}/lib" |
81 |
LIBS="-L${NETCDF_ROOT}/lib" |
82 |
elif [ "x$NETCDF_HOME" != x ]; then |
83 |
INCLUDEDIR="${NETCDF_HOME}/include" |
84 |
INCLUDES="-I${NETCDF_HOME}/include" |
85 |
LIBDIR="${NETCDF_HOME}/lib" |
86 |
LIBS="-L${NETCDF_HOME}/lib" |
87 |
elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then |
88 |
NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'` |
89 |
NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'` |
90 |
INCLUDEDIR="${NETCDF_INC}" |
91 |
INCLUDES="-I${NETCDF_INC}" |
92 |
LIBDIR="${NETCDF_LIB}" |
93 |
LIBS="-L${NETCDF_LIB}" |
94 |
elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then |
95 |
INCLUDEDIR="${NETCDF_INCDIR}" |
96 |
INCLUDES="-I${NETCDF_INCDIR}" |
97 |
LIBDIR="${NETCDF_LIBDIR}" |
98 |
LIBS="-L${NETCDF_LIBDIR}" |
99 |
elif test -d /usr/include/netcdf-3 ; then |
100 |
INCLUDES='-I/usr/include/netcdf-3' |
101 |
LIBS='-L/usr/lib/netcdf-3' |
102 |
elif test -d /usr/include/netcdf ; then |
103 |
INCLUDES='-I/usr/include/netcdf' |
104 |
elif test -d /usr/local/netcdf ; then |
105 |
INCLUDES='-I/usr/local/netcdf/include' |
106 |
LIBS='-L/usr/local/netcdf/lib' |
107 |
elif test -d /usr/local/include/netcdf.inc ; then |
108 |
INCLUDES='-I/usr/local/include' |
109 |
LIBS='-L/usr/local/lib' |
110 |
fi |
111 |
|
112 |
if [ -n "$MPI_INC_DIR" -a "x$MPI" = xtrue ] ; then |
113 |
INCLUDES="$INCLUDES -I$MPI_INC_DIR" |
114 |
INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR" |
115 |
#- used for parallel (MPI) DIVA |
116 |
MPIINCLUDEDIR="$MPI_INC_DIR" |
117 |
#MPI_HEADER_FILES='mpif.h mpiof.h' |
118 |
fi |