1 |
jmc |
1.5 |
#! /usr/bin/env bash |
2 |
ce107 |
1.1 |
# |
3 |
jmc |
1.13 |
# $Header: /u/gcmpack/MITgcm/tools/build_options/linux_amd64_pathf90,v 1.12 2014/07/16 18:45:15 jmc Exp $ |
4 |
ce107 |
1.1 |
# $Name: $ |
5 |
|
|
# |
6 |
jmc |
1.5 |
# Build options for PathScale (EKOPATH) Compiler on Linux x86-64 |
7 |
|
|
# first version tested on Fedore Core 3 x86-64 Opteron (Linux batsi) |
8 |
jmc |
1.6 |
# updated and tested on acesgrid (Fedora Core 15), using: |
9 |
|
|
# module load ekopath (Version 4.0.10) |
10 |
jmc |
1.8 |
# 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 |
jmc |
1.5 |
#------- |
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 |
ce107 |
1.1 |
|
30 |
jmc |
1.8 |
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 |
jmc |
1.6 |
|
40 |
ce107 |
1.2 |
DEFINES='-DWORDLENGTH=4' |
41 |
jmc |
1.7 |
EXTENDED_SRC_FLAG='-extend-source' |
42 |
jmc |
1.8 |
GET_FC_VERSION="--version" |
43 |
jmc |
1.6 |
OMPFLAG='-openmp' |
44 |
jmc |
1.7 |
#OMPFLAG='-openmp -OPT:early_mp=ON' |
45 |
jmc |
1.6 |
|
46 |
jmc |
1.5 |
NOOPTFLAGS='-O0 -g' |
47 |
ce107 |
1.2 |
NOOPTFILES='' |
48 |
|
|
|
49 |
jmc |
1.11 |
CFLAGS='-O0 -m64' |
50 |
|
|
FFLAGS="$FFLAGS -m64 -convert big_endian" |
51 |
|
|
|
52 |
|
|
#- for big setups, compile & link with "-fPIC" or set memory-model to "medium": |
53 |
|
|
CFLAGS="$CFLAGS -fPIC" |
54 |
|
|
FFLAGS="$FFLAGS -fPIC" |
55 |
|
|
#- with FC 19, need to use this without -fPIC (which cancels -mcmodel option): |
56 |
|
|
#CFLAGS="$CFLAGS -mcmodel=medium" |
57 |
|
|
#FFLAGS="$FFLAGS -mcmodel=medium" |
58 |
jmc |
1.7 |
#- might want to use '-r8' for fizhi pkg: |
59 |
|
|
#FFLAGS="$FFLAGS -r8" |
60 |
|
|
|
61 |
|
|
if test "x$IEEE" = x ; then #- with optimisation: |
62 |
|
|
#- full optimisation, trips over MITgcm code because of compiler problems: |
63 |
|
|
#FOPTIM='-Ofast -LNO:fusion=2 -funsafe-math-optimizations' |
64 |
jmc |
1.9 |
#- high optimisation (-O3 & (loop)fusion=2), might find Pb with few S/R: |
65 |
|
|
#FOPTIM='-O3 -LNO:fusion=2 -funsafe-math-optimizations' |
66 |
jmc |
1.13 |
#FOPTIM='-O3 -funsafe-math-optimizations' |
67 |
jmc |
1.12 |
#- fully safe: switch to -O2 without (loop)fusion=2 (to fix some restart Pb): |
68 |
jmc |
1.13 |
FOPTIM='-O2 -funsafe-math-optimizations' |
69 |
jmc |
1.12 |
NOOPTFILES="$NOOPTFILES exf_interpolate.F" |
70 |
jmc |
1.9 |
#- multi-threaded: mon_set_iounit.F needs lower optimisation (lower than -02) |
71 |
jmc |
1.8 |
NOOPTFILES="$NOOPTFILES mon_set_iounit.F" |
72 |
jmc |
1.12 |
NOOPTFLAGS='-O1' |
73 |
ce107 |
1.2 |
else |
74 |
jmc |
1.7 |
if test "x$DEVEL" = x ; then #- no optimisation + IEEE : |
75 |
|
|
FOPTIM='-O0 -OPT:roundoff=0:IEEE_arithmetic=1 -fmath-errno -fno-fast-math' |
76 |
|
|
else #- development/check options: |
77 |
|
|
FFLAGS="$FFLAGS -ffortran-bounds-check -trapuv -g" |
78 |
jmc |
1.5 |
FOPTIM='-O0 -OPT:roundoff=0:IEEE_arithmetic=1 -fmath-errno -fno-fast-math' |
79 |
jmc |
1.7 |
fi |
80 |
ce107 |
1.1 |
fi |
81 |
ce107 |
1.2 |
|
82 |
|
|
F90FLAGS=$FFLAGS |
83 |
|
|
F90OPTIM=$FOPTIM |
84 |
jmc |
1.3 |
GSLLIB='-lgsl -lgslcblas' |
85 |
ce107 |
1.2 |
|
86 |
jmc |
1.8 |
INCLUDEDIRS='' |
87 |
|
|
INCLUDES='' |
88 |
|
|
LIBS='' |
89 |
|
|
|
90 |
ce107 |
1.2 |
if [ "x$NETCDF_ROOT" != x ] ; then |
91 |
|
|
INCLUDEDIR="${NETCDF_ROOT}/include" |
92 |
|
|
INCLUDES="-I${NETCDF_ROOT}/include" |
93 |
|
|
LIBDIR="${NETCDF_ROOT}/lib" |
94 |
|
|
LIBS="-L${NETCDF_ROOT}/lib" |
95 |
|
|
elif [ "x$NETCDF_HOME" != x ]; then |
96 |
|
|
INCLUDEDIR="${NETCDF_HOME}/include" |
97 |
|
|
INCLUDES="-I${NETCDF_HOME}/include" |
98 |
|
|
LIBDIR="${NETCDF_HOME}/lib" |
99 |
|
|
LIBS="-L${NETCDF_HOME}/lib" |
100 |
|
|
elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then |
101 |
|
|
NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'` |
102 |
|
|
NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'` |
103 |
|
|
INCLUDEDIR="${NETCDF_INC}" |
104 |
|
|
INCLUDES="-I${NETCDF_INC}" |
105 |
|
|
LIBDIR="${NETCDF_LIB}" |
106 |
|
|
LIBS="-L${NETCDF_LIB}" |
107 |
|
|
elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then |
108 |
|
|
INCLUDEDIR="${NETCDF_INCDIR}" |
109 |
|
|
INCLUDES="-I${NETCDF_INCDIR}" |
110 |
|
|
LIBDIR="${NETCDF_LIBDIR}" |
111 |
|
|
LIBS="-L${NETCDF_LIBDIR}" |
112 |
|
|
elif test -d /usr/include/netcdf-3 ; then |
113 |
|
|
INCLUDES='-I/usr/include/netcdf-3' |
114 |
|
|
LIBS='-L/usr/lib/netcdf-3 -L/usr/lib64/netcdf-3' |
115 |
|
|
elif test -d /usr/include/netcdf ; then |
116 |
|
|
INCLUDES='-I/usr/include/netcdf' |
117 |
|
|
elif test -d /usr/local/netcdf ; then |
118 |
|
|
INCLUDES='-I/usr/local/netcdf/include' |
119 |
|
|
LIBS='-L/usr/local/netcdf/lib' |
120 |
|
|
elif test -d /usr/local/include/netcdf.inc ; then |
121 |
|
|
INCLUDES='-I/usr/local/include' |
122 |
|
|
LIBS='-L/usr/local/lib64' |
123 |
|
|
fi |
124 |
|
|
|
125 |
jmc |
1.8 |
if [ -n "$MPI_INC_DIR" -a "x$MPI" = xtrue ] ; then |
126 |
|
|
INCLUDES="$INCLUDES -I$MPI_INC_DIR" |
127 |
|
|
INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR" |
128 |
jmc |
1.10 |
#- used for parallel (MPI) DIVA |
129 |
jmc |
1.8 |
MPIINCLUDEDIR="$MPI_INC_DIR" |
130 |
jmc |
1.10 |
#MPI_HEADER_FILES='mpif.h mpiof.h' |
131 |
jmc |
1.8 |
fi |