1 |
#!/bin/bash |
2 |
# |
3 |
# $Header: /u/gcmpack/MITgcm/tools/build_options/linux_amd64_open64,v 1.9 2013/09/23 23:36:05 jmc Exp $ |
4 |
# $Name: $ |
5 |
# |
6 |
# Build options for Open64 Compiler on Linux x86-64 |
7 |
# first version tested on Fedore Core 4 x86-64 Opteron (Linux batsi) |
8 |
# updated and tested on acesgrid (Fedora Core 15), using: |
9 |
# module load open64 (Version 4.2.4) |
10 |
# Also tested with MPI on acesgrid, using: |
11 |
# module load open64 (Version 4.2.4) |
12 |
# and with mpich1: |
13 |
# module load mvapich |
14 |
# or with mpich2: |
15 |
# module load mvapich2 |
16 |
# or with openmpi: <== not yet tested |
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 OMP_SLAVE_STACK_SIZE=400m |
25 |
# - csh,tcsh: |
26 |
# > setenv OMP_NUM_THREADS 2 |
27 |
# > setenv OMP_SLAVE_STACK_SIZE 400m |
28 |
#------- |
29 |
|
30 |
if test "x$MPI" = xtrue ; then |
31 |
CC=mpicc |
32 |
FC=mpif90 |
33 |
F90C=mpif90 |
34 |
LINK=mpif90 |
35 |
else |
36 |
CC=opencc |
37 |
FC=openf90 |
38 |
F90C=openf90 |
39 |
LINK=openf90 |
40 |
fi |
41 |
|
42 |
DEFINES='-DWORDLENGTH=4' |
43 |
EXTENDED_SRC_FLAG='-extend-source' |
44 |
F90FIXEDFORMAT='-fixedform -x f95' |
45 |
GET_FC_VERSION="--version" |
46 |
OMPFLAG='-openmp' |
47 |
#OMPFLAG='-openmp -OPT:early_mp=ON' |
48 |
|
49 |
NOOPTFLAGS='-O0 -g' |
50 |
NOOPTFILES='' |
51 |
|
52 |
CFLAGS='-O0 -m64' |
53 |
FFLAGS="$FFLAGS -m64 -convert big_endian" |
54 |
|
55 |
#- for big setups, compile & link with "-fPIC" or set memory-model to "medium": |
56 |
#CFLAGS="$CFLAGS -fPIC" |
57 |
#FFLAGS="$FFLAGS -fPIC" |
58 |
#- with FC 19, need to use this without -fPIC (which cancels -mcmodel option): |
59 |
CFLAGS="$CFLAGS -mcmodel=medium" |
60 |
FFLAGS="$FFLAGS -mcmodel=medium" |
61 |
#- might want to use '-r8' for fizhi pkg: |
62 |
#FFLAGS="$FFLAGS -r8" |
63 |
|
64 |
if test "x$IEEE" = x ; then #- with optimisation: |
65 |
#- full optimisation |
66 |
# ("-Ofast" eqv "-O3 -ipa -OPT:Ofast -fno-math-errno -ffast-math" and "-OPT:Ofast" |
67 |
# eqv to "-OPT:roundoff=2 -OPT:Olimit=0 -OPT:div_split=ON -OPT:alias=typed") |
68 |
#FOPTIM='-Ofast -OPT:roundoff=1:IEEE_arithmetic=3 -LNO:fusion=2' |
69 |
FOPTIM='-O3 -OPT:Ofast:roundoff=1:IEEE_arithmetic=3 -ffast-math -LNO:fusion=2' |
70 |
#- high optimisation (-O3), might find Pb with few S/R; fully safe: switch to -O2: |
71 |
#FOPTIM='-O3 -OPT:roundoff=1:IEEE_arithmetic=3 -LNO:fusion=2' |
72 |
#- safer: switch to -O2 with IEEE_arithmetic=2 (to fix some restart Pb): |
73 |
#FOPTIM='-O2 -OPT:roundoff=1:IEEE_arithmetic=2 -ffast-math -LNO:fusion=2' |
74 |
else |
75 |
if test "x$DEVEL" = x ; then #- no optimisation + IEEE : |
76 |
FOPTIM='-O0 -OPT:roundoff=0:IEEE_arithmetic=1 -fmath-errno -fno-fast-math' |
77 |
else #- development/check options: |
78 |
FFLAGS="$FFLAGS -ffortran-bounds-check -trapuv -g" |
79 |
FOPTIM='-O0 -OPT:roundoff=0:IEEE_arithmetic=1 -fmath-errno -fno-fast-math' |
80 |
fi |
81 |
fi |
82 |
|
83 |
F90FLAGS=$FFLAGS |
84 |
F90OPTIM=$FOPTIM |
85 |
GSLLIB='-lgsl -lgslcblas' |
86 |
|
87 |
INCLUDEDIRS='' |
88 |
INCLUDES='' |
89 |
LIBS='' |
90 |
|
91 |
if [ "x$NETCDF_ROOT" != x ] ; then |
92 |
INCLUDEDIR="${NETCDF_ROOT}/include" |
93 |
INCLUDES="-I${NETCDF_ROOT}/include" |
94 |
LIBDIR="${NETCDF_ROOT}/lib" |
95 |
LIBS="-L${NETCDF_ROOT}/lib" |
96 |
elif [ "x$NETCDF_HOME" != x ]; then |
97 |
INCLUDEDIR="${NETCDF_HOME}/include" |
98 |
INCLUDES="-I${NETCDF_HOME}/include" |
99 |
LIBDIR="${NETCDF_HOME}/lib" |
100 |
LIBS="-L${NETCDF_HOME}/lib" |
101 |
elif [ "x$NETCDF_INC" != x -a "x$NETCDF_LIB" != x ]; then |
102 |
NETCDF_INC=`echo $NETCDF_INC | sed 's/-I//g'` |
103 |
NETCDF_LIB=`echo $NETCDF_LIB | sed 's/-L//g'` |
104 |
INCLUDEDIR="${NETCDF_INC}" |
105 |
INCLUDES="-I${NETCDF_INC}" |
106 |
LIBDIR="${NETCDF_LIB}" |
107 |
LIBS="-L${NETCDF_LIB}" |
108 |
elif [ "x$NETCDF_INCDIR" != x -a "x$NETCDF_LIBDIR" != x ]; then |
109 |
INCLUDEDIR="${NETCDF_INCDIR}" |
110 |
INCLUDES="-I${NETCDF_INCDIR}" |
111 |
LIBDIR="${NETCDF_LIBDIR}" |
112 |
LIBS="-L${NETCDF_LIBDIR}" |
113 |
elif test -d /usr/include/netcdf-3 ; then |
114 |
INCLUDES='-I/usr/include/netcdf-3' |
115 |
LIBS='-L/usr/lib64/netcdf-3 -lnetcdf_g77' |
116 |
elif test -d /usr/include/netcdf ; then |
117 |
INCLUDES='-I/usr/include/netcdf' |
118 |
elif test -d /usr/local/netcdf ; then |
119 |
INCLUDES='-I/usr/local/netcdf/include' |
120 |
LIBS='-L/usr/local/netcdf/lib' |
121 |
elif test -d /usr/local/include/netcdf.inc ; then |
122 |
INCLUDES='-I/usr/local/include' |
123 |
LIBS='-L/usr/local/lib64' |
124 |
fi |
125 |
|
126 |
if [ -n "$MPI_INC_DIR" -a "x$MPI" = xtrue ] ; then |
127 |
INCLUDES="$INCLUDES -I$MPI_INC_DIR" |
128 |
INCLUDEDIRS="$INCLUDEDIRS $MPI_INC_DIR" |
129 |
#- used for parallel (MPI) DIVA |
130 |
MPIINCLUDEDIR="$MPI_INC_DIR" |
131 |
#MPI_HEADER_FILES='mpif.h mpiof.h' |
132 |
fi |