1 |
#! /usr/bin/env bash |
2 |
# |
3 |
# $Header: /u/gcmpack/MITgcm/tools/build_options/linux_amd64_pathf90,v 1.8 2011/08/19 22:54:04 jmc Exp $ |
4 |
# $Name: $ |
5 |
# |
6 |
# Build options for PathScale (EKOPATH) Compiler on Linux x86-64 |
7 |
# first version tested on Fedore Core 3 x86-64 Opteron (Linux batsi) |
8 |
# updated and tested on acesgrid (Fedora Core 15), using: |
9 |
# module load ekopath (Version 4.0.10) |
10 |
# Also tested with MPI on acesgrid, using: |
11 |
# module load ekopath (Version 4.0.10) |
12 |
# and with mpich1: |
13 |
# module load mvapich |
14 |
# or with mpich2: |
15 |
# module load mvapich2 |
16 |
# or with openmpi: |
17 |
# module load openmpi |
18 |
|
19 |
#------- |
20 |
# run with OpenMP: needs to set environment var. OMP_NUM_THREADS |
21 |
# and generally, needs to increase the thread stack-size: |
22 |
# - sh,bash: |
23 |
# > export OMP_NUM_THREADS=2 |
24 |
# > export PSC_OMP_STACK_SIZE=400m |
25 |
# - csh,tcsh: |
26 |
# > setenv OMP_NUM_THREADS 2 |
27 |
# > setenv PSC_OMP_STACK_SIZE 400m |
28 |
#------- |
29 |
|
30 |
if test "x$MPI" = xtrue ; then |
31 |
CC=mpicc |
32 |
FC=mpif90 |
33 |
LINK=mpif90 |
34 |
else |
35 |
CC=pathcc |
36 |
FC=pathf90 |
37 |
LINK=pathf90 |
38 |
fi |
39 |
|
40 |
DEFINES='-DWORDLENGTH=4' |
41 |
CPP='cpp -traditional -P' |
42 |
EXTENDED_SRC_FLAG='-extend-source' |
43 |
GET_FC_VERSION="--version" |
44 |
OMPFLAG='-openmp' |
45 |
#OMPFLAG='-openmp -OPT:early_mp=ON' |
46 |
|
47 |
NOOPTFLAGS='-O0 -g' |
48 |
NOOPTFILES='' |
49 |
|
50 |
FFLAGS="$FFLAGS -m64 -fPIC -convert big_endian" |
51 |
#- might want to use '-r8' for fizhi pkg: |
52 |
#FFLAGS="$FFLAGS -r8" |
53 |
|
54 |
if test "x$IEEE" = x ; then #- with optimisation: |
55 |
#- full optimisation, trips over MITgcm code because of compiler problems: |
56 |
#FOPTIM='-Ofast -LNO:fusion=2 -funsafe-math-optimizations' |
57 |
#- high optimisation (-O3 & (loop)fusion=2), might find Pb with few S/R: |
58 |
#FOPTIM='-O3 -LNO:fusion=2 -funsafe-math-optimizations' |
59 |
#- fully safe: switch to -O2 without (loop)fusion=2: |
60 |
FOPTIM='-O3 -funsafe-math-optimizations' |
61 |
#- multi-threaded: mon_set_iounit.F needs lower optimisation (lower than -02) |
62 |
NOOPTFILES="$NOOPTFILES mon_set_iounit.F" |
63 |
else |
64 |
if test "x$DEVEL" = x ; then #- no optimisation + IEEE : |
65 |
FOPTIM='-O0 -OPT:roundoff=0:IEEE_arithmetic=1 -fmath-errno -fno-fast-math' |
66 |
else #- development/check options: |
67 |
FFLAGS="$FFLAGS -ffortran-bounds-check -trapuv -g" |
68 |
FOPTIM='-O0 -OPT:roundoff=0:IEEE_arithmetic=1 -fmath-errno -fno-fast-math' |
69 |
fi |
70 |
fi |
71 |
|
72 |
F90FLAGS=$FFLAGS |
73 |
F90OPTIM=$FOPTIM |
74 |
CFLAGS='-O0 -m64 -fPIC' |
75 |
GSLLIB='-lgsl -lgslcblas' |
76 |
|
77 |
INCLUDEDIRS='' |
78 |
INCLUDES='' |
79 |
LIBS='' |
80 |
|
81 |
if [ "x$NETCDF_ROOT" != x ] ; then |
82 |
INCLUDEDIR="${NETCDF_ROOT}/include" |
83 |
INCLUDES="-I${NETCDF_ROOT}/include" |
84 |
LIBDIR="${NETCDF_ROOT}/lib" |
85 |
LIBS="-L${NETCDF_ROOT}/lib" |
86 |
elif [ "x$NETCDF_HOME" != x ]; then |
87 |
INCLUDEDIR="${NETCDF_HOME}/include" |
88 |
INCLUDES="-I${NETCDF_HOME}/include" |
89 |
LIBDIR="${NETCDF_HOME}/lib" |
90 |
LIBS="-L${NETCDF_HOME}/lib" |
91 |
elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then |
92 |
NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'` |
93 |
NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'` |
94 |
INCLUDEDIR="${NETCDF_INC}" |
95 |
INCLUDES="-I${NETCDF_INC}" |
96 |
LIBDIR="${NETCDF_LIB}" |
97 |
LIBS="-L${NETCDF_LIB}" |
98 |
elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then |
99 |
INCLUDEDIR="${NETCDF_INCDIR}" |
100 |
INCLUDES="-I${NETCDF_INCDIR}" |
101 |
LIBDIR="${NETCDF_LIBDIR}" |
102 |
LIBS="-L${NETCDF_LIBDIR}" |
103 |
elif test -d /usr/include/netcdf-3 ; then |
104 |
INCLUDES='-I/usr/include/netcdf-3' |
105 |
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
106 |
elif test -d /usr/include/netcdf ; then |
107 |
INCLUDES='-I/usr/include/netcdf' |
108 |
elif test -d /usr/local/netcdf ; then |
109 |
INCLUDES='-I/usr/local/netcdf/include' |
110 |
LIBS='-L/usr/local/netcdf/lib' |
111 |
elif test -d /usr/local/include/netcdf.inc ; then |
112 |
INCLUDES='-I/usr/local/include' |
113 |
LIBS='-L/usr/local/lib64' |
114 |
fi |
115 |
|
116 |
if [ -n "$MPI_INC_DIR" -a "x$MPI" = xtrue ] ; then |
117 |
INCLUDES="$INCLUDES -I$MPI_INC_DIR" |
118 |
INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR" |
119 |
MPIINCLUDEDIR="$MPI_INC_DIR" |
120 |
MPI_HEADER_FILES='mpif.h mpiof.h' |
121 |
MPI_HEADER_FILES_INC='./mpi_headers/mpif.h ./mpi_headers/mpiof.h' |
122 |
fi |