1 |
#!/bin/bash |
2 |
# |
3 |
# $Header: /u/gcmpack/MITgcm/tools/build_options/linux_amd64_gfortran,v 1.2 2007/01/31 21:43:34 ce107 Exp $ |
4 |
# $Name: $ |
5 |
# |
6 |
|
7 |
# Tested with gcc-gfortran v4.1.1 on FC5+, using flags formally for |
8 |
# gcc-gfortran 4.3* |
9 |
# It fixes the ' \' versus ' &' terminator problem but some |
10 |
# namelist problems remain. The biggest seems to be the inability |
11 |
# of current gfortran versions to support namelist syntax such as: |
12 |
# |
13 |
# fields(1,1) = 'UVELSLT ','VVELSLT ','WVELSLT ', |
14 |
# |
15 |
# which results in run-time errors. |
16 |
|
17 |
|
18 |
FC=gfortran |
19 |
F90C=gfortran |
20 |
CC=gcc |
21 |
DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR -DUSE_OMP_THREADING' |
22 |
CPP='cpp -traditional -P' |
23 |
NOOPTFLAGS='-O0 -fopenmp' |
24 |
|
25 |
if test "x$DEVEL" != x ; then |
26 |
FFLAGS='-g -Wall -W -ffpe-trap=invalid,zero,overflow -fbounds-check' |
27 |
else |
28 |
FFLAGS='' |
29 |
fi |
30 |
|
31 |
# Requires gfortran from 2006 onwards for -fconvert=big-endian |
32 |
FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none -fopenmp" |
33 |
|
34 |
if test "x$IEEE" = x ; then |
35 |
# No need for IEEE-754 |
36 |
FOPTIM='-O3 -malign-double -funroll-loops' |
37 |
else |
38 |
# Try to follow IEEE-754 |
39 |
has_sse2=f |
40 |
grep flags /proc/cpuinfo | grep sse2 > /dev/null 2>&1 && has_sse2=t |
41 |
if test "x$has_sse2" = xt ; then |
42 |
FOPTIM='-O0 -malign-double -mfpmath=sse -msse -msse2' |
43 |
else |
44 |
FOPTIM='-O0 -malign-double -ffloat-store' |
45 |
fi |
46 |
fi |
47 |
F90FLAGS=$FFLAGS |
48 |
F90OPTIM=$FOPTIM |
49 |
CFLAGS=$FOPTIM |
50 |
|
51 |
if [ "x$NETCDF_ROOT" != x ] ; then |
52 |
INCLUDEDIR="${NETCDF_ROOT}/include" |
53 |
INCLUDES="-I${NETCDF_ROOT}/include" |
54 |
LIBDIR="${NETCDF_ROOT}/lib" |
55 |
LIBS="-L${NETCDF_ROOT}/lib" |
56 |
elif [ "x$NETCDF_HOME" != x ]; then |
57 |
INCLUDEDIR="${NETCDF_HOME}/include" |
58 |
INCLUDES="-I${NETCDF_HOME}/include" |
59 |
LIBDIR="${NETCDF_HOME}/lib" |
60 |
LIBS="-L${NETCDF_HOME}/lib" |
61 |
elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then |
62 |
NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'` |
63 |
NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'` |
64 |
INCLUDEDIR="${NETCDF_INC}" |
65 |
INCLUDES="-I${NETCDF_INC}" |
66 |
LIBDIR="${NETCDF_LIB}" |
67 |
LIBS="-L${NETCDF_LIB}" |
68 |
elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then |
69 |
INCLUDEDIR="${NETCDF_INCDIR}" |
70 |
INCLUDES="-I${NETCDF_INCDIR}" |
71 |
LIBDIR="${NETCDF_LIBDIR}" |
72 |
LIBS="-L${NETCDF_LIBDIR}" |
73 |
elif test -d /usr/include/netcdf-3 ; then |
74 |
INCLUDES='-I/usr/include/netcdf-3' |
75 |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
76 |
elif test -d /usr/include/netcdf ; then |
77 |
INCLUDES='-I/usr/include/netcdf' |
78 |
elif test -d /usr/local/netcdf ; then |
79 |
INCLUDES='-I/usr/local/netcdf/include' |
80 |
LIBS='-L/usr/local/netcdf/lib' |
81 |
elif test -d /usr/local/include/netcdf.inc ; then |
82 |
INCLUDES='-I/usr/local/include' |
83 |
LIBS='-L/usr/local/lib64' |
84 |
fi |