3 |
# $Header$ |
# $Header$ |
4 |
# $Name$ |
# $Name$ |
5 |
|
|
6 |
|
# Build options for gfortran compiler (GNU) on Linux AMD64 platform |
7 |
|
# |
8 |
# Tested with gcc-gfortran v4.1.x as shipped with Fedora Core 6,7,8 |
# Tested with gcc-gfortran v4.1.x as shipped with Fedora Core 6,7,8 |
9 |
# with gcc-gfortran v4.3.x as shipped with Fedora Core 9,10 |
# with gcc-gfortran v4.3.x as shipped with Fedora Core 9,10 |
10 |
# It fixes the ' \' versus ' &' terminator ; |
# |
|
# with older versions (v4.0): namelist problems with syntax such as: |
|
|
# fields(1,1) = 'UVELSLT ','VVELSLT ','WVELSLT ', |
|
|
# which results in run-time errors.) |
|
|
|
|
11 |
# OpenMP : Tested on dickens with gcc-gfortran v4.3.2 as shipped with FC 10 |
# OpenMP : Tested on dickens with gcc-gfortran v4.3.2 as shipped with FC 10 |
12 |
|
# on baudelaire with gcc-gfortran v4.4.5 as shipped with FC 13 |
13 |
|
# on danton with gcc-gfortran v4.5.1 as shipped with FC 14 |
14 |
|
# with gcc-gfortran v4.7.x as shipped with FC 17 |
15 |
|
# with gcc-gfortran v4.8.1 as shipped with FC 19 |
16 |
|
# on acesgrid with gcc-gfortran v4.6.0 as shipped with FC 15 |
17 |
|
# |
18 |
|
# MPI : Tested on acesgrid (Fedora Core 15), using: |
19 |
|
# module load gcc (Version 4.6.0) |
20 |
|
# and with mpich1: |
21 |
|
# module load mvapich |
22 |
|
# or with mpich2: |
23 |
|
# module load mvapich2 |
24 |
|
# or with openmpi: |
25 |
|
# module load openmpi |
26 |
|
# and on baudelaire.csail.mit.edu (FC13), using: |
27 |
|
# export MPI_GCC_DIR=/srv/software/gcc/gcc-packages/gcc-4.4.5/mpich2/mpich2-1.3 |
28 |
|
# export MPI_INC_DIR=$MPI_GCC_DIR/include |
29 |
|
# export PATH=$MPI_GCC_DIR/bin:$PATH |
30 |
|
# |
31 |
|
# and on IRIDIS at Southampton |
32 |
|
# http://www.southampton.ac.uk/isolutions/computing/hpc/iridis/ |
33 |
|
# with |
34 |
|
# module load openmpi/1.4.3/gcc-4.3.3 |
35 |
|
# and |
36 |
|
# export MPI_INC_DIR=$MPIROOT/include |
37 |
|
|
38 |
#------- |
#------- |
39 |
# run with OpenMP: needs to set environment var. OMP_NUM_THREADS |
# run with OpenMP: needs to set environment var. OMP_NUM_THREADS |
40 |
# and generally, needs to increase the thread stack-size: |
# and generally, needs to increase the thread stack-size: |
41 |
# - sh,bash: |
# - sh,bash: |
42 |
# > export OMP_NUM_THREADS=2 |
# > export OMP_NUM_THREADS=2 |
46 |
# > setenv GOMP_STACKSIZE 400m |
# > setenv GOMP_STACKSIZE 400m |
47 |
#------- |
#------- |
48 |
|
|
49 |
FC=gfortran |
if test "x$MPI" = xtrue ; then |
50 |
F90C=gfortran |
CC=${CC:=mpicc} |
51 |
CC=gcc |
FC=${FC:=mpif77} |
52 |
|
F90C=${F90C:=mpif90} |
53 |
|
else |
54 |
|
CC=gcc |
55 |
|
FC=gfortran |
56 |
|
F90C=gfortran |
57 |
|
fi |
58 |
|
|
59 |
DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR' |
DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR' |
|
CPP='cpp -traditional -P' |
|
|
NOOPTFLAGS='-O0' |
|
60 |
EXTENDED_SRC_FLAG='-ffixed-line-length-132' |
EXTENDED_SRC_FLAG='-ffixed-line-length-132' |
61 |
|
F90FIXEDFORMAT='-ffixed-form' |
62 |
|
GET_FC_VERSION="--version" |
63 |
OMPFLAG='-fopenmp' |
OMPFLAG='-fopenmp' |
64 |
|
|
65 |
if test "x$DEVEL" != x ; then |
NOOPTFLAGS='-O0' |
66 |
FFLAGS='-g -Wall -W -ffpe-trap=invalid,zero,overflow -fbounds-check' |
NOOPTFILES='' |
|
else |
|
|
FFLAGS='' |
|
|
fi |
|
67 |
|
|
68 |
# Requires gfortran from 2006 onwards for -fconvert=big-endian |
CFLAGS='-O0' |
69 |
|
#- Requires gfortran from 2006 onwards for -fconvert=big-endian |
70 |
FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none" |
FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none" |
71 |
|
#- for big setups, compile & link with "-fPIC" or set memory-model to "medium": |
72 |
|
#CFLAGS="$CFLAGS -fPIC" |
73 |
|
#FFLAGS="$FFLAGS -fPIC" |
74 |
|
#- with FC 19, need to use this without -fPIC (which cancels -mcmodel option): |
75 |
|
CFLAGS="$CFLAGS -mcmodel=medium" |
76 |
|
FFLAGS="$FFLAGS -mcmodel=medium" |
77 |
|
#- might want to use '-fdefault-real-8' for fizhi pkg: |
78 |
|
#FFLAGS="$FFLAGS -fdefault-real-8 -fdefault-double-8" |
79 |
|
|
80 |
if test "x$IEEE" = x ; then |
if test "x$IEEE" = x ; then #- with optimisation: |
81 |
# No need for IEEE-754 |
#- full optimisation |
82 |
FOPTIM='-O3 -funroll-loops' |
FOPTIM='-O3 -funroll-loops' |
83 |
|
NOOPTFILES="$NOOPTFILES ini_masks_etc.F" |
84 |
|
#- can use -O2 (safe optimisation) to avoid Pb with some gcc version of -O3: |
85 |
|
#FOPTIM='-O2 -funroll-loops' |
86 |
else |
else |
87 |
# Try to follow IEEE-754 |
# these may also be useful, but require specific gfortran versions: |
88 |
# these may also be useful, but require specific gfortran versions: |
# -Wnonstd-intrinsics for gfortran <= 4.3 |
89 |
# -Wnonstd-intrinsics for gfortran <= 4.3 |
# -Wintrinsics-std for gfortran >= 4.4 |
90 |
# -Wintrinsics-std for gfortran >= 4.4 |
# -Wno-tabs for gfortran >= 4.3 |
|
# -Wno-tabs for gfortran >= 4.3 |
|
91 |
FFLAGS="$FFLAGS -Waliasing -Wampersand -Wsurprising -Wline-truncation" |
FFLAGS="$FFLAGS -Waliasing -Wampersand -Wsurprising -Wline-truncation" |
92 |
# to get plenty of warnings : |
#- to get plenty of warnings: -Wall -Wextra (older form: -Wall -W) or: |
93 |
# FFLAGS="$FFLAGS -Wconversion -Wimplicit-interface -Wunused-labels" |
#FFLAGS="$FFLAGS -Wconversion -Wimplicit-interface -Wunused-labels" |
94 |
|
if test "x$DEVEL" = x ; then #- no optimisation + IEEE : |
95 |
FOPTIM='-O0' |
FOPTIM='-O0' |
96 |
# for automatic testing with testreport (but no relation with IEEE arithmetic): |
else #- development/check options: |
97 |
FOPTIM="$FOPTIM -g -ffpe-trap=invalid,zero,overflow -fbounds-check" |
FOPTIM='-O0 -g -fbounds-check' |
98 |
|
FOPTIM="$FOPTIM -ffpe-trap=invalid,zero,overflow -finit-real=inf" |
99 |
|
fi |
100 |
fi |
fi |
101 |
|
|
102 |
F90FLAGS=$FFLAGS |
F90FLAGS=$FFLAGS |
103 |
F90OPTIM=$FOPTIM |
F90OPTIM=$FOPTIM |
104 |
CFLAGS=$FOPTIM |
|
105 |
|
INCLUDEDIRS='' |
106 |
|
INCLUDES='' |
107 |
|
LIBS='' |
108 |
|
|
109 |
if [ "x$NETCDF_ROOT" != x ] ; then |
if [ "x$NETCDF_ROOT" != x ] ; then |
110 |
INCLUDEDIR="${NETCDF_ROOT}/include" |
INCLUDEDIR="${NETCDF_ROOT}/include" |
128 |
INCLUDES="-I${NETCDF_INCDIR}" |
INCLUDES="-I${NETCDF_INCDIR}" |
129 |
LIBDIR="${NETCDF_LIBDIR}" |
LIBDIR="${NETCDF_LIBDIR}" |
130 |
LIBS="-L${NETCDF_LIBDIR}" |
LIBS="-L${NETCDF_LIBDIR}" |
|
elif test -d /sopt/netcdf/netcdf3-gcc-serial; then |
|
|
INCLUDES='-I/sopt/netcdf/netcdf3-gcc-serial/include' |
|
|
LIBS='-L/sopt/netcdf/netcdf3-gcc-serial/lib' |
|
131 |
elif test -d /usr/include/netcdf-3 ; then |
elif test -d /usr/include/netcdf-3 ; then |
132 |
INCLUDES='-I/usr/include/netcdf-3' |
INCLUDES='-I/usr/include/netcdf-3' |
133 |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
139 |
elif test -d /usr/local/include/netcdf.inc ; then |
elif test -d /usr/local/include/netcdf.inc ; then |
140 |
INCLUDES='-I/usr/local/include' |
INCLUDES='-I/usr/local/include' |
141 |
LIBS='-L/usr/local/lib64' |
LIBS='-L/usr/local/lib64' |
142 |
|
elif test -d /usr/include/netcdf.inc ; then |
143 |
|
INCLUDES='-I/usr/include' |
144 |
|
LIBS='-L/usr/lib64' |
145 |
|
fi |
146 |
|
|
147 |
|
if [ -n "$MPI_INC_DIR" -a "x$MPI" = xtrue ] ; then |
148 |
|
INCLUDES="$INCLUDES -I$MPI_INC_DIR" |
149 |
|
INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR" |
150 |
|
#- used for parallel (MPI) DIVA |
151 |
|
MPIINCLUDEDIR="$MPI_INC_DIR" |
152 |
|
#MPI_HEADER_FILES='mpif.h mpiof.h' |
153 |
fi |
fi |