source: trunk/environment/ew_linux.bash @ 7549

Revision 7549, 4.8 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 PC Linux
6# This file should be sourced by a Bourne shell wanting
7# to run or build an EARTHWORM system under Linux on a PC.
8
9# For running EW on Linux, 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.ipv4.ip_local_port_range)
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_FILE_OFFSET_BITS=64 is for Large Filesystem Support (64-bit offsets) on a 32-bit compile (gcc only); it is benign on a 64-bit compile
82
83   export GLOBALFLAGS="${TARGET}-g -D_LINUX -Dlinux -D_INTEL -D_USE_SCHED -D_USE_PTHREADS -D_USE_TERMIOS -D_FILE_OFFSET_BITS=64 -I${EW_HOME}/${EW_VERSION}/include ${WARNFLAGS}"
84   export PLATFORM="LINUX"
85
86   export LINK_LIBS="-lm -lpthread"
87
88   # Set initial defaults
89   export CFLAGS=${GLOBALFLAGS}
90   export CXXFLAGS=${GLOBALFLAGS}
91
92else
93
94   echo "CC must be gcc"
95
96fi
97
98# Pick a Fortran compiler
99# gfortran (freeware, part of GNU GCC)
100FC=gfortran
101# Intel Fortran (requires a paid license)
102#FC=ifort
103
104if [ "${FC}" = "gfortran" ] ; then
105
106   export FC
107   # Extra run-time checks: -fcheck=all
108   #export FFLAGS="${TARGET}-O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fcheck=all,no-array-temps -fbacktrace"
109   export FFLAGS="${TARGET}-O -g -Wuninitialized -Werror=line-truncation -ffpe-trap=invalid,zero,overflow -fbacktrace"
110
111   # FC_MAIN_IS_C is not needed with gfortran
112   #export FC_MAIN_IS_C=-nofor-main
113
114elif [ "${FC}" = "ifort" ] ; then
115
116   export FC
117   # Extra run-time checks: -check bounds,uninit
118   # ifort version 15 introduced the -init option; older compilers complain, but ignore it
119   # ifort complains about comments past column 72; -warn truncated_source is pretty useless
120   #export FFLAGS="${TARGET}-O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -check bounds,uninit -diag-disable 8290 -traceback"
121   export FFLAGS="${TARGET}-O3 -g -init=snan -init=arrays -extend-source -warn truncated_source -fpe-all=0 -diag-disable 8290 -traceback"
122
123   # Intel Fortran supplies main() unless told not to
124   export FC_MAIN_IS_C=-nofor-main
125
126else
127
128   echo "FC must be either gfortran or ifort"
129
130fi
131
132# Alternatively, you can hard-code values here:
133#export FC='...'
134#export FFLAGS='...'
Note: See TracBrowser for help on using the repository browser.