1 |
#!/bin/bash |
#!/bin/bash |
2 |
# |
|
3 |
# $Header$ |
# $Header$ |
4 |
# $Name$ |
# $Name$ |
|
# |
|
5 |
|
|
6 |
# Tested with gcc-gfortran v4.0.x as shipped with Fedora Core 4. |
|
7 |
# It fixes the ' \' versus ' &' terminator problem but some |
# Tested with gcc-gfortran v4.1.x as shipped with Fedora Core 6,7,8 |
8 |
# namelist problems remain. The biggest seems to be the inability |
# with gcc-gfortran v4.3.x as shipped with Fedora Core 9,10 |
9 |
# of current gfortran versions to support namelist syntax such as: |
# It fixes the ' \' versus ' &' terminator ; |
10 |
# |
# with older versions (v4.0): namelist problems with syntax such as: |
11 |
# fields(1,1) = 'UVELSLT ','VVELSLT ','WVELSLT ', |
# fields(1,1) = 'UVELSLT ','VVELSLT ','WVELSLT ', |
12 |
# |
# which results in run-time errors.) |
|
# which results in run-time errors. |
|
13 |
|
|
14 |
|
# OpenMP : Tested on dickens with gcc-gfortran v4.3.2 as shipped with FC 10 |
15 |
|
#------- |
16 |
|
# run with OpenMP: needs to set environment var. OMP_NUM_THREADS |
17 |
|
# and generally, needs to increase the thread stack-size: |
18 |
|
# - sh,bash: |
19 |
|
# > export OMP_NUM_THREADS=2 |
20 |
|
# > export GOMP_STACKSIZE=400m |
21 |
|
# - csh,tcsh: |
22 |
|
# > setenv OMP_NUM_THREADS 2 |
23 |
|
# > setenv GOMP_STACKSIZE 400m |
24 |
|
#------- |
25 |
|
|
26 |
FC=gfortran |
FC=gfortran |
27 |
|
F90C=gfortran |
28 |
CC=gcc |
CC=gcc |
29 |
DEFINES='-D_BYTESWAPIO -DWORDLENGTH=4 -DNML_TERMINATOR' |
DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR' |
|
# CPP='gcc -E -traditional -P -' |
|
30 |
CPP='cpp -traditional -P' |
CPP='cpp -traditional -P' |
31 |
NOOPTFLAGS='-O0' |
NOOPTFLAGS='-O0' |
32 |
|
EXTENDED_SRC_FLAG='-ffixed-line-length-132' |
33 |
|
OMPFLAG='-fopenmp' |
34 |
|
|
35 |
|
if test "x$DEVEL" != x ; then |
36 |
|
FFLAGS='-g -Wall -W -ffpe-trap=invalid,zero,overflow -fbounds-check' |
37 |
|
else |
38 |
|
FFLAGS='' |
39 |
|
fi |
40 |
|
|
41 |
|
# Requires gfortran from 2006 onwards for -fconvert=big-endian |
42 |
|
FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none" |
43 |
|
|
44 |
if test "x$IEEE" = x ; then |
if test "x$IEEE" = x ; then |
45 |
# No need for IEEE-754 |
# No need for IEEE-754 |
|
# "warning: -Wuninitialized is not supported without -O" |
|
|
FFLAGS='-Wunused' |
|
46 |
FOPTIM='-O3 -funroll-loops' |
FOPTIM='-O3 -funroll-loops' |
47 |
else |
else |
48 |
# Try to follow IEEE-754 |
# Try to follow IEEE-754 |
49 |
has_sse2=f |
# these may also be useful, but require specific gfortran versions: |
50 |
grep flags /proc/cpuinfo | grep sse2 > /dev/null 2>&1 && has_sse2=t |
# -Wnonstd-intrinsics for gfortran <= 4.3 |
51 |
if test "x$has_sse2" = xt ; then |
# -Wintrinsics-std for gfortran >= 4.4 |
52 |
FFLAGS='-Wunused -mfpmath=sse -msse -msse2' |
# -Wno-tabs for gfortran >= 4.3 |
53 |
else |
FFLAGS="$FFLAGS -Waliasing -Wampersand -Wsurprising -Wline-truncation" |
54 |
FFLAGS='-Wunused -ffloat-store' |
# to get plenty of warnings : |
55 |
fi |
# FFLAGS="$FFLAGS -Wconversion -Wimplicit-interface -Wunused-labels" |
56 |
# echo 'FFLAGS="'$FFLAGS'"' |
FOPTIM='-O0' |
57 |
FOPTIM='-O0 -malign-double' |
# for automatic testing with testreport (but no relation with IEEE arithmetic): |
58 |
|
FOPTIM="$FOPTIM -g -ffpe-trap=invalid,zero,overflow -fbounds-check" |
59 |
fi |
fi |
60 |
|
F90FLAGS=$FFLAGS |
61 |
if test -d /usr/include/netcdf-3 ; then |
F90OPTIM=$FOPTIM |
62 |
|
CFLAGS=$FOPTIM |
63 |
|
|
64 |
|
if [ "x$NETCDF_ROOT" != x ] ; then |
65 |
|
INCLUDEDIR="${NETCDF_ROOT}/include" |
66 |
|
INCLUDES="-I${NETCDF_ROOT}/include" |
67 |
|
LIBDIR="${NETCDF_ROOT}/lib" |
68 |
|
LIBS="-L${NETCDF_ROOT}/lib" |
69 |
|
elif [ "x$NETCDF_HOME" != x ]; then |
70 |
|
INCLUDEDIR="${NETCDF_HOME}/include" |
71 |
|
INCLUDES="-I${NETCDF_HOME}/include" |
72 |
|
LIBDIR="${NETCDF_HOME}/lib" |
73 |
|
LIBS="-L${NETCDF_HOME}/lib" |
74 |
|
elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then |
75 |
|
NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'` |
76 |
|
NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'` |
77 |
|
INCLUDEDIR="${NETCDF_INC}" |
78 |
|
INCLUDES="-I${NETCDF_INC}" |
79 |
|
LIBDIR="${NETCDF_LIB}" |
80 |
|
LIBS="-L${NETCDF_LIB}" |
81 |
|
elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then |
82 |
|
INCLUDEDIR="${NETCDF_INCDIR}" |
83 |
|
INCLUDES="-I${NETCDF_INCDIR}" |
84 |
|
LIBDIR="${NETCDF_LIBDIR}" |
85 |
|
LIBS="-L${NETCDF_LIBDIR}" |
86 |
|
elif test -d /usr/include/netcdf-3 ; then |
87 |
INCLUDES='-I/usr/include/netcdf-3' |
INCLUDES='-I/usr/include/netcdf-3' |
88 |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
89 |
elif test -d /usr/include/netcdf ; then |
elif test -d /usr/include/netcdf ; then |
91 |
elif test -d /usr/local/netcdf ; then |
elif test -d /usr/local/netcdf ; then |
92 |
INCLUDES='-I/usr/local/netcdf/include' |
INCLUDES='-I/usr/local/netcdf/include' |
93 |
LIBS='-L/usr/local/netcdf/lib' |
LIBS='-L/usr/local/netcdf/lib' |
94 |
|
elif test -d /usr/local/include/netcdf.inc ; then |
95 |
|
INCLUDES='-I/usr/local/include' |
96 |
|
LIBS='-L/usr/local/lib64' |
97 |
fi |
fi |
|
|
|