source: trunk/environment/ew_macosx_intel.sh @ 7549

Revision 7549, 4.9 KB checked in by baker, 3 months ago (diff)

add (disabled) USE_CC_BITS option to use default compiler target bits; use simpler if [] (test) syntax

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# Enable USE_CC_BITS to default EW_BITs to the compiler target (removes -m32/64)
2# Otherwise, the default is 32, as it was
3#USE_CC_BITS=true
4
5# Create an Earthworm environment on Intel Mac OS X
6# This file should be sourced by a Bourne shell wanting
7# to run or build an EARTHWORM system under Intel Mac OS X.
8
9# For running EW on a Mac, if any ports are used, make sure that your
10# selected ports for wave_serverV or exports are below the range specified
11# by your kernel for dynamic port allocation
12# (see sysctl net.inet.ip.portrange.{first,last})
13
14# Set environment variables describing your Earthworm directory/version
15
16# Use value from elsewhere IF defined (eg from .bashrc)
17# otherwise use the value after the :-
18export EW_HOME="${EW_INSTALL_HOME:-/opt/earthworm}"
19export EW_VERSION="${EW_INSTALL_VERSION:-earthworm_7.10}"
20# Or set your own values directly
21#export EW_HOME=/Users/earthworm
22#export EW_VERSION=earthworm_7.10
23EW_RUN_DIR="${EW_RUN_DIR:-$EW_HOME/run_working}"
24# Or set your own value directly
25#EW_RUN_DIR=$EW_HOME/run_working
26
27# This next env var is required if you run statmgr:
28export SYS_NAME=`hostname`
29
30# Set environment variables used by Earthworm modules at run-time
31# Path names must end with the slash "/"
32export EW_INSTALLATION="${EW_INSTALL_INSTALLATION:-INST_UNKNOWN}"
33export EW_PARAMS="${EW_RUN_DIR}/params/"
34export EW_LOG="${EW_RUN_DIR}/log/"
35export EW_DATA_DIR="${EW_RUN_DIR}/data/"
36
37# Tack the Earthworm bin directory in front of the current path
38export PATH="$EW_HOME/$EW_VERSION/bin:$PATH"
39
40# Set environment variables for compiling Earthworm modules
41
42# Be explicit about which compilers to use (only CC is checked for validity)
43CC=gcc
44CXX=g++
45
46if [ "${CC}" = "gcc" ] ; then
47
48   export CC
49   export CXX
50
51   # Set EW_BITS=64 to build for 64-bit target (note that with EW_BITS=64
52   # size of 'long' type changes from 4 bytes to 8 bytes)
53
54   if [ -n "${USE_CC_BITS}" ] ; then
55      # gcc target prefix is "i686" on 32-bit PCs, "x86_64" on 64-bit PCs
56      CC_BITS=`${CC} -v 2>&1 |
57               awk '/^Target:/{
58                       split( $2, arch, "-" );
59                       if ( arch[1] == "x86_64" )
60                          print( "64" )
61                       else
62                          print( "32" )
63                    }'`
64      if [ -n "${EW_INSTALL_BITS}" ] ; then
65         export EW_BITS="${EW_INSTALL_BITS}"
66         TARGET="-m${EW_BITS} "
67      else
68         export EW_BITS="${CC_BITS}"
69         TARGET=""
70      fi
71   else
72      export EW_BITS="${EW_INSTALL_BITS:-32}"
73      TARGET="-m${EW_BITS} "
74   fi
75
76   # Warning flags for compiler:
77   export WARNFLAGS="-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unknown-pragmas -Wno-pragmas -Wformat -Wdeclaration-after-statement"
78   # Extra flags for enabling more warnings during code development:
79   #export WARNFLAGS="-Wall -Wextra -Wcast-align -Wpointer-arith -Wbad-function-cast -Winline -Wundef -Wnested-externs -Wshadow -Wfloat-equal -Wno-unused-parameter -Wformat -Wdeclaration-after-statement"
80
81   # -D_DARWIN_USE_64_BIT_INODE (OSX 10.5 and later) is for 64-bit inode numbers (see man 2 stat)
82
83   export GLOBALFLAGS="${TARGET}-g -D_MACOSX -D_DARWIN_C_SOURCE -D_INTEL -D_USE_SCHED -D_USE_PTHREADS -D_DARWIN_USE_64_BIT_INODE -I${EW_HOME}/${EW_VERSION}/include ${WARNFLAGS}"
84   export PLATFORM="LINUX" # Uses the same make options as Linux, so used here
85
86   # This is needed to get the Mac linker to work with some modules
87   export LDFLAGS=-Wl,-search_paths_first
88
89   # Set initial defaults
90   export CFLAGS=${GLOBALFLAGS}
91   export CXXFLAGS=${GLOBALFLAGS}
92
93else
94
95   echo "CC must be gcc"
96
97fi
98
99# Pick a Fortran compiler
100# gfortran (freeware, available from http://hpc.sourceforge.net)
101FC=gfortran
102# Intel Fortran (requires a paid license)
103#FC=ifort
104
105if [ "${FC}" = "gfortran" ] ; then
106
107   export FC
108   # Extra run-time checks: -fcheck=all
109   #export FFLAGS="${TARGET}-O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fcheck=all,no-array-temps -fbacktrace"
110   export FFLAGS="${TARGET}-O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fbacktrace"
111
112   # FC_MAIN_IS_C is not needed with gfortran
113   #export FC_MAIN_IS_C=-nofor-main
114
115elif [ "${FC}" = "ifort" ] ; then
116
117   export FC
118   # Extra run-time checks: -check bounds,uninit
119   # ifort version 15 introduced the -init option; older compilers complain, but ignore it
120   # ifort complains about comments past column 72; -warn truncated_source is pretty useless
121   #export FFLAGS="${TARGET}-O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -check bounds,uninit -diag-disable 8290 -traceback"
122   export FFLAGS="${TARGET}-O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -diag-disable 8290 -traceback"
123
124   # Intel Fortran supplies main() unless told not to
125   export FC_MAIN_IS_C=-nofor-main
126
127else
128
129   echo "FC must be either gfortran or ifort"
130
131fi
132
133# Alternatively, you can hard-code values here:
134#export FC='...'
135#export FFLAGS='...'
Note: See TracBrowser for help on using the repository browser.