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. |
# Build options for gfortran compiler (GNU) on Linux AMD64 platform |
7 |
# It fixes the ' \' versus ' &' terminator problem but some |
# |
8 |
# namelist problems remain. The biggest seems to be the inability |
# Tested with gcc-gfortran v4.1.x as shipped with Fedora Core 6,7,8 |
9 |
# of current gfortran versions to support namelist syntax such as: |
# with gcc-gfortran v4.3.x as shipped with Fedora Core 9,10 |
10 |
# |
# |
11 |
# fields(1,1) = 'UVELSLT ','VVELSLT ','WVELSLT ', |
# 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 |
|
# on acesgrid with gcc-gfortran v4.6.0 as shipped with FC 15 |
15 |
# |
# |
16 |
# which results in run-time errors. |
# MPI : Tested on acesgrid (Fedora Core 15), using: |
17 |
|
# module load gcc (Version 4.6.0) |
18 |
|
# and with mpich1: |
19 |
|
# module load mvapich |
20 |
|
# or with mpich2: |
21 |
|
# module load mvapich2 |
22 |
|
# or with openmpi: |
23 |
|
# module load openmpi |
24 |
|
# and on baudelaire.csail.mit.edu (FC13), using: |
25 |
|
# export MPI_GCC_DIR=/srv/software/gcc/gcc-packages/gcc-4.4.5/mpich2/mpich2-1.3 |
26 |
|
# export MPI_INC_DIR=$MPI_GCC_DIR/include |
27 |
|
# export PATH=$MPI_GCC_DIR/bin:$PATH |
28 |
|
|
29 |
|
#------- |
30 |
|
# run with OpenMP: needs to set environment var. OMP_NUM_THREADS |
31 |
|
# and generally, needs to increase the thread stack-size: |
32 |
|
# - sh,bash: |
33 |
|
# > export OMP_NUM_THREADS=2 |
34 |
|
# > export GOMP_STACKSIZE=400m |
35 |
|
# - csh,tcsh: |
36 |
|
# > setenv OMP_NUM_THREADS 2 |
37 |
|
# > setenv GOMP_STACKSIZE 400m |
38 |
|
#------- |
39 |
|
|
40 |
|
if test "x$MPI" = xtrue ; then |
41 |
|
CC=${CC:=mpicc} |
42 |
|
FC=${FC:=mpif77} |
43 |
|
F90C=${F90C:=mpif90} |
44 |
|
else |
45 |
|
CC=gcc |
46 |
|
FC=gfortran |
47 |
|
F90C=gfortran |
48 |
|
fi |
49 |
|
|
50 |
|
DEFINES='-DWORDLENGTH=4 -DNML_TERMINATOR' |
51 |
|
CPP='cpp -traditional -P' |
52 |
|
EXTENDED_SRC_FLAG='-ffixed-line-length-132' |
53 |
|
F90FIXEDFORMAT='-ffixed-form' |
54 |
|
GET_FC_VERSION="--version" |
55 |
|
OMPFLAG='-fopenmp' |
56 |
|
|
|
FC=gfortran |
|
|
CC=gcc |
|
|
DEFINES='-D_BYTESWAPIO -DWORDLENGTH=4 -DNML_TERMINATOR' |
|
|
# CPP='gcc -E -traditional -P -' |
|
|
CPP='cpp -traditional -P' |
|
57 |
NOOPTFLAGS='-O0' |
NOOPTFLAGS='-O0' |
58 |
|
NOOPTFILES='' |
59 |
|
|
60 |
if test "x$IEEE" = x ; then |
# Requires gfortran from 2006 onwards for -fconvert=big-endian |
61 |
# No need for IEEE-754 |
FFLAGS="$FFLAGS -fconvert=big-endian -fimplicit-none" |
62 |
# "warning: -Wuninitialized is not supported without -O" |
# for big objects: |
63 |
FFLAGS='-Wunused' |
FFLAGS="$FFLAGS -fPIC" |
64 |
|
#- might want to use '-fdefault-real-8' for fizhi pkg: |
65 |
|
#FFLAGS="$FFLAGS -fdefault-real-8" |
66 |
|
|
67 |
|
if test "x$IEEE" = x ; then #- with optimisation: |
68 |
|
#- full optimisation |
69 |
FOPTIM='-O3 -funroll-loops' |
FOPTIM='-O3 -funroll-loops' |
70 |
|
NOOPTFILES="$NOOPTFILES ini_masks_etc.F" |
71 |
|
#- can use -O2 (safe optimisation) to avoid Pb with some gcc version of -O3: |
72 |
|
#FOPTIM='-O2 -funroll-loops' |
73 |
else |
else |
74 |
# Try to follow IEEE-754 |
# these may also be useful, but require specific gfortran versions: |
75 |
has_sse2=f |
# -Wnonstd-intrinsics for gfortran <= 4.3 |
76 |
grep flags /proc/cpuinfo | grep sse2 > /dev/null 2>&1 && has_sse2=t |
# -Wintrinsics-std for gfortran >= 4.4 |
77 |
if test "x$has_sse2" = xt ; then |
# -Wno-tabs for gfortran >= 4.3 |
78 |
FFLAGS='-Wunused -mfpmath=sse -msse -msse2' |
FFLAGS="$FFLAGS -Waliasing -Wampersand -Wsurprising -Wline-truncation" |
79 |
else |
#- to get plenty of warnings: -Wall -Wextra (older form: -Wall -W) or: |
80 |
FFLAGS='-Wunused -ffloat-store' |
#FFLAGS="$FFLAGS -Wconversion -Wimplicit-interface -Wunused-labels" |
81 |
fi |
if test "x$DEVEL" = x ; then #- no optimisation + IEEE : |
82 |
# echo 'FFLAGS="'$FFLAGS'"' |
FOPTIM='-O0' |
83 |
FOPTIM='-O0 -malign-double' |
else #- development/check options: |
84 |
|
FOPTIM='-O0' |
85 |
|
FOPTIM="$FOPTIM -g -ffpe-trap=invalid,zero,overflow -fbounds-check" |
86 |
|
fi |
87 |
fi |
fi |
88 |
|
|
89 |
if test -d /usr/include/netcdf-3 ; then |
F90FLAGS=$FFLAGS |
90 |
|
F90OPTIM=$FOPTIM |
91 |
|
CFLAGS='-O0 -fPIC' |
92 |
|
|
93 |
|
INCLUDEDIRS='' |
94 |
|
INCLUDES='' |
95 |
|
LIBS='' |
96 |
|
|
97 |
|
if [ "x$NETCDF_ROOT" != x ] ; then |
98 |
|
INCLUDEDIR="${NETCDF_ROOT}/include" |
99 |
|
INCLUDES="-I${NETCDF_ROOT}/include" |
100 |
|
LIBDIR="${NETCDF_ROOT}/lib" |
101 |
|
LIBS="-L${NETCDF_ROOT}/lib" |
102 |
|
elif [ "x$NETCDF_HOME" != x ]; then |
103 |
|
INCLUDEDIR="${NETCDF_HOME}/include" |
104 |
|
INCLUDES="-I${NETCDF_HOME}/include" |
105 |
|
LIBDIR="${NETCDF_HOME}/lib" |
106 |
|
LIBS="-L${NETCDF_HOME}/lib" |
107 |
|
elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then |
108 |
|
NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'` |
109 |
|
NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'` |
110 |
|
INCLUDEDIR="${NETCDF_INC}" |
111 |
|
INCLUDES="-I${NETCDF_INC}" |
112 |
|
LIBDIR="${NETCDF_LIB}" |
113 |
|
LIBS="-L${NETCDF_LIB}" |
114 |
|
elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then |
115 |
|
INCLUDEDIR="${NETCDF_INCDIR}" |
116 |
|
INCLUDES="-I${NETCDF_INCDIR}" |
117 |
|
LIBDIR="${NETCDF_LIBDIR}" |
118 |
|
LIBS="-L${NETCDF_LIBDIR}" |
119 |
|
elif test -d /usr/include/netcdf-3 ; then |
120 |
INCLUDES='-I/usr/include/netcdf-3' |
INCLUDES='-I/usr/include/netcdf-3' |
121 |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
122 |
elif test -d /usr/include/netcdf ; then |
elif test -d /usr/include/netcdf ; then |
124 |
elif test -d /usr/local/netcdf ; then |
elif test -d /usr/local/netcdf ; then |
125 |
INCLUDES='-I/usr/local/netcdf/include' |
INCLUDES='-I/usr/local/netcdf/include' |
126 |
LIBS='-L/usr/local/netcdf/lib' |
LIBS='-L/usr/local/netcdf/lib' |
127 |
|
elif test -d /usr/local/include/netcdf.inc ; then |
128 |
|
INCLUDES='-I/usr/local/include' |
129 |
|
LIBS='-L/usr/local/lib64' |
130 |
|
elif test -d /usr/include/netcdf.inc ; then |
131 |
|
INCLUDES='-I/usr/include' |
132 |
|
LIBS='-L/usr/lib64' |
133 |
fi |
fi |
134 |
|
|
135 |
|
if [ -n "$MPI_INC_DIR" -a "x$MPI" = xtrue ] ; then |
136 |
|
INCLUDES="$INCLUDES -I$MPI_INC_DIR" |
137 |
|
INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR" |
138 |
|
MPIINCLUDEDIR="$MPI_INC_DIR" |
139 |
|
MPI_HEADER_FILES='mpif.h mpiof.h' |
140 |
|
MPI_HEADER_FILES_INC='./mpi_headers/mpif.h ./mpi_headers/mpiof.h' |
141 |
|
fi |